UNPKG

1.69 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import ts from 'typescript';
9import { ParsedConfiguration } from './perform_compile';
10import * as api from './transformers/api';
11export declare enum FileChangeEvent {
12 Change = 0,
13 CreateDelete = 1,
14 CreateDeleteDir = 2
15}
16export interface PerformWatchHost<CbEmitRes extends ts.EmitResult = ts.EmitResult> {
17 reportDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>): void;
18 readConfiguration(): ParsedConfiguration;
19 createCompilerHost(options: api.CompilerOptions): api.CompilerHost;
20 createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback<CbEmitRes> | undefined;
21 onFileChange(options: api.CompilerOptions, listener: (event: FileChangeEvent, fileName: string) => void, ready: () => void): {
22 close: () => void;
23 };
24 setTimeout(callback: () => void, ms: number): any;
25 clearTimeout(timeoutId: any): void;
26}
27export declare function createPerformWatchHost<CbEmitRes extends ts.EmitResult = ts.EmitResult>(configFileName: string, reportDiagnostics: (diagnostics: ReadonlyArray<ts.Diagnostic>) => void, existingOptions?: ts.CompilerOptions, createEmitCallback?: (options: api.CompilerOptions) => api.TsEmitCallback<CbEmitRes> | undefined): PerformWatchHost;
28/**
29 * The logic in this function is adapted from `tsc.ts` from TypeScript.
30 */
31export declare function performWatchCompilation(host: PerformWatchHost): {
32 close: () => void;
33 ready: (cb: () => void) => void;
34 firstCompileResult: ReadonlyArray<ts.Diagnostic>;
35};