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(parser): Add support for class static initialization block #219

Merged
merged 2 commits into from
May 15, 2022

Conversation

prantlf
Copy link
Contributor

@prantlf prantlf commented May 7, 2022

Attempts to fix #194 and one point from #214.

extend interface ClassBody {
  body: [ MethodDefinition | PropertyDefinition | StaticBlock ];
}

interface StaticBlock <: BlockStatement {
  type: "StaticBlock";
}

Proposal: https://github.com/tc39/proposal-class-static-block
MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Class_static_initialization_blocks
V8 examples: https://v8.dev/features/class-static-initializer-blocks
ESTree: https://github.com/estree/estree/blob/master/es2022.md#staticblock

src/parser.ts Outdated Show resolved Hide resolved
Copy link
Member

@3cp 3cp left a comment

Choose a reason for hiding this comment

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

LGTM

@3cp
Copy link
Member

3cp commented May 9, 2022

@aladdin-add could you have a look too?

@3cp 3cp requested a review from aladdin-add May 13, 2022 00:35
Copy link
Collaborator

@aladdin-add aladdin-add left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

import { Context } from '../../../src/common';
import { pass, fail } from '../../test-utils';

describe('Next - Class static initialization block', () => {
Copy link
Collaborator

@aladdin-add aladdin-add May 13, 2022

Choose a reason for hiding this comment

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

good to have a few more tests. afaict, the test262 has many failing cases. tc39/test262@afe217b

we can try to add the test262 at some point, but surely it should be another PR, and won't block merging this one.

@3cp 3cp merged commit fd54074 into meriyah:master May 15, 2022
@3cp
Copy link
Member

3cp commented May 15, 2022

There are works to be done before we can ship it. I tried first few test262, it didn't work as expected.

@3cp
Copy link
Member

3cp commented Aug 2, 2022

I don't have time to improve this for now. Just released v4.3.0 to include this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement static blocks (stage 3)
3 participants