Better spans for import/export errors.

This commit is contained in:
Cyrus Najmabadi 2014-11-20 14:27:09 -08:00
parent 617fd2c5c9
commit c005c33244
18 changed files with 49 additions and 49 deletions

View File

@ -4066,10 +4066,10 @@ module ts {
if (statement.kind === SyntaxKind.ExportAssignment) {
// Export assignments are not allowed in an internal module
return grammarErrorOnFirstToken(statement, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
return grammarErrorOnNode(statement, Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
}
else if (statement.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>statement).externalModuleName) {
return grammarErrorOnFirstToken(statement, Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
return grammarErrorOnNode((<ImportDeclaration>statement).externalModuleName, Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
}
}
}

View File

@ -1,9 +1,9 @@
tests/cases/compiler/importDeclarationInModuleDeclaration1.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/importDeclarationInModuleDeclaration1.ts(2,25): error TS1147: Import declarations in an internal module cannot reference an external module.
==== tests/cases/compiler/importDeclarationInModuleDeclaration1.ts (1 errors) ====
module m2 {
import m3 = require("use_glo_M1_public");
~~~~~~
~~~~~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
}

View File

@ -1,11 +1,11 @@
tests/cases/compiler/importInsideModule_file2.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/importInsideModule_file2.ts(2,26): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/importInsideModule_file2.ts(2,26): error TS2307: Cannot find external module 'importInsideModule_file1'.
==== tests/cases/compiler/importInsideModule_file2.ts (2 errors) ====
export module myModule {
import foo = require("importInsideModule_file1");
~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2307: Cannot find external module 'importInsideModule_file1'.

View File

@ -5,7 +5,7 @@ tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignm
==== tests/cases/conformance/parser/ecmascript5/ExportAssignments/parserExportAssignment5.ts (2 errors) ====
module M {
export = A;
~~~~~~
~~~~~~~~~~~
!!! error TS1063: An export assignment cannot be used in an internal module.
~~~~~~~~~~~
!!! error TS2304: Cannot find name 'A'.

View File

@ -1,7 +1,7 @@
tests/cases/compiler/privacyGloImportParseErrors.ts(59,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyGloImportParseErrors.ts(121,9): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyGloImportParseErrors.ts(59,37): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyGloImportParseErrors.ts(121,38): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyGloImportParseErrors.ts(133,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
tests/cases/compiler/privacyGloImportParseErrors.ts(146,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyGloImportParseErrors.ts(22,27): error TS2435: Ambient external modules cannot be nested in other modules.
tests/cases/compiler/privacyGloImportParseErrors.ts(30,20): error TS2435: Ambient external modules cannot be nested in other modules.
tests/cases/compiler/privacyGloImportParseErrors.ts(59,37): error TS2307: Cannot find external module 'm1_M3_public'.
@ -75,7 +75,7 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2435: Ambie
var m1_im2_private_v4_private = m1_im2_private.f1();
import m1_im3_private = require("m1_M3_public");
~~~~~~
~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
~~~~~~~~~~~~~~
!!! error TS2307: Cannot find external module 'm1_M3_public'.
@ -143,7 +143,7 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2435: Ambie
module m2 {
import errorImport = require("glo_M2_public");
~~~~~~
~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
import nonerrorImport = glo_M1_public;
@ -178,7 +178,7 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(141,12): error TS2435: Ambie
module m2 {
import m3 = require("use_glo_M1_public");
~~~~~~
~~~~~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
module m4 {
var a = 10;

View File

@ -1,11 +1,11 @@
tests/cases/compiler/privacyImportParseErrors.ts(59,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(143,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(273,9): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(302,9): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(273,38): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(302,38): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(314,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context.
tests/cases/compiler/privacyImportParseErrors.ts(326,9): error TS1029: 'export' modifier must precede 'declare' modifier.
tests/cases/compiler/privacyImportParseErrors.ts(341,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(350,5): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(341,25): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import declarations in an internal module cannot reference an external module.
tests/cases/compiler/privacyImportParseErrors.ts(22,27): error TS2435: Ambient external modules cannot be nested in other modules.
tests/cases/compiler/privacyImportParseErrors.ts(30,20): error TS2435: Ambient external modules cannot be nested in other modules.
tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS2307: Cannot find external module 'm1_M3_public'.
@ -102,7 +102,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient
var m1_im2_private_v4_private = m1_im2_private.f1();
import m1_im3_private = require("m1_M3_public");
~~~~~~
~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
~~~~~~~~~~~~~~
!!! error TS2307: Cannot find external module 'm1_M3_public'.
@ -196,7 +196,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient
var m1_im2_private_v4_private = m1_im2_private.f1();
import m1_im3_private = require("m2_M3_public");
~~~~~~
~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
~~~~~~~~~~~~~~
!!! error TS2307: Cannot find external module 'm2_M3_public'.
@ -352,7 +352,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient
module m2 {
import errorImport = require("glo_M2_public");
~~~~~~
~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
import nonerrorImport = glo_M1_public;
@ -391,7 +391,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient
module m2 {
import errorImport = require("glo_M4_private");
~~~~~~
~~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
import nonerrorImport = glo_M3_private;
@ -452,7 +452,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient
module m2 {
import m3 = require("use_glo_M1_public");
~~~~~~
~~~~~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
module m4 {
var a = 10;
@ -463,7 +463,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(336,12): error TS2435: Ambient
export module m3 {
import m3 = require("use_glo_M1_public");
~~~~~~
~~~~~~~~~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
module m4 {
var a = 10;

View File

@ -1,10 +1,10 @@
internal2.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.
internal2.ts(2,21): error TS1147: Import declarations in an internal module cannot reference an external module.
==== internal2.ts (1 errors) ====
module outer {
import g = require("external2")
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
export var a = g.square(5);
export var b = "foo";

View File

@ -1,10 +1,10 @@
internal2.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.
internal2.ts(2,21): error TS1147: Import declarations in an internal module cannot reference an external module.
==== internal2.ts (1 errors) ====
module outer {
import g = require("external2")
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
export var a = g.square(5);
export var b = "foo";

View File

@ -1,10 +1,10 @@
test1.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.
test1.ts(2,23): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test1.ts (1 errors) ====
export module myModule {
import foo = require("test2");
~~~~~~
~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
//console.log(foo.$);
}

View File

@ -1,10 +1,10 @@
test1.ts(2,2): error TS1147: Import declarations in an internal module cannot reference an external module.
test1.ts(2,23): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test1.ts (1 errors) ====
export module myModule {
import foo = require("test2");
~~~~~~
~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
//console.log(foo.$);
}

View File

@ -1,11 +1,11 @@
test1.ts(3,2): error TS1147: Import declarations in an internal module cannot reference an external module.
test1.ts(3,23): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test1.ts (1 errors) ====
module myModule {
import foo = require("test2");
~~~~~~
~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
//console.log(foo.$);

View File

@ -1,11 +1,11 @@
test1.ts(3,2): error TS1147: Import declarations in an internal module cannot reference an external module.
test1.ts(3,23): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test1.ts (1 errors) ====
module myModule {
import foo = require("test2");
~~~~~~
~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
//console.log(foo.$);

View File

@ -1,10 +1,10 @@
testGlo.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
testGlo.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module.
==== testGlo.ts (1 errors) ====
module m2 {
export import mExported = require("mExported");
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
export var c1 = new mExported.me.class1;
export function f1() {

View File

@ -1,10 +1,10 @@
testGlo.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
testGlo.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module.
==== testGlo.ts (1 errors) ====
module m2 {
export import mExported = require("mExported");
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
export var c1 = new mExported.me.class1;
export function f1() {

View File

@ -1,4 +1,4 @@
test.ts(5,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(5,39): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test.ts (1 errors) ====
@ -7,7 +7,7 @@ test.ts(5,5): error TS1147: Import declarations in an internal module cannot ref
module m2 {
export import mExported = require("mExported");
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
export var c1 = new mExported.me.class1;
export function f1() {

View File

@ -1,4 +1,4 @@
test.ts(5,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(5,39): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test.ts (1 errors) ====
@ -7,7 +7,7 @@ test.ts(5,5): error TS1147: Import declarations in an internal module cannot ref
module m2 {
export import mExported = require("mExported");
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
export var c1 = new mExported.me.class1;
export function f1() {

View File

@ -1,10 +1,10 @@
test.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test.ts (1 errors) ====
export module m2 {
export import mExported = require("mExported");
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
module Internal_M1 {

View File

@ -1,10 +1,10 @@
test.ts(2,5): error TS1147: Import declarations in an internal module cannot reference an external module.
test.ts(2,39): error TS1147: Import declarations in an internal module cannot reference an external module.
==== test.ts (1 errors) ====
export module m2 {
export import mExported = require("mExported");
~~~~~~
~~~~~~~~~~~
!!! error TS1147: Import declarations in an internal module cannot reference an external module.
module Internal_M1 {