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

Disallow usage of invalid keyword after export abstract statement in Typescript #9336

Merged
merged 2 commits into from Jan 19, 2019
Merged

Disallow usage of invalid keyword after export abstract statement in Typescript #9336

merged 2 commits into from Jan 19, 2019

Conversation

armano2
Copy link
Contributor

@armano2 armano2 commented Jan 14, 2019

Q                       A
Fixed Issues? Fixes #9304
Patch: Bug Fix? 👍
Major: Breaking Change? 👎
Minor: New Feature? 👎
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? 👎
License MIT

This PR makes parser error on unexpected keywords used after export abstract and disallow usage of unknown keywords as "classes":

example of fixed cases:

export abstract interface X {}
export abstract putHereWhathever X {}

this.parseClass does not check if its actually class, it's just doing this.next() on first token
it can be also solved by moving this check there

@babel-bot
Copy link
Collaborator

babel-bot commented Jan 14, 2019

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

@armano2 armano2 changed the title @babel/parser(ts): error on invalid export abstract interface Disallow usage of invalid keyword after export abstract statement in Typescript Jan 14, 2019
@existentialism existentialism added PR: Bug Fix 🐛 A type of pull request used for our changelog categories area: typescript labels Jan 15, 2019
@nicolo-ribaudo
Copy link
Member

Don't the other things inside that switch (enum, interface) have the same problem?

@armano2
Copy link
Contributor Author

armano2 commented Jan 18, 2019

no, in other cases we are checking identifier and only abstract is multi keyword abstract class

additionally issue is present only if export keyword is in front of it


before this change

abstract interface will throw error
export abstract interface is valid


i found this issue by doing alignment tests between typescript-estree with babel 🐱

@existentialism existentialism merged commit a2e6d8e into babel:master Jan 19, 2019
@armano2 armano2 deleted the export-abstract branch January 19, 2019 21:54
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
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 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.

@babel/parser(ts): exported abstract interface is parsed as a class
4 participants