-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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(parser): throw error with wrong typescript 'export declare' #12684
fix(parser): throw error with wrong typescript 'export declare' #12684
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/38377/ |
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 1cb13af:
|
packages/babel-parser/test/fixtures/typescript/export/declare-invalid/options.json
Outdated
Show resolved
Hide resolved
isDeclare && | ||
(this.isContextual("declare") || !this.shouldParseExportDeclaration()) | ||
) { | ||
throw this.raise( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not throw here to make it recoverable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about how we could recover. What should the AST for export declare foo
be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right. Let's stick with throwing!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, pending a reply from @existentialism to #12684 (comment) (if we can easily recover we should do it).
We check if after the first
declare
there is an exportable value.