Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Labels
bugSomething isn't workinghas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@tao-cumplido

Description

@tao-cumplido

The ruleno-unsafe-return exits with an error on array types with TS versions < 3.7
Apparently the rule uses the methodgetTypeArguments 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',},};
functionfoo(){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 functionOccurred 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

packageversion
@typescript-eslint/eslint-plugin2.25.0
@typescript-eslint/parser2.25.0
TypeScript3.6.x
ESLint6.8.0
node13.10.1
npm6.13.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas prthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp