Skip to content

Commit 31a55e6

Browse files
Merge pull request #11570 from Microsoft/fixErrorMessageForUmdGlobals
Fix error message for UMD globals
2 parents 1b32744 + fbb9d5b commit 31a55e6

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ namespace ts {
922922
if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value) {
923923
const decls = result.declarations;
924924
if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) {
925-
error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
925+
error(errorLocation, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name);
926926
}
927927
}
928928
}

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@
19231923
"category": "Error",
19241924
"code": 2685
19251925
},
1926-
"Identifier '{0}' must be imported from a module": {
1926+
"'{0}' refers to a UMD global, but the current file is a module. Consider adding an import instead.": {
19271927
"category": "Error",
19281928
"code": 2686
19291929
},

tests/baselines/reference/umd5.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/externalModules/a.ts(6,9): error TS2686: Identifier 'Foo' must be imported from a module
1+
tests/cases/conformance/externalModules/a.ts(6,9): error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead.
22

33

44
==== tests/cases/conformance/externalModules/a.ts (1 errors) ====
@@ -9,7 +9,7 @@ tests/cases/conformance/externalModules/a.ts(6,9): error TS2686: Identifier 'Foo
99
// should error
1010
let z = Foo;
1111
~~~
12-
!!! error TS2686: Identifier 'Foo' must be imported from a module
12+
!!! error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead.
1313

1414
==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ====
1515

tests/baselines/reference/umd8.errors.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Foo' must be imported from a module
1+
tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead.
22

33

44
==== tests/cases/conformance/externalModules/a.ts (1 errors) ====
@@ -10,7 +10,7 @@ tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Fo
1010
let z: Foo.SubThing; // OK in ns position
1111
let x: any = Foo; // Not OK in value position
1212
~~~
13-
!!! error TS2686: Identifier 'Foo' must be imported from a module
13+
!!! error TS2686: 'Foo' refers to a UMD global, but the current file is a module. Consider adding an import instead.
1414

1515
==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ====
1616

0 commit comments

Comments
 (0)