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): add getConstraintInfo to handle generic constraints better#10496

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

Conversation

kirkwaiblinger
Copy link
Member

@kirkwaiblingerkirkwaiblinger commentedDec 13, 2024
edited
Loading

PR Checklist

Overview

Since removing or modifyinggetConstrainedTypeAtLocation would be a breaking change (seehttps://typescript-eslint.io/users/versioning#parser-typescript-estree-scope-manager-types-type-utils-utils),I've deprecated it and added a new utility in its place I've left it in place for now, and just added a new utility. Since we may change our implementation in the future, I've made the new utility internal, and not deprecated the existinggetConstrainedTypeAtLocation. Deprecating it and replacing internal usages can be handled in followup work. See#10496 (comment)

I've redone the testing so that the tests forgetConstrainedTypeAtLocation actually test something useful, and tested several edge cases for both the old and new APIs.

I've used the new API for a few rules for good measure. We'll want to gradually replace the rest of our usages in followup work.

Retouched the fix in#10314and used the new strategy to solve#10443 and in#10474


TODO - I'll have to find a way to manage the deprecation linting failures 🙁#9899 would be extremely clutch. Not really sure how to handle this otherwise, other than to alias the function with a non-deprecated version to replace the existing usages, with the intention of cleaning up the alias later. Not deprecating anything yet.

UPDATE - I chose to aliasgetConstrainedTypeAtLocation as the ironically not-deprecatedDEPRECATED_getConstrainedTypeAtLocation in order to allow existing usages not to fail CI.

ronami, JoshuaKGoldberg, and controversial reacted with heart emoji
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@kirkwaiblinger!

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 commentedDec 13, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit4c9da08
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/6770924ce4d8050008c05021
😎 Deploy Previewhttps://deploy-preview-10496--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 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (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.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedDec 13, 2024
edited
Loading

View yourCI Pipeline Execution ↗ for commit4c9da08.

CommandStatusDurationResult
nx run-many --target=build --exclude website --...✅ Succeeded3sView ↗
nx run-many --target=clean✅ Succeeded10sView ↗

☁️Nx Cloud last updated this comment at2024-12-29 08:16:41 UTC

@codecovCodecov
Copy link

codecovbot commentedDec 14, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.87%. Comparing base(3ae4148) to head(4c9da08).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@##             main   #10496   +/-   ##=======================================  Coverage   86.86%   86.87%           =======================================  Files         445      446    +1       Lines       15455    15465   +10       Branches     4507     4508    +1     =======================================+ Hits        13425    13435   +10  Misses       1675     1675             Partials      355      355
FlagCoverage Δ
unittest86.87% <100.00%> (+<0.01%)⬆️

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

Files with missing linesCoverage Δ
packages/eslint-plugin/src/rules/await-thenable.ts100.00% <100.00%> (ø)
...rc/rules/no-unnecessary-boolean-literal-compare.ts97.56% <100.00%> (+0.09%)⬆️
...slint-plugin/src/rules/no-unnecessary-condition.ts99.25% <100.00%> (-0.01%)⬇️
...ckages/eslint-plugin/src/util/getConstraintInfo.ts100.00% <100.00%> (ø)
...ackages/eslint-plugin/src/util/needsToBeAwaited.ts100.00% <100.00%> (ø)
...ges/type-utils/src/getConstrainedTypeAtLocation.ts100.00% <ø> (ø)

JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesDec 14, 2024
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

LGTM, nice to see the cleanup & related fixes!

Just requesting a collection of touchups, nothing major.

kirkwaiblinger reacted with heart emoji
@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 14, 2024
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
@github-actionsgithub-actionsbot removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 14, 2024
JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesDec 15, 2024
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

I like this strategy 😄

kirkwaiblinger reacted with hooray emoji
@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 15, 2024
@github-actionsgithub-actionsbot removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 16, 2024
*
* Successor to {@link getConstrainedTypeAtLocation} due to https://github.com/typescript-eslint/typescript-eslint/issues/10438
*/
export function getConstraintTypeInfoAtLocation(
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@JoshuaKGoldberg I've just had the thought - I think this might be the wrong API to write. It might be better to just accept a type as input, like

exportdeclarefunctiongetConstraintInfo(type:ts.Type):{isTypeParameter:boolean,constraint:ts.Type|undefined};

This maintains a separation betweengetting types andanalyzing types.

Choose a reason for hiding this comment

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

@kirkwaiblinger just confirming, are you planning on making changes? And/or, is this a question?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Lol. In my head, I was asking you for your opinion, yeah, but I forgot to write that out 😆

Coming back to this, I currently lean towards: let's go with this PR in its current state, and if there's a need to extract just the constraint info part of this function that's quite easy to do in a followup when the need arises.

Feel free to offer your opinion! 😁

JoshuaKGoldberg reacted with laugh emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

If you're on board with this plan, then this PR is up to date and ready to be merged 👍

Choose a reason for hiding this comment

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

Oh awesome! I don't have a strong preference here.

Proposal: whatever strategy you want to go with, how about marking the final creation as@internal so it's not part of the public API? That way we can play with it as we want.

kirkwaiblinger reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Made lots of changes in this arena. New utility is just internal to eslint-plugin for now, no deprecation yet. Should be much easier to review!

JoshuaKGoldberg 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.

I like this strategy. The union of possible constraint info points seems reasonable to me.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelDec 26, 2024
@kirkwaiblingerkirkwaiblinger changed the titlefix(type-utils): add getConstraintTypeInfoAtLocation and deprecate getConstrainedTypeAtLocationfix(eslint-plugin): add getConstraintInfo to handle generic constraints betterDec 29, 2024
@kirkwaiblingerkirkwaiblinger removed the awaiting responseIssues waiting for a reply from the OP or another party labelDec 29, 2024
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

🎉 This is great!

kirkwaiblinger reacted with heart emoji
@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 29, 2024
@JoshuaKGoldbergJoshuaKGoldberg merged commit2e2731d intotypescript-eslint:mainDec 30, 2024
72 of 75 checks passed
renovatebot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull requestDec 30, 2024
##### [v8.19.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8190-2024-12-30)##### 🚀 Features-   **eslint-plugin:** \[strict-boolean-expressions] check array predicate functions' return statements ([#10106](typescript-eslint/typescript-eslint#10106))##### 🩹 Fixes-   **eslint-plugin:** \[member-ordering] ignore method overloading ([#10536](typescript-eslint/typescript-eslint#10536))-   **eslint-plugin:** \[consistent-indexed-object-style] don't report on indirect circular references ([#10537](typescript-eslint/typescript-eslint#10537))-   **eslint-plugin:** \[array-type] autofix with conditional types needs parentheses ([#10522](typescript-eslint/typescript-eslint#10522))-   **eslint-plugin:** add getConstraintInfo to handle generic constraints better ([#10496](typescript-eslint/typescript-eslint#10496))##### ❤️ Thank You-   Karl Werner-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)-   Ronen Amiel-   YeonJuan [@yeonjuan](https://github.com/yeonjuan)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
OlivierZal pushed a commit to OlivierZal/typescript-eslint that referenced this pull requestDec 30, 2024
…ts better (typescript-eslint#10496)* add getConstraintTypeInfoAtLocation* revisittypescript-eslint#10314* handletypescript-eslint#10443* tweak tests* Apply suggestions from code reviewCo-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>* code review* deal with deprecated API lint failures* space* remove vfs, derp* typo* simplify* more simplify* jsdoc* more better* better---------Co-authored-by: typescript-eslint[bot] <53356952+typescript-eslint[bot]@users.noreply.github.com>Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
renovatebot added a commit to andrei-picus-tink/auto-renovate that referenced this pull requestDec 31, 2024
| datasource | package                          | from   | to     || ---------- | -------------------------------- | ------ | ------ || npm        | @typescript-eslint/eslint-plugin | 8.18.2 | 8.19.0 || npm        | @typescript-eslint/parser        | 8.18.2 | 8.19.0 |## [v8.19.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8190-2024-12-30)##### 🚀 Features-   **eslint-plugin:** \[strict-boolean-expressions] check array predicate functions' return statements ([#10106](typescript-eslint/typescript-eslint#10106))##### 🩹 Fixes-   **eslint-plugin:** \[member-ordering] ignore method overloading ([#10536](typescript-eslint/typescript-eslint#10536))-   **eslint-plugin:** \[consistent-indexed-object-style] don't report on indirect circular references ([#10537](typescript-eslint/typescript-eslint#10537))-   **eslint-plugin:** \[array-type] autofix with conditional types needs parentheses ([#10522](typescript-eslint/typescript-eslint#10522))-   **eslint-plugin:** add getConstraintInfo to handle generic constraints better ([#10496](typescript-eslint/typescript-eslint#10496))##### ❤️ Thank You-   Karl Werner-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)-   Ronen Amiel-   YeonJuan [@yeonjuan](https://github.com/yeonjuan)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJan 7, 2025
@kirkwaiblingerkirkwaiblinger deleted the get-constraint-type-info-at-location branchMarch 31, 2025 01:14
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Repo: Investigate better handling of unconstrained generics
2 participants
@kirkwaiblinger@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp