-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
test(eslint-plugin): adjust tests to verify no-unnecessary-type-assertion
doesn't report template literals with expressions
#10671
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
Conversation
… template expressions with expressions
Thanks for the PR, @ronami! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
View your CI Pipeline Execution ↗ for commit 27ba6f7.
☁️ Nx Cloud last updated this comment at |
no-unnecessary-type-assertion
doesn't throw on template literals with expressionsno-unnecessary-type-assertion
doesn't report template literals with expressions
should we just use |
Hmm since these two are different types (one is a "fresh literal", the other isn't): // not a "fresh literal"
declare const a: 'foo';
// is a "fresh literal"
const b = 'foo'; Along with seeing how much complexity there is around "fresh literals", I've changed both tests to use Wdyt? Edit: I manually removed the |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10671 +/- ##
=======================================
Coverage 87.15% 87.15%
=======================================
Files 448 448
Lines 15576 15578 +2
Branches 4551 4551
=======================================
+ Hits 13575 13577 +2
Misses 1645 1645
Partials 356 356
Flags with carried forward coverage won't be shown. Click here to find out more. |
609a78f
into
typescript-eslint:main
PR Checklist
Overview
I've noticed this while reviewing #10618.
To my understanding, these tests should make sure the rule doesn't report on template literals with expressions.
It seems that even if this check is removed, these tests still pass. I think it's related to "fresh literals" (more on this here), as is shown below (playground link):
The expression coming from a widened
let
variable doesn't count as a literal, and it falls back to being checked as a non-literal (which always allowsas const
assertions).This PR adjusts the tests to fail if this check is removed or changed incorrectly (this seems correct according to the original issue).