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

Parse static blocks with typescript plugin #13243

Merged
merged 8 commits into from May 3, 2021

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented May 1, 2021

Q                       A
Fixed Issues? Fixes #13234
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 Spec: Class Static Block labels May 1, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented May 1, 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 a334b8f:

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

@babel-bot
Copy link
Collaborator

babel-bot commented May 1, 2021

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

@@ -0,0 +1,3 @@
class Foo {
static private {}
Copy link
Member

Choose a reason for hiding this comment

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

We can report a better error, like Static class blocks cannot have any modifier

@@ -131,6 +131,8 @@ const TSErrors = makeErrorTemplates(
"A 'set' accessor cannot have rest parameter.",
SetAccesorCannotHaveReturnType:
"A 'set' accessor cannot have a return type annotation.",
StaticBlockCannotHaveanyModifier:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
StaticBlockCannotHaveanyModifier:
StaticBlockCannotHaveModifier:

nit-picking: I prefer shorter error codes.

@@ -0,0 +1,4 @@
class Foo {
static foo;
Copy link
Contributor

Choose a reason for hiding this comment

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

As I read the name of the test, did you mean

Suggested change
static foo;
static static;

?

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.

LGTM with some comments.

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.

Can you add a test case on static static {}? I think it should throw static block can not have static modifier.

@sosukesuzuki

This comment has been minimized.

@sosukesuzuki sosukesuzuki force-pushed the static-blocks-with-typescript branch from 7cc5d28 to a334b8f Compare May 3, 2021 18:38
@JLHwung JLHwung merged commit ef87648 into babel:main May 3, 2021
@sosukesuzuki sosukesuzuki deleted the static-blocks-with-typescript branch May 4, 2021 07:57
@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 Aug 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript i: regression 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 Spec: Class Static Block
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Unexpected token syntax error is thrown with classStaticBlock and typescript.
4 participants