From d98a9a0150b4b363b27c44eb336443b02581112f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 14 May 2018 18:27:52 -0700 Subject: [PATCH] WIP --- src/compiler/tsbuild.ts | 69 ++++++++++++++++++++++++++++++++++++++ src/compiler/tsconfig.json | 3 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/compiler/tsbuild.ts diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts new file mode 100644 index 00000000000..ee41584d1fe --- /dev/null +++ b/src/compiler/tsbuild.ts @@ -0,0 +1,69 @@ +namespace ts { +/* + interface BuildContext { + unchangedOutputs: FileMap; + } + + + + interface FileMap { + 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(): FileMap { + 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]; + } + } + } + */ +} diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 46e5384434a..0db027d555f 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -46,6 +46,7 @@ "resolutionCache.ts", "watch.ts", "commandLineParser.ts", - "tsc.ts" + "tsc.ts", + "tsbuild.ts" ] }