Skip to content

Bug: [no-unnecessary-type-assertion] fixer produces syntax error when there are some extra tokens before as keyword #8325

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
4 tasks done
auvred opened this issue Jan 31, 2024 · 0 comments · Fixed by #8326
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@auvred
Copy link
Member

auvred commented Jan 31, 2024

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Playground Link

https://typescript-eslint.io/play/#ts=5.3.2&fileType=.tsx&code=BQRgBA1GBMYJRgIYGcwDsCuBbARgUwCcAocKaAegCokxLylVNdCg&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWkOTJE0fJQ5N0UOdA7RI4MAF8QOoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

(1 + 2 ) as number
1 + 2/* a */ as number

ESLint Config

module.exports = {
  "rules": {
    "@typescript-eslint/no-unnecessary-type-assertion": "error"
  }
}

tsconfig

{
  "compilerOptions": {
    "strictNullChecks": true
  }
}

Expected Result

It should be fixed to

(1 + 2 )
1 + 2/* a */

Actual Result

It's fixed to

(1 + 2 
1 + 2/

Additional Info

UPD: it also doesn't provide (but it should) fixes when type annotation of angle bracket assertion contains some extra tokens: playground

<(number )>(1 + 2)
@auvred auvred added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Jan 31, 2024
@auvred auvred changed the title Bug: [no-unnecessary-type-assertion] fixer produces syntax error when there are spaces in parenthesized expression Bug: [no-unnecessary-type-assertion] fixer produces syntax error when there are some extra tokens before as keyword Jan 31, 2024
@bradzacher bradzacher added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for team members to take a look labels Jan 31, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants