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

[ts] Support override modifiers for parameter properties #13428

Merged
merged 6 commits into from Jun 10, 2021

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Jun 6, 2021

Q                       A
Fixed Issues? Fixes #13427
Patch: Bug Fix? Y
Tests Added + Pass? Yes
License MIT

@sosukesuzuki sosukesuzuki added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser area: typescript labels Jun 6, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Jun 6, 2021

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/46782/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 6, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8f7c78c:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@fedeci
Copy link
Member

fedeci commented Jun 6, 2021

Do we enforce modifier order in constructor args too?
The following seems to be throwing the wrong error:

class Foo extends Bar {
  constructor(override private readonly foo: string) {
  }
}

And can you test this also on a regular class method, because the test should fail in that case as for readonly.

if (allowModifiers !== undefined) {
accessibility = this.parseAccessModifier();
override = !!this.tsParseModifier(["override"]);
readonly = !!this.tsParseModifier(["readonly"]);

This comment was marked as duplicate.

if (allowModifiers !== undefined) {
accessibility = this.parseAccessModifier();
override = !!this.tsParseModifier(["override"]);
readonly = !!this.tsParseModifier(["readonly"]);
if (allowModifiers === false && (accessibility || readonly)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we also check override here?

Comment on lines +1936 to +1943
const modified = {};
this.tsParseModifiers(modified, [
"public",
"private",
"protected",
"override",
"readonly",
]);
accessibility = modified.accessibility;
override = modified.override;
readonly = modified.readonly;
Copy link
Member Author

Choose a reason for hiding this comment

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

I used tsParseModifiers on an empty object to reuse the logic to enforce the order. What do you think?

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Thanks!

@nicolo-ribaudo nicolo-ribaudo changed the title babel-parser: [ts] Support override modifiers for parameter properties [ts] Support override modifiers for parameter properties Jun 10, 2021
@nicolo-ribaudo nicolo-ribaudo merged commit 0eb2853 into babel:main Jun 10, 2021
@sosukesuzuki sosukesuzuki deleted the fix-13427 branch June 11, 2021 00:19
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 10, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Syntax error is thrown for override modifiers for parameter properties
5 participants