[ts] Throw a syntax error for index signature with declare (#12111)

This commit is contained in:
Sosuke Suzuki
2020-09-27 01:06:13 +09:00
committed by GitHub
parent 1a074ee7e6
commit 434b65bc2a
3 changed files with 57 additions and 22 deletions

View File

@@ -80,6 +80,8 @@ const TSErrors = Object.freeze({
IndexSignatureHasAccessibility:
"Index signatures cannot have an accessibility modifier ('%0')",
IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier",
IndexSignatureHasDeclare:
"Index signatures cannot have the 'declare' modifier",
InvalidTupleMemberLabel:
"Tuple members must be labeled with a simple identifier.",
MixedLabeledAndUnlabeledElements:
@@ -2108,6 +2110,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
(member: any).accessibility,
);
}
if ((member: any).declare) {
this.raise(member.start, TSErrors.IndexSignatureHasDeclare);
}
return;
}