Skip to content

[no-extra-parens] behaving incorrectly with a type assertion #807

@fasttime

Description

@fasttime

Repro

{
  "rules": {
    "@typescript-eslint/no-extra-parens": ["error"]
  }
}
function foo(a: string): number
{
    return ((a as any) | 0) - 1;
}

Expected Result

No warning.

Actual Result

Produces a warning:

Unnecessary parentheses around expression

Autofixed code has different semantics:

function foo(a: string): number
{
    return a as any | 0 - 1;
}

Versions

package version
@typescript-eslint/eslint-plugin 1.13.0
@typescript-eslint/parser 1.13.0
TypeScript 3.5.3
ESLint 6.1.0
node 12.7.0
npm 6.10.0

Playground links

Metadata

Metadata

Assignees

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

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy