@@ -1816,7 +1816,9 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
1816
1816
}
1817
1817
else {
1818
1818
forEach ( options . lib , ( libFileName , index ) => {
1819
- processRootFile ( pathForLibFile ( libFileName ) , /*isDefaultLib*/ true , { kind : FileIncludeKind . LibFile , index } ) ;
1819
+ for ( const p of pathsForLibFile ( libFileName ) ) {
1820
+ processRootFile ( p , /*isDefaultLib*/ true , { kind : FileIncludeKind . LibFile , index } ) ;
1821
+ }
1820
1822
} ) ;
1821
1823
}
1822
1824
}
@@ -3818,6 +3820,22 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
3818
3820
}
3819
3821
}
3820
3822
3823
+ function pathsForLibFile ( libFileName : string ) : string [ ] {
3824
+ const names = [ libFileName ] ;
3825
+ // Force the inclusion of ES6 and DOM's iterable libs.
3826
+ switch ( libFileName ) {
3827
+ case "lib.dom.d.ts" :
3828
+ names . push ( "lib.dom.iterable.d.ts" ) ;
3829
+ // TODO: auto add dom.asynciterable.d.ts in es2018?
3830
+ break ;
3831
+ case "lib.es5.d.ts" :
3832
+ names . push ( "lib.es2015.d.ts" ) ;
3833
+ break ;
3834
+ }
3835
+
3836
+ return names . map ( pathForLibFile ) ;
3837
+ }
3838
+
3821
3839
function pathForLibFile ( libFileName : string ) : string {
3822
3840
const existing = resolvedLibReferences ?. get ( libFileName ) ;
3823
3841
if ( existing ) return existing . actual ;
@@ -3888,7 +3906,12 @@ export function createProgram(_rootNamesOrOptions: readonly string[] | CreatePro
3888
3906
forEach ( file . libReferenceDirectives , ( libReference , index ) => {
3889
3907
const libFileName = getLibFileNameFromLibReference ( libReference ) ;
3890
3908
if ( libFileName ) {
3891
- processRootFile ( pathForLibFile ( libFileName ) , /*isDefaultLib*/ true , { kind : FileIncludeKind . LibReferenceDirective , file : file . path , index } ) ;
3909
+ for ( const p of pathsForLibFile ( libFileName ) ) {
3910
+ if ( file . fileName === p ) {
3911
+ continue ;
3912
+ }
3913
+ processRootFile ( p , /*isDefaultLib*/ true , { kind : FileIncludeKind . LibReferenceDirective , file : file . path , index } ) ;
3914
+ }
3892
3915
}
3893
3916
else {
3894
3917
programDiagnostics . addFileProcessingDiagnostic ( {
0 commit comments