This commit is contained in:
Ryan Cavanaugh 2018-05-14 18:27:52 -07:00
parent b58e4e1fa1
commit d98a9a0150
2 changed files with 71 additions and 1 deletions

69
src/compiler/tsbuild.ts Normal file
View file

@ -0,0 +1,69 @@
namespace ts {
/*
interface BuildContext {
unchangedOutputs: FileMap<number>;
}
interface FileMap<T> {
setValue(fileName: string, value: T): void;
getValue(fileName: string): T | never;
getValueOrUndefined(fileName: string): T | undefined;
getValueOrDefault(fileName: string, defaultValue: T): T;
tryGetValue(fileName: string): [false, undefined] | [true, T];
}
function createFileMap<T>(): FileMap<T> {
const lookup: { [key: string]: T } = Object.create(null);
return {
setValue,
getValue,
getValueOrUndefined,
getValueOrDefault,
tryGetValue
}
function setValue(fileName: string, value: T) {
lookup[normalizePath(fileName)] = value;
}
function getValue(fileName: string): T | never {
const f = normalizePath(fileName);
if (f in lookup) {
return lookup[f];
} else {
throw new Error(`No value corresponding to ${fileName} exists in this map`);
}
}
function getValueOrUndefined(fileName: string): T | undefined {
const f = normalizePath(fileName);
if (f in lookup) {
return lookup[f];
} else {
return undefined;
}
}
function getValueOrDefault(fileName: string, defaultValue: T): T {
const f = normalizePath(fileName);
if (f in lookup) {
return lookup[f];
} else {
return defaultValue;
}
}
function tryGetValue(fileName: string): [false, undefined] | [true, T] {
const f = normalizePath(fileName);
if (f in lookup) {
return [true as true, lookup[f]];
} else {
return [false as false, undefined];
}
}
}
*/
}

View file

@ -46,6 +46,7 @@
"resolutionCache.ts",
"watch.ts",
"commandLineParser.ts",
"tsc.ts"
"tsc.ts",
"tsbuild.ts"
]
}