You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search Terms: generic type parameter, scope leak, scope escape, conditional type, mapped type
Code
typeHmm<T,UextendsT>=UextendsT ? {[KinkeyofU]: number} : never;typeWhat=Hmm<{},{a: string}>// type What = { [K in keyof (T & { a: string; })]: number; } 🤪constw: What={a: 4};// error! '{ a: number; }' not assignable to What
Expected 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.
This looks to be an issue in getAnonymousTypeInstantiation where we're computing the outer type parameters. We appear to miss the fact that the mapped type depends on T.
TypeScript Version: 3.5.0-dev.20190509
Search Terms: generic type parameter, scope leak, scope escape, conditional type, mapped type
Code
Expected behavior:
What
should be the concrete object type{ a: number }
and therefore the assignment tow
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
The text was updated successfully, but these errors were encountered: