-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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: 3.5.0-dev.20190509
Search Terms: generic type parameter, scope leak, scope escape, conditional type, mapped type
Code
type Hmm<T, U extends T> = U extends T ? { [K in keyof U]: number } : never;
type What = Hmm<{}, { a: string }>
// type What = { [K in keyof (T & { a: string; })]: number; } 🤪
const w: What = { a: 4 }; // error! '{ a: number; }' not assignable to WhatExpected behavior:
What should be the concrete object type { a: number } and therefore the assignment to w should compile without errors.
Actual behavior:
An unbound type parameter T has escaped from its scope and is terrorizing the surrounding countryside. Please stay indoors with windows and doors locked until further notice.
Playground Link: 👨💻🔗
Related Issues:
Probably caused by: #29437
Prior escapes: #31099
Also: Relevant SO question
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