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

feat: [4.7] support optional variance annotation #4831

Merged
merged 12 commits into from May 19, 2022

Conversation

sosukesuzuki
Copy link
Contributor

@sosukesuzuki sosukesuzuki commented Apr 17, 2022

PR Checklist

Overview

Based on #4829

Support optional variance syntax.

@nx-cloud
Copy link

nx-cloud bot commented Apr 17, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 68c350b. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @sosukesuzuki!

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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@netlify
Copy link

netlify bot commented Apr 17, 2022

👷 Deploy request for typescript-eslint pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 68c350b

@bradzacher bradzacher added the AST PRs and Issues about the AST structure label Apr 25, 2022
@bradzacher
Copy link
Member

i merged the version bump so this can be rebased on top of main

@sosukesuzuki sosukesuzuki marked this pull request as ready for review May 17, 2022 15:16
@codecov
Copy link

codecov bot commented May 17, 2022

Codecov Report

Merging #4831 (68c350b) into main (c673e15) will increase coverage by 0.38%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #4831      +/-   ##
==========================================
+ Coverage   91.32%   91.70%   +0.38%     
==========================================
  Files         132      359     +227     
  Lines        1487    12117   +10630     
  Branches      224     3518    +3294     
==========================================
+ Hits         1358    11112    +9754     
- Misses         65      657     +592     
- Partials       64      348     +284     
Flag Coverage Δ
unittest 91.70% <ø> (+0.38%) ⬆️

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

Impacted Files Coverage Δ
packages/typescript-estree/src/convert.ts 98.39% <ø> (ø)
packages/eslint-plugin/src/rules/no-shadow.ts 78.48% <0.00%> (ø)
...kages/eslint-plugin/src/rules/naming-convention.ts 81.09% <0.00%> (ø)
packages/eslint-plugin/src/rules/dot-notation.ts 96.29% <0.00%> (ø)
packages/type-utils/src/isTypeReadonly.ts 85.71% <0.00%> (ø)
...ackages/eslint-plugin/src/rules/no-explicit-any.ts 92.85% <0.00%> (ø)
...ges/eslint-plugin/src/rules/no-extraneous-class.ts 100.00% <0.00%> (ø)
...rc/rules/indent-new-do-not-use/BinarySearchTree.ts 100.00% <0.00%> (ø)
packages/utils/src/ast-utils/eslint-utils/index.ts 20.00% <0.00%> (ø)
...-plugin/src/rules/restrict-template-expressions.ts 100.00% <0.00%> (ø)
... and 218 more

@@ -2342,6 +2362,7 @@ export class Converter {
? this.convertType(node.constraint)
: undefined,
default: node.default ? this.convertType(node.default) : undefined,
...this.convertTypeParamVariances(node.modifiers),
Copy link
Member

Choose a reason for hiding this comment

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

what do you think about changing it to hasModifier to be consistent with other use cases?

Suggested change
...this.convertTypeParamVariances(node.modifiers),
in: hasModifier(SyntaxKind.InKeyword, node) || undefined,
out: hasModifier(SyntaxKind.OutKeyword, node) || undefined,

Copy link
Member

Choose a reason for hiding this comment

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

instead of undefined - could we make it false?
I'd love for us to standardise on not emitting undefined for properties.
I personally don't like having 3 states on a flag - the keyword is either there, or it's not - there's no 3rd state!

bradzacher
bradzacher previously approved these changes May 19, 2022
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

this LGTM now! Thanks so much for helping us prep for 4.7!

@bradzacher bradzacher changed the title feat(typescript-estree): support optional variance annotation feat: [4.7] support optional variance annotation May 19, 2022
@bradzacher bradzacher enabled auto-merge (squash) May 19, 2022 04:36
@bradzacher bradzacher added the enhancement New feature or request label May 19, 2022
@bradzacher
Copy link
Member

there's a few snapshots which need regenerating in ast-spec - cd packages/ast-spec && yarn test -u

@sosukesuzuki
Copy link
Contributor Author

Thank you for reviewing! I've updated tests!

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

brilliant - thanks for all your hard work!

@bradzacher bradzacher merged commit 7e7b24c into typescript-eslint:main May 19, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
AST PRs and Issues about the AST structure enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants