@@ -239,18 +239,21 @@ namespace ts.server {
239
239
getFileName ( f : T ) : string ;
240
240
getScriptKind ( f : T ) : ScriptKind ;
241
241
hasMixedContent ( f : T , extraFileExtensions : JsFileExtensionInfo [ ] ) : boolean ;
242
+ isDynamicFile ( f : T ) : boolean ;
242
243
}
243
244
244
245
const fileNamePropertyReader : FilePropertyReader < string > = {
245
246
getFileName : x => x ,
246
247
getScriptKind : _ => undefined ,
247
248
hasMixedContent : ( fileName , extraFileExtensions ) => some ( extraFileExtensions , ext => ext . isMixedContent && fileExtensionIs ( fileName , ext . extension ) ) ,
249
+ isDynamicFile : x => x [ 0 ] === "^" ,
248
250
} ;
249
251
250
252
const externalFilePropertyReader : FilePropertyReader < protocol . ExternalFile > = {
251
253
getFileName : x => x . fileName ,
252
254
getScriptKind : x => tryConvertScriptKindName ( x . scriptKind ) ,
253
- hasMixedContent : x => x . hasMixedContent
255
+ hasMixedContent : x => x . hasMixedContent ,
256
+ isDynamicFile : x => x . fileName [ 0 ] === "^" ,
254
257
} ;
255
258
256
259
function findProjectByName < T extends Project > ( projectName : string , projects : T [ ] ) : T {
@@ -1210,15 +1213,16 @@ namespace ts.server {
1210
1213
private addFilesToProjectAndUpdateGraph < T > ( project : ConfiguredProject | ExternalProject , files : T [ ] , propertyReader : FilePropertyReader < T > , clientFileName : string , typeAcquisition : TypeAcquisition , configFileErrors : ReadonlyArray < Diagnostic > ) : void {
1211
1214
let errors : Diagnostic [ ] ;
1212
1215
for ( const f of files ) {
1213
- const rootFilename = propertyReader . getFileName ( f ) ;
1216
+ const rootFileName = propertyReader . getFileName ( f ) ;
1214
1217
const scriptKind = propertyReader . getScriptKind ( f ) ;
1215
1218
const hasMixedContent = propertyReader . hasMixedContent ( f , this . hostConfiguration . extraFileExtensions ) ;
1216
- if ( this . host . fileExists ( rootFilename ) ) {
1217
- const info = this . getOrCreateScriptInfoForNormalizedPath ( toNormalizedPath ( rootFilename ) , /*openedByClient*/ clientFileName === rootFilename , /*fileContent*/ undefined , scriptKind , hasMixedContent ) ;
1219
+ const isDynamicFile = propertyReader . isDynamicFile ( f ) ;
1220
+ if ( isDynamicFile || this . host . fileExists ( rootFileName ) ) {
1221
+ const info = this . getOrCreateScriptInfoForNormalizedPath ( toNormalizedPath ( rootFileName ) , /*openedByClient*/ clientFileName === rootFileName , /*fileContent*/ undefined , scriptKind , hasMixedContent , isDynamicFile ) ;
1218
1222
project . addRoot ( info ) ;
1219
1223
}
1220
1224
else {
1221
- ( errors || ( errors = [ ] ) ) . push ( createFileNotFoundDiagnostic ( rootFilename ) ) ;
1225
+ ( errors || ( errors = [ ] ) ) . push ( createFileNotFoundDiagnostic ( rootFileName ) ) ;
1222
1226
}
1223
1227
}
1224
1228
project . setProjectErrors ( concatenate ( configFileErrors , errors ) ) ;
@@ -1248,7 +1252,8 @@ namespace ts.server {
1248
1252
let rootFilesChanged = false ;
1249
1253
for ( const f of newUncheckedFiles ) {
1250
1254
const newRootFile = propertyReader . getFileName ( f ) ;
1251
- if ( ! this . host . fileExists ( newRootFile ) ) {
1255
+ const isDynamic = propertyReader . isDynamicFile ( f ) ;
1256
+ if ( ! isDynamic && ! this . host . fileExists ( newRootFile ) ) {
1252
1257
( projectErrors || ( projectErrors = [ ] ) ) . push ( createFileNotFoundDiagnostic ( newRootFile ) ) ;
1253
1258
continue ;
1254
1259
}
@@ -1259,7 +1264,7 @@ namespace ts.server {
1259
1264
if ( ! scriptInfo ) {
1260
1265
const scriptKind = propertyReader . getScriptKind ( f ) ;
1261
1266
const hasMixedContent = propertyReader . hasMixedContent ( f , this . hostConfiguration . extraFileExtensions ) ;
1262
- scriptInfo = this . getOrCreateScriptInfoForNormalizedPath ( normalizedPath , /*openedByClient*/ false , /*fileContent*/ undefined , scriptKind , hasMixedContent ) ;
1267
+ scriptInfo = this . getOrCreateScriptInfoForNormalizedPath ( normalizedPath , /*openedByClient*/ false , /*fileContent*/ undefined , scriptKind , hasMixedContent , isDynamic ) ;
1263
1268
}
1264
1269
}
1265
1270
newRootScriptInfos . push ( scriptInfo ) ;
@@ -1443,17 +1448,17 @@ namespace ts.server {
1443
1448
1444
1449
watchClosedScriptInfo ( info : ScriptInfo ) {
1445
1450
// do not watch files with mixed content - server doesn't know how to interpret it
1446
- if ( ! info . hasMixedContent ) {
1451
+ if ( ! info . hasMixedContent && ! info . isDynamic ) {
1447
1452
const { fileName } = info ;
1448
1453
info . setWatcher ( this . host . watchFile ( fileName , _ => this . onSourceFileChanged ( fileName ) ) ) ;
1449
1454
}
1450
1455
}
1451
1456
1452
- getOrCreateScriptInfoForNormalizedPath ( fileName : NormalizedPath , openedByClient : boolean , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean ) {
1457
+ getOrCreateScriptInfoForNormalizedPath ( fileName : NormalizedPath , openedByClient : boolean , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean , isDynamic ?: boolean ) {
1453
1458
let info = this . getScriptInfoForNormalizedPath ( fileName ) ;
1454
1459
if ( ! info ) {
1455
- if ( openedByClient || this . host . fileExists ( fileName ) ) {
1456
- info = new ScriptInfo ( this . host , fileName , scriptKind , hasMixedContent ) ;
1460
+ if ( openedByClient || isDynamic || this . host . fileExists ( fileName ) ) {
1461
+ info = new ScriptInfo ( this . host , fileName , scriptKind , hasMixedContent , isDynamic ) ;
1457
1462
1458
1463
this . filenameToScriptInfo . set ( info . path , info ) ;
1459
1464
@@ -1463,6 +1468,7 @@ namespace ts.server {
1463
1468
fileContent = this . host . readFile ( fileName ) || "" ;
1464
1469
}
1465
1470
}
1471
+
1466
1472
else {
1467
1473
this . watchClosedScriptInfo ( info ) ;
1468
1474
}
0 commit comments