File tree 4 files changed +47
-8
lines changed
cases/conformance/externalModules
4 files changed +47
-8
lines changed Original file line number Diff line number Diff line change @@ -914,8 +914,8 @@ namespace ts {
914
914
}
915
915
}
916
916
917
- // If we're in an external module, we can't reference symbols created from UMD export declarations
918
- if (result && isInExternalModule) {
917
+ // If we're in an external module, we can't reference value symbols created from UMD export declarations
918
+ if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value ) {
919
919
const decls = result.declarations;
920
920
if (decls && decls.length === 1 && decls[0].kind === SyntaxKind.NamespaceExportDeclaration) {
921
921
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 5
5
declare class Thing {
6
6
foo ( ) : number ;
7
7
}
8
+ declare namespace Thing {
9
+ interface SubThing { }
10
+ }
8
11
export = Thing ;
9
12
export as namespace Foo ;
10
13
11
14
//// [a.ts]
12
15
/// <reference path="foo.d.ts" />
13
- let y : Foo ;
14
- y . foo ( ) ;
16
+ import * as ff from './foo' ;
15
17
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
16
22
17
23
18
24
//// [a.js]
19
- /// <reference path="foo.d.ts" />
20
- var y ;
25
+ "use strict" ;
26
+ var y ; // OK in type position
21
27
y . 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 5
5
declare class Thing {
6
6
foo ( ) : number ;
7
7
}
8
+ declare namespace Thing {
9
+ interface SubThing { }
10
+ }
8
11
export = Thing ;
9
12
export as namespace Foo ;
10
13
11
14
// @filename : a.ts
12
15
/// <reference path="foo.d.ts" />
13
- let y : Foo ;
14
- y . foo ( ) ;
16
+ import * as ff from './foo' ;
15
17
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