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 {
689
689
this . logErrorWorker ( err , cmd ) ;
690
690
}
691
691
692
- private logErrorWorker ( err : Error , cmd : string , fileRequest ?: protocol . FileRequestArgs ) : void {
692
+ private logErrorWorker ( err : Error & PossibleProgramFileInfo , cmd : string , fileRequest ?: protocol . FileRequestArgs ) : void {
693
693
let msg = "Exception on executing command " + cmd ;
694
694
if ( err . message ) {
695
695
msg += ":\n" + indent ( err . message ) ;
@@ -711,8 +711,9 @@ namespace ts.server {
711
711
catch { } // tslint:disable-line no-empty
712
712
}
713
713
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` ;
716
717
msg += `\n\nProjects::\n` ;
717
718
let counter = 0 ;
718
719
const addProjectInfo = ( project : Project ) => {
Original file line number Diff line number Diff line change @@ -1158,10 +1158,11 @@ namespace ts {
1158
1158
function getValidSourceFile ( fileName : string ) : SourceFile {
1159
1159
const sourceFile = program . getSourceFile ( fileName ) ;
1160
1160
if ( ! sourceFile ) {
1161
- let error = new Error ( `Could not find sourceFile: '${ fileName } '.` ) ;
1161
+ const error : Error & PossibleProgramFileInfo = new Error ( `Could not find sourceFile: '${ fileName } '.` ) ;
1162
1162
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 ) ;
1165
1166
1166
1167
throw error ;
1167
1168
}
Original file line number Diff line number Diff line change @@ -967,6 +967,11 @@ namespace ts {
967
967
readonly called : Identifier ;
968
968
readonly nTypeArguments : number ;
969
969
}
970
+
971
+ export interface PossibleProgramFileInfo {
972
+ ProgramFiles ?: string [ ] ;
973
+ }
974
+
970
975
// Get info for an expression like `f <` that may be the start of type arguments.
971
976
export function getPossibleTypeArgumentsInfo ( tokenIn : Node , sourceFile : SourceFile ) : PossibleTypeArgumentInfo | undefined {
972
977
let token : Node | undefined = tokenIn ;
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ namespace ts.projectSystem {
139
139
assert . isTrue ( false , `should not find file '${ imported . path } '` ) ;
140
140
}
141
141
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 } ` ) ;
143
143
}
144
144
const f2Lookups = getLocationsForModuleLookup ( "f2" ) ;
145
145
callsTrackingHost . verifyCalledOnEachEntryNTimes ( CalledMapsWithSingleArg . fileExists , f2Lookups , 1 ) ;
You can’t perform that action at this time.
0 commit comments