Skip to content

Fix matching of jsClassProperty without an initial value #1202

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

Merged
merged 1 commit into from
Apr 13, 2020

Conversation

ohcibi
Copy link
Contributor

@ohcibi ohcibi commented Apr 6, 2020

Given the following code

class Foo {
  bar;

  baz = 'biz';
}

The baz is properly matched as a jsClassProperty but bar is jsClassBody. The regex for jsClassPropertywas requiring the=that followed the property name. The changes allow value less properties by allowing either;or=` to follow the name.

jsClassPropertyComputed was not affected since that is matched by using the delimiters [] and
that works regardless of an initial value. But I noticed that for properties that have no semicolons
then the matching does not work for property values as well. I don't know if the recent spec
actually requires semicolons, so I didn't add it yet. But I would add it if class properties without
semicolons are still allowed.

Given the following code

```javascript
class Foo {
  bar;

  baz = 'biz';
}
```

The `baz` is properly matched as a `jsClassProperty` but `bar is
`jsClassBody`. The regex for `jsClassProperty` was requiring the `=`
that followed the property name. The changes allow value less
properties by allowing either `;` or `=` to follow the name.
@amadeus amadeus merged commit c396615 into pangloss:master Apr 13, 2020
@amadeus
Copy link
Collaborator

amadeus commented Apr 13, 2020

Thanks for the PR!

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.

2 participants