Skip to content

[no-unnecessary-type-assertion] support const assertions #1734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xiaoxiangmoe opened this issue Mar 14, 2020 · 1 comment · Fixed by #1741
Closed

[no-unnecessary-type-assertion] support const assertions #1734

xiaoxiangmoe opened this issue Mar 14, 2020 · 1 comment · Fixed by #1741
Labels
enhancement New feature or request good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@xiaoxiangmoe
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/no-unnecessary-type-assertion": ["error"]
  }
}
const a = [1, 2];
const b = [3, 4];
const c = [...a, ...b] as const;  // This assertion is unnecessary since it does not change the type of the expression.eslint(@typescript-eslint/no-unnecessary-type-assertion)

Expected Result
No Error
Actual Result
See Error
Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.23.0
@typescript-eslint/parser 2.23.0
TypeScript 3.7.5
ESLint 6.8.0
node 13.5.0
npm 6.13.4
@xiaoxiangmoe xiaoxiangmoe added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Mar 14, 2020
@bradzacher
Copy link
Member

shouldn't be all that hard to add support to the rule for the const keyword.
happy to accept a PR

@bradzacher bradzacher added enhancement New feature or request good first issue Good for newcomers and removed triage Waiting for team members to take a look labels Mar 14, 2020
@bradzacher bradzacher changed the title [no-unnecessary-type-assertion] error on const assertions [no-unnecessary-type-assertion] support const assertions Mar 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants