Skip to content

[eslint-plugin-packlets] Linting TypeError with typescript version >=4.2.0 #2591

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

Closed
klonowicki opened this issue Apr 7, 2021 · 8 comments · Fixed by #2603
Closed

[eslint-plugin-packlets] Linting TypeError with typescript version >=4.2.0 #2591

klonowicki opened this issue Apr 7, 2021 · 8 comments · Fixed by #2603
Labels
bug Something isn't working as intended priority The maintainers consider it to be an important issue. We should try to fix it soon. repro confirmed The issue comments included repro instructions, and the maintainers reproduced the problem

Comments

@klonowicki
Copy link

klonowicki commented Apr 7, 2021

Summary

I'm getting a typescript error from eslint-plugin-packlets while linting after upgrading TypeScript version to any equal or above 4.2.0
Error contents:
TypeError: program.getRefFileMap is not a function
It's from DependencyAnalizer file from checkEntryPointForCircularImport function.
Eslint exits with error code 2.

Repro steps

  1. Upgrade TypeScript version from 4.1.3 to 4.2.3
  2. Run 'eslint' script

Details

eslint script: eslint 'packages//{src,tests}/**/.{js,ts,tsx}' '/*.json' 'cypress//.{js,ts,tsx}' --fix && stylelint --fix 'packages/**/.scss'

"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"eslint": "^7.15.0",

An Error occurs also when upgrading above packages to the newest ones.

"webpack": "^5.17.0",

.eslintrc.json

{
"extends": ["../../.eslintrc.json", "plugin:@rushstack/eslint-plugin-packlets/recommended"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"project": ["./tsconfig.json"],
"tsconfigRootDir": "./packages/client"
},
"ignorePatterns": ["*.json"],
"rules": {
"@rushstack/packlets/mechanics": "error"
}
}

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@rushstack/eslint-plugin-packlets version? 0.2.0
Operating system? Windows
Would you consider contributing a PR? No
TypeScript compiler version? >=4.2.0
Node.js version (node -v)? 14.16.0
@klonowicki klonowicki changed the title [eslint-plugin-packlets] Linting TypeError with typescript version <4.2.0 [eslint-plugin-packlets] Linting TypeError with typescript version >4.2.0 Apr 7, 2021
@klonowicki klonowicki changed the title [eslint-plugin-packlets] Linting TypeError with typescript version >4.2.0 [eslint-plugin-packlets] Linting TypeError with typescript version >=4.2.0 Apr 7, 2021
@iclanton
Copy link
Member

iclanton commented Apr 8, 2021

IS the issue just that the typescript-eslint project doesn't have support for TS 4.2 yet? @octogonz, have you tried upgrading any of your projects to 4.2 and seen this issue?

@octogonz
Copy link
Collaborator

octogonz commented Apr 9, 2021

@iclanton The problem is that eslint-plugin-packlets calls an internal API:

const refFileMap: Map<string, RefFile[]> = (program as any).getRefFileMap();

And that API doesn't exist in TS 4.2. Lemme investigate it real quick.

@octogonz octogonz added bug Something isn't working as intended priority The maintainers consider it to be an important issue. We should try to fix it soon. repro confirmed The issue comments included repro instructions, and the maintainers reproduced the problem labels Apr 9, 2021
@octogonz
Copy link
Collaborator

octogonz commented Apr 9, 2021

It was removed in microsoft/TypeScript#40011

@octogonz
Copy link
Collaborator

octogonz commented Apr 9, 2021

Seems like Program.getFileProcessingDiagnostics() or Program.getFileIncludeReasons() might be a suitable replacement.

@octogonz
Copy link
Collaborator

Program.getFileIncludeReasons() works. Lemme see if I can make a PR.

@octogonz
Copy link
Collaborator

octogonz commented Apr 10, 2021

Here is a PR: #2603

@octogonz
Copy link
Collaborator

@iclanton The problem is that eslint-plugin-packlets calls an internal API:

const refFileMap: Map<string, RefFile[]> = (program as any).getRefFileMap();

And that API doesn't exist in TS 4.2. Lemme investigate it real quick.

@sheetalkamat Maybe the compiler could provide a public supported version of this API? There doesn't seem to be an easy way to implement this analysis without relying on the internal API.

@octogonz
Copy link
Collaborator

This fix was released with @rushstack/eslint-plugin-packlets version 0.2.2

@iclanton iclanton moved this to Closed in Bug Triage Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as intended priority The maintainers consider it to be an important issue. We should try to fix it soon. repro confirmed The issue comments included repro instructions, and the maintainers reproduced the problem
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants