program.getSourceFile[ByPath] can return undefined

This commit is contained in:
Klaus Meinhardt
2017-06-03 00:10:41 +02:00
parent 1f606bd56d
commit 456a6bf658
2 changed files with 4 additions and 4 deletions

View File

@@ -969,11 +969,11 @@ namespace ts {
return emitResult;
}
function getSourceFile(fileName: string): SourceFile {
function getSourceFile(fileName: string): SourceFile | undefined {
return getSourceFileByPath(toPath(fileName, currentDirectory, getCanonicalFileName));
}
function getSourceFileByPath(path: Path): SourceFile {
function getSourceFileByPath(path: Path): SourceFile | undefined {
return filesByName.get(path);
}

View File

@@ -2352,8 +2352,8 @@ namespace ts {
export interface ScriptReferenceHost {
getCompilerOptions(): CompilerOptions;
getSourceFile(fileName: string): SourceFile;
getSourceFileByPath(path: Path): SourceFile;
getSourceFile(fileName: string): SourceFile | undefined;
getSourceFileByPath(path: Path): SourceFile | undefined;
getCurrentDirectory(): string;
}