Skip to content

unicorn/prefer-native-coercion-functions doesn't work well with typescript and should be disabled.  #242

Open
@hjeti

Description

@hjeti

The Boolean part of this rule and the auto fix break my code, because they don't work well with typescript.

I write this:

const testArray = ['test', null];
        
const output = testArray.filter((value): value is string => Boolean(value));

and it converts it to this:

const testArray = ['test', null];

const output = testArray.filter(Boolean);

This is not the same. The type of output is Array<string> in my code and Array<string | null> in the 'autofixed' code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions