Skip to content
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

Regression in 2.24.0: TypeError: Cannot read property 'name' of undefined #1746

Closed
crfrolik opened this issue Mar 16, 2020 · 18 comments · Fixed by #1751
Closed

Regression in 2.24.0: TypeError: Cannot read property 'name' of undefined #1746

crfrolik opened this issue Mar 16, 2020 · 18 comments · Fixed by #1751
Labels
bug Something isn't working has pr there is a PR raised to close this package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@crfrolik
Copy link
Contributor

crfrolik commented Mar 16, 2020

What code were you trying to parse?

This seems to be an issue with barrel files, and was likely introduced by 133f622#diff-68b2b0b0d2d0ff1846b1114472008332R1606

export * from './app/foo';

What did you expect to happen?

No error.

What actually happened?

myrepo\src\public_api.ts
  0:0  error  Parsing error: Cannot read property 'name' of undefined

Running with --debug gives the following (clipped for brevity):

 eslint:file-enumerator Yield: public_api.ts +51ms
  eslint:cascading-config-array-factory Load config files for myrepo\src. +52ms
  eslint:cascading-config-array-factory Cache hit: myrepo\src. +6ms
  eslint:cli-engine Lint myrepo\src\public_api.ts +50ms
  eslint:linter Linting code for myrepo\src\public_api.ts (pass 1) +26ms
  eslint:linter Verify +8ms
  eslint:linter With ConfigArray: myrepo\src\public_api.ts +2ms
  eslint:linter Parsing error: Cannot read property 'name' of undefined
  eslint:linter TypeError: Cannot read property 'name' of undefined
    at Converter.convertNode (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:1247:67)
    at Converter.converter (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:72:29)
    at Converter.convertChild (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:147:21)
    at myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:203:32
    at Array.map (<anonymous>)
    at Converter.convertBodyExpressions (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:202:14)
    at Converter.convertNode (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:441:32)
    at Converter.converter (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:72:29)
    at Converter.convertProgram (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\convert.js:47:21)
    at Object.astConverter (myrepo\node_modules\@typescript-eslint\typescript-estree\dist\ast-converter.js:26:29) +9ms

Versions

package version
@typescript-eslint/typescript-estree 2.24.0
TypeScript 3.7.5
node 13.9.0
npm yarn 1.22.1
@crfrolik crfrolik added package: typescript-estree Issues related to @typescript-eslint/typescript-estree triage Waiting for maintainers to take a look labels Mar 16, 2020
@crfrolik crfrolik changed the title Regression in 2.24.0: TypeError: Cannot read property 'name' of undefined Regression in 2.2.24: TypeError: Cannot read property 'name' of undefined Mar 16, 2020
@crfrolik crfrolik changed the title Regression in 2.2.24: TypeError: Cannot read property 'name' of undefined Regression in 2.24.0: TypeError: Cannot read property 'name' of undefined Mar 16, 2020
@bradzacher
Copy link
Member

I'm unable to repro this against master.

The line in the stack trace cannot cause this error, because it can only be hit if node.exportClause is not undefined.

node.exportClause?.kind === SyntaxKind.NamespaceExport
? this.convertChild(node.exportClause.name)
: null,

Could you please create a repro repo to help us investigate this?

@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for maintainers to take a look labels Mar 16, 2020
@crfrolik
Copy link
Contributor Author

Thanks for the response. I will work on trimming down my repo to a minimal example and get back to you.

@crfrolik
Copy link
Contributor Author

crfrolik commented Mar 16, 2020

It looks like SyntaxKind.NamespaceExport is undefined, which is causing the node.exportClause?.kind === SyntaxKind.NamespaceExport expression to be truthy. Is this because I am using typescript 3.7 instead of 3.8?

@bradzacher
Copy link
Member

interesting. I hadn't thought about that outcome.
that's definitely it. simple fix.

@bradzacher bradzacher added bug Something isn't working and removed awaiting response Issues waiting for a reply from the OP or another party labels Mar 16, 2020
@bradzacher bradzacher pinned this issue Mar 16, 2020
@bradzacher bradzacher added the has pr there is a PR raised to close this label Mar 17, 2020
@bradzacher
Copy link
Member

PR: #1751
Followup issue to make sure this doesn't happen again: #1752

PhilippeMorier added a commit to PhilippeMorier/talus that referenced this issue Mar 18, 2020
* build(dep): bump `@nestjs` to `7.0.3`

* build(dep): bump `@nrwl` to `9.1.2`

* build(dep): bump div dep

* build(dep): bump @angular cdk & material

* build(dep): bump `cypress`, `zone.js` & `jest-preset-angular`

* build(dep): revert to `eslint/parser` `2.23.0`:

- typescript-eslint/typescript-eslint#1746

* refactor(frontend): add comment about not dispatching action with `File`
@san4ezgig
Copy link

san4ezgig commented Mar 18, 2020

Could you please help, how to fix it without waiting new version? Upgrade to typescript 3.8.0 doesnt work

@jameschao
Copy link

My workaround was to downgrade to 2.23.0.

@canpoyrazoglu
Copy link

In my case I'm using create-react-app which only includes react-scripts in this manner (and all the logic is handled by react-scripts), and I have no idea how to change version separately.

@ibc
Copy link

ibc commented Mar 18, 2020

Just wondering, any ETA for a new version with the fix?

@bradzacher
Copy link
Member

If you're stuck on ts 3.7, then downgrade to 2.23.0.
If you can upgrade to 3.8, then doing so will fix it.

I have a fix ready, but due to a glitch in azure, our per commit canary release is broken. So this will go out with our regular release schedule, listed on our readme.

@bradzacher
Copy link
Member

@JamesHenry managed to fix the canary pipeline 🎉

The fix for this is now released to the canary tag on npm.
Will be released to the main tag as per our regular release schedule.

@jmlew
Copy link

jmlew commented Mar 19, 2020

Any advice on how to downgrade when this is included with create-react-app? This is breaking all builds at the moment.

@bradzacher
Copy link
Member

I don't know exactly how create-react-app does its dependency management, but you might just be able to install your own version of our packages?

Having a look at their eslint config, it has a peer dep on our packages, so you should just be able to bump the version yourself?

https://github.com/facebook/create-react-app/blob/6adb82a505eb06080dc11702a472f74131e95dc7/packages/eslint-config-react-app/package.json#L18-L19

Worst case, you can use a mechanism like yarn resolutions to force a certain version
https://classic.yarnpkg.com/en/docs/selective-version-resolutions/

@jmlew
Copy link

jmlew commented Mar 19, 2020

Thanks. Confirming forcing version 2.23.0 manually as well as through Yarn resolutions for the following now works.

"resolutions": {
"@typescript-eslint/eslint-plugin": "2.23.0",
"@typescript-eslint/parser": "2.23.0",
"@typescript-eslint/typescript-estree": "2.23.0"
},

@mend3
Copy link

mend3 commented Mar 19, 2020

Thanks. Confirming forcing version 2.23.0 manually as well as through Yarn resolutions for the following now works.

"resolutions": {
"@typescript-eslint/eslint-plugin": "2.23.0",
"@typescript-eslint/parser": "2.23.0",
"@typescript-eslint/typescript-estree": "2.23.0"
},

Confirmed that downgrading is now working, thanks!

react: 16.12.0
npm: 6.13.4

@canpoyrazoglu
Copy link

I've upgraded to TS 3.8 (even 3.9 nightly), no avail. Tried the resolutions, still no avail. I'm still getting the same error.

@netpoe
Copy link

netpoe commented Mar 20, 2020

I've upgraded to TS 3.8 (even 3.9 nightly), no avail. Tried the resolutions, still no avail. I'm still getting the same error.

Same here, this happens when trying to import a dependency built with typescript in one of my components:

../libraries/api/index.ts 1:7
Module parse failed: Unexpected token (1:7)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> export type Maybe<T> = T | null;

my env:

node v12.16.1
npm 6.13.4
yarn 1.22.4
typescript ^3.8.3
react: ^16.13.1

I also tried @mend3 resolutions 🤷‍♂

I'd appreciate some signs of light here, an important project is stuck due to this.

@bradzacher
Copy link
Member

bradzacher commented Mar 20, 2020

You may need an appropriate loader to handle this file type

@netpoe - this isn't an error related to our project. Loaders are a webpack concept, and we do not do anything with webpack. Nothing I can do to help here, sorry.


@canpoyrazoglu - hard to help without some more information. But this is confirmed working via pinning your dependencies. You'll have to check your setup


For anyone coming here - the fix is released on our canary tag on NPM.
So pin your dependency on the canary tag of our package.
You should be able to do this by simply updating the dependency in your package.json.
As mentioned before yarn resolutions are a great way to do this, as they force a certain version, regardless of what dependencies of dependencies specify.

I don't know what your individual setups are, so I can't provide more concrete advice than that.

If you don't want to use our canary version, then pin your dependency on last week's version - 2.23.0, which is known good.

Make sure you restart vscode (or whatever IDE you are using) after you change your dependencies, as the IDE extensions will not automatically switch to the new version.

Otherwise it will be released to the latest tag on Monday morning, as per our standard release schedule.

https://github.com/typescript-eslint/typescript-eslint#package-versions


Locking to prevent further commenting.

@typescript-eslint typescript-eslint locked as resolved and limited conversation to collaborators Mar 20, 2020
@bradzacher bradzacher unpinned this issue Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working has pr there is a PR raised to close this package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants