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

fix(typescript-estree): support override modifier for parameter property #3485

Conversation

sosukesuzuki
Copy link
Contributor

ref: prettier/prettier#11017

Support TS 4.3 override modifier for parameter properties.

TS Playground Link

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

@@ -386,6 +386,11 @@ tester.addFixturePatternConfig('typescript/basics', {
* This is intentional; babel is not checking types
*/
'catch-clause-with-invalid-annotation',
/**
* [BABEL ERRORED, BUT TS-ESTREE DID NOT]
* SyntaxError: Unexpected token, expected ","
Copy link
Contributor Author

Choose a reason for hiding this comment

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

babel/parser cannot parse override modifier for parameter properties, I'll report and fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codecov
Copy link

codecov bot commented Jun 6, 2021

Codecov Report

Merging #3485 (90bd914) into master (44452dd) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3485   +/-   ##
=======================================
  Coverage   92.63%   92.63%           
=======================================
  Files         325      325           
  Lines       11226    11227    +1     
  Branches     3163     3164    +1     
=======================================
+ Hits        10399    10400    +1     
  Misses        367      367           
  Partials      460      460           
Flag Coverage Δ
unittest 92.63% <100.00%> (+<0.01%) ⬆️

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.27% <100.00%> (+<0.01%) ⬆️

@bradzacher
Copy link
Member

I'm not sure about this. It currently is an explicit TS error, so I think that babel has it right.

This should probably be a syntax error, and something we shouldn't support explicitly.

I think this is another case where prettier could access the underlying TS ast to look for the existence of a bad modifier (until such time that we have support for syntax errors?)

@sosukesuzuki
Copy link
Contributor Author

sosukesuzuki commented Jun 6, 2021

For example, in this case the override modifier of the parameter property is required. TypeScript Playground Link(The noImplicitOverride option is not set to true in this link, please set it to true manually.)
Also in TypeScript complier, override modifier for parameter property is allowed explicitly. (ref: microsoft/TypeScript#43831)

@bradzacher
Copy link
Member

OH! I see.
microsoft/TypeScript#43831 was released as part of the RC.

When I built the feature, I used the playground to figure out what was supported.
The playground doesn't ever use the RC version, so I was working against 4.3-beta.
So when I tested the parameter property case, it was a TS error.

But that PR obviously makes it supported - and testing against 4.3.2 it does work without an error.
This is correct then.

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.

LGTM - one suggestion:
could you please add a test for this case with JUST the override as this emits as a parameter property:

class SpecializedComponent extends SomeComponent {
  constructor(override param: string) {
      super();
  }
}

repl

packages/typescript-estree/src/convert.ts Show resolved Hide resolved
@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Jun 6, 2021
@sosukesuzuki sosukesuzuki force-pushed the override-modifer-in-parameter-property branch from f6416ff to 255c57f Compare June 7, 2021 02:23
@sosukesuzuki sosukesuzuki force-pushed the override-modifer-in-parameter-property branch from 255c57f to 5213f4a Compare June 7, 2021 02:41
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Jun 7, 2021
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.

thanks for this!

@bradzacher bradzacher changed the title feat(typescript-estree): support override modifer for parameter property fix(typescript-estree): support override modifier for parameter property Jun 7, 2021
@bradzacher bradzacher enabled auto-merge (squash) June 7, 2021 02:43
@bradzacher bradzacher merged commit 33b9f69 into typescript-eslint:master Jun 9, 2021
@sosukesuzuki sosukesuzuki deleted the override-modifer-in-parameter-property branch June 9, 2021 06:58
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants