typeof 'function' using with Exclude<T, Function> #29614
Labels
Bug
A bug in TypeScript
Domain: Conditional Types
The issue relates to conditional types
Domain: Control Flow
The issue relates to control flow analysis
Milestone
TypeScript Version: 3.2.2
Search Terms: Generic typeof
Code
Expected behavior:
No error, type v is just (() => T).
Actual behavior:
Line 3 report an error: Type '(() => T) | (Exclude<T, Function> & Function)' has no compatible call signatures.
Playground Link: https://www.typescriptlang.org/play/index.html#src=function%20f2%3CT%3E(v%3A%20Exclude%3CT%2C%20Function%3E%20%7C%20(()%20%3D%3E%20T))%3A%20T%20%7B%0D%0A%20%20%20%20if%20(typeof%20v%20%3D%3D%3D%20'function')%20%7B%0D%0A%20%20%20%20%20%20%20%20v%20%3D%20v()%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20return%20v%0D%0A%7D
The text was updated successfully, but these errors were encountered: