File tree Expand file tree Collapse file tree 4 files changed +14
-7
lines changed
testRunner/unittests/tsserver Expand file tree Collapse file tree 4 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -689,7 +689,7 @@ namespace ts.server {
689689 this . logErrorWorker ( err , cmd ) ;
690690 }
691691
692- private logErrorWorker ( err : Error , cmd : string , fileRequest ?: protocol . FileRequestArgs ) : void {
692+ private logErrorWorker ( err : Error & PossibleProgramFileInfo , cmd : string , fileRequest ?: protocol . FileRequestArgs ) : void {
693693 let msg = "Exception on executing command " + cmd ;
694694 if ( err . message ) {
695695 msg += ":\n" + indent ( err . message ) ;
@@ -711,8 +711,9 @@ namespace ts.server {
711711 catch { } // tslint:disable-line no-empty
712712 }
713713
714- if ( err . hasOwnProperty ( "ProgramFiles" ) ) {
715- msg += `\n\nProgram files: {(err as any)["ProgramFiles"]}\n` ;
714+
715+ if ( err . ProgramFiles ) {
716+ msg += `\n\nProgram files: {JSON.stringify(error.ProgramFiles}}\n` ;
716717 msg += `\n\nProjects::\n` ;
717718 let counter = 0 ;
718719 const addProjectInfo = ( project : Project ) => {
Original file line number Diff line number Diff line change @@ -1158,10 +1158,11 @@ namespace ts {
11581158 function getValidSourceFile ( fileName : string ) : SourceFile {
11591159 const sourceFile = program . getSourceFile ( fileName ) ;
11601160 if ( ! sourceFile ) {
1161- let error = new Error ( `Could not find sourceFile: '${ fileName } '.` ) ;
1161+ const error : Error & PossibleProgramFileInfo = new Error ( `Could not find sourceFile: '${ fileName } '.` ) ;
11621162
1163- // Attach sidecar data for the server log
1164- ( error as any ) [ "ProgramFiles" ] = program && JSON . stringify ( program . getSourceFiles ( ) . map ( f => f . fileName ) ) ;
1163+ // We've been having trouble debugging this, so attach sidecar data for the tsserver log.
1164+ // See https://github.com/microsoft/TypeScript/issues/30180.
1165+ error . ProgramFiles = program . getSourceFiles ( ) . map ( f => f . fileName ) ;
11651166
11661167 throw error ;
11671168 }
Original file line number Diff line number Diff line change @@ -967,6 +967,11 @@ namespace ts {
967967 readonly called : Identifier ;
968968 readonly nTypeArguments : number ;
969969 }
970+
971+ export interface PossibleProgramFileInfo {
972+ ProgramFiles ?: string [ ] ;
973+ }
974+
970975 // Get info for an expression like `f <` that may be the start of type arguments.
971976 export function getPossibleTypeArgumentsInfo ( tokenIn : Node , sourceFile : SourceFile ) : PossibleTypeArgumentInfo | undefined {
972977 let token : Node | undefined = tokenIn ;
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ namespace ts.projectSystem {
139139 assert . isTrue ( false , `should not find file '${ imported . path } '` ) ;
140140 }
141141 catch ( e ) {
142- assert . isTrue ( e . message . indexOf ( `Could not find sourceFile: '${ imported . path } ' in [" ${ root . path } "] .` ) === 0 , `Actual: ${ e . message } ` ) ;
142+ assert . isTrue ( e . message . indexOf ( `Could not find sourceFile: '${ imported . path } '.` ) === 0 , `Actual: ${ e . message } ` ) ;
143143 }
144144 const f2Lookups = getLocationsForModuleLookup ( "f2" ) ;
145145 callsTrackingHost . verifyCalledOnEachEntryNTimes ( CalledMapsWithSingleArg . fileExists , f2Lookups , 1 ) ;
You can’t perform that action at this time.
0 commit comments