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
typelocales='us'|'jp'|'nz'typeYZ={[routeName: string]: {someRandomProperty?:string}&{// this does not throw the error!// [routeName: string]: {} & { // this will throw the error!// [routeName: string]: { // just like this!// [routeName: string]: undefined & { // or this!urls: {[Pinlocales]?: string;}}}letvalue: YZ={'hello': {urls: {jp: 'dragon',ph: 'unknown'}}};
Expected behavior:
There should be an error message along the lines of Type '{ jp: string; ph: string; }' is not assignable to type '{ us?: string | undefined; jp?: string | undefined; nz?: string | undefined; }'. Object literal may only specify known properties, and 'ph' does not exist in type '{ us?: string | undefined; jp?: string | undefined; nz?: string | undefined; }'
Actual behavior:
No error message is thrown :(
Playground Link:
Playground never shows the error message for some reason.
TypeScript Version: typescript@3.1.0-dev.20180915 (also happens in 2.7.2)
tested with unmodified tsconfig generated by
tsc --init
Search Terms: intersection mapped types restrictions
Code
Expected behavior:
There should be an error message along the lines of
Type '{ jp: string; ph: string; }' is not assignable to type '{ us?: string | undefined; jp?: string | undefined; nz?: string | undefined; }'. Object literal may only specify known properties, and 'ph' does not exist in type '{ us?: string | undefined; jp?: string | undefined; nz?: string | undefined; }'
Actual behavior:
No error message is thrown :(
Playground Link:
Playground never shows the error message for some reason.
Related Issues:
#19927
#22255
The text was updated successfully, but these errors were encountered: