-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathcommon.ts
More file actions
35 lines (29 loc) · 894 Bytes
/
common.ts
File metadata and controls
35 lines (29 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as ts from "./typescript";
export class Project {
public program: ts.Program = null;
private host: ts.CompilerHost;
constructor(
public tsConfig: string,
public config: ts.ParsedCommandLine,
public packageEntryPoints: Map<string, string>) {
let host = ts.createCompilerHost(config.options, true);
host.trace = undefined; // Disable tracing which would otherwise go to standard out
this.host = host;
}
public unload(): void {
this.program = null;
}
public load(): void {
const { config, host } = this;
this.program = ts.createProgram(config.fileNames, config.options, host);
}
/**
* Discards the old compiler instance and starts a new one.
*/
public reload(): void {
// Ensure all references to the old compiler instance
// are cleared before calling `createProgram`.
this.unload();
this.load();
}
}