@@ -14,7 +14,7 @@ namespace ts.projectSystem {
14
14
content : "import { a } from './b'; new a.A();"
15
15
} ;
16
16
17
- assertUsageError ( [ a , b , c ] , c ) ;
17
+ assertUsageError ( [ a , b , c ] , c , Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type ) ;
18
18
} ) ;
19
19
20
20
it ( "named export -> type-only named import -> named export -> named import" , ( ) => {
@@ -31,7 +31,7 @@ namespace ts.projectSystem {
31
31
content : "import { A } from './b'; new A();"
32
32
} ;
33
33
34
- assertUsageError ( [ a , b , c ] , c ) ;
34
+ assertUsageError ( [ a , b , c ] , c , Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type ) ;
35
35
} ) ;
36
36
37
37
it ( "named export -> type-only namespace import -> export equals -> import equals" , ( ) => {
@@ -48,7 +48,7 @@ namespace ts.projectSystem {
48
48
content : "import a = require('./b'); new a.A();"
49
49
} ;
50
50
51
- assertUsageError ( [ a , b , c ] , c ) ;
51
+ assertUsageError ( [ a , b , c ] , c , Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type ) ;
52
52
} ) ;
53
53
54
54
it ( "named export -> type-only namespace import -> export default -> import default" , ( ) => {
@@ -65,13 +65,13 @@ namespace ts.projectSystem {
65
65
content : "import a from './b'; new a.A();"
66
66
} ;
67
67
68
- assertUsageError ( [ a , b , c ] , c ) ;
68
+ assertUsageError ( [ a , b , c ] , c , Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type ) ;
69
69
} ) ;
70
70
71
71
it ( "export default -> type-only import default -> export default -> import default" , ( ) => {
72
72
const a = {
73
73
path : "/a.ts" ,
74
- content : "export defai;t class A {}"
74
+ content : "export default class A {}"
75
75
} ;
76
76
const b = {
77
77
path : "/b.ts" ,
@@ -82,11 +82,74 @@ namespace ts.projectSystem {
82
82
content : "import A from './b'; new A();"
83
83
} ;
84
84
85
- assertUsageError ( [ a , b , c ] , c ) ;
85
+ assertUsageError ( [ a , b , c ] , c , Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type ) ;
86
+ } ) ;
87
+
88
+ it ( "named export -> type-only export from -> export star from -> named import" , ( ) => {
89
+ const a = {
90
+ path : "/a.ts" ,
91
+ content : "export class A {}"
92
+ } ;
93
+ const b = {
94
+ path : "/b.ts" ,
95
+ content : "export type { A } from './a';"
96
+ } ;
97
+ const c = {
98
+ path : "/c.ts" ,
99
+ content : "export * from './b';"
100
+ } ;
101
+ const d = {
102
+ path : "/d.ts" ,
103
+ content : "import { A } from './c'; new A();"
104
+ } ;
105
+
106
+ assertUsageError ( [ a , b , c , d ] , d , Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type ) ;
107
+ } ) ;
108
+
109
+ it ( "named export -> export namespace from -> type-only named import -> named export -> named import" , ( ) => {
110
+ const a = {
111
+ path : "/a.ts" ,
112
+ content : "export class A {}"
113
+ } ;
114
+ const b = {
115
+ path : "/b.ts" ,
116
+ content : "export * as a from './a';"
117
+ } ;
118
+ const c = {
119
+ path : "/c.ts" ,
120
+ content : "import type { a } from './b'; export { a };"
121
+ } ;
122
+ const d = {
123
+ path : "/d.ts" ,
124
+ content : "import { a } from './c'; new a.A();"
125
+ } ;
126
+
127
+ assertUsageError ( [ a , b , c , d ] , d , Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type ) ;
128
+ } ) ;
129
+
130
+ it ( "named export -> type-only export from -> export namespace from -> named import" , ( ) => {
131
+ const a = {
132
+ path : "/a.ts" ,
133
+ content : "export class A {}"
134
+ } ;
135
+ const b = {
136
+ path : "/b.ts" ,
137
+ content : "export type { A } from './a';"
138
+ } ;
139
+ const c = {
140
+ path : "/c.ts" ,
141
+ content : "export * as a from './b';"
142
+ } ;
143
+ const d = {
144
+ path : "/d.ts" ,
145
+ content : "import { a } from './c'; new a.A();"
146
+ } ;
147
+
148
+ assertUsageError ( [ a , b , c , d ] , d , Diagnostics . Property_0_does_not_exist_on_type_1 ) ;
86
149
} ) ;
87
150
} ) ;
88
151
89
- function assertUsageError ( files : readonly TestFSWithWatch . File [ ] , openFile : TestFSWithWatch . File ) {
152
+ function assertUsageError ( files : readonly TestFSWithWatch . File [ ] , openFile : TestFSWithWatch . File , diagnostic : DiagnosticMessage ) {
90
153
const host = createServerHost ( files ) ;
91
154
const session = createSession ( host ) ;
92
155
openFilesForSession ( [ openFile ] , session ) ;
@@ -96,9 +159,6 @@ namespace ts.projectSystem {
96
159
) ;
97
160
const diagnostics = session . executeCommand ( req ) . response as protocol . Diagnostic [ ] ;
98
161
assert . lengthOf ( diagnostics , 1 ) ;
99
- assert . oneOf ( diagnostics [ 0 ] . code , [
100
- Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type . code ,
101
- Diagnostics . _0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type . code
102
- ] ) ;
162
+ assert . equal ( diagnostics [ 0 ] . code , diagnostic . code ) ;
103
163
}
104
164
}
0 commit comments