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
Minimal example is in the attached zip package. Extract it somewhere, go to main directory with tsconfig.json and
install npm i
compile node node_modules/typescript/bin/tsc
Expected behavior:
everything works fine - preferred, because with TS 2.8.x there are no errors,
or some reasonable error message for problem solving
Actual behavior:
compiler crashes with
E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:69365
throw e;
^
TypeError: Cannot read property 'parent' of undefined
at Object.getDeclarationOfExpando (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:7328:19)
at getTypeOfFuncClassEnumModule (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:28883:40)
at getTypeOfSymbol (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:28984:24)
at checkImportCallExpression (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:40833:96)
at checkExpressionWorker (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:42356:32)
at checkExpression (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:42301:42)
at checkAwaitExpression (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:41525:31)
at checkExpressionWorker (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:42383:28)
at checkExpression (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:42301:42)
at checkExpressionCached (E:\projects\vscode-crash\node_modules\typescript\lib\tsc.js:42182:38)
Problem is with the imported javascript in TestComponent.tsx with
Problem is only with Typescript 2.9, 3.x, Typescript 2.8 compiles without any errors.
I tried to exclude javascript with tsconfig.json and jsconfig.json - see exclude properties in these files, but nothing works. Javascript is always compiled. So another question - is it possible exclude javascripts in similar situations?
The text was updated successfully, but these errors were encountered:
The immediate cause is the improved handling of module.exports in Typescript 2.9. The compiler is trying to figure out what the exports of ./js-xlsx/xlsx are, but somehow creates a defective export= symbol from the line module.exports = CFB.
Workaround
Any time you import a file, the compiler will read that file. Excludes will not help you. For a JS file that you do not want to compile, but nonetheless want to import, the easiest workaround is to put a d.ts file next to it. Here's the one I created:
This just exports a dummy variable with the type any so that the compiler doesn't spend any time analysing xlsx.js to figure out what it actually exports.
Edit: You are free to make the type of dummy as accurate as you want; it will probably be more accurate than the type the compiler produces after this bug is fixed.
Thank you for analysis and workaround. I will try it.
I found another possible workaround. I made another node_modules directory and copy the whole directory js-xlsx inside it. So the directory tree is components/node_modules/js-xlsx`/xlsx.js.
Dynamic import will be import('js-xlsx/xlsx).
It seems that because of module resolution or something like that, the compiler ignores the node_modules even of dynamic import. Final app is build via webpack and babel and it seems it has no problem with it.
What do you think about that?
I definitely waiting for the final typescript fix, thank you.
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 3.1.3 2.9.2
Code
tsjs-crash.zip
Minimal example is in the attached zip package. Extract it somewhere, go to main directory with tsconfig.json and
install
npm i
compile
node node_modules/typescript/bin/tsc
Expected behavior:
everything works fine - preferred, because with TS 2.8.x there are no errors,
or some reasonable error message for problem solving
Actual behavior:
compiler crashes with
Problem is with the imported javascript in TestComponent.tsx with
Problem is only with Typescript 2.9, 3.x, Typescript 2.8 compiles without any errors.
I tried to exclude javascript with tsconfig.json and jsconfig.json - see exclude properties in these files, but nothing works. Javascript is always compiled. So another question - is it possible exclude javascripts in similar situations?
The text was updated successfully, but these errors were encountered: