TypeScript Version: 3.3.0-dev.20181201
Search Terms:
Code
Sorry, I need help finding which part of my code is triggering this error. We have a very large code base, and the error does not tell me which file/line/expression is being compiled. Happy to provide more information with assistance.
Expected behavior:
Building through awesome-typescript-loader. Expect compilation and type check to complete without exceptions being thrown.
Actual behavior:
Logs these two error messages (with two different traces).
Sometimes the type check completes and I get all my errors (there are many after the upgrading to 3.2.1). Other times the compile errors are never logged.
On 3.2.1:
On 3.3.0-dev.20181201:
Only did this once because the build is taking a few minutes on this version (is that normal?).
Error 1:
TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:13389:21)
at getTypeReferenceTypeWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:38553:51)
at getTypeReferenceType (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:38492:24)
at getTypeFromTypeReference (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:38671:28)
at getTypeFromTypeNode (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:40178:28)
at tryGetTypeFromEffectiveTypeNode (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35562:24)
at getTypeForVariableLikeDeclaration (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35192:32)
at getWidenedTypeForVariableLikeDeclaration (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35531:56)
at getTypeOfVariableOrParameterOrPropertyWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35645:24)
at getTypeOfVariableOrParameterOrProperty (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35567:48)
at getTypeOfSymbol (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35856:24)
at checkPropertyAccessExpressionOrQualifiedName (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48170:53)
at checkPropertyAccessExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48122:20)
at checkExpressionWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51802:28)
at checkExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51745:42)
at checkTruthinessExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:54156:24)
at checkBinaryLikeExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51208:28)
at checkBinaryExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51199:20)
at checkExpressionWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51841:28)
at checkExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51745:42)
at checkParenthesizedExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51768:20)
at checkExpressionWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51815:28)
Error 2:
TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:13389:21)
at getTypeReferenceTypeWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:38576:51)
at getTypeReferenceType (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:38515:24)
at getTypeFromTypeReference (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:38694:28)
at getTypeFromTypeNode (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:40201:28)
at tryGetTypeFromEffectiveTypeNode (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35585:24)
at getTypeForVariableLikeDeclaration (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35215:32)
at getWidenedTypeForVariableLikeDeclaration (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35554:56)
at getTypeOfVariableOrParameterOrPropertyWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35668:24)
at getTypeOfVariableOrParameterOrProperty (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35590:48)
at getTypeOfSymbol (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:35879:24)
at checkPropertyAccessExpressionOrQualifiedName (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48194:53)
at checkPropertyAccessExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48146:20)
at checkExpressionWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51826:28)
at checkExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51769:42)
at checkNonNullExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48120:37)
at checkPropertyAccessExpressionOrQualifiedName (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48153:28)
at checkPropertyAccessExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48146:20)
at checkExpressionWorker (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51826:28)
at checkExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:51769:42)
at checkNonNullExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:48120:37)
at resolveCallExpression (/Users/rhys/Projects/usability-hub/usability_hub/node_modules/typescript/lib/typescript.js:49446:28)
Related Issues:
There are many issues with this error message but with different callstacks. Most are resolved. My understanding is that this error ("Cannot read property 'kind' of undefined") can arise under many circumstances so the others may not be strictly related.
To search related issues to callstacks is better search the top function in callstack: Object.isBinaryExpression or getTypeReferenceTypeWorker
Thanks @j-oliveras. Only hits are this issue and one other for the latter which seems unrelated.
i have the same error,when react-hot-loader begin to compile
i 「wdm」: Compiling...
**\[email protected]@typescript\lib\typescript.js:86983
throw e;
TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:13389:21)
at getTypeReferenceTypeWorker (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:38553:51)
at getTypeReferenceType (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:38492:24)
at getTypeFromTypeReference (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:38671:28)
at getTypeFromTypeNode (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:40178:28)
at tryGetTypeFromEffectiveTypeNode (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35562:24)
at getTypeForVariableLikeDeclaration (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35192:32)
at getWidenedTypeForVariableLikeDeclaration (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35531:56)
at getTypeOfVariableOrParameterOrPropertyWorker (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35645:24)
at getTypeOfVariableOrParameterOrProperty (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35567:48)
at getTypeOfSymbol (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35856:24)
at checkPropertyAccessExpressionOrQualifiedName (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:48170:53)
at checkPropertyAccessExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:48122:20)
at checkExpressionWorker (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:51802:28)
at checkExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:51745:42)
at checkNonNullExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:48096:37)
Do you have an example project which reproduces the issue that we can look at?
@weswigham is it possible to get more information on which file is being parsed from the error with a compiler setting? I'm happy to look into it, but we have ~1000 TS files in our project, as well as external types. Not quite clear how to start.
If you instrument the checkSourceFile
function in typescript.js
to print node.path
on entry, you can at least check what file started the chain of operations that led to the crash (we have nothing builtin for tracking checker crashes or progress in general).
@weswigham I spent a day trying to find the cause of this error,but no clue.
I don't know what clues I can provide.
I am also seeing this error intermittently compiling with 3.2.1 ... This never happens with 3.1.6.
I _think_ this may be the result of a UMD global merging with a class? Like maybe
// @filename: class.d.ts
class Foo {}
export = Foo;
declare global {
const Mod: typeof Foo;
}
export as namespace Mod;
// @filename: usage.d.ts
type Foob = Mod;
... maybe? Does anyone know if they've got any export as namespace
's going on in their projects, and, if so, if they also have any declare global
s of the same? Doesn't explain how it could possibly be intermittent, but...
Our project has a module that exports a function and a namespace with the same name if that fits your scenario. We could make some changes, but that's never been a problem before now.
Mmm, not really, not what I was thinking of.
@weswigham @rhys-vdw you could try the error by https://github.com/wanliyunyan/test-typescript-issue-28810, the error occur in my environment at least
I have exactly the same error when react-hot-loader begins to compile like @wanliyunyan with the same stack on TS 3.2.1 and 3.2.2
I get the same error if I try to use the rest operator to split one object into two objects. I'm not sure if this is even legal as I couldn't find a definitive answer, but I thought I'd try it and see. There's no Error in Webstorm, or on compilation, but on load, I get:
ERROR in : TypeError: Cannot read property 'kind' of undefined
at Object.getTextOfPropertyName (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:8653:22)
at getRestType (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:34290:30)
at checkObjectLiteralDestructuringPropertyAssignment (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:49992:28)
at checkObjectLiteralAssignment (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:49958:17)
at checkDestructuringAssignment (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50097:24)
at checkBinaryLikeExpression (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50187:24)
at checkBinaryExpression (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50182:20)
at checkExpressionWorker (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50789:28)
at checkExpression (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50696:42)
at checkParenthesizedExpression (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50719:20)
at checkExpressionWorker (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50763:28)
at checkExpression (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:50696:42)
at checkExpressionStatement (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:53068:13)
at checkSourceElement (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:55035:28)
at Object.forEach (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:210:30)
at checkBlock (/Users/jimbrownfield/radical/Consulting/ComAppTech/node_modules/typescript/lib/typescript.js:52672:20)
The code line is:
({...this.address, ...this.aniRecordInformation} = value);
If I comment this like out, it compiles and loads.
Totally willing to admit that my code may be illegal, but it should give me a better compile-time error (or at least any compile-time error).
I got the same error. I use webpack
, ts-loader
, webpack-dev-middleware
.
typescript/lib/typescript.js:13389
return node.kind === 204 /* BinaryExpression */;
^
TypeError: Cannot read property 'kind' of undefined
Having the same problem here. Usually random but I can get it to happen consistently by switching between two branches in my repo (happens in both directions). I was able to narrow it down to one file by instrumenting part of typescript.js
as @weswigham suggested, but I don't see anything in that file that looks suspicious. That said, its not exactly tiny at 480 lines. Any way to narrow down to a line in that file?
Instrumenting getTypeReferenceTypeWorker
to log the locations of each element of symbol.declarations
when symbol.valueDeclaration.parent === undefined
is probably what you'd want to look at.
@weswigham Thanks for the tip, but I think I might not be doing something right. I added the following right before the if statement that contains the throwing call to isBinaryExpression
:
if (symbol.valueDeclaration && symbol.valueDeclaration.parent === undefined) {
console.log('symbol.declarations', symbol.declarations);
}
And I'm seeing a huge SourceFileObject
that appears to be node_modules/@types/history/index.d.ts
, but it appears to crash before console.log
finishes printing the whole object.
After further inspection, the file I mentioned in my previous post does use history.pushState
in one place. After commenting this out, the compile doesn't crash when switching branches, and instead just shows me a bunch of compile errors related to not picking up some .d.ts files that are present in one branch but not the other or vice versa (not entirely unexpected). I also tried changing the call to window.history.pushState
just to see but that still results in the crash.
I'm not really sure what any of that means, but I'm happy to do more testing on my end since I'm able to reproduce it consistently.
Seems like it might be an issue with something in the shape of @types/history
. I think it's probably caused by the merge of a class and a source file via a UMD declaration and a global. Once I get an isolated repro (so we don't regress) it should be easy to fix.
https://github.com/wanliyunyan/test-typescript-issue-28810, do you try this repro ? @weswigham
I meant a minimal repro for our regression testing suite. :smile: Still gotta sort thru that one to see what's required to cause the issue.
well, I tried to delete unnecessary files("/src/applyLoan" that is not be imported actually, I think this is the key to the problem.) about the repro, but the error is gone. I don't know how I can help you anymore. @weswigham
That's OK. I wasn't asking for anyone specifically to reduce it. Just remarking that it needs doing to make a fix~
Not sure if this is helpful for anyone:
For me this line of code was causing the same problem
history.pushState(origForm, 'page 2',
/Crm/Customers/?${origForm});
I implemented fork-ts-checker-webpack-plugin which also decreased my build time a bit.
for me, the issue only occurs with webpack HMR (when using webpack-dev-server). The config scripts are sourced from create-react-app
.
Here is a stacktrace for reference:
/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:86984
throw e;
^
TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:13389:21)
at getTypeReferenceTypeWorker (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:38553:51)
at getTypeReferenceType (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:38492:24)
at getTypeFromTypeReference (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:38671:28)
at getTypeFromTypeNode (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:40178:28)
at tryGetTypeFromEffectiveTypeNode (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:35562:24)
at getTypeForVariableLikeDeclaration (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:35192:32)
at getWidenedTypeForVariableLikeDeclaration (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:35531:56)
at getTypeOfVariableOrParameterOrPropertyWorker (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:35645:24)
at getTypeOfVariableOrParameterOrProperty (/home/christopher/IdeaProjects/collections-ui/packages/collections-ui-app/node_modules/typescript/lib/typescript.js:35567:48)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node scripts/start.js`
normal tsc compilation works without error. When any file is changed, the above exception is thrown.
Not sure if this is helpful for anyone:
For me this line of code was causing the same problem
history.pushState(origForm, 'page 2',
/Crm/Customers/?${origForm});
I implemented fork-ts-checker-webpack-plugin which also decreased my build time a bit.
I've got the same problem.
If i use history
or window.history
in a scope without a variable called history
, HMR will crash.
TypeScript version 3.2.2. When back to use v3.1.6, this problem won't happen.
Here's my stacktrace:
/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:86983
throw e;
^
TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:13389:21)
at getTypeReferenceTypeWorker (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:38553:51)
at getTypeReferenceType (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:38492:24)
at getTypeFromTypeReference (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:38671:28)
at getTypeFromTypeNode (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:40178:28)
at tryGetTypeFromEffectiveTypeNode (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35562:24)
at getTypeForVariableLikeDeclaration (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35192:32)
at getWidenedTypeForVariableLikeDeclaration (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35531:56)
at getTypeOfVariableOrParameterOrPropertyWorker (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35645:24)
at getTypeOfVariableOrParameterOrProperty (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35567:48)
Not sure if this is helpful for anyone:
For me this line of code was causing the same problem
history.pushState(origForm, 'page 2',
/Crm/Customers/?${origForm});
I implemented fork-ts-checker-webpack-plugin which also decreased my build time a bit.I've got the same problem.
If i usehistory
orwindow.history
in a scope without a variable calledhistory
, HMR will crash.TypeScript version 3.2.2. When back to use v3.1.6, this problem won't happen.
Here's my stacktrace:
/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:86983 throw e; ^ TypeError: Cannot read property 'kind' of undefined at Object.isBinaryExpression (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:13389:21) at getTypeReferenceTypeWorker (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:38553:51) at getTypeReferenceType (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:38492:24) at getTypeFromTypeReference (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:38671:28) at getTypeFromTypeNode (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:40178:28) at tryGetTypeFromEffectiveTypeNode (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35562:24) at getTypeForVariableLikeDeclaration (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35192:32) at getWidenedTypeForVariableLikeDeclaration (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35531:56) at getTypeOfVariableOrParameterOrPropertyWorker (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35645:24) at getTypeOfVariableOrParameterOrProperty (/Users/pegasusknight/git/monorepo/node_modules/byted-react-scripts/node_modules/typescript/lib/typescript.js:35567:48)
If remove export as namespace History;
(or rename History
to whatever other name) from @types/history
, this problem will be solved. Is it seemed to be a bug of TypeScript or breaking changes of v3.2 ?
Oh, most definitely a bug. We're pretty much never supposed to crash ;)
Is it possible this is related to #28762 ? When I run my build out of webpack dev server I get the error listed in that bug where as when I run a webpack build I get this bug. (The only typescript on my system/project is 3.2.2).
When I throw a breakpoint on the invalid cast Debug.fail (typescript.js:1325) I can see that the value
has a fileName
of node_modules/@types/history/index.d.ts
to further support this idea that this is somehow related to the way that the histroy typings have been written.
I had the same problem, but with these versions it's working now:
webpack 4.28.3, webpack-dev-server 3.1.14, react-hot-loader 4.6.3, typescript 3.2.2
Fixed it by just adding @types/history
I had the same problem, but with these versions it's working now:
webpack 4.28.3, webpack-dev-server 3.1.14, react-hot-loader 4.6.3, typescript 3.2.2
I have this problem with those versions ;/
It happend to me when I renamed a file name that starts with lowercase, to start with uppercase.
While the import statment that loads this file stays on the lowercase version.
The moment I changed the casing in the import statment it got fixed, so it might be related to the OS filesystem case sensitivity. (I'm using windows 10 if that helps)
in addition to this error I started to get
✖ 「atl」: Child process failed to process the request: Error: Debug Failure. False expression: Semantic diagnostics shouldnt be available for changed files
at createBuilderProgramState (/Users/denis/golangci-web/node_modules/typescript/lib/typescript.js:89054:26)
at Object.createBuilderProgram (/Users/denis/golangci-web/node_modules/typescript/lib/typescript.js:89358:21)
at createSemanticDiagnosticsBuilderProgram (/Users/denis/golangci-web/node_modules/typescript/lib/typescript.js:89504:19)
at createNewProgram (/Users/denis/golangci-web/node_modules/typescript/lib/typescript.js:90967:30)
at Object.synchronizeProgram [as getProgram] (/Users/denis/golangci-web/node_modules/typescript/lib/typescript.js:90947:17)
at getProgram (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/runtime.ts:154:16)
at getEmitOutput (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/runtime.ts:403:19)
at emit (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/runtime.ts:422:24)
at processEmit (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/runtime.ts:458:22)
at /Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/runtime.ts:610:6
at Object.send (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/runtime.ts:49:6)
at Checker.req (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/checker.ts:100:15)
at Checker.emitFile (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/checker/checker.ts:105:15)
at transform (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/index.ts:130:26)
at transformationFunction (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/index.ts:72:40)
at compiler (/Users/denis/golangci-web/node_modules/awesome-typescript-loader/src/index.ts:83:21)
from today.
Fixed both problems by downgrading typescript
to 3.1.6
cc @sheetalkamat @jirfag 's error seems distinctly different than the rest of these. @jirfag would you like to open a new issue (and, maybe, if you could, provide a repro?)
Got the exact same issue as @christopher-johnson. Compiling goes correct the first time around. After a change in the file, I get the following error (stacktrace):
Uncaught Error: Module build failed (from ./node_modules/ts-loader/index.js):
TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:13389)
at getTypeReferenceTypeWorker (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:38553)
at getTypeReferenceType (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:38492)
at getTypeFromTypeReference (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:38671)
at getTypeFromTypeNode (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:40178)
at tryGetTypeFromEffectiveTypeNode (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:35562)
at getTypeForVariableLikeDeclaration (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:35192)
at getWidenedTypeForVariableLikeDeclaration (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:35531)
at getTypeOfVariableOrParameterOrPropertyWorker (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:35645)
at getTypeOfVariableOrParameterOrProperty (:3000/Users/user/Development/repo/node_modules/typescript/lib/typescript.js:35567)
at Object../src/AppRouter.tsx (log.js:47)
at __webpack_require__ (bootstrap:724)
at fn (bootstrap:101)
at Module../src/index.tsx (index.tsx:1)
at __webpack_require__ (bootstrap:724)
at fn (bootstrap:101)
at Object.0 (index.tsx:7)
at __webpack_require__ (bootstrap:724)
at bootstrap:791
at bootstrap:791
Versions:
I tried upgrading to the suggested versions as @Q-Man suggested, but that did not work out for me.
Can confirm I was able to resolve this issue by downgrading Typescript to 3.1.6.
Just for the record, here are my versions:
I have the same issue but I generally do restart my server on other port and it automatically fix the issue. 'Strange thing is that it just came the very first time when I start working on my project every day once resolved it won't be back until I restart my computer. But I'll try to downgrade the Typescript to 3.1.6 and will let you know.
I confirm that I have to downgrade my Typescript version to 3.1.6 to resolve the problem
I am experiencing the same problem when launching my unit tests with Karma:
28 01 2019 17:15:39.334:INFO [compiler.karma-typescript]: Compiling project using Typescript 3.2.4
28 01 2019 17:15:43.370:ERROR [karma-server]: TypeError: Cannot read property 'kind' of undefined
at checkNestedBlockScopedBinding (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:45895:48)
at checkIdentifier (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:45801:13)
at checkExpressionWorker (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:51785:28)
at checkExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:51757:42)
at checkNonNullExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:48108:37)
at checkPropertyAccessExpressionOrQualifiedName (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:48141:28)
at checkPropertyAccessExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:48134:20)
at checkExpressionWorker (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:51814:28)
at checkExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:51757:42)
at checkNonNullExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:48108:37)
at checkPropertyAccessExpressionOrQualifiedName (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:48141:28)
at checkPropertyAccessExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:48134:20)
at checkExpressionWorker (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:51814:28)
at checkExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:51757:42)
at checkNonNullExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:48108:37)
at resolveCallExpression (C:\Radium\GitSources\flww-ui\shared-ui\src\Core.UI\node_modules\typescript\lib\typescript.js:49434:28)
npm ERR! Test failed. See above for more details.
Downgrading to TS 3.1.6 fixes the issue.
I have the same issue but I generally do restart my server on other port and it automatically fix the issue. 'Strange thing is that it just came the very first time when I start working on my project every day once resolved it won't be back until I restart my computer. But I'll try to downgrade the Typescript to 3.1.6 and will let you know.
@abhishek1716 I'm using Angular 7 with Angular-CLI, without webpack and just killing the ng serve and executing the npm run start again makes the error go away
Top Kek
The problem is the line export as namespace History
at @types/history/index.d.ts
. If this is removed or commented out, no issues appear to arise.
diff --git a/node_modules/@types/history/index.d.ts b/node_modules/@types/history/index.d.ts
index 3fff510..c9aede4 100644
--- a/node_modules/@types/history/index.d.ts
+++ b/node_modules/@types/history/index.d.ts
@@ -3,7 +3,7 @@
// Definitions by: Sergey Buturlakin <https://github.com/sergey-buturlakin>, Nathan Brown <https://github.com/ngbrown>, Young Rok Kim <https://github.com/rokoroku>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
-export as namespace History;
+// export as namespace History;
export type Action = 'PUSH' | 'POP' | 'REPLACE';
export type UnregisterCallback = () => void;
I encounter the same problem in typescript 3.3.1, when I upgrade typescript, awesome-typescript-loader report error. l like it, but at last I switch to ts-loader. and then the proplem has resolved, very happy.
Yea only solution right now seems to downgrade to 3.1.6
I had the same problem as @jirfag. 3.1.6
worked and 3.3.3
didn't. I switched like @kaimiyang from awesome typescript loader to ts-loader and everything seems all right
I can confirm the crash, and that it is triggered by line mentioned above in the history
library:
export as namespace History;
Manually deleting that line keeps TS from crashing, for my application.
Currently, this issue keeps me locked at TS 3.1, newer versions reproducibly crash, with that line from history
(a widely-used library BTW).
For what it's worth, I also had this error.
I tracked it down to this line in my code:
const x = async () => {
await a()
}
Where a
was undefined (I forgot an import).
I hope this is useful in tracking down the underlying bug.
Run into the problem again. Removing export as namespace History;
does not fix the error in my case. But I traced down to the error and it turned out to be a problem in @types/history
.
function getTypeReferenceTypeWorker(node, symbol, typeArguments) {
if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
if (symbol.valueDeclaration && symbol.valueDeclaration.parent == null) {
console.log(node) // <-------- where I put my log
}
if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent)) {
var jsdocType = getJSDocTypeReference(node, symbol, typeArguments);
if (jsdocType) {
return jsdocType;
}
}
return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments);
}
if (symbol.flags & 524288 /* TypeAlias */) {
return getTypeFromTypeAliasReference(node, symbol, typeArguments);
}
if (symbol.flags & 16 /* Function */ &&
isJSDocTypeReference(node) &&
isJSConstructor(symbol.valueDeclaration)) {
var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol));
if (resolved.callSignatures.length === 1) {
return getReturnTypeOfSignature(resolved.callSignatures[0]);
}
}
}
The output looks messy and I failed to stringify it(circular, but still too large to stringify). Logs is here: https://gist.github.com/chenyong/3ea3c1fe5f07a10ad5e0541727a21001
Run into the problem again. Removing
export as namespace History;
does not fix the error in my case. But I traced down to the error and it turned out to be a problem in@types/history
.
@chenyong Maybe you had another copy of @types/history
from another dependency? It is a fairly common dependency.
I am also suffering from the same issue,
Child process failed to process the request: TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:13451:21)
at getTypeReferenceTypeWorker (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:38865:51)
at getTypeReferenceType (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:38809:24)
at getTypeFromTypeReference (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:38986:28)
at getTypeFromTypeNode (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:40488:28)
at tryGetTypeFromEffectiveTypeNode (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:35772:24)
at getTypeForVariableLikeDeclaration (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:35401:32)
at getWidenedTypeForVariableLikeDeclaration (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:35741:56)
at getTypeOfVariableOrParameterOrPropertyWorker (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:35859:24)
at getTypeOfVariableOrParameterOrProperty (D:\hardik\cp-05-10-18\node_modules\typescript\lib\typescript.js:35777:48)
I got this problem caused by @types/history
being required by @types/react-router
. I removed @types/react-router
from my project to get rid of @types/history
and it solved it for me. Not ideal, but works for now. Typescript 3.3.1.
I use two different loaders depending on environment and noticed happypack works fine, but ts-loader doesn't.
Temporary workaround:
"postinstall": "sed -i -e 's,export as namespace History;,,' node_modules/@types/history/index.d.ts"
In package.json (scripts) and of course reinstall.
I can also confirm removing export as namespace History;
from @types/history did the trick for me.
Is this a problems with the typing file? Should someone open an issue with @DefinitelyTyped
@Pharylon @types/history
could create a workaround, but ultimately the compiler should not be crashing. Either the code is invalid and should cause a compile error, or the code is correct and should behave as expected (e.g. however it was handled in 3.1.6).
We also believe that PR #29339 probably fixes the issue, but have no idea how to write a repro in our test harness - the repro given in this thread needs webpack and a bunch of other moving parts to actually trigger the crash, and it all seems required, but we're not really sure _why_ - the construct in the checker that causes the crash doesn't seem to be constructable under normal circumstances.
Sounds like you had a fun time with that one @weswigham. Thanks. :)
I have the same error message, but in TS 3.3.3333
function checkNestedBlockScopedBinding(node, symbol) {
// console.log(symbol); // added some logging here
if (languageVersion >= 2 /* ES2015 */ ||
(symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 ||
symbol.valueDeclaration.parent.kind === 274 /* CatchClause */) {
return;
}
The log tells me the last symbol is zoomIdentity
: https://github.com/d3/d3-zoom#zoomIdentity
Used settings are:
{
"sourceMap": false,
"noFallthroughCasesInSwitch": true,
"strict": true,
"noImplicitReturns": true,
"preserveConstEnums": true,
"removeComments": true,
"traceResolution": false
module: 'UMD',
target: 'ES6',
moduleResolution: "node",
}
I think installing node_module updates solves the issue
npm install
it worked for me
I simply re-run
ng serve
again and it worked!
I simply re-run
ng serve
again and it worked!
That doesn't fix anything though. The issue still happens during live reload.
also, downgrading to typescript 3.1.6 made no difference for me
Surely somebody understands why this error is happening, and if they believed how difficult this is making Angular development for so many people, they'd fix it.
@robmandoe but it _is_ fixed in latest for me. Hence the issue being closed... Are you still having the issue in 3.4.1?
ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.3.0 but 3.4.1
was found instead. Maybe i need to upgrade something else.
@robmandoe Sounds like your "Angular Compiler" needs to be updated, or its dependencies do. Either way this issue is solved in tsc as far as I can tell.
Fixed it by just adding @types/history
Adding where?
Upgrading to 3.4.1 fixed it for me, without making any other changes.
I think installing node_module updates solves the issue
npm install
it worked for me
thanks it worked for me too
I had this error today in a NodeJS project (not Angular) using TypeScript 3.4.2.
Upgrading to 3.4.5 did not fix the error.
Deleting and reinstalling node_modules
did not fix the error.
TypeError: Cannot read property 'kind' of undefined
at Object.getTextOfIdentifierOrLiteral (node_modules\typescript\lib\tsc.js:8418:21)
at checkPropertyAccessibility (node_modules\typescript\lib\tsc.js:41021:148)
at checkPropertyAccessExpressionOrQualifiedName (node_modules\typescript\lib\tsc.js:41148:17)
at checkPropertyAccessExpression (node_modules\typescript\lib\tsc.js:41098:20)
at checkExpressionWorker (node_modules\typescript\lib\tsc.js:44383:28)
at checkExpression (node_modules\typescript\lib\tsc.js:44320:38)
at checkBinaryLikeExpression (node_modules\typescript\lib\tsc.js:43770:29)
at checkBinaryExpression (node_modules\typescript\lib\tsc.js:43756:20)
at checkExpressionWorker (node_modules\typescript\lib\tsc.js:44423:28)
at checkExpression (node_modules\typescript\lib\tsc.js:44320:38)
Here is the reproduction:
export default abstract class {
protected abstract get foobar(): string;
constructor() {
console.log(this.foobar);
}
}
I got this error while pushing code changes with GitKraken on an Ionic App
I have this issue while trying to add custom transformers with ts-loader. Tried with the following ts versions:
TypeError: Cannot read property 'kind' of undefined
at Object.isSourceFile (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:14006:2
1)
at emitShebangIfNeeded (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:86038:2
0)
at Object.writeFile (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:83735:13)
at printSourceFileOrBundle (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:832
66:25)
at emitJsFileOrBundle (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:83176:13
)
at emitSourceFileOrBundle (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:8310
8:13)
at forEachEmittedFile (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:82900:34
)
at Object.emitFiles (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:83091:9)
at emitWorker (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:89012:33)
at C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:88972:66
at runWithCancellationToken (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:89
063:24)
at Object.emit (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:88972:20)
at Object.transpileModule (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:1081
26:17)
at getTranspilationEmit (C:\Users\U\Desktop\Project\node_modules\ts-loader\dist\index.js:231:74)
at successLoader (C:\Users\U\Desktop\Project\node_modules\ts-loader\dist\index.js:33:11)
at Object.loader (C:\Users\U\Desktop\Project\node_modules\ts-loader\dist\index.js:21:12)
Transformer config is like that:
// webpack.config
const tsLoaderOptions = {
transpileOnly: true,
getCustomTransformers: path.join(__dirname, './webpack.ts-transformers.js')
}
````
```js
// webpack.ts-transformers.js
const optChainTransformer = require('ts-optchain/transform').default
const getCustomTransformers = () => ({ after: [optChainTransformer] })
module.exports = getCustomTransformers
If I change after
to before
, then I have this error:
Module build failed (from ./node_modules/ts-loader/index.js):
TypeError: Cannot read property 'length' of undefined
at Object.firstOrUndefined (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:108
3:22)
at Object.startsWithUseStrict (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:
64032:33)
at Object.visitLexicalEnvironment (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript
.js:64984:36)
at visitSourceFile (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:67712:53)
at saveStateAndInvoke (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:67355:27
)
at transformSourceFile (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:67338:2
7)
at transformSourceFileOrBundle (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js
:67318:20)
at C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:1492:86
at reduceLeft (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:1187:30)
at C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:1492:42
at transformRoot (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:82675:82)
at Object.map (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:499:29)
at Object.transformNodes (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:82662
:30)
at emitJsFileOrBundle (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:83154:32
)
at emitSourceFileOrBundle (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:8310
8:13)
at forEachEmittedFile (C:\Users\U\Desktop\Project\node_modules\typescript\lib\typescript.js:82900:34
)
Same error when I try to add a new element via a custom transformer with ts-loader:
import transformateurRepoGraphql from '../serveur/plugins/typescript/repo-graphql';
...
{
loader: 'ts-loader',
options: {
transpileOnly: false,
configFile: resolvePath('./tsconfig.json'),
context: ROOT_DIR,
getCustomTransformers: () => ({
before: [transformateurRepoGraphql()]
}),
}
}
import * as path from 'path';
import * as ts from 'typescript';
export function createTransformer(): ts.TransformerFactory<ts.SourceFile> {
const transformer: ts.TransformerFactory<ts.SourceFile> = (context) => {
const { sourceRoot } = context.getCompilerOptions();
return (file) => {
const visitor: ts.Visitor = (node) => {
if (ts.isCallExpression( node )) {
node.arguments = [ ts.createObjectLiteral([]) ];
return node;
}
return ts.visitEachChild(node, visitor, context);
}
return ts.visitNode(file, visitor);
};
};
return transformer;
}
export default createTransformer;
md5-b3a34f9b8db49f520d000880c6de411c
TypeError: Cannot read property 'kind' of undefined
at getAssignmentTargetKind (node_modules/typescript/lib/typescript.js:10688:28)
at Object.isAssignmentTarget (node_modules/typescript/lib/typescript.js:10731:16)
at checkArrayLiteral (node_modules/typescript/lib/typescript.js:49045:45)
at checkExpressionWorker (node_modules/typescript/lib/typescript.js:53941:28)
at checkExpression (node_modules/typescript/lib/typescript.js:53878:38)
at checkExpressionWithContextualType (node_modules/typescript/lib/typescript.js:53596:24)
at checkApplicableSignature (node_modules/typescript/lib/typescript.js:50853:35)
at chooseOverload (node_modules/typescript/lib/typescript.js:51238:26)
at resolveCall (node_modules/typescript/lib/typescript.js:51157:26)
at resolveCallExpression (node_modules/typescript/lib/typescript.js:51468:20)
at resolveSignature (node_modules/typescript/lib/typescript.js:51759:28)
at getResolvedSignature (node_modules/typescript/lib/typescript.js:51790:26)
at checkCallExpression (node_modules/typescript/lib/typescript.js:51877:29)
at checkExpressionWorker (node_modules/typescript/lib/typescript.js:53956:28)
at checkExpression (node_modules/typescript/lib/typescript.js:53878:38)
at checkAwaitExpression (node_modules/typescript/lib/typescript.js:52855:31)
md5-f088a500e094ead923704b8c6c4b2a3a
TypeError: Cannot read property 'text' of undefined
at getErrorSpanForNode (node_modules/typescript/lib/typescript.js:9363:40)
at Object.createDiagnosticForNodeFromMessageChain (node_modules/typescript/lib/typescript.js:9290:20)
at checkTypeRelatedTo (node_modules/typescript/lib/typescript.js:42751:31)
at checkTypeRelatedToAndOptionallyElaborate (node_modules/typescript/lib/typescript.js:42030:24)
at checkApplicableSignature (node_modules/typescript/lib/typescript.js:50858:26)
at resolveCall (node_modules/typescript/lib/typescript.js:51168:21)
at resolveCallExpression (node_modules/typescript/lib/typescript.js:51468:20)
at resolveSignature (node_modules/typescript/lib/typescript.js:51759:28)
at getResolvedSignature (node_modules/typescript/lib/typescript.js:51790:26)
at checkCallExpression (node_modules/typescript/lib/typescript.js:51877:29)
at checkExpressionWorker (node_modules/typescript/lib/typescript.js:53956:28)
at checkExpression (node_modules/typescript/lib/typescript.js:53878:38)
at checkAwaitExpression (node_modules/typescript/lib/typescript.js:52855:31)
at checkExpressionWorker (node_modules/typescript/lib/typescript.js:53980:28)
at checkExpression (node_modules/typescript/lib/typescript.js:53878:38)
at checkExpressionCached (node_modules/typescript/lib/typescript.js:53617:38)
Typescript version: 3.5.3
Exactly the same if I change before
to after
~Temporarily fixed by using awesome-typescript-loader instead of ts-loader~
The errors also occurs with at-loader
Updated to 3.6.4
and still getting the error.
I only get the error when I use ts-react-display-name
Is there anyway to debug this issue?
For my case, my issue was fixed by adding the following code to my tsconfig.json
"awesomeTypescriptLoaderOptions": {
"useTranspileModule": true
}
This happened to me because i left out the exclude property in webpack config for the awesome-typescript-loader rule.
module: {
rules: [
{
test: /\.(t|j)sx?$/,
use: { loader: 'awesome-typescript-loader' },
### Added exclude for node_modules
exclude: /node_modules/,
},
}
I just upgraded typescript for my project and I am seeing this issue again. I upgraded from to 3.6.3 to 3.7.2. Not quite sure how to find the specific offending code, but switching back to 3.6.3 works for now.
Fixed after upgrading to "typescript": "~3.7.4"
3.7.5 or 3.7.4 Not working for me either.
Works on 3.8.0 (nightly)
For anyone who is developing a transformer: if you are using npm link
/ yarn link
, this error may be caused by using a different versions of ts at the same time.
Hi!, @weswigham , it there any answer about this bug? Local version of typescript of my project is 3.8.3, and ts crush whatever I changed..... It is makes me can not do anything.....
i have the same error,when react-hot-loader begin to compile
i 「wdm」: Compiling...
**\[email protected]@typescript\lib\typescript.js:86983
throw e;
TypeError: Cannot read property 'kind' of undefined
at Object.isBinaryExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:13389:21)
at getTypeReferenceTypeWorker (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:38553:51)
at getTypeReferenceType (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:38492:24)
at getTypeFromTypeReference (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:38671:28)
at getTypeFromTypeNode (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:40178:28)
at tryGetTypeFromEffectiveTypeNode (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35562:24)
at getTypeForVariableLikeDeclaration (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35192:32)
at getWidenedTypeForVariableLikeDeclaration (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35531:56)
at getTypeOfVariableOrParameterOrPropertyWorker (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35645:24)
at getTypeOfVariableOrParameterOrProperty (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35567:48)
at getTypeOfSymbol (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:35856:24)
at checkPropertyAccessExpressionOrQualifiedName (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:48170:53)
at checkPropertyAccessExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:48122:20)
at checkExpressionWorker (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:51802:28)
at checkExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:51745:42)
at checkNonNullExpression (E:\work\sqyypt-portal-h5-web\[email protected]@typescript\lib\typescript.js:48096:37)
I also have the same error,when angular hot loading
Any resolution for this issue ?? its happening with 3.8.3
I was receiving this error while using typescript in my react application. In the hopes that it may help some people, I was able to resolve this by removing the defaultProps
declaration that I had on my functional component.
type MenuActionProps = {
id:string;
menuItems:SubMenuItem[];
children:string
}
export default function MenuAction(props:MenuActionProps) {
const [menuAnchorEl, setMenuAnchorEl] = React.useState<null | HTMLElement>(null);
const classes = useStyles()
function toggleMenu(e:React.MouseEvent<HTMLElement> | null) {
if (e && !menuAnchorEl) setMenuAnchorEl(e.currentTarget)
else setMenuAnchorEl(null)
}
return (
<>
<button
className="file-menu__item"
onClick={toggleMenu}
>
{props.children}
</button>
<MenuPanel
id={props.id}
isHover={false}
anchorEl={menuAnchorEl}
menuItems={props.menuItems}
toggleMenu={toggleMenu}
/>
</>
)
}
/**
* @Error TypeError: Cannot read property 'kind' of undefined
* Commenting out the below declaration solved the error. No idea why though
**/
MenuAction.defaultProps = {
id: "menu",
menuItems: [] as SubMenuItem[],
children: "Menu"
}
My console error stack appeared as the following
ERROR in ./src/components/common/MenuAction.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
TypeError: Cannot read property 'kind' of undefined
at Object.isFunctionDeclaration (./node_modules/typescript/lib/typescript.js:11435:21)
at Object.getEffectiveTypeAnnotationNode (./node_modules/typescript/lib/typescript.js:16308:37)
at getIsContextSensitiveAssignmentOrContextType (./node_modules/typescript/lib/typescript.js:53993:52)
at getContextualTypeForBinaryOperand (./node_modules/typescript/lib/typescript.js:53941:44)
at getContextualType (./node_modules/typescript/lib/typescript.js:54288:28)
at getApparentTypeOfContextualType (./node_modules/typescript/lib/typescript.js:54185:17)
at checkObjectLiteral (./node_modules/typescript/lib/typescript.js:54704:34)
at checkExpressionWorker (./node_modules/typescript/lib/typescript.js:60100:28)
at checkExpression (./node_modules/typescript/lib/typescript.js:60023:38)
at checkExpressionCached (./node_modules/typescript/lib/typescript.js:59701:38)
@ ./src/components/HeaderMenu.tsx 11:0-23:2
@ ./src/components/App.tsx
@ ./src/index.tsx
Module versions
"typscript": "^3.8.3"
"ts-loader": "^6.2.2"
"react": "^16.13.1",
"react-dom": "^16.13.1"
This error appears on v3.9.2 but not on v3.8.3
my error was 'TypeError: Cannot read property 'kind' of undefined at getErrorSpanForNode',and disappeared after downgrade typescript from ^3.9.2 to 3.7.2.
my error was 'TypeError: Cannot read property 'kind' of undefined at getErrorSpanForNode',and disappeared after downgrade typescript from ^3.9.2 to 3.7.2.
Yes i have the same issue
At the risk of contributing to a lot of "me too's" - me too (with 3.9.3)
there is also a related open issue here https://github.com/microsoft/TypeScript/issues/38383
Getting this on 3.9.3 and 3.9.5.
I got this error while using typescript 3.9.6, 3.7.5, when enter command ng lint, but run successfully when downgrade to version 3.1.6
we had problem with running local development environment with fuse-box bundler.
it did work on ts v3.4.1, but not v3.6.3
thanks to @dmytro-lymarenko hint, in https://github.com/microsoft/TypeScript/issues/28810#issuecomment-628432830 answer, v3.8.3 works like a charm!
Most helpful comment
Getting this on 3.9.3 and 3.9.5.