Merge pull request #32785 from amcasey/FileNotFoundError

Include fewer paths in exception
This commit is contained in:
Andrew Casey
2019-08-09 14:28:32 -07:00
committed by GitHub
4 changed files with 17 additions and 4 deletions
+7 -1
View File
@@ -1158,7 +1158,13 @@ namespace ts {
function getValidSourceFile(fileName: string): SourceFile {
const sourceFile = program.getSourceFile(fileName);
if (!sourceFile) {
throw new Error(`Could not find sourceFile: '${fileName}' in ${program && JSON.stringify(program.getSourceFiles().map(f => f.fileName))}.`);
const error: Error & PossibleProgramFileInfo = new Error(`Could not find sourceFile: '${fileName}'.`);
// We've been having trouble debugging this, so attach sidecar data for the tsserver log.
// See https://github.com/microsoft/TypeScript/issues/30180.
error.ProgramFiles = program.getSourceFiles().map(f => f.fileName);
throw error;
}
return sourceFile;
}
+5
View File
@@ -967,6 +967,11 @@ namespace ts {
readonly called: Identifier;
readonly nTypeArguments: number;
}
export interface PossibleProgramFileInfo {
ProgramFiles?: string[];
}
// Get info for an expression like `f <` that may be the start of type arguments.
export function getPossibleTypeArgumentsInfo(tokenIn: Node, sourceFile: SourceFile): PossibleTypeArgumentInfo | undefined {
let token: Node | undefined = tokenIn;