You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Using-the-Compiler-API.md
+74
Original file line number
Diff line number
Diff line change
@@ -283,6 +283,80 @@ function reportWatchStatusChanged(diagnostic: ts.Diagnostic) {
283
283
watchMain();
284
284
```
285
285
286
+
## A minimal incremental compiler
287
+
288
+
To compile incrementally, we need to create a builder program that reads the older program by reading tsbuildinfo file. This is as simple as calling `createIncrementalProgram`. `createIncrementalProgram` abstracts any interaction with the underlying system in the `IncrementalCompilerHost` interface. The `IncrementalCompilerHost` allows the compiler to read and write files, get the current directory, ensure that files and directories exist, and query some of the underlying system properties such as case sensitivity and new line characters. For convenience, we expose a function to create a default host using `createIncrementalCompilerHost`.
289
+
290
+
```TypeScript
291
+
import*astsfrom"typescript";
292
+
293
+
function incrementalCompile():void {
294
+
const configPath =ts.findConfigFile(
295
+
/*searchPath*/"./",
296
+
ts.sys.fileExists,
297
+
"tsconfig.json"
298
+
);
299
+
if (!configPath) {
300
+
thrownewError("Could not find a valid 'tsconfig.json'.");
0 commit comments