Skip to content

Commit d98a9a0

Browse files
committed
WIP
1 parent b58e4e1 commit d98a9a0

2 files changed

Lines changed: 71 additions & 1 deletion

File tree

src/compiler/tsbuild.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
namespace ts {
2+
/*
3+
interface BuildContext {
4+
unchangedOutputs: FileMap<number>;
5+
}
6+
7+
8+
9+
interface FileMap<T> {
10+
setValue(fileName: string, value: T): void;
11+
getValue(fileName: string): T | never;
12+
getValueOrUndefined(fileName: string): T | undefined;
13+
getValueOrDefault(fileName: string, defaultValue: T): T;
14+
tryGetValue(fileName: string): [false, undefined] | [true, T];
15+
}
16+
17+
function createFileMap<T>(): FileMap<T> {
18+
const lookup: { [key: string]: T } = Object.create(null);
19+
20+
return {
21+
setValue,
22+
getValue,
23+
getValueOrUndefined,
24+
getValueOrDefault,
25+
tryGetValue
26+
}
27+
28+
function setValue(fileName: string, value: T) {
29+
lookup[normalizePath(fileName)] = value;
30+
}
31+
32+
function getValue(fileName: string): T | never {
33+
const f = normalizePath(fileName);
34+
if (f in lookup) {
35+
return lookup[f];
36+
} else {
37+
throw new Error(`No value corresponding to ${fileName} exists in this map`);
38+
}
39+
}
40+
41+
function getValueOrUndefined(fileName: string): T | undefined {
42+
const f = normalizePath(fileName);
43+
if (f in lookup) {
44+
return lookup[f];
45+
} else {
46+
return undefined;
47+
}
48+
}
49+
50+
function getValueOrDefault(fileName: string, defaultValue: T): T {
51+
const f = normalizePath(fileName);
52+
if (f in lookup) {
53+
return lookup[f];
54+
} else {
55+
return defaultValue;
56+
}
57+
}
58+
59+
function tryGetValue(fileName: string): [false, undefined] | [true, T] {
60+
const f = normalizePath(fileName);
61+
if (f in lookup) {
62+
return [true as true, lookup[f]];
63+
} else {
64+
return [false as false, undefined];
65+
}
66+
}
67+
}
68+
*/
69+
}

src/compiler/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"resolutionCache.ts",
4747
"watch.ts",
4848
"commandLineParser.ts",
49-
"tsc.ts"
49+
"tsc.ts",
50+
"tsbuild.ts"
5051
]
5152
}

0 commit comments

Comments
 (0)