Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

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;
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #return #type #depends #input #typescript
ADD COMMENT
Topic
Name
5+5 =