@@ -234,18 +234,21 @@ namespace ts.server {
234
234
getFileName ( f : T ) : string ;
235
235
getScriptKind ( f : T ) : ScriptKind ;
236
236
hasMixedContent ( f : T , extraFileExtensions : JsFileExtensionInfo [ ] ) : boolean ;
237
+ isDynamicFile ( f : T ) : boolean ;
237
238
}
238
239
239
240
const fileNamePropertyReader : FilePropertyReader < string > = {
240
241
getFileName : x => x ,
241
242
getScriptKind : _ => undefined ,
242
243
hasMixedContent : ( fileName , extraFileExtensions ) => some ( extraFileExtensions , ext => ext . isMixedContent && fileExtensionIs ( fileName , ext . extension ) ) ,
244
+ isDynamicFile : x => x [ 0 ] == '^' ,
243
245
} ;
244
246
245
247
const externalFilePropertyReader : FilePropertyReader < protocol . ExternalFile > = {
246
248
getFileName : x => x . fileName ,
247
249
getScriptKind : x => tryConvertScriptKindName ( x . scriptKind ) ,
248
- hasMixedContent : x => x . hasMixedContent
250
+ hasMixedContent : x => x . hasMixedContent ,
251
+ isDynamicFile : x => x . fileName [ 0 ] == '^' ,
249
252
} ;
250
253
251
254
function findProjectByName < T extends Project > ( projectName : string , projects : T [ ] ) : T {
@@ -1177,15 +1180,16 @@ namespace ts.server {
1177
1180
private addFilesToProjectAndUpdateGraph < T > ( project : ConfiguredProject | ExternalProject , files : T [ ] , propertyReader : FilePropertyReader < T > , clientFileName : string , typeAcquisition : TypeAcquisition , configFileErrors : ReadonlyArray < Diagnostic > ) : void {
1178
1181
let errors : Diagnostic [ ] ;
1179
1182
for ( const f of files ) {
1180
- const rootFilename = propertyReader . getFileName ( f ) ;
1183
+ const rootFileName = propertyReader . getFileName ( f ) ;
1181
1184
const scriptKind = propertyReader . getScriptKind ( f ) ;
1182
1185
const hasMixedContent = propertyReader . hasMixedContent ( f , this . hostConfiguration . extraFileExtensions ) ;
1183
- if ( this . host . fileExists ( rootFilename ) ) {
1184
- const info = this . getOrCreateScriptInfoForNormalizedPath ( toNormalizedPath ( rootFilename ) , /*openedByClient*/ clientFileName === rootFilename , /*fileContent*/ undefined , scriptKind , hasMixedContent ) ;
1186
+ const isDynamicFile = propertyReader . isDynamicFile ( f ) ;
1187
+ if ( isDynamicFile || this . host . fileExists ( rootFileName ) ) {
1188
+ const info = this . getOrCreateScriptInfoForNormalizedPath ( toNormalizedPath ( rootFileName ) , /*openedByClient*/ clientFileName === rootFileName , /*fileContent*/ undefined , scriptKind , hasMixedContent , isDynamicFile ) ;
1185
1189
project . addRoot ( info ) ;
1186
1190
}
1187
1191
else {
1188
- ( errors || ( errors = [ ] ) ) . push ( createFileNotFoundDiagnostic ( rootFilename ) ) ;
1192
+ ( errors || ( errors = [ ] ) ) . push ( createFileNotFoundDiagnostic ( rootFileName ) ) ;
1189
1193
}
1190
1194
}
1191
1195
project . setProjectErrors ( concatenate ( configFileErrors , errors ) ) ;
@@ -1215,7 +1219,8 @@ namespace ts.server {
1215
1219
let rootFilesChanged = false ;
1216
1220
for ( const f of newUncheckedFiles ) {
1217
1221
const newRootFile = propertyReader . getFileName ( f ) ;
1218
- if ( ! this . host . fileExists ( newRootFile ) ) {
1222
+ const isDynamic = propertyReader . isDynamicFile ( f ) ;
1223
+ if ( ! isDynamic && ! this . host . fileExists ( newRootFile ) ) {
1219
1224
( projectErrors || ( projectErrors = [ ] ) ) . push ( createFileNotFoundDiagnostic ( newRootFile ) ) ;
1220
1225
continue ;
1221
1226
}
@@ -1226,7 +1231,7 @@ namespace ts.server {
1226
1231
if ( ! scriptInfo ) {
1227
1232
const scriptKind = propertyReader . getScriptKind ( f ) ;
1228
1233
const hasMixedContent = propertyReader . hasMixedContent ( f , this . hostConfiguration . extraFileExtensions ) ;
1229
- scriptInfo = this . getOrCreateScriptInfoForNormalizedPath ( normalizedPath , /*openedByClient*/ false , /*fileContent*/ undefined , scriptKind , hasMixedContent ) ;
1234
+ scriptInfo = this . getOrCreateScriptInfoForNormalizedPath ( normalizedPath , /*openedByClient*/ false , /*fileContent*/ undefined , scriptKind , hasMixedContent , isDynamic ) ;
1230
1235
}
1231
1236
}
1232
1237
newRootScriptInfos . push ( scriptInfo ) ;
@@ -1410,17 +1415,17 @@ namespace ts.server {
1410
1415
1411
1416
watchClosedScriptInfo ( info : ScriptInfo ) {
1412
1417
// do not watch files with mixed content - server doesn't know how to interpret it
1413
- if ( ! info . hasMixedContent ) {
1418
+ if ( ! info . hasMixedContent && ! info . isDynamic ) {
1414
1419
const { fileName } = info ;
1415
1420
info . setWatcher ( this . host . watchFile ( fileName , _ => this . onSourceFileChanged ( fileName ) ) ) ;
1416
1421
}
1417
1422
}
1418
1423
1419
- getOrCreateScriptInfoForNormalizedPath ( fileName : NormalizedPath , openedByClient : boolean , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean ) {
1424
+ getOrCreateScriptInfoForNormalizedPath ( fileName : NormalizedPath , openedByClient : boolean , fileContent ?: string , scriptKind ?: ScriptKind , hasMixedContent ?: boolean , isDynamic ?: boolean ) {
1420
1425
let info = this . getScriptInfoForNormalizedPath ( fileName ) ;
1421
1426
if ( ! info ) {
1422
- if ( openedByClient || this . host . fileExists ( fileName ) ) {
1423
- info = new ScriptInfo ( this . host , fileName , scriptKind , hasMixedContent ) ;
1427
+ if ( openedByClient || isDynamic || this . host . fileExists ( fileName ) ) {
1428
+ info = new ScriptInfo ( this . host , fileName , scriptKind , hasMixedContent , isDynamic ) ;
1424
1429
1425
1430
this . filenameToScriptInfo . set ( info . path , info ) ;
1426
1431
@@ -1430,6 +1435,7 @@ namespace ts.server {
1430
1435
fileContent = this . host . readFile ( fileName ) || "" ;
1431
1436
}
1432
1437
}
1438
+
1433
1439
else {
1434
1440
this . watchClosedScriptInfo ( info ) ;
1435
1441
}
0 commit comments