diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index e1f230ce096..0f0680bd7aa 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -909,8 +909,8 @@ namespace ts {
}
}
- // If we're in an external module, we can't reference symbols created from UMD export declarations
- if (result && isInExternalModule) {
+ // If we're in an external module, we can't reference value symbols created from UMD export declarations
+ if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value) {
const decls = result.declarations;
if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) {
error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
diff --git a/tests/baselines/reference/umd8.errors.txt b/tests/baselines/reference/umd8.errors.txt
new file mode 100644
index 00000000000..9396c8c5450
--- /dev/null
+++ b/tests/baselines/reference/umd8.errors.txt
@@ -0,0 +1,25 @@
+tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Foo' must be imported from a module
+
+
+==== tests/cases/conformance/externalModules/a.ts (1 errors) ====
+ ///
+ import * as ff from './foo';
+
+ let y: Foo; // OK in type position
+ y.foo();
+ let z: Foo.SubThing; // OK in ns position
+ let x: any = Foo; // Not OK in value position
+ ~~~
+!!! error TS2686: Identifier 'Foo' must be imported from a module
+
+==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ====
+
+ declare class Thing {
+ foo(): number;
+ }
+ declare namespace Thing {
+ interface SubThing { }
+ }
+ export = Thing;
+ export as namespace Foo;
+
\ No newline at end of file
diff --git a/tests/baselines/reference/umd8.js b/tests/baselines/reference/umd8.js
index b4c6e0fa76b..e76b3902156 100644
--- a/tests/baselines/reference/umd8.js
+++ b/tests/baselines/reference/umd8.js
@@ -5,17 +5,25 @@
declare class Thing {
foo(): number;
}
+declare namespace Thing {
+ interface SubThing { }
+}
export = Thing;
export as namespace Foo;
//// [a.ts]
///
-let y: Foo;
-y.foo();
+import * as ff from './foo';
+let y: Foo; // OK in type position
+y.foo();
+let z: Foo.SubThing; // OK in ns position
+let x: any = Foo; // Not OK in value position
//// [a.js]
-///
-var y;
+"use strict";
+var y; // OK in type position
y.foo();
+var z; // OK in ns position
+var x = Foo; // Not OK in value position
diff --git a/tests/cases/conformance/externalModules/umd8.ts b/tests/cases/conformance/externalModules/umd8.ts
index caab734f5e0..9a8331fded3 100644
--- a/tests/cases/conformance/externalModules/umd8.ts
+++ b/tests/cases/conformance/externalModules/umd8.ts
@@ -5,11 +5,17 @@
declare class Thing {
foo(): number;
}
+declare namespace Thing {
+ interface SubThing { }
+}
export = Thing;
export as namespace Foo;
// @filename: a.ts
///
-let y: Foo;
-y.foo();
+import * as ff from './foo';
+let y: Foo; // OK in type position
+y.foo();
+let z: Foo.SubThing; // OK in ns position
+let x: any = Foo; // Not OK in value position