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
interfaceI{x: number|null;}functiongeneric<TextendsI>(a: T,b: Partial<T>){if(a.x!=null){a.x.toFixed(2);// OK}if(b.x!=null){b.x.toFixed(2);// ERROR: Property 'toFixed' does not exist on type 'T["x"]'}}functionnotGeneric(a: I,b: Partial<I>){if(a.x!=null){a.x.toFixed(2);// OK}if(b.x!=null){b.x.toFixed(2);// OK}}
Expected behavior:
The mapped generic code should compile without error.
Actual behavior:
The mapped generic code does not compile.
For context, the place I'm seeing this issue is React when interacting with props. The React typings for a Component are:
Activity
ahejlsberg commentedon Jun 5, 2017
Duplicate of #14091. Fixed by #15576.
jaredru commentedon Jun 5, 2017
Ah, I searched but didn't find the dupe. Sorry about that. Thanks for the quick follow up!