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
TypeScript Version: 3.3.2 (tried latest next and issue still existed)
Search Terms:
charCodeAt, isLateBoundName
Code
exportinterfaceA{type: 'a'}exportinterfaceB{type: 'b'}exporttypeAB=A|BconstitemId='some-id'// --- test on first level ---constitems: {[id: string]: AB}={}const{[itemId]: itemOk1}=itemstypeofitemOk1// pass// --- test on second level ---interfaceObjWithItems{items: {[s: string]: AB}}constobjWithItems: ObjWithItems={items: {}}constitemOk2=objWithItems.items[itemId]typeofitemOk2// passconst{items: {[itemId]: itemWithTSError}={}/*happens when default value is provided*/}=objWithItems// in order to re-produce the error, uncomment next line:// typeof itemWithTSError // :(// will result in:// Error from compilation: TypeError: Cannot read property 'charCodeAt' of undefined TypeError: Cannot read property 'charCodeAt' of undefined
Expected behavior:
No crash.
Actual behavior:
Crashes with TypeError mid-compilation:
TypeError: Cannot read property 'charCodeAt' of undefined
at isLateBoundName (...\typescript.js:36537:25)
at createUnionOrIntersectionProperty (...\typescript.js:37624:42)
at getUnionOrIntersectionProperty (...\typescript.js:37690:28)
at getPropertyOfUnionOrIntersectionType (...\typescript.js:37698:28)
at getPropertyOfType (...\typescript.js:37731:24)
at getTypeOfPropertyOfType (...\typescript.js:35017:24)
at getTypeOfDestructuredProperty (...\typescript.js:44548:45)
at getInitialTypeOfBindingElement (...\typescript.js:44613:17)
at getInitialType (...\typescript.js:44641:17)
at getInitialOrAssignedType (...\typescript.js:44645:17)
The text was updated successfully, but these errors were encountered:
weswigham
added
Bug
A bug in TypeScript
Crash
For flagging bugs which are compiler or service crashes or unclean exits, rather than bad output
labels
Dec 13, 2018
TypeScript Version: 3.3.2 (tried latest
next
and issue still existed)Search Terms:
charCodeAt, isLateBoundName
Code
Expected behavior:
No crash.
Actual behavior:
Crashes with TypeError mid-compilation:
Playground Link:
https://www.typescriptlang.org/play/#src=export%20interface%20A%20%7B%20type%3A%20'a'%20%7D%0D%0Aexport%20interface%20B%20%7B%20type%3A%20'b'%20%7D%0D%0Aexport%20type%20AB%20%3D%20A%20%7C%20B%0D%0A%0D%0Aconst%20itemId%20%3D%20'some-id'%0D%0A%0D%0A%2F%2F%20---%20test%20on%20first%20level%20---%0D%0Aconst%20items%3A%20%7B%20%5Bid%3A%20string%5D%3A%20AB%20%7D%20%3D%20%7B%7D%0D%0Aconst%20%7B%20%5BitemId%5D%3A%20itemOk1%20%7D%20%3D%20items%0D%0Atypeof%20itemOk1%20%2F%2F%20pass%0D%0A%0D%0A%2F%2F%20---%20test%20on%20second%20level%20---%0D%0Ainterface%20ObjWithItems%20%7B%0D%0A%20%20%20%20items%3A%20%7B%5Bs%3A%20string%5D%3A%20AB%7D%0D%0A%7D%0D%0Aconst%20objWithItems%3A%20ObjWithItems%20%3D%20%7B%20items%3A%20%7B%7D%7D%0D%0A%0D%0Aconst%20itemOk2%20%3D%20objWithItems.items%5BitemId%5D%0D%0Atypeof%20itemOk2%20%2F%2F%20pass%0D%0A%0D%0Aconst%20%7B%0D%0A%20%20%20%20items%3A%20%7B%20%5BitemId%5D%3A%20itemWithTSError%20%7D%20%3D%20%7B%7D%20%2F*happens%20when%20default%20value%20is%20provided*%2F%0D%0A%7D%20%3D%20objWithItems%0D%0A%0D%0A%2F%2F%20in%20order%20to%20re-produce%20the%20error%2C%20uncomment%20next%20line%3A%0D%0A%2F%2F%20typeof%20itemWithTSError%20%2F%2F%20%3A(%0D%0A%0D%0A%2F%2F%20will%20result%20in%3A%0D%0A%2F%2F%20Error%20from%20compilation%3A%20TypeError%3A%20Cannot%20read%20property%20'charCodeAt'%20of%20undefined%20%20TypeError%3A%20Cannot%20read%20property%20'charCodeAt'%20of%20undefined
Related Issues:
Looks similar to #26321
The text was updated successfully, but these errors were encountered: