UNPKG

2.4 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 { NgCompiler } from './core';
10import { UnifiedModulesHost } from './core/api';
11/**
12 * A `ts.CompilerHost` which also returns a list of input files, out of which the `ts.Program`
13 * should be created.
14 *
15 * Currently mirrored from @bazel/concatjs/internal/tsc_wrapped/plugin_api (with the naming of
16 * `fileNameToModuleName` corrected).
17 */
18export interface PluginCompilerHost extends ts.CompilerHost, Partial<UnifiedModulesHost> {
19 readonly inputFiles: ReadonlyArray<string>;
20}
21/**
22 * Mirrors the plugin interface from tsc_wrapped which is currently under active development. To
23 * enable progress to be made in parallel, the upstream interface isn't implemented directly.
24 * Instead, `TscPlugin` here is structurally assignable to what tsc_wrapped expects.
25 */
26interface TscPlugin {
27 readonly name: string;
28 wrapHost(host: ts.CompilerHost & Partial<UnifiedModulesHost>, inputFiles: ReadonlyArray<string>, options: ts.CompilerOptions): PluginCompilerHost;
29 setupCompilation(program: ts.Program, oldProgram?: ts.Program): {
30 ignoreForDiagnostics: Set<ts.SourceFile>;
31 ignoreForEmit: Set<ts.SourceFile>;
32 };
33 getDiagnostics(file?: ts.SourceFile): ts.Diagnostic[];
34 getOptionDiagnostics(): ts.Diagnostic[];
35 getNextProgram(): ts.Program;
36 createTransformers(): ts.CustomTransformers;
37}
38/**
39 * A plugin for `tsc_wrapped` which allows Angular compilation from a plain `ts_library`.
40 */
41export declare class NgTscPlugin implements TscPlugin {
42 private ngOptions;
43 name: string;
44 private options;
45 private host;
46 private _compiler;
47 get compiler(): NgCompiler;
48 constructor(ngOptions: {});
49 wrapHost(host: ts.CompilerHost & Partial<UnifiedModulesHost>, inputFiles: readonly string[], options: ts.CompilerOptions): PluginCompilerHost;
50 setupCompilation(program: ts.Program, oldProgram?: ts.Program): {
51 ignoreForDiagnostics: Set<ts.SourceFile>;
52 ignoreForEmit: Set<ts.SourceFile>;
53 };
54 getDiagnostics(file?: ts.SourceFile): ts.Diagnostic[];
55 getOptionDiagnostics(): ts.Diagnostic[];
56 getNextProgram(): ts.Program;
57 createTransformers(): ts.CustomTransformers;
58}
59export {};