mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Move grammar checking: moduleDeclaration; there are still errors from incomplete grammar migration
This commit is contained in:
parent
003515655e
commit
c525877aaa
@ -8880,6 +8880,27 @@ module ts {
|
||||
}
|
||||
|
||||
function checkModuleDeclaration(node: ModuleDeclaration) {
|
||||
// Grammar checking
|
||||
if (!checkGrammarModifiers(node)) {
|
||||
if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) {
|
||||
grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names);
|
||||
}
|
||||
else if (node.name.kind === SyntaxKind.Identifier && node.body.kind === SyntaxKind.ModuleBlock) {
|
||||
var statements = (<ModuleBlock>node.body).statements;
|
||||
for (var i = 0, n = statements.length; i < n; i++) {
|
||||
var statement = statements[i];
|
||||
|
||||
if (statement.kind === SyntaxKind.ExportAssignment) {
|
||||
// Export assignments are not allowed in an internal module
|
||||
grammarErrorOnNode(statement, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
|
||||
}
|
||||
else if (isExternalModuleImportDeclaration(statement)) {
|
||||
grammarErrorOnNode(getExternalModuleImportDeclarationExpression(statement), Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fullTypeCheck) {
|
||||
checkCollisionWithCapturedThisVariable(node, node.name);
|
||||
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
|
||||
|
||||
@ -4656,7 +4656,7 @@ module ts {
|
||||
//case SyntaxKind.MethodDeclaration:
|
||||
//case SyntaxKind.MethodSignature:
|
||||
//return checkMethod(<MethodDeclaration>node);
|
||||
case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(<ModuleDeclaration>node);
|
||||
//case SyntaxKind.ModuleDeclaration: return checkModuleDeclaration(<ModuleDeclaration>node);
|
||||
//case SyntaxKind.ObjectLiteralExpression: return checkObjectLiteralExpression(<ObjectLiteralExpression>node);
|
||||
//case SyntaxKind.NumericLiteral: return checkNumericLiteral(<LiteralExpression>node);
|
||||
//case SyntaxKind.Parameter: return checkParameter(<ParameterDeclaration>node);
|
||||
@ -5330,7 +5330,7 @@ module ts {
|
||||
//case SyntaxKind.MethodSignature:
|
||||
//case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
//case SyntaxKind.ModuleDeclaration:
|
||||
//case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
//case SyntaxKind.VariableStatement:
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
tests/cases/compiler/declareAlreadySeen.ts(5,13): error TS1030: 'declare' modifier already seen.
|
||||
tests/cases/compiler/declareAlreadySeen.ts(2,13): error TS1030: 'declare' modifier already seen.
|
||||
tests/cases/compiler/declareAlreadySeen.ts(3,13): error TS1030: 'declare' modifier already seen.
|
||||
tests/cases/compiler/declareAlreadySeen.ts(5,13): error TS1030: 'declare' modifier already seen.
|
||||
tests/cases/compiler/declareAlreadySeen.ts(7,13): error TS1030: 'declare' modifier already seen.
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user