TypeScript: [BUG] Error: Debug Failure. Invalid cast. The supplied value [object Object] did not pass the test 'isJsonSourceFile'.
TypeScript Version: 3.2.1
Search Terms:
Code
declare global {
const React: typeof import("react");
const ReactDOM: typeof import("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)
Playground Link: https://gist.github.com/magic-akari/aa10dfb809268eb4f63d5749d113a93a
Related Issues:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 21
- Comments: 24 (9 by maintainers)
Commits related to this issue
- fix typescript version https://github.com/Microsoft/TypeScript/issues/28762 — committed to yuya373/manga-viewer by yuya373 6 years ago
- fix typescript version https://github.com/Microsoft/TypeScript/issues/28762 — committed to yuya373/manga-viewer by yuya373 6 years ago
- fix: use html-webpack-plugin stable release and use TS 3.1.6 to avoid bug Microsoft/TypeScript#28762 — committed to tianzhich/counseling-system-fe by deleted user 5 years ago
I remove
"esModuleInterop": true; add"allowSyntheticDefaultImports": true.solved the problem.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.
I am still getting the same error in TypeScript 3.2.2 where it should have been fixed.
@weswigham I solved it by downgrading to TypeScript 3.1 (if this makes sense!)
Can confirm, that’s my issue as well after updating to 3.2.1, although I’m using webpack standalone(no create react app)
Same issue here. The only change I made to a repository is to update 3.1.3 to 3.2.1.
If typescript version is locked to 3.1.6 it will remove the ‘isJsonSourceFile’ error
Same issue, also went from 3.1.3 to 3.2.1. I tried making the change suggested by @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)