@@ -407,7 +407,7 @@ namespace ts {
407
407
const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter ( file , i + 1 , 0 ) : file . text . length ;
408
408
let lineContent = file . text . slice ( lineStart , lineEnd ) ;
409
409
lineContent = lineContent . replace ( / \s + $ / g, "" ) ; // trim from end
410
- lineContent = lineContent . replace ( "\t" , " " ) ; // convert tabs to single spaces
410
+ lineContent = lineContent . replace ( / \t / g , " " ) ; // convert tabs to single spaces
411
411
412
412
// Output the gutter and the actual contents of the line.
413
413
context += indent + formatColorAndReset ( padLeft ( i + 1 + "" , gutterWidth ) , gutterStyleSequence ) + gutterSeparator ;
@@ -833,7 +833,7 @@ namespace ts {
833
833
// Track source files that are source files found by searching under node_modules, as these shouldn't be compiled.
834
834
const sourceFilesFoundSearchingNodeModules = new Map < string , boolean > ( ) ;
835
835
836
- tracing . push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
836
+ tracing ? .push ( tracing . Phase . Program , "createProgram" , { configFilePath : options . configFilePath , rootDir : options . rootDir } , /*separateBeginAndEnd*/ true ) ;
837
837
performance . mark ( "beforeProgram" ) ;
838
838
839
839
const host = createProgramOptions . host || createCompilerHost ( options ) ;
@@ -919,15 +919,15 @@ namespace ts {
919
919
forEachResolvedProjectReference
920
920
} ) ;
921
921
922
- tracing . push ( tracing . Phase . Program , "shouldProgramCreateNewSourceFiles" , { hasOldProgram : ! ! oldProgram } ) ;
922
+ tracing ? .push ( tracing . Phase . Program , "shouldProgramCreateNewSourceFiles" , { hasOldProgram : ! ! oldProgram } ) ;
923
923
const shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles ( oldProgram , options ) ;
924
- tracing . pop ( ) ;
924
+ tracing ? .pop ( ) ;
925
925
// We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks
926
926
// `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`.
927
927
let structureIsReused : StructureIsReused ;
928
- tracing . push ( tracing . Phase . Program , "tryReuseStructureFromOldProgram" , { } ) ;
928
+ tracing ? .push ( tracing . Phase . Program , "tryReuseStructureFromOldProgram" , { } ) ;
929
929
structureIsReused = tryReuseStructureFromOldProgram ( ) ; // eslint-disable-line prefer-const
930
- tracing . pop ( ) ;
930
+ tracing ? .pop ( ) ;
931
931
if ( structureIsReused !== StructureIsReused . Completely ) {
932
932
processingDefaultLibFiles = [ ] ;
933
933
processingOtherFiles = [ ] ;
@@ -964,23 +964,23 @@ namespace ts {
964
964
}
965
965
}
966
966
967
- tracing . push ( tracing . Phase . Program , "processRootFiles" , { count : rootNames . length } ) ;
967
+ tracing ? .push ( tracing . Phase . Program , "processRootFiles" , { count : rootNames . length } ) ;
968
968
forEach ( rootNames , ( name , index ) => processRootFile ( name , /*isDefaultLib*/ false , /*ignoreNoDefaultLib*/ false , { kind : FileIncludeKind . RootFile , index } ) ) ;
969
- tracing . pop ( ) ;
969
+ tracing ? .pop ( ) ;
970
970
971
971
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
972
972
const typeReferences : string [ ] = rootNames . length ? getAutomaticTypeDirectiveNames ( options , host ) : emptyArray ;
973
973
974
974
if ( typeReferences . length ) {
975
- tracing . push ( tracing . Phase . Program , "processTypeReferences" , { count : typeReferences . length } ) ;
975
+ tracing ? .push ( tracing . Phase . Program , "processTypeReferences" , { count : typeReferences . length } ) ;
976
976
// This containingFilename needs to match with the one used in managed-side
977
977
const containingDirectory = options . configFilePath ? getDirectoryPath ( options . configFilePath ) : host . getCurrentDirectory ( ) ;
978
978
const containingFilename = combinePaths ( containingDirectory , inferredTypesContainingFile ) ;
979
979
const resolutions = resolveTypeReferenceDirectiveNamesWorker ( typeReferences , containingFilename ) ;
980
980
for ( let i = 0 ; i < typeReferences . length ; i ++ ) {
981
981
processTypeReferenceDirective ( typeReferences [ i ] , resolutions [ i ] , { kind : FileIncludeKind . AutomaticTypeDirectiveFile , typeReference : typeReferences [ i ] , packageId : resolutions [ i ] ?. packageId } ) ;
982
982
}
983
- tracing . pop ( ) ;
983
+ tracing ? .pop ( ) ;
984
984
}
985
985
986
986
// Do not process the default library if:
@@ -1108,33 +1108,33 @@ namespace ts {
1108
1108
verifyCompilerOptions ( ) ;
1109
1109
performance . mark ( "afterProgram" ) ;
1110
1110
performance . measure ( "Program" , "beforeProgram" , "afterProgram" ) ;
1111
- tracing . pop ( ) ;
1111
+ tracing ? .pop ( ) ;
1112
1112
1113
1113
return program ;
1114
1114
1115
1115
function resolveModuleNamesWorker ( moduleNames : string [ ] , containingFile : SourceFile , reusedNames : string [ ] | undefined ) : readonly ResolvedModuleFull [ ] {
1116
1116
if ( ! moduleNames . length ) return emptyArray ;
1117
1117
const containingFileName = getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) ;
1118
1118
const redirectedReference = getRedirectReferenceForResolution ( containingFile ) ;
1119
- tracing . push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1119
+ tracing ? .push ( tracing . Phase . Program , "resolveModuleNamesWorker" , { containingFileName } ) ;
1120
1120
performance . mark ( "beforeResolveModule" ) ;
1121
1121
const result = actualResolveModuleNamesWorker ( moduleNames , containingFileName , reusedNames , redirectedReference ) ;
1122
1122
performance . mark ( "afterResolveModule" ) ;
1123
1123
performance . measure ( "ResolveModule" , "beforeResolveModule" , "afterResolveModule" ) ;
1124
- tracing . pop ( ) ;
1124
+ tracing ? .pop ( ) ;
1125
1125
return result ;
1126
1126
}
1127
1127
1128
1128
function resolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames : string [ ] , containingFile : string | SourceFile ) : readonly ( ResolvedTypeReferenceDirective | undefined ) [ ] {
1129
1129
if ( ! typeDirectiveNames . length ) return [ ] ;
1130
1130
const containingFileName = ! isString ( containingFile ) ? getNormalizedAbsolutePath ( containingFile . originalFileName , currentDirectory ) : containingFile ;
1131
1131
const redirectedReference = ! isString ( containingFile ) ? getRedirectReferenceForResolution ( containingFile ) : undefined ;
1132
- tracing . push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1132
+ tracing ? .push ( tracing . Phase . Program , "resolveTypeReferenceDirectiveNamesWorker" , { containingFileName } ) ;
1133
1133
performance . mark ( "beforeResolveTypeReference" ) ;
1134
1134
const result = actualResolveTypeReferenceDirectiveNamesWorker ( typeDirectiveNames , containingFileName , redirectedReference ) ;
1135
1135
performance . mark ( "afterResolveTypeReference" ) ;
1136
1136
performance . measure ( "ResolveTypeReference" , "beforeResolveTypeReference" , "afterResolveTypeReference" ) ;
1137
- tracing . pop ( ) ;
1137
+ tracing ? .pop ( ) ;
1138
1138
return result ;
1139
1139
}
1140
1140
@@ -1655,7 +1655,7 @@ namespace ts {
1655
1655
1656
1656
function emitBuildInfo ( writeFileCallback ?: WriteFileCallback ) : EmitResult {
1657
1657
Debug . assert ( ! outFile ( options ) ) ;
1658
- tracing . push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
1658
+ tracing ? .push ( tracing . Phase . Emit , "emitBuildInfo" , { } , /*separateBeginAndEnd*/ true ) ;
1659
1659
performance . mark ( "beforeEmit" ) ;
1660
1660
const emitResult = emitFiles (
1661
1661
notImplementedResolver ,
@@ -1668,7 +1668,7 @@ namespace ts {
1668
1668
1669
1669
performance . mark ( "afterEmit" ) ;
1670
1670
performance . measure ( "Emit" , "beforeEmit" , "afterEmit" ) ;
1671
- tracing . pop ( ) ;
1671
+ tracing ? .pop ( ) ;
1672
1672
return emitResult ;
1673
1673
}
1674
1674
@@ -1729,9 +1729,9 @@ namespace ts {
1729
1729
}
1730
1730
1731
1731
function emit ( sourceFile ?: SourceFile , writeFileCallback ?: WriteFileCallback , cancellationToken ?: CancellationToken , emitOnlyDtsFiles ?: boolean , transformers ?: CustomTransformers , forceDtsEmit ?: boolean ) : EmitResult {
1732
- tracing . push ( tracing . Phase . Emit , "emit" , { path : sourceFile ?. path } , /*separateBeginAndEnd*/ true ) ;
1732
+ tracing ? .push ( tracing . Phase . Emit , "emit" , { path : sourceFile ?. path } , /*separateBeginAndEnd*/ true ) ;
1733
1733
const result = runWithCancellationToken ( ( ) => emitWorker ( program , sourceFile , writeFileCallback , cancellationToken , emitOnlyDtsFiles , transformers , forceDtsEmit ) ) ;
1734
- tracing . pop ( ) ;
1734
+ tracing ? .pop ( ) ;
1735
1735
return result ;
1736
1736
}
1737
1737
@@ -2485,13 +2485,13 @@ namespace ts {
2485
2485
2486
2486
// Get source file from normalized fileName
2487
2487
function findSourceFile ( fileName : string , path : Path , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , reason : FileIncludeReason , packageId : PackageId | undefined ) : SourceFile | undefined {
2488
- tracing . push ( tracing . Phase . Program , "findSourceFile" , {
2488
+ tracing ? .push ( tracing . Phase . Program , "findSourceFile" , {
2489
2489
fileName,
2490
2490
isDefaultLib : isDefaultLib || undefined ,
2491
2491
fileIncludeKind : ( FileIncludeKind as any ) [ reason . kind ] ,
2492
2492
} ) ;
2493
2493
const result = findSourceFileWorker ( fileName , path , isDefaultLib , ignoreNoDefaultLib , reason , packageId ) ;
2494
- tracing . pop ( ) ;
2494
+ tracing ? .pop ( ) ;
2495
2495
return result ;
2496
2496
}
2497
2497
@@ -2792,9 +2792,9 @@ namespace ts {
2792
2792
resolvedTypeReferenceDirective : ResolvedTypeReferenceDirective | undefined ,
2793
2793
reason : FileIncludeReason
2794
2794
) : void {
2795
- tracing . push ( tracing . Phase . Program , "processTypeReferenceDirective" , { directive : typeReferenceDirective , hasResolved : ! ! resolveModuleNamesReusingOldState , refKind : reason . kind , refPath : isReferencedFile ( reason ) ? reason . file : undefined } ) ;
2795
+ tracing ? .push ( tracing . Phase . Program , "processTypeReferenceDirective" , { directive : typeReferenceDirective , hasResolved : ! ! resolveModuleNamesReusingOldState , refKind : reason . kind , refPath : isReferencedFile ( reason ) ? reason . file : undefined } ) ;
2796
2796
processTypeReferenceDirectiveWorker ( typeReferenceDirective , resolvedTypeReferenceDirective , reason ) ;
2797
- tracing . pop ( ) ;
2797
+ tracing ? .pop ( ) ;
2798
2798
}
2799
2799
2800
2800
function processTypeReferenceDirectiveWorker (
0 commit comments