File tree Expand file tree Collapse file tree 4 files changed +47
-8
lines changed
cases/conformance/externalModules Expand file tree Collapse file tree 4 files changed +47
-8
lines changed Original file line number Diff line number Diff line change @@ -909,8 +909,8 @@ namespace ts {
909909 }
910910 }
911911
912- // If we're in an external module, we can't reference symbols created from UMD export declarations
913- if (result && isInExternalModule) {
912+ // If we're in an external module, we can't reference value symbols created from UMD export declarations
913+ if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value ) {
914914 const decls = result.declarations;
915915 if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) {
916916 error(errorLocation, Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
Original file line number Diff line number Diff line change 1+ tests/cases/conformance/externalModules/a.ts(7,14): error TS2686: Identifier 'Foo' must be imported from a module
2+
3+
4+ ==== tests/cases/conformance/externalModules/a.ts (1 errors) ====
5+ /// <reference path="foo.d.ts" />
6+ import * as ff from './foo';
7+
8+ let y: Foo; // OK in type position
9+ y.foo();
10+ let z: Foo.SubThing; // OK in ns position
11+ let x: any = Foo; // Not OK in value position
12+ ~~~
13+ !!! error TS2686: Identifier 'Foo' must be imported from a module
14+
15+ ==== tests/cases/conformance/externalModules/foo.d.ts (0 errors) ====
16+
17+ declare class Thing {
18+ foo(): number;
19+ }
20+ declare namespace Thing {
21+ interface SubThing { }
22+ }
23+ export = Thing;
24+ export as namespace Foo;
25+
Original file line number Diff line number Diff line change 55declare class Thing {
66 foo ( ) : number ;
77}
8+ declare namespace Thing {
9+ interface SubThing { }
10+ }
811export = Thing ;
912export as namespace Foo ;
1013
1114//// [a.ts]
1215/// <reference path="foo.d.ts" />
13- let y : Foo ;
14- y . foo ( ) ;
16+ import * as ff from './foo' ;
1517
18+ let y : Foo ; // OK in type position
19+ y . foo ( ) ;
20+ let z : Foo . SubThing ; // OK in ns position
21+ let x : any = Foo ; // Not OK in value position
1622
1723
1824//// [a.js]
19- /// <reference path="foo.d.ts" />
20- var y ;
25+ "use strict" ;
26+ var y ; // OK in type position
2127y . foo ( ) ;
28+ var z ; // OK in ns position
29+ var x = Foo ; // Not OK in value position
Original file line number Diff line number Diff line change 55declare class Thing {
66 foo ( ) : number ;
77}
8+ declare namespace Thing {
9+ interface SubThing { }
10+ }
811export = Thing ;
912export as namespace Foo ;
1013
1114// @filename : a.ts
1215/// <reference path="foo.d.ts" />
13- let y : Foo ;
14- y . foo ( ) ;
16+ import * as ff from './foo' ;
1517
18+ let y : Foo ; // OK in type position
19+ y . foo ( ) ;
20+ let z : Foo . SubThing ; // OK in ns position
21+ let x : any = Foo ; // Not OK in value position
You can’t perform that action at this time.
0 commit comments