Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(eslint-plugin): [no-unnecessary-type-assertion] false positive on non-null assertion after an implicitly-any variable gets initialised inside conditional block#11082

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mdm317 wants to merge1 commit intotypescript-eslint:main
base:main
Choose a base branch
Loading
frommdm317:11054-no-unnecessary-type-assertion

Conversation

mdm317
Copy link
Contributor

@mdm317mdm317 commentedApr 16, 2025
edited by kirkwaiblinger
Loading

Caution

Currently blocked by#10334 /microsoft/TypeScript#60514. See#11082 (comment)


PR Checklist

Overview

I have updated it so thatisPossiblyUsedBeforeAssigned returnstrue when the variable is not explicitly typed at the time of declaration

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@mdm317!

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 onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedApr 16, 2025
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitb568ec6
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/67ff766abcee570008e6c5cb
😎 Deploy Previewhttps://deploy-preview-11082--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 75 (🔴 down 21 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify site configuration.

@mdm317mdm317 marked this pull request as draftApril 16, 2025 09:20
@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedApr 16, 2025
edited
Loading

View yourCI Pipeline Execution ↗ for commitb568ec6.

CommandStatusDurationResult
nx typecheck ast-spec✅ Succeeded<1sView ↗
nx run-many --target=build --exclude website --...✅ Succeeded5sView ↗
nx run-many --target=clean✅ Succeeded11sView ↗

☁️Nx Cloud last updated this comment at2025-05-05 05:32:36 UTC

@codecovCodecov
Copy link

codecovbot commentedApr 16, 2025
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.82%. Comparing base(f30a20e) to head(b568ec6).
Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@##             main   #11082   +/-   ##=======================================  Coverage   90.82%   90.82%           =======================================  Files         497      497             Lines       50204    50206    +2       Branches     8274     8275    +1     =======================================+ Hits        45600    45602    +2  Misses       4589     4589             Partials       15       15
FlagCoverage Δ
unittest90.82% <100.00%> (+<0.01%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Files with missing linesCoverage Δ
...-plugin/src/rules/no-unnecessary-type-assertion.ts98.99% <100.00%> (+<0.01%)⬆️
🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mdm317mdm317 marked this pull request as ready for reviewApril 16, 2025 15:40
) {
if (declaration.type == null) {
return true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We're definitely in the right ballpark, but I notice that this introduces a regression with the following case:

functionfoo(){letxif(Math.random()>0.5){x=3;}else{x=4;}// should be flagged as unnecessaryx!;}

I wonder if it's possible to get that case correct still? (it may or may not be feasible to prevent some false positives or negatives)

mdm317 reacted with eyes emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

actually - I think you can ignore this regression... This is most likely a symptom of#10334 /microsoft/TypeScript#60514

Copy link
ContributorAuthor

@mdm317mdm317Apr 18, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@kirkwaiblinger
Thanks for review! 🙏

The regression also occurs in this simplified case:

function foo() {  let x;  x =4;  // should be flagged as unnecessary  x!;}

This is most likely a symptom of#10334 /microsoft/TypeScript#60514

As you mentioned, it's not possible to fix that case for now.

Should I close this PR until that issue is resolved?

kirkwaiblinger reacted with eyes emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hmmm. I'm not sure which choice is the lesser of two evils here... fixing the bug at the cost of that rather undesirable-looking regression, or marking the bug as blocked. I'm gently leaning towards making this work as blocked unless we can find away to proceed while mitigating this regression 🤔 But then again if it was that important of a case, you'd think we might have a test case that caught it?

Looking for thoughts from @typescript-eslint/triage-team too.

mdm317 reacted with thumbs up emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah I don't really want to wade into these murky waters 🙃. +1 on marking as blocked.

kirkwaiblinger and mdm317 reacted with thumbs up emoji
@kirkwaiblingerkirkwaiblinger added the blocked by another issueIssues which are not ready because another issue needs to be resolved first labelMay 5, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg left review comments

@kirkwaiblingerkirkwaiblingerkirkwaiblinger left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
blocked by another issueIssues which are not ready because another issue needs to be resolved first
Projects
None yet
Milestone
No milestone
3 participants
@mdm317@JoshuaKGoldberg@kirkwaiblinger

[8]ページ先頭

©2009-2025 Movatter.jp