@@ -816,8 +816,7 @@ namespace Harness {
816816 } ;
817817
818818 export function getDefaultLibrarySourceFile ( fileName = defaultLibFileName ) : ts . SourceFile {
819- if ( ! isLibraryFile ( fileName ) ) {
820- assert ( ! isLibraryFile ( fileName ) , "Expected library fileName" ) ;
819+ if ( ! isDefaultLibraryFile ( fileName ) ) {
821820 return undefined ;
822821 }
823822
@@ -1157,7 +1156,7 @@ namespace Harness {
11571156 // then they will be added twice thus triggering 'total errors' assertion with condition
11581157 // 'totalErrorsReportedInNonLibraryFiles + numLibraryDiagnostics + numTest262HarnessDiagnostics, diagnostics.length
11591158
1160- if ( ! error . file || ! isLibraryFile ( error . file . fileName ) ) {
1159+ if ( ! error . file || ! isDefaultLibraryFile ( error . file . fileName ) ) {
11611160 totalErrorsReportedInNonLibraryFiles ++ ;
11621161 }
11631162 }
@@ -1236,7 +1235,7 @@ namespace Harness {
12361235 } ) ;
12371236
12381237 const numLibraryDiagnostics = ts . countWhere ( diagnostics , diagnostic => {
1239- return diagnostic . file && ( isLibraryFile ( diagnostic . file . fileName ) || isBuiltFile ( diagnostic . file . fileName ) ) ;
1238+ return diagnostic . file && ( isDefaultLibraryFile ( diagnostic . file . fileName ) || isBuiltFile ( diagnostic . file . fileName ) ) ;
12401239 } ) ;
12411240
12421241 const numTest262HarnessDiagnostics = ts . countWhere ( diagnostics , diagnostic => {
@@ -1623,10 +1622,10 @@ namespace Harness {
16231622 }
16241623 }
16251624
1626- // Regex for check if the give filePath is a library file
1627- const libRegex = / l i b ( \. \S + ) * \. d \ .t s / ;
1628- export function isLibraryFile ( filePath : string ) : boolean {
1629- return ! ! libRegex . exec ( Path . getFileName ( filePath ) ) ;
1625+ export function isDefaultLibraryFile ( filePath : string ) : boolean {
1626+ // We need to make sure that the filePath is prefixed with " lib." not just containing "lib." and end with ".d .ts"
1627+ const fileName = Path . getFileName ( filePath ) ;
1628+ return ts . startsWith ( fileName , "lib." ) && ts . endsWith ( fileName , ".d.ts" ) ;
16301629 }
16311630
16321631 export function isBuiltFile ( filePath : string ) : boolean {
0 commit comments