Skip to content
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

Bug: [no-unnecessary-type-assertion] (regression) false positives on template literals with no expressions #8819

Closed
4 tasks done
abrahamguo opened this issue Apr 1, 2024 · 0 comments · Fixed by #8820
Closed
4 tasks done
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@abrahamguo
Copy link
Contributor

abrahamguo commented Apr 1, 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.4.3&fileType=.tsx&code=DYUwLgBAhhC8EAMoOgZwgYwPYDtVgG4AoUSAIzggHIyq1Nd8Cg&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1tiacTJTIAhtEK0ipWkOTJE0fJQ5N0UOdA7RI4MAF8QOoA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=false

Repro Code

let a = `a` as const;
let b = 'b' as const;

ESLint Config

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

Expected Result

No lint errors should be reported, as the type assertions are meaningful.

Actual Result

The type assertion on the backtick strings is reported as unnecessary, while the quoted string is not reported.

Additional Info

A regression from #8740

@abrahamguo abrahamguo added bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Apr 1, 2024
@abrahamguo abrahamguo changed the title Bug: [no-unnecessary-type-assertion] (regression) false positive on as const on template literals in nested data structures Bug: [no-unnecessary-type-assertion] (regression) false negatives and positives on template literals Apr 2, 2024
@abrahamguo abrahamguo changed the title Bug: [no-unnecessary-type-assertion] (regression) false negatives and positives on template literals Bug: [no-unnecessary-type-assertion] (regression) false positives on template literals with no expressions Apr 2, 2024
@bradzacher bradzacher added awaiting response Issues waiting for a reply from the OP or another party accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look awaiting response Issues waiting for a reply from the OP or another party labels Apr 2, 2024
@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Jun 9, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 9, 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 locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants