@@ -14,7 +14,7 @@ namespace ts.projectSystem {
1414 content : "import { a } from './b'; new a.A();"
1515 } ;
1616
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 ) ;
1818 } ) ;
1919
2020 it ( "named export -> type-only named import -> named export -> named import" , ( ) => {
@@ -31,7 +31,7 @@ namespace ts.projectSystem {
3131 content : "import { A } from './b'; new A();"
3232 } ;
3333
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 ) ;
3535 } ) ;
3636
3737 it ( "named export -> type-only namespace import -> export equals -> import equals" , ( ) => {
@@ -48,7 +48,7 @@ namespace ts.projectSystem {
4848 content : "import a = require('./b'); new a.A();"
4949 } ;
5050
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 ) ;
5252 } ) ;
5353
5454 it ( "named export -> type-only namespace import -> export default -> import default" , ( ) => {
@@ -65,13 +65,13 @@ namespace ts.projectSystem {
6565 content : "import a from './b'; new a.A();"
6666 } ;
6767
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 ) ;
6969 } ) ;
7070
7171 it ( "export default -> type-only import default -> export default -> import default" , ( ) => {
7272 const a = {
7373 path : "/a.ts" ,
74- content : "export defai;t class A {}"
74+ content : "export default class A {}"
7575 } ;
7676 const b = {
7777 path : "/b.ts" ,
@@ -82,11 +82,74 @@ namespace ts.projectSystem {
8282 content : "import A from './b'; new A();"
8383 } ;
8484
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 ) ;
86149 } ) ;
87150 } ) ;
88151
89- function assertUsageError ( files : readonly TestFSWithWatch . File [ ] , openFile : TestFSWithWatch . File ) {
152+ function assertUsageError ( files : readonly TestFSWithWatch . File [ ] , openFile : TestFSWithWatch . File , diagnostic : DiagnosticMessage ) {
90153 const host = createServerHost ( files ) ;
91154 const session = createSession ( host ) ;
92155 openFilesForSession ( [ openFile ] , session ) ;
@@ -96,9 +159,6 @@ namespace ts.projectSystem {
96159 ) ;
97160 const diagnostics = session . executeCommand ( req ) . response as protocol . Diagnostic [ ] ;
98161 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 ) ;
103163 }
104164}
0 commit comments