Skip to content

TypeError: type.getSymbol is not a function #35

Description

@thebanjomatic

When attempting to use this project with typescript-eslint, I get the following error:

ESLint: 9.39.5

TypeError: type.getSymbol is not a function
Occurred while linting D:\source\test-project\src\test-file.ts:1:
Rule: "@typescript-eslint/promise-function-async"
    at containsAllTypesByName (D:\source\test-project\node_modules\@typescript-eslint\type-utils\dist\containsAllTypesByName.js:54:25)
    at predicate (D:\source\test-project\node_modules\@typescript-eslint\type-utils\dist\containsAllTypesByName.js:58:30)
    at Array.every (<anonymous>)
    at containsAllTypesByName (D:\source\test-project\node_modules\@typescript-eslint\type-utils\dist\containsAllTypesByName.js:68:41)
    at D:\source\test-project\node_modules\@typescript-eslint\eslint-plugin\dist\rules\promise-function-async.js:134:73
    at Array.every (<anonymous>)
    at validateNode (D:\source\test-project\node_modules\@typescript-eslint\eslint-plugin\dist\rules\promise-function-async.js:134:25)
    at FunctionDeclaration[async = false] (D:\source\test-project\node_modules\@typescript-eslint\eslint-plugin\dist\rules\promise-function-async.js:187:21)
    at ruleErrorHandler (D:\source\test-project\node_modules\eslint\lib\linter\linter.js:1173:33)
    at D:\source\test-project\node_modules\eslint\lib\linter\source-code-visitor.js:76:46

Code to reproduce the error:

function testFunction(): string[] {
  return []
}

There appears to be something weird going on, but I was ableo to trace containsAllTypesByName and it does:

    if (tsutils.isTypeReference(type)) {
        type = type.target;
    }

    const symbol = type.getSymbol();

In the failure path, type.target returns the literal number 73 instead of the TypeObject with id: 73 like it does with the actual typescript API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions