-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Conditional TypesThe issue relates to conditional typesThe issue relates to conditional typesDomain: Control FlowThe issue relates to control flow analysisThe issue relates to control flow analysis
Milestone
Description
TypeScript Version: 3.2.2
Search Terms: Generic typeof
Code
function f2<T>(v: Exclude<T, Function> | (() => T)): T {
if (typeof v === 'function') {
v = v() // error!
}
return v
}
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Conditional TypesThe issue relates to conditional typesThe issue relates to conditional typesDomain: Control FlowThe issue relates to control flow analysisThe issue relates to control flow analysis