-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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.7.0-dev.201xxxxx
Code
class C { }
function f<T extends C>(v: T | string): void {
if (v instanceof C) {
const x: T = v;
console.log(x);
}
}
Expected behavior:
No compile errors:
Actual behavior:
p.ts(5,11): error TS2322: Type 'string | T' is not assignable to type 'T'.
Type 'string' is not assignable to type 'T'.
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