fix(parser): throw error with wrong typescript 'export declare' (#12684)
This commit is contained in:
@@ -74,6 +74,8 @@ const TSErrors = Object.freeze({
|
||||
EmptyHeritageClauseType: "'%0' list cannot be empty.",
|
||||
EmptyTypeArguments: "Type argument list cannot be empty.",
|
||||
EmptyTypeParameters: "Type parameter list cannot be empty.",
|
||||
ExpectedAmbientAfterExportDeclare:
|
||||
"'export declare' must be followed by an ambient declaration.",
|
||||
IndexSignatureHasAbstract:
|
||||
"Index signatures cannot have the 'abstract' modifier",
|
||||
IndexSignatureHasAccessibility:
|
||||
@@ -2281,6 +2283,16 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
// "export declare" is equivalent to just "export".
|
||||
const isDeclare = this.eatContextual("declare");
|
||||
|
||||
if (
|
||||
isDeclare &&
|
||||
(this.isContextual("declare") || !this.shouldParseExportDeclaration())
|
||||
) {
|
||||
throw this.raise(
|
||||
this.state.start,
|
||||
TSErrors.ExpectedAmbientAfterExportDeclare,
|
||||
);
|
||||
}
|
||||
|
||||
let declaration: ?N.Declaration;
|
||||
|
||||
if (this.match(tt.name)) {
|
||||
|
||||
Reference in New Issue
Block a user