@@ -158,11 +158,8 @@ namespace ts {
158
158
return result ;
159
159
}
160
160
161
- export interface FileFromConfigExplainInfo {
162
- basePath : string | undefined ;
163
- includeSpecs : { include : string ; regExp : RegExp ; } [ ] | undefined ;
164
- }
165
- export function getFileFromConfigExplainInfo ( program : Program ) : FileFromConfigExplainInfo {
161
+ export type FileFromConfigExplainInfo = ReturnType < typeof getFileFromConfigExplainInfo > ;
162
+ export function getFileFromConfigExplainInfo ( program : Program ) {
166
163
const options = program . getCompilerOptions ( ) ;
167
164
const { validatedIncludeSpecs } = options . configFile ?. configFileSpecs || { } ;
168
165
const useCaseSensitiveFileNames = program . useCaseSensitiveFileNames ( ) ;
@@ -176,7 +173,8 @@ namespace ts {
176
173
regExp : getRegexFromPattern ( `(${ pattern } )$` , useCaseSensitiveFileNames )
177
174
} ) ;
178
175
} ) ;
179
- return { basePath, includeSpecs } ;
176
+ const getCanonicalFileName = createGetCanonicalFileName ( useCaseSensitiveFileNames )
177
+ return { basePath, includeSpecs, getCanonicalFileName } ;
180
178
}
181
179
182
180
export function fileIncludeReasonToDiagnostics (
@@ -223,12 +221,12 @@ namespace ts {
223
221
switch ( reason . kind ) {
224
222
case FileIncludeKind . RootFile :
225
223
if ( ! options . configFile ?. configFileSpecs ) return chainDiagnosticMessages ( /*details*/ undefined , Diagnostics . Root_file_specified_for_compilation ) ;
226
- const { basePath, includeSpecs } = configFileExplainInfo || getFileFromConfigExplainInfo ( program ) ;
224
+ const { basePath, includeSpecs, getCanonicalFileName } = configFileExplainInfo || getFileFromConfigExplainInfo ( program ) ;
227
225
if ( includeSpecs ) {
228
226
const rootName = program . getRootFileNames ( ) [ reason . index ] ;
229
227
const fileName = getNormalizedAbsolutePath ( rootName , program . getCurrentDirectory ( ) ) ;
230
- const filePath = program . getCanonicalFileName ( fileName ) ;
231
- const matchedByFiles = forEach ( options . configFile . configFileSpecs . validatedFilesSpec , fileSpec => program . getCanonicalFileName ( getNormalizedAbsolutePath ( fileSpec , basePath ) ) === filePath ) ;
228
+ const filePath = getCanonicalFileName ( fileName ) ;
229
+ const matchedByFiles = forEach ( options . configFile . configFileSpecs . validatedFilesSpec , fileSpec => getCanonicalFileName ( getNormalizedAbsolutePath ( fileSpec , basePath ) ) === filePath ) ;
232
230
if ( ! matchedByFiles ) {
233
231
const isJsonFile = fileExtensionIs ( fileName , Extension . Json ) ;
234
232
const matchedByInclude = find ( includeSpecs , spec => ( ! isJsonFile || endsWith ( spec . include , Extension . Json ) ) && spec . regExp . test ( fileName ) ) ;
@@ -291,7 +289,7 @@ namespace ts {
291
289
function toFileName ( program : Program , file : SourceFile | string , relativeFileName : boolean | undefined ) {
292
290
const fileName = isString ( file ) ? file : file . fileName ;
293
291
return relativeFileName ?
294
- convertToRelativePath ( fileName , program . getCurrentDirectory ( ) , fileName => program . getCanonicalFileName ( fileName ) ) :
292
+ convertToRelativePath ( fileName , program . getCurrentDirectory ( ) , fileName => createGetCanonicalFileName ( program . useCaseSensitiveFileNames ( ) ) ( fileName ) ) :
295
293
fileName ;
296
294
}
297
295
0 commit comments