File tree 5 files changed +135
-0
lines changed 5 files changed +135
-0
lines changed Original file line number Diff line number Diff line change @@ -21189,6 +21189,11 @@ namespace ts {
21189
21189
Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
21190
21190
error(node, message, symbolToString(symbol));
21191
21191
}
21192
+
21193
+ // Don't allow to re-export something with no value side when `--isolatedModules` is set.
21194
+ if (node.kind === SyntaxKind.ExportSpecifier && compilerOptions.isolatedModules && !(target.flags & SymbolFlags.Value)) {
21195
+ error(node, Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided);
21196
+ }
21192
21197
}
21193
21198
}
21194
21199
Original file line number Diff line number Diff line change 635
635
"category" : " Error" ,
636
636
"code" : 1203
637
637
},
638
+ "Cannot re-export a type when the '--isolatedModules' flag is provided." : {
639
+ "category" : " Error" ,
640
+ "code" : 1205
641
+ },
638
642
"Decorators are not valid here." : {
639
643
"category" : " Error" ,
640
644
"code" : 1206
Original file line number Diff line number Diff line change
1
+ /user.ts(2,10): error TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
2
+ /user.ts(17,10): error TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
3
+
4
+
5
+ ==== /user.ts (2 errors) ====
6
+ // Error, can't re-export something that's only a type.
7
+ export { T } from "./exportT";
8
+ ~
9
+ !!! error TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
10
+ export import T2 = require("./exportEqualsT");
11
+
12
+ // OK, has a value side
13
+ export { C } from "./exportValue";
14
+
15
+ // OK, even though the namespace it exports is only types.
16
+ import * as NS from "./exportT";
17
+ export { NS };
18
+
19
+ // OK, syntactically clear that a type is being re-exported.
20
+ export type T3 = T;
21
+
22
+ // Error, not clear (to an isolated module) whether `T4` is a type.
23
+ import { T } from "./exportT";
24
+ export { T as T4 };
25
+ ~~~~~~~
26
+ !!! error TS1205: Cannot re-export a type when the '--isolatedModules' flag is provided.
27
+
28
+ ==== /exportT.ts (0 errors) ====
29
+ export type T = number;
30
+
31
+ ==== /exportValue.ts (0 errors) ====
32
+ export class C {}
33
+
34
+ ==== /exportEqualsT.ts (0 errors) ====
35
+ declare type T = number;
36
+ export = T;
37
+
38
+
Original file line number Diff line number Diff line change
1
+ //// [tests/cases/compiler/isolatedModulesReExportType.ts] ////
2
+
3
+ //// [exportT.ts]
4
+ export type T = number ;
5
+
6
+ //// [exportValue.ts]
7
+ export class C { }
8
+
9
+ //// [exportEqualsT.ts]
10
+ declare type T = number ;
11
+ export = T ;
12
+
13
+
14
+ //// [user.ts]
15
+ // Error, can't re-export something that's only a type.
16
+ export { T } from "./exportT" ;
17
+ export import T2 = require ( "./exportEqualsT" ) ;
18
+
19
+ // OK, has a value side
20
+ export { C } from "./exportValue" ;
21
+
22
+ // OK, even though the namespace it exports is only types.
23
+ import * as NS from "./exportT" ;
24
+ export { NS } ;
25
+
26
+ // OK, syntactically clear that a type is being re-exported.
27
+ export type T3 = T ;
28
+
29
+ // Error, not clear (to an isolated module) whether `T4` is a type.
30
+ import { T } from "./exportT" ;
31
+ export { T as T4 } ;
32
+
33
+
34
+ //// [exportT.js]
35
+ "use strict" ;
36
+ exports . __esModule = true ;
37
+ //// [exportEqualsT.js]
38
+ "use strict" ;
39
+ exports . __esModule = true ;
40
+ //// [exportValue.js]
41
+ "use strict" ;
42
+ exports . __esModule = true ;
43
+ var C = ( function ( ) {
44
+ function C ( ) {
45
+ }
46
+ return C ;
47
+ } ( ) ) ;
48
+ exports . C = C ;
49
+ //// [user.js]
50
+ "use strict" ;
51
+ exports . __esModule = true ;
52
+ // OK, has a value side
53
+ var exportValue_1 = require ( "./exportValue" ) ;
54
+ exports . C = exportValue_1 . C ;
55
+ // OK, even though the namespace it exports is only types.
56
+ var NS = require ( "./exportT" ) ;
57
+ exports . NS = NS ;
Original file line number Diff line number Diff line change
1
+ // @isolatedModules : true
2
+
3
+ // @Filename : /exportT.ts
4
+ export type T = number ;
5
+
6
+ // @Filename : /exportValue.ts
7
+ export class C { }
8
+
9
+ // @Filename : /exportEqualsT.ts
10
+ declare type T = number ;
11
+ export = T ;
12
+
13
+
14
+ // @Filename : /user.ts
15
+ // Error, can't re-export something that's only a type.
16
+ export { T } from "./exportT" ;
17
+ export import T2 = require ( "./exportEqualsT" ) ;
18
+
19
+ // OK, has a value side
20
+ export { C } from "./exportValue" ;
21
+
22
+ // OK, even though the namespace it exports is only types.
23
+ import * as NS from "./exportT" ;
24
+ export { NS } ;
25
+
26
+ // OK, syntactically clear that a type is being re-exported.
27
+ export type T3 = T ;
28
+
29
+ // Error, not clear (to an isolated module) whether `T4` is a type.
30
+ import { T } from "./exportT" ;
31
+ export { T as T4 } ;
You can’t perform that action at this time.
0 commit comments