3
3
4
4
namespace ts . projectSystem {
5
5
import TI = server . typingsInstaller ;
6
- import protocol = server . protocol ;
7
6
import CommandNames = server . CommandNames ;
8
7
9
8
const safeList = {
@@ -126,7 +125,7 @@ namespace ts.projectSystem {
126
125
return combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) ;
127
126
}
128
127
129
- export function toExternalFile ( fileName : string ) : protocol . ExternalFile {
128
+ export function toExternalFile ( fileName : string ) : server . protocol . ExternalFile {
130
129
return { fileName } ;
131
130
}
132
131
@@ -552,7 +551,7 @@ namespace ts.projectSystem {
552
551
}
553
552
554
553
export function makeSessionRequest < T > ( command : string , args : T ) {
555
- const newRequest : protocol . Request = {
554
+ const newRequest : server . protocol . Request = {
556
555
seq : 0 ,
557
556
type : "request" ,
558
557
command,
@@ -563,7 +562,7 @@ namespace ts.projectSystem {
563
562
564
563
export function openFilesForSession ( files : FileOrFolder [ ] , session : server . Session ) {
565
564
for ( const file of files ) {
566
- const request = makeSessionRequest < protocol . OpenRequestArgs > ( CommandNames . Open , { file : file . path } ) ;
565
+ const request = makeSessionRequest < server . protocol . OpenRequestArgs > ( CommandNames . Open , { file : file . path } ) ;
567
566
session . executeCommand ( request ) ;
568
567
}
569
568
}
@@ -1776,7 +1775,7 @@ namespace ts.projectSystem {
1776
1775
} ) ;
1777
1776
1778
1777
describe ( "navigate-to for javascript project" , ( ) => {
1779
- function containsNavToItem ( items : protocol . NavtoItem [ ] , itemName : string , itemKind : string ) {
1778
+ function containsNavToItem ( items : server . protocol . NavtoItem [ ] , itemName : string , itemKind : string ) {
1780
1779
return find ( items , item => item . name === itemName && item . kind === itemKind ) !== undefined ;
1781
1780
}
1782
1781
@@ -1794,12 +1793,12 @@ namespace ts.projectSystem {
1794
1793
openFilesForSession ( [ file1 ] , session ) ;
1795
1794
1796
1795
// Try to find some interface type defined in lib.d.ts
1797
- const libTypeNavToRequest = makeSessionRequest < protocol . NavtoRequestArgs > ( CommandNames . Navto , { searchValue : "Document" , file : file1 . path , projectFileName : configFile . path } ) ;
1798
- const items : protocol . NavtoItem [ ] = session . executeCommand ( libTypeNavToRequest ) . response ;
1796
+ const libTypeNavToRequest = makeSessionRequest < server . protocol . NavtoRequestArgs > ( CommandNames . Navto , { searchValue : "Document" , file : file1 . path , projectFileName : configFile . path } ) ;
1797
+ const items : server . protocol . NavtoItem [ ] = session . executeCommand ( libTypeNavToRequest ) . response ;
1799
1798
assert . isFalse ( containsNavToItem ( items , "Document" , "interface" ) , `Found lib.d.ts symbol in JavaScript project nav to request result.` ) ;
1800
1799
1801
- const localFunctionNavToRequst = makeSessionRequest < protocol . NavtoRequestArgs > ( CommandNames . Navto , { searchValue : "foo" , file : file1 . path , projectFileName : configFile . path } ) ;
1802
- const items2 : protocol . NavtoItem [ ] = session . executeCommand ( localFunctionNavToRequst ) . response ;
1800
+ const localFunctionNavToRequst = makeSessionRequest < server . protocol . NavtoRequestArgs > ( CommandNames . Navto , { searchValue : "foo" , file : file1 . path , projectFileName : configFile . path } ) ;
1801
+ const items2 : server . protocol . NavtoItem [ ] = session . executeCommand ( localFunctionNavToRequst ) . response ;
1803
1802
assert . isTrue ( containsNavToItem ( items2 , "foo" , "function" ) , `Cannot find function symbol "foo".` ) ;
1804
1803
} ) ;
1805
1804
} ) ;
@@ -2246,82 +2245,7 @@ namespace ts.projectSystem {
2246
2245
// verify content
2247
2246
const snap2 = projectServiice . getScriptInfo ( f1 . path ) . snap ( ) ;
2248
2247
assert . equal ( snap2 . getText ( 0 , snap2 . getLength ( ) ) , f1 . content , "content should be equal to the content of original file" ) ;
2249
- } ) ;
2250
- } ) ;
2251
-
2252
- describe ( "skipLibCheck" , ( ) => {
2253
- it ( "should be turned on for js-only inferred projects" , ( ) => {
2254
- const file1 = {
2255
- path : "/a/b/file1.js" ,
2256
- content : `
2257
- /// <reference path="file2.d.ts" />
2258
- var x = 1;`
2259
- } ;
2260
- const file2 = {
2261
- path : "/a/b/file2.d.ts" ,
2262
- content : `
2263
- interface T {
2264
- name: string;
2265
- };
2266
- interface T {
2267
- name: number;
2268
- };`
2269
- } ;
2270
- const host = createServerHost ( [ file1 , file2 ] ) ;
2271
- const session = createSession ( host ) ;
2272
- openFilesForSession ( [ file1 , file2 ] , session ) ;
2273
-
2274
- const file2GetErrRequest = makeSessionRequest < protocol . SemanticDiagnosticsSyncRequestArgs > (
2275
- CommandNames . SemanticDiagnosticsSync ,
2276
- { file : file2 . path }
2277
- ) ;
2278
- let errorResult = < protocol . Diagnostic [ ] > session . executeCommand ( file2GetErrRequest ) . response ;
2279
- assert . isTrue ( errorResult . length === 0 ) ;
2280
2248
2281
- const closeFileRequest = makeSessionRequest < protocol . FileRequestArgs > ( CommandNames . Close , { file : file1 . path } ) ;
2282
- session . executeCommand ( closeFileRequest ) ;
2283
- errorResult = < protocol . Diagnostic [ ] > session . executeCommand ( file2GetErrRequest ) . response ;
2284
- assert . isTrue ( errorResult . length !== 0 ) ;
2285
-
2286
- openFilesForSession ( [ file1 ] , session ) ;
2287
- errorResult = < protocol . Diagnostic [ ] > session . executeCommand ( file2GetErrRequest ) . response ;
2288
- assert . isTrue ( errorResult . length === 0 ) ;
2289
- } ) ;
2290
-
2291
- it ( "should be turned on for js-only external projects" , ( ) => {
2292
- const jsFile = {
2293
- path : "/a/b/file1.js" ,
2294
- content : "let x =1;"
2295
- } ;
2296
- const dTsFile = {
2297
- path : "/a/b/file2.d.ts" ,
2298
- content : `
2299
- interface T {
2300
- name: string;
2301
- };
2302
- interface T {
2303
- name: number;
2304
- };`
2305
- } ;
2306
- const host = createServerHost ( [ jsFile , dTsFile ] ) ;
2307
- const session = createSession ( host ) ;
2308
-
2309
- const openExternalProjectRequest = makeSessionRequest < protocol . OpenExternalProjectArgs > (
2310
- CommandNames . OpenExternalProject ,
2311
- {
2312
- projectFileName : "project1" ,
2313
- rootFiles : toExternalFiles ( [ jsFile . path , dTsFile . path ] ) ,
2314
- options : { }
2315
- }
2316
- ) ;
2317
- session . executeCommand ( openExternalProjectRequest ) ;
2318
-
2319
- const dTsFileGetErrRequest = makeSessionRequest < protocol . SemanticDiagnosticsSyncRequestArgs > (
2320
- CommandNames . SemanticDiagnosticsSync ,
2321
- { file : dTsFile . path }
2322
- ) ;
2323
- const errorResult = < protocol . Diagnostic [ ] > session . executeCommand ( dTsFileGetErrRequest ) . response ;
2324
- assert . isTrue ( errorResult . length === 0 ) ;
2325
2249
} ) ;
2326
2250
} ) ;
2327
2251
}
0 commit comments