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

Parsing error: Cannot read property 'map' of undefined on import when a function has an array return type #2446

Closed
3 tasks done
mwiedmann opened this issue Aug 31, 2020 · 4 comments
Labels
awaiting response Issues waiting for a reply from the OP or another party package: parser Issues related to @typescript-eslint/parser

Comments

@mwiedmann
Copy link

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

// some export in a file1.ts, it doesn't matter what you export
export type Foo = number

// file2.ts, import from file1.ts and have an array return type on a function.
// The [sometype] return type seems to be the key to causing the issue.
import { Foo } from './test-import' // This line has error: "Parsing error: Cannot read property 'map' of undefined"

export function foo(id: Foo): [number] { // The [number] or any array return type seems to be the cause
  return [id]
}

Expected Result
I expected it not to fail.

Actual Result
Parsing error: Cannot read property 'map' of undefined

@mwiedmann mwiedmann added package: parser Issues related to @typescript-eslint/parser triage Waiting for maintainers to take a look labels Aug 31, 2020
@bradzacher
Copy link
Member

bradzacher commented Aug 31, 2020

What version of our tooling are you using?
That section is part of our template for a reason.

As mentioned in the first comment in the template:

<!--
Please don't ignore this template.

If you ignore it, we're just going to respond asking you to fill it out, which wastes everyone's time.
The more relevant information you can include, the faster we can find the issue and fix it without asking you for more info.
-->

@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 Aug 31, 2020
@mwiedmann
Copy link
Author

"@typescript-eslint/eslint-plugin": "4.0.0",
"@typescript-eslint/parser": "4.0.0",
"eslint": "7.7.0",
"typescript": "4.0.2",

@bradzacher
Copy link
Member

bradzacher commented Aug 31, 2020

TS4.0 included a breaking change to their AST shape which we've properly handled since our v3.3.0 release.
If you've got v4 of our packages installed and you're still seeing errors, likely you also have older version(s) of our tooling installed alongside the new versions, and your local tooling is using the older versions.

See discussion in: #2260
Packages like react-scripts (part of create react app) will depend on their own (older) versions of our packages. You will have to use resolutions to bypass.

@mwiedmann
Copy link
Author

Yes. Confirmed that we did have an older version of the parser being pulled in by another package. Terribly sorry about this. Working fine now.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party package: parser Issues related to @typescript-eslint/parser
Projects
None yet
Development

No branches or pull requests

2 participants