-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS 3.2.1 TypeError: Cannot read property 'kind' of undefined #28810
Comments
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... |
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 |
@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 |
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:
The code line is:
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
|
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 |
Instrumenting |
@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 if (symbol.valueDeclaration && symbol.valueDeclaration.parent === undefined) {
console.log('symbol.declarations', symbol.declarations);
} And I'm seeing a huge After further inspection, the file I mentioned in my previous post does use 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 |
https://github.com/wanliyunyan/test-typescript-issue-28810, do you try this repro ? @weswigham |
I meant a minimal repro for our regression testing suite. 😄 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, the issue only occurs with webpack HMR (when using webpack-dev-server). The config scripts are sourced from
normal tsc compilation works without error. When any file is changed, the above exception is thrown. |
I have this issue while trying to add custom transformers with ts-loader. Tried with the following ts versions:
Transformer config is like that: // webpack.config
const tsLoaderOptions = {
transpileOnly: true,
getCustomTransformers: path.join(__dirname, './webpack.ts-transformers.js')
} // webpack.ts-transformers.js
const optChainTransformer = require('ts-optchain/transform').default
const getCustomTransformers = () => ({ after: [optChainTransformer] })
module.exports = getCustomTransformers If I change
|
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; I get this error:
Same with
Typescript version: 3.5.3 Exactly the same if I change |
This fixes history problem. More info here microsoft/TypeScript#28810. It was fixed here microsoft/TypeScript#29339 with version 3.4.x
Updated to Is there anyway to debug this issue? |
For my case, my issue was fixed by adding the following code to my
|
This happened to me because i left out the exclude property in webpack config for the awesome-typescript-loader rule.
|
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 |
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 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
My console error stack appeared as the following
Module versions
|
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. |
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 #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. thanks to @dmytro-lymarenko hint, in #28810 (comment) answer, v3.8.3 works like a charm! |
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:
Error 2:
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.
The text was updated successfully, but these errors were encountered: