mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-11 01:34:55 -06:00
Move grammar checking: declare keyword in checkGrammarModifier; there are still erros from incomplete grammar migration
This commit is contained in:
parent
d584737ea2
commit
60eb37df94
@ -9947,7 +9947,20 @@ module ts {
|
||||
break;
|
||||
|
||||
case SyntaxKind.DeclareKeyword:
|
||||
// TODO (yuisu) : Revisit this once moving ambient Context into type checking
|
||||
if (flags & NodeFlags.Ambient) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "declare");
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.ClassDeclaration) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
|
||||
}
|
||||
else if (node.kind === SyntaxKind.Parameter) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
|
||||
}
|
||||
else if (isInAmbientContext(node.parent) && node.parent.kind === SyntaxKind.ModuleBlock) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
|
||||
}
|
||||
flags |= NodeFlags.Ambient;
|
||||
lastDeclare = modifier
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ module ts {
|
||||
Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names.", isEarly: true },
|
||||
Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts.", isEarly: true },
|
||||
A_function_implementation_cannot_be_declared_in_an_ambient_context: { code: 1037, category: DiagnosticCategory.Error, key: "A function implementation cannot be declared in an ambient context.", isEarly: true },
|
||||
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." },
|
||||
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context.", isEarly: true },
|
||||
Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts.", isEarly: true },
|
||||
_0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element.", isEarly: true },
|
||||
A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." },
|
||||
|
||||
@ -144,7 +144,8 @@
|
||||
},
|
||||
"A 'declare' modifier cannot be used in an already ambient context.": {
|
||||
"category": "Error",
|
||||
"code": 1038
|
||||
"code": 1038,
|
||||
"isEarly": true
|
||||
},
|
||||
"Initializers are not allowed in ambient contexts.": {
|
||||
"category": "Error",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user