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
enumA{a,b,c}typeb=A.a|A.bconsta: {[keyinA]?: {[keyinA]?: string}}={[A.a]: {[A.a]: "a"}}functiont(){// below line will have error on a[A.a][A.a] for possibly `undefined` when enabled `strictNullChecks`if(a[A.a]&&a[A.a][A.a]){returna[A.a][A.a];}return}
Expected behavior:
no err when enable strictNullChecks, as the undefined should be ruled out after first a[A.a] check.
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
enum as key
Code
Expected behavior:
no err when enable
strictNullChecks
, as theundefined
should be ruled out after firsta[A.a]
check.Actual behavior:
Object is possibly 'undefined'.
fora[A.a][A.a]
Playground Link: https://www.typescriptlang.org/play/#src=enum%20A%20%7B%0D%0A%20%20a%2C%0D%0A%20%20b%2C%0D%0A%20%20c%0D%0A%7D%0D%0A%0D%0Atype%20b%20%3D%20A.a%7CA.b%0D%0A%0D%0Aconst%20a%3A%20%7B%0D%0A%20%20%5Bkey%20in%20A%5D%3F%3A%20%7B%0D%0A%20%20%20%20%5Bkey%20in%20A%5D%3F%3A%20string%0D%0A%20%20%7D%0D%0A%7D%20%3D%20%7B%0D%0A%20%20%5BA.a%5D%3A%20%7B%0D%0A%20%20%20%20%5BA.a%5D%3A%20%22a%22%0D%0A%20%20%7D%0D%0A%7D%0D%0A%0D%0Afunction%20t()%20%7B%0D%0A%20%20if%20(a%5BA.a%5D%20%26%26%20a%5BA.a%5D%5BA.a%5D)%20%7B%0D%0A%20%20%20%20return%20a%5BA.a%5D%5BA.a%5D%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20return%0D%0A%7D
The text was updated successfully, but these errors were encountered: