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
{{ message }}
Repository navigation
Visitor throws Cannot read property 'kind' of undefined using [email protected]Β #38558
TypeError: Cannot read property 'kind' of undefined
at visitObjectLiteralExpression (node_modules/typescript/lib/typescript.js:85032:35)
at visitJavaScript (node_modules/typescript/lib/typescript.js:83441:28)
at visitor (node_modules/typescript/lib/typescript.js:83384:24)
at visitNode (node_modules/typescript/lib/typescript.js:74768:23)
at Object.visitEachChild (node_modules/typescript/lib/typescript.js:75209:108)
at visitJavaScript (node_modules/typescript/lib/typescript.js:83491:31)
at visitor (node_modules/typescript/lib/typescript.js:83384:24)
at visitNodes (node_modules/typescript/lib/typescript.js:74819:48)
at Object.visitEachChild (node_modules/typescript/lib/typescript.js:75034:53)
at visitObjectLiteralExpression (node_modules/typescript/lib/typescript.js:85057:23)
The issue is in the es2015 transformer so any target above es2015 will be fine. In fact, the issue is in the object literal visitor when the node contains "es2015 features (eg. template literals, arrow functions, ...)" that need to be transformed. So you can reproduce the same crash with this code using arrow functions:
Until the bug is fixed, Lukas Klusis (@lukaskl) you can use a string instead of a template literal for the background variable or use an external variable to store the template literal outside of the object literal like that:
After more investigations, I confirmed that the code crashing is in the es2015 transformer but the root cause is not in here. The bug is actually in the es2018 transformer.
Here is an example of code with a target es2017 (< es2018):
tsc throws the same error for me with TypeScript version 3.9.7:
Chase@DESKTOP-P21MP39 MINGW64 ~/company/companyWeb/projects/company.Server.Web ((b99b96a0de...))
$ node_modules/typescript/bin/tsc
C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:82931
throw e;
^
TypeError: Cannot read property 'kind' of undefined
at visitObjectLiteralExpression (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:70631:35)
at visitJavaScript (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:69611:28)
at visitor (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:69554:24)
at visitNode (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:63010:23)
at Object.visitEachChild (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:63260:45)
at visitParenthesizedExpression (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:70365:23)
at visitJavaScript (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:69625:28)
at visitor (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:69554:24)
at Object.visitNode (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:63010:23)
at transformFunctionBody (C:\Users\Chase\company\companyWeb\projects\company.Server.Web\node_modules\typescript\lib\tsc.js:70307:37)
My project is quite large. I don't know which code tsc fails on.
Edit: This happens when I try to upgrade directly from typescript version 3.7.3 to 3.9.7. Version 3.7.3 works for me.
Activity
lissein commentedon May 14, 2020
I managed to reduce the reproduction code down to:
The issue is in the es2015 transformer so any target above es2015 will be fine. In fact, the issue is in the object literal visitor when the node contains "es2015 features (eg. template literals, arrow functions, ...)" that need to be transformed. So you can reproduce the same crash with this code using arrow functions:
This code, for instance does not crash because the object literal doesn't have any es2015 features in it.
I'll try to fix this.
Until the bug is fixed, Lukas Klusis (@lukaskl) you can use a string instead of a template literal for the background variable or use an external variable to store the template literal outside of the object literal like that:
lukaskl commentedon May 14, 2020
Thank you Lissein (@lissein) for investigating this!
To add another workaround, it is also possible to split this into two definitions, e.g.:
lissein commentedon May 14, 2020
After more investigations, I confirmed that the code crashing is in the es2015 transformer but the root cause is not in here. The bug is actually in the es2018 transformer.
Here is an example of code with a target es2017 (< es2018):
As you can see, the second spread is transpiled correctly but the first one isn't.
elibarzilay commentedon May 15, 2020
(This is most likely very unrelated to #38383...)
Make `processTaggedTemplateExpression` visit a returned node
Make `processTaggedTemplateExpression` visit a returned node
Make `processTaggedTemplateExpression` visit a returned node
chaselal commentedon Jul 21, 2020
tscthrows the same error for me with TypeScript version 3.9.7:My project is quite large. I don't know which code
tscfails on.Edit: This happens when I try to upgrade directly from typescript version 3.7.3 to 3.9.7. Version 3.7.3 works for me.
peterj35-dd commentedon Aug 11, 2021
Why has this issue been closed, what is the resolution without having to make manual code changes? I'm facing the same issue on 3.9.10, targetting ES5