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

[no-unsafe-return] TypeError: checker.getTypeArguments is not a function #1807

Closed
tao-cumplido opened this issue Mar 26, 2020 · 1 comment · Fixed by #1815
Closed

[no-unsafe-return] TypeError: checker.getTypeArguments is not a function #1807

tao-cumplido opened this issue Mar 26, 2020 · 1 comment · Fixed by #1815
Labels
bug Something isn't working has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@tao-cumplido
Copy link

The rule no-unsafe-return exits with an error on array types with TS versions < 3.7
Apparently the rule uses the method getTypeArguments which was only added to the TS api in version 3.7: https://github.com/microsoft/TypeScript-wiki/blob/master/API-Breaking-Changes.md

Repro

module.exports = {
   parser: '@typescript-eslint/parser',
   plugins: ['@typescript-eslint'],
   parserOptions: {
      project: './tsconfig.json',
   },
   rules: {
      '@typescript-eslint/no-unsafe-return': 'error',
   },
};
function foo() {
   return [];
}

I created a minimal repo here: https://github.com/tao-cumplido/ts-eslint-error
If you bump the TS version to 3.7 it works as expected.

Expected Result
no error

Actual Result

TypeError: checker.getTypeArguments is not a function
Occurred while linting C:\Users\taocu\Desktop\Projekte\ts-eslint-error\test.ts:2
    at Object.isAnyOrAnyArrayTypeDiscriminated (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\@typescript-eslint\eslint-plugin\dist\util\types.js:242:31)
    at checkReturn (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\@typescript-eslint\eslint-plugin\dist\rules\no-unsafe-return.js:49:34)
    at ReturnStatement (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\@typescript-eslint\eslint-plugin\dist\rules\no-unsafe-return.js:105:17)
    at C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\eslint\lib\linter\node-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\eslint\lib\linter\node-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\eslint\lib\linter\node-event-generator.js:297:14)
    at CodePathAnalyzer.enterNode (C:\Users\taocu\Desktop\Projekte\ts-eslint-error\node_modules\eslint\lib\linter\code-path-analysis\code-path-analyzer.js:634:23)
error Command failed with exit code 2.

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.25.0
@typescript-eslint/parser 2.25.0
TypeScript 3.6.x
ESLint 6.8.0
node 13.10.1
npm 6.13.7
@tao-cumplido tao-cumplido added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Mar 26, 2020
@bradzacher
Copy link
Member

Ahhh. Another thing #1752 would have caught.
I probably need to get that implemented sooner rather than later.

Thanks for reporting!

@bradzacher bradzacher added bug Something isn't working has pr there is a PR raised to close this and removed triage Waiting for maintainers to take a look labels Mar 26, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 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: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants