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] Compilation error when method name is string instead of identifier #2514

Merged
merged 1 commit into from Dec 9, 2019

Conversation

@shijistar
Copy link
Contributor

@shijistar shijistar commented Dec 6, 2019

I got a compilation error when a component method name is string instead of identifier. The sample code is,

class MyComponent {
    "special-method-name"() {
        // ...
    }
}

Normally method names should be valid identifiers. However for some reason, I need one of my methods must be in a special form. Eslint raises an error, but babel goes well and the code works well in chrome too.

The difference between Identifier and String method is that the node.key.type is Identifier/Literal. If method name is Identifier, the node.key.name is the identifier name, however if method name is String, we should get the method name by node.key.value.

Copy link
Collaborator

@ljharb ljharb left a comment

Thanks! Can you please provide a regression test?

@shijistar shijistar force-pushed the shijistar:master branch 2 times, most recently from c22ffbe to 7cf4a10 Dec 9, 2019
@shijistar shijistar requested a review from ljharb Dec 9, 2019
@shijistar
Copy link
Contributor Author

@shijistar shijistar commented Dec 9, 2019

Thanks! Can you please provide a regression test?

Regression test added.

@ljharb ljharb force-pushed the shijistar:master branch from 7cf4a10 to 4fedc5f Dec 9, 2019
@ljharb
ljharb approved these changes Dec 9, 2019
@ljharb ljharb merged commit 4fedc5f into yannickcr:master Dec 9, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.01%) to 97.525%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants