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

babel-parser(ts): Add new plugin option dts: boolean #13113

Merged
merged 7 commits into from Apr 28, 2021

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Apr 7, 2021

Q                       A
Fixed Issues? Fixes #13108
Minor: New Feature? Y
Tests Added + Pass? Yes
Documentation PR Link babel/website#2487
License MIT

I want to use checkCommaAfterRest method that is implemented in #13101 so this branch is based on main, not feat-7.14.0/parser-updates.

  • Rename this.state.isDeclareContext => this.state.isAmbientContext.
  • Add new parser plugin option dts: boolean.
  • Add tests for syntax errors related ambient context.

@sosukesuzuki sosukesuzuki added PR: New Feature 🚀 A type of pull request used for our changelog categories pkg: parser area: typescript labels Apr 7, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Apr 7, 2021

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 7, 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 98f5c6a:

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

}

parse() {
if (this.shouldParseAsDts()) {
Copy link
Member

Choose a reason for hiding this comment

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

Doing so all files would be parsed as declaration though, maybe we should check the filename also?

Copy link
Member

Choose a reason for hiding this comment

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

The parser ignores filenames (e.g. it doesn't check if a file has a .ts extension). Only files for which the dts: true option is enabled will be parsed as declaration, and it's up to the @babel/parser consumer to decide when to enable it.

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.

For consistency we should also extend

getExpression(): N.Expression & N.ParserOutput {

@nicolo-ribaudo nicolo-ribaudo added the PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release label Apr 9, 2021
@nicolo-ribaudo nicolo-ribaudo added this to the v7.14.0 milestone Apr 13, 2021
@nicolo-ribaudo nicolo-ribaudo merged commit 7f5b212 into babel:main Apr 28, 2021
@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 Jul 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2021
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 pkg: parser PR: New Feature 🚀 A type of pull request used for our changelog categories PR: Ready to be Merged A pull request with already two approvals, but waiting for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new option dts: boolean to babel-parser TypeScript plugin
5 participants