return type depends on input typescript

The solution for “return type depends on input typescript” can be found here. The following code will assist you in solving the problem.

function dependsOnParameter(x: B): B extends true ? number : string {
if (x) {
return 3 as any;
} else {
return “string”as any;

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

inline scripts encapsulated in