Skip to content

[no-base-to-string] still many false positive with union values #1974

Closed
@HolgerJeromin

Description

@HolgerJeromin

Thanks for #1969 :-)
Found a real bug while testing no-base-to-string :-)

Repro

{
  "rules": {
    "@typescript-eslint/no-base-to-string": ["error"]
  }
}
((myvar1: string | number | boolean) => {
    myvar1.toString();
})('');
((myvar1: string | number | boolean | null) => {
    myvar1.toString();
})('');
((myvar1: number | boolean | null) => {
    myvar1.toString();
})(true);

Expected Result
should lint without problems
Actual Result

warning @typescript-eslint/no-base-to-string : 'myvar1 may evaluate to '[object Object]' when stringified.

for all of them

Versions

package version
@typescript-eslint/eslint-plugin 2.31.0
@typescript-eslint/parser 2.31.0
TypeScript 3.8.3
ESLint 6.8.0
node X.Y.Z
npm X.Y.Z

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