From ae4b5dc842fa042485c2e275170d4ff6e714357c Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 12 Dec 2014 14:02:32 -0800 Subject: [PATCH] Move grammar checking: externalModuleReferences; there are still errors from incomplete grammar checking migration --- src/compiler/checker.ts | 10 ++++++++-- src/compiler/parser.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6f81b879885..e3123a54c51 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -468,6 +468,13 @@ module ts { if (!links.target) { links.target = resolvingSymbol; var node = getDeclarationOfKind(symbol, SyntaxKind.ImportDeclaration); + // Grammar checking + if (node.moduleReference.kind === SyntaxKind.ExternalModuleReference) { + if ((node.moduleReference).expression.kind !== SyntaxKind.StringLiteral) { + grammarErrorOnNode((node.moduleReference).expression, Diagnostics.String_literal_expected); + } + } + var target = node.moduleReference.kind === SyntaxKind.ExternalModuleReference ? resolveExternalModuleName(node, getExternalModuleImportDeclarationExpression(node)) : getSymbolOfPartOfRightHandSideOfImport(node.moduleReference, node); @@ -10040,15 +10047,14 @@ module ts { // Since computed properties are not supported in the type checker, disallow them in TypeScript 1.4 // Once full support is added, remove this error. grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_not_currently_supported); + return; - /* TODO (jfreeman) if (compilerOptions.target < ScriptTarget.ES6) { grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher); } else if (node.expression.kind === SyntaxKind.BinaryExpression && (node.expression).operator === SyntaxKind.CommaToken) { grammarErrorOnNode(node.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } - */ } function hasParseDiagnostics(sourceFile: SourceFile): boolean { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 2aacbe5ab04..ed30af4301b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4643,7 +4643,7 @@ module ts { //case SyntaxKind.DeleteExpression: return checkDeleteExpression( node); //case SyntaxKind.ElementAccessExpression: return checkElementAccessExpression(node); //case SyntaxKind.ExportAssignment: return checkExportAssignment(node); - case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); + //case SyntaxKind.ExternalModuleReference: return checkExternalModuleReference(node); case SyntaxKind.ForInStatement: return checkForInStatement(node); case SyntaxKind.ForStatement: return checkForStatement(node); case SyntaxKind.FunctionDeclaration: return checkFunctionDeclaration(node);