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
[BUG] Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isJsonSourceFile'. #28762
declare global {constReact: typeofimport("react");constReactDOM: typeofimport("react-dom");}export{};
Expected behavior:
Actual behavior:
> tsc
/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:71026
throw e;
^
Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isJsonSourceFile'.
at Object.cast (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:1158:22)
at getTypeOfVariableOrParameterOrPropertyWorker (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:29354:41)
at getTypeOfVariableOrParameterOrProperty (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:29334:48)
at getTypeOfSymbol (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:29603:24)
at resolveImportSymbolType (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:33159:45)
at getTypeFromImportTypeNode (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:33141:25)
at getTypeFromTypeNode (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:33460:28)
at checkImportType (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:43996:13)
at checkSourceElement (/Users/akari/Developer/test/node_modules/typescript/lib/tsc.js:46921:28)
I got this issue while using webpack's dev server (in a project based on create-react-app). It will compile fine initially, but it will then throw this error whenever it attempts to re-compile.
Reacted by Thomas Cranny, Richard Honor, Samarychau Yury, Timothée Astier, Pavel Struhar, Andrey Ivlev, Quentin Hu, Nathan Hsieh, Michael Ceber, Chris Dopuch and 4 more
I got this issue while using webpack's dev server (in a project based on create-react-app). It will compile fine initially, but it will then throw this error whenever it attempts to re-compile.
Can confirm, that's my issue as well after updating to 3.2.1, although I'm using webpack standalone(no create react app)
Reacted by Elad Ossadon, Thomas Cranny and Nathan Hsieh
Ah, no, it's not fixed in master, i just had an outdated master in my laptop. Regression introduced by #27281 - now that it's resolving aliases prior to merging, a sourcefile can end up merged with a property (it used to merge with the alias declaration instead), and that should be handled.
I remove "esModuleInterop": true; add "allowSyntheticDefaultImports": true.solved the problem.
Reacted by Роман Герасимович, Paul Marlow, Frank Fang, Heidi Olsen, LoserAntbear, Anton Ratnikov, Saiya, Eugene Pyatibratov, Filip Andersson, 김나영 and 8 more
Same issue, also went from 3.1.3 to 3.2.1. I tried making the change suggested by leekk (@li2568261), however our project requires esModuleInterop to build at all.
(It's a React Redux frontend building with babel-loader, awesome-typescript-loader and through webpack)
I have the same error with different cause (I guess):
yarn start v0.17.8
$ ts-node ./src/engine/server/server
/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:1325
return Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + Debug.getFunctionName(test) + "'.");
^
Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isJsonSourceFile'.
at Object.cast (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:1325:22)
at getTypeOfVariableOrParameterOrPropertyWorker (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:35591:41)
at getTypeOfVariableOrParameterOrProperty (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:35567:48)
at getTypeOfSymbol (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:35856:24)
at getExternalModuleMember (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:32495:64)
at getTargetOfImportSpecifier (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:32530:20)
at getTargetOfAliasDeclaration (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:32562:28)
at resolveAlias (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:32595:30)
at checkAliasSymbol (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:55749:26)
at checkImportBinding (/Users/aa/.nvm/versions/node/v6.10.3/lib/node_modules/typescript/lib/typescript.js:55778:13)
error Command failed with exit code 1.
Does something in the react module somehow depend on the global declaration you add? Offhandedly, that's what I can think of.
I have no idea. I never modified @types/react or other libs, The gist will reproduce the error with typescript@next.
I am going to export the types of React as global Object, for I import React in html's script tag via CDN.
The gist works fine in typescript@3.1.6 and crashes in typescript@3.2.1.
And typescript@next gives me the error.
I am still getting the same error in TypeScript 3.2.2 where it should have been fixed.
ERROR in : Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isJsonSourceFile'.
at Object.cast (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:1325:22)
at getTypeOfVariableOrParameterOrPropertyWorker (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:35591:41)
at getTypeOfVariableOrParameterOrProperty (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:35567:48)
at getTypeOfSymbol (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:35856:24)
at checkVariableLikeDeclaration (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:54043:41)
at checkVariableDeclaration (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:54116:20)
at checkSourceElement (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:56137:28)
at Object.forEach (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:210:30)
at checkVariableStatement (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:54126:16)
at checkSourceElement (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:56106:28)
at Object.forEach (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:210:30)
at checkSourceFileWorker (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:56305:20)
at checkSourceFile (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:56277:13)
at getDiagnosticsWorker (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:56352:17)
at Object.getDiagnostics (/home/myprofile/myproject/node_modules/typescript/lib/typescript.js:56338:24)
at /home/myprofile/myproject/node_modules/typescript/lib/typescript.js:87001:85
Reacted by Thomas Cranny, Andrii Kharsun, Bowen Ni, Timmy Huang and Juan Camilo Salazar
Activity
li2568261 commentedon Nov 30, 2018
had a similar issue.wait......
sheetalkamat commentedon Nov 30, 2018
Seems like we are doing something wrong when getting import type for module
luvies commentedon Nov 30, 2018
I got this issue while using webpack's dev server (in a project based on create-react-app). It will compile fine initially, but it will then throw this error whenever it attempts to re-compile.
tmkn commentedon Nov 30, 2018
Can confirm, that's my issue as well after updating to 3.2.1, although I'm using webpack standalone(no create react app)
weswigham commentedon Nov 30, 2018
This seems to be fixed in
master, but not in3.2- will have to see by what change.weswigham commentedon Nov 30, 2018
Ah, no, it's not fixed in master, i just had an outdated
masterin my laptop. Regression introduced by #27281 - now that it's resolving aliases prior to merging, a sourcefile can end up merged with a property (it used to merge with the alias declaration instead), and that should be handled.li2568261 commentedon Dec 1, 2018
I remove
"esModuleInterop": true; add"allowSyntheticDefaultImports": true.solved the problem.Can-Sahin commentedon Dec 1, 2018
Same issue here. The only change I made to a repository is to update 3.1.3 to 3.2.1.
favna commentedon Dec 3, 2018
Same issue, also went from 3.1.3 to 3.2.1. I tried making the change suggested by leekk (@li2568261), however our project requires esModuleInterop to build at all.
(It's a React Redux frontend building with babel-loader, awesome-typescript-loader and through webpack)
AlexAtrx commentedon Dec 5, 2018
I have the same error with different cause (I guess):
Any idea?
mandarzope commentedon Dec 5, 2018
If typescript version is locked to 3.1.6 it will remove the 'isJsonSourceFile' error
weswigham commentedon Dec 5, 2018
@A-Atrash with what version of the compiler? This fix is only in
typescript@next.1 remaining item
weswigham commentedon Dec 6, 2018
Does something in the react module somehow depend on the global declaration you add? Offhandedly, that's what I can think of.
AlexAtrx commentedon Dec 6, 2018
Wesley Wigham (@weswigham) I solved it by downgrading to TypeScript 3.1 (if this makes sense!)
magic-akari commentedon Dec 7, 2018
I have no idea. I never modified
@types/reactor other libs, The gist will reproduce the error withtypescript@next.I am going to export the types of React as global Object, for I import React in html's script tag via CDN.
The gist works fine in
typescript@3.1.6and crashes intypescript@3.2.1.And
typescript@nextgives me the error.fix typescript version
fix typescript version
livthomas commentedon Jan 10, 2019
I am still getting the same error in TypeScript 3.2.2 where it should have been fixed.
eugene1g commentedon Jan 10, 2019
Tomáš Livora (@livthomas) the betas work for me e.g.
3.3.0-dev.20190110fix: use html-webpack-plugin stable release and use TS 3.1.6 to avoid…
davidLeonardi commentedon Jan 31, 2019
Still having this issue with typescript@next , which is now 3.4.0-dev[31st jan 2019]
edsilv commentedon May 2, 2019
Same issue with typescript@next
3.5.0-dev.weswigham commentedon May 2, 2019
Do you have a small repro?
edsilv commentedon May 2, 2019
Wesley Wigham (@weswigham) https://github.com/IIIF-Commons/iiif-metadata
I solved it by updating stencil to
0.18.0. Try setting it back to0.16.2to reproduce.As far as I can tell it's the contents of
globals.d.tsthat are causing the build error. So not sure why updating stencil made a difference...weswigham commentedon May 3, 2019
Stencil
0.16.2uses TS3.2.2internally (irrespective of what version you install above it), which'd be why upgrading stencil fixed it for you :Pedsilv commentedon May 3, 2019