typescript-eslint: "Parsing error" when using Yarn 2.0's Plug 'n' Play
I just migrated to Yarn 2.0 and enabled PnP. Got our webpack + babel + TypeScript pipeline up and running. Eslint, however, both when run through the CLI and as part of Webpack, throws OOM errors. Running eslint with --debug, I could see that something in the plugin chain throws an error and if you get enough of them, a generic OOM triggers. Basically all files being checked throw this error.
What did you expect to happen?
Being able to run eslint w/ @typescript-eslint/plugin on our TypeScript code base.
What actually happened?
eslint:cli-engine Lint [redacted]\wwwroot\app\helpers.ts +0ms
eslint:linter Linting code for [redacted]\wwwroot\app\helpers.ts (pass 1) +0ms
eslint:linter Verify +0ms
eslint:linter With ConfigArray: [redacted]\wwwroot\app\helpers.ts +1ms
eslint:linter Parsing error: Cannot destructure property `name` of 'undefined' or 'null'.
eslint:linter TypeError: Cannot destructure property `name` of 'undefined' or 'null'.
at getPackageInformation ([redacted]\.pnp.js:29078:33)
at Object.getPackageInformation ([redacted]\.pnp.js:29398:20)
at getPnpTypeRoots ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:27922:42)
at getDefaultTypeRoots ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:27938:24)
at getEffectiveTypeRoots ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:27893:20)
at Object.getAutomaticTypeDirectiveNames ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:28068:29)
at Object.createProgram ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:95251:56)
at Object.getBuilderCreationParameters ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:98523:29)
at createSemanticDiagnosticsBuilderProgram ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:98839:100)
at createNewProgram ([redacted]\.yarn\cache\typescript-patch-fea84800fa-1.zip\node_modules\typescript\lib\typescript.js:100505:30) +2s
I cannot tell if this is a bug in the parser, the plugin, or in the PnP API, or Yarn’s bundled patched TypeScript compiler, or a combination. However, disabling @typescript-eslint/parser and running the same setup on a .js file works fine., so hence why I’m posting it here. I’ve also disabled all other eslint plugins with no change, so any of those shouldn’t be the culprit either.
Versions
| package | version |
|---|---|
@typescript-eslint/parser |
2.19.2 |
TypeScript |
3.7.5 * |
babel |
7.8.4 |
ESLint |
6.8.0 |
node |
10.16.3 |
yarn |
2.0.0-rc28 |
| *: only used for manually invoking a project-wide type-checking from the CLI (works perfectly fine), otherwise Babel is doing the transpiling |
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 26 (19 by maintainers)
@regevbr I’ve opened a PR, check the instruction inside it: https://github.com/yarnpkg/berry/pull/1205#issue-404285658
PR confirmed and merged; I’ve tested myself, and the repository set up by @jstaro doesn’t exhibit the problem anymore starting from Yarn master. I think this issue can be closed! 🙂
From my understanding, there are two ways this issue could be fixed:
Yarn could switch to a case insensitive model on relevant platforms, similar to what TS is doing. I don’t think we’ll do that, because it doesn’t solve the problem at core (what if there’s a tool that assumes case strictness? It will be the same issue all over again).
Or, since Yarn enforces casing anyway, maybe the
isFileSystemCaseSensitivecheck from TS should return “true” for Windows when operating within a PnP runtime - because in this case, the filesystem is effectively case sensitive. Since Typescript-Eslint is (correctly) using the TSsysinterface, it should pick up the right information and stop normalizing the paths.I’ll apply a change in https://github.com/microsoft/TypeScript/pull/35206 to implement his second option, I’ll appreciate if some of you can then test it in your projects.