-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Conditional types - Extract works incorrect #22899
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.8.0-rc, 2.9.0-dev.20180327
declare function isFunction<T>(value: T): value is Extract<T, Function>;
declare function toString1(value: object | Function): string ;
declare function toString2(value: Function): string ;
function foo<T>(value: T) {
if (isFunction(value)) {
toString1(value); // ok
toString2(value); // error TS2345: Argument of type 'Extract<T, Function>' is not assignable to parameter of type 'Function'.
// Type 'T' is not assignable to type 'Function'.
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue