@@ -118,5 +118,133 @@ namespace ts.projectSystem {
118
118
}
119
119
] ) ;
120
120
} ) ;
121
+
122
+ it ( "works when files are included from two different drives of windows" , ( ) => {
123
+ const projectRoot = "e:/myproject" ;
124
+ const appPackage : File = {
125
+ path : `${ projectRoot } /package.json` ,
126
+ content : JSON . stringify ( {
127
+ name : "test" ,
128
+ version : "0.1.0" ,
129
+ dependencies : {
130
+ "react" : "^16.12.0" ,
131
+ "react-router-dom" : "^5.1.2" ,
132
+ }
133
+ } )
134
+ } ;
135
+ const appFile : File = {
136
+ path : `${ projectRoot } /src/app.js` ,
137
+ content : `import React from 'react';
138
+ import {
139
+ BrowserRouter as Router,
140
+ } from "react-router-dom";
141
+ `
142
+ } ;
143
+ const localNodeModules = `${ projectRoot } /node_modules` ;
144
+ const localAtTypes = `${ localNodeModules } /@types` ;
145
+ const localReactPackage : File = {
146
+ path : `${ localAtTypes } /react/package.json` ,
147
+ content : JSON . stringify ( {
148
+ name : "@types/react" ,
149
+ version : "16.9.14" ,
150
+ } )
151
+ } ;
152
+ const localReact : File = {
153
+ path : `${ localAtTypes } /react/index.d.ts` ,
154
+ content : `import * as PropTypes from 'prop-types';
155
+ `
156
+ } ;
157
+ const localReactRouterDomPackage : File = {
158
+ path : `${ localNodeModules } /react-router-dom/package.json` ,
159
+ content : JSON . stringify ( {
160
+ name : "react-router-dom" ,
161
+ version : "5.1.2" ,
162
+ } )
163
+ } ;
164
+ const localReactRouterDom : File = {
165
+ path : `${ localNodeModules } /react-router-dom/index.js` ,
166
+ content : `export function foo() {}`
167
+ } ;
168
+ const localPropTypesPackage : File = {
169
+ path : `${ localAtTypes } /prop-types/package.json` ,
170
+ content : JSON . stringify ( {
171
+ name : "@types/prop-types" ,
172
+ version : "15.7.3" ,
173
+ } )
174
+ } ;
175
+ const localPropTypes : File = {
176
+ path : `${ localAtTypes } /prop-types/index.d.ts` ,
177
+ content : `export type ReactComponentLike =
178
+ | string
179
+ | ((props: any, context?: any) => any)
180
+ | (new (props: any, context?: any) => any);
181
+ `
182
+ } ;
183
+
184
+ const globalCacheLocation = `c:/typescript` ;
185
+ const globalAtTypes = `${ globalCacheLocation } /node_modules/@types` ;
186
+ const globalReactRouterDomPackage : File = {
187
+ path : `${ globalAtTypes } /react-router-dom/package.json` ,
188
+ content : JSON . stringify ( {
189
+ name : "@types/react-router-dom" ,
190
+ version : "5.1.2" ,
191
+ } )
192
+ } ;
193
+ const globalReactRouterDom : File = {
194
+ path : `${ globalAtTypes } /react-router-dom/index.d.ts` ,
195
+ content : `import * as React from 'react';
196
+ export interface BrowserRouterProps {
197
+ basename?: string;
198
+ getUserConfirmation?: ((message: string, callback: (ok: boolean) => void) => void);
199
+ forceRefresh?: boolean;
200
+ keyLength?: number;
201
+ }`
202
+ } ;
203
+ const globalReactPackage : File = {
204
+ path : `${ globalAtTypes } /react/package.json` ,
205
+ content : localReactPackage . content
206
+ } ;
207
+ const globalReact : File = {
208
+ path : `${ globalAtTypes } /react/index.d.ts` ,
209
+ content : localReact . content
210
+ } ;
211
+
212
+ const filesInProject = [
213
+ appFile ,
214
+ localReact ,
215
+ localPropTypes ,
216
+ globalReactRouterDom ,
217
+ globalReact ,
218
+ ] ;
219
+ const files = [
220
+ ...filesInProject ,
221
+ appPackage , libFile ,
222
+ localReactPackage ,
223
+ localReactRouterDomPackage , localReactRouterDom ,
224
+ localPropTypesPackage ,
225
+ globalReactRouterDomPackage ,
226
+ globalReactPackage ,
227
+ ] ;
228
+
229
+ const host = createServerHost ( files , { windowsStyleRoot : "c:/" } ) ;
230
+ const session = createSession ( host , {
231
+ typingsInstaller : new TestTypingsInstaller ( globalCacheLocation , /*throttleLimit*/ 5 , host ) ,
232
+ } ) ;
233
+ const service = session . getProjectService ( ) ;
234
+ openFilesForSession ( [ appFile ] , session ) ;
235
+ checkNumberOfProjects ( service , { inferredProjects : 1 } ) ;
236
+ const windowsStyleLibFilePath = "c:/" + libFile . path . substring ( 1 ) ;
237
+ checkProjectActualFiles ( service . inferredProjects [ 0 ] , filesInProject . map ( f => f . path ) . concat ( windowsStyleLibFilePath ) ) ;
238
+ session . executeCommandSeq < protocol . CompletionsRequest > ( {
239
+ command : protocol . CommandTypes . CompletionInfo ,
240
+ arguments : {
241
+ file : appFile . path ,
242
+ line : 5 ,
243
+ offset : 1 ,
244
+ includeExternalModuleExports : true ,
245
+ includeInsertTextCompletions : true
246
+ }
247
+ } ) ;
248
+ } ) ;
121
249
} ) ;
122
250
}
0 commit comments