diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 834122b3584..d481e72b689 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -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); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ed1d5dcbe23..da438809d92 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -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; }