Answers for "return type depends on input typescript"

0

return type depends on input typescript

function dependsOnParameter<B extends boolean>(x: B): B extends true ? number : string {
    if (x) {
        return 3 as any;
    } else {
        return "string"as any;
    }
}
Posted by: Guest on July-08-2021

Code answers related to "return type depends on input typescript"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language