Change getModifiedTime type

This commit is contained in:
Alexander T 2018-07-16 11:10:09 +03:00
parent 60986adee5
commit bf567b8a40
5 changed files with 20 additions and 11 deletions

View File

@ -63,7 +63,7 @@ namespace ts {
interface OutputFingerprint {
hash: string;
byteOrderMark: boolean;
mtime: Date;
mtime: Date | undefined;
}
export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost {
@ -128,6 +128,7 @@ namespace ts {
if (fingerprint &&
fingerprint.byteOrderMark === writeByteOrderMark &&
fingerprint.hash === hash &&
fingerprint.mtime !== undefined &&
fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
return;
}

View File

@ -482,7 +482,7 @@ namespace ts {
getCurrentDirectory(): string;
getDirectories(path: string): string[];
readDirectory(path: string, extensions?: ReadonlyArray<string>, exclude?: ReadonlyArray<string>, include?: ReadonlyArray<string>, depth?: number): string[];
getModifiedTime?(path: string): Date;
getModifiedTime?(path: string): Date | undefined;
setModifiedTime?(path: string, time: Date): void;
deleteFile?(path: string): void;
/**

View File

@ -848,9 +848,14 @@ namespace ts {
const outputs = getAllProjectOutputs(proj);
let priorNewestUpdateTime = minimumDate;
for (const file of outputs) {
if (isDeclarationFile(file)) {
priorNewestUpdateTime = newer(priorNewestUpdateTime, compilerHost.getModifiedTime!(file));
const fileModifiedTime = compilerHost.getModifiedTime!(file);
if (fileModifiedTime !== undefined) {
priorNewestUpdateTime = newer(priorNewestUpdateTime, fileModifiedTime);
}
}
compilerHost.setModifiedTime!(file, now);
}
@ -1058,7 +1063,7 @@ namespace ts {
}
const inputTime = host.getModifiedTime(inputFile);
if (inputTime > newestInputFileTime) {
if (inputTime !== undefined && inputTime > newestInputFileTime) {
newestInputFileName = inputFile;
newestInputFileTime = inputTime;
}
@ -1090,19 +1095,19 @@ namespace ts {
}
const outputTime = host.getModifiedTime(output);
if (outputTime < oldestOutputFileTime) {
if (outputTime !== undefined && outputTime < oldestOutputFileTime) {
oldestOutputFileTime = outputTime;
oldestOutputFileName = output;
}
// If an output is older than the newest input, we can stop checking
// Don't immediately return because we can still be upstream-blocked, which is a higher-priority status
if (outputTime < newestInputFileTime) {
if (outputTime !== undefined && outputTime < newestInputFileTime) {
isOutOfDateWithInputs = true;
break;
}
if (outputTime > newestOutputFileTime) {
if (outputTime !== undefined && outputTime > newestOutputFileTime) {
newestOutputFileTime = outputTime;
newestOutputFileName = output;
}
@ -1117,7 +1122,10 @@ namespace ts {
newestDeclarationFileContentChangedTime = newer(unchangedTime, newestDeclarationFileContentChangedTime);
}
else {
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, host.getModifiedTime(output));
const outputModifiedTime = host.getModifiedTime(output);
if (outputModifiedTime !== undefined) {
newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
}
}
}
}

View File

@ -4682,7 +4682,7 @@ namespace ts {
export interface UpToDateHost {
fileExists(fileName: string): boolean;
getModifiedTime(fileName: string): Date;
getModifiedTime(fileName: string): Date | undefined;
getUnchangedTime?(fileName: string): Date | undefined;
getLastStatus?(fileName: string): UpToDateStatus | undefined;
setLastStatus?(fileName: string, status: UpToDateStatus): void;
@ -4820,7 +4820,7 @@ namespace ts {
/* @internal */ hasChangedAutomaticTypeDirectiveNames?: boolean;
createHash?(data: string): string;
getModifiedTime?(fileName: string): Date;
getModifiedTime?(fileName: string): Date | undefined;
setModifiedTime?(fileName: string, date: Date): void;
deleteFile?(fileName: string): void;
}

View File

@ -676,7 +676,7 @@ namespace ts.server {
fs.stat(watchedFile.fileName, (err, stats) => {
if (err) {
if (err.code === "ENOENT") {
if (watchedFile.mtime.getTime() !== 0) {
if (watchedFile.mtime !== undefined && watchedFile.mtime.getTime() !== 0) {
watchedFile.mtime = missingFileModifiedTime;
watchedFile.callback(watchedFile.fileName, FileWatcherEventKind.Deleted);
}