Skip to content

[no-unsafe-return] does not allow return any[] when function is typed as any #3549

Closed
@HolgerJeromin

Description

@HolgerJeromin
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/no-unsafe-return": "error"
  }
}
function foo(): any {
    if (Math.random()) {
        let res: any = {};
        return res;
    }
    let resArr: any[] = [];
    resArr.push(true);
    return resArr; // <-- eslint unhappy
}

Expected Result

any is any and the rule should be happy with anything :-)

Actual Result

error @typescript-eslint/no-unsafe-return : Unsafe return of an any[] typed value.

Additional Info

Follow up to #3482

Versions

package version
@typescript-eslint/eslint-plugin 4.27.0
@typescript-eslint/parser 4.27.0
TypeScript 4.1
ESLint 7.27.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: 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