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 | */
|
8 | /// <amd-module name="@angular/compiler-cli/src/transformers/api" />
|
9 | import ts from 'typescript';
|
10 | import { ExtendedTsCompilerHost, NgCompilerOptions } from '../ngtsc/core/api';
|
11 | export declare const DEFAULT_ERROR_CODE = 100;
|
12 | export declare const UNKNOWN_ERROR_CODE = 500;
|
13 | export declare const SOURCE: "angular";
|
14 | export declare function isTsDiagnostic(diagnostic: any): diagnostic is ts.Diagnostic;
|
15 | export interface CompilerOptions extends NgCompilerOptions, ts.CompilerOptions {
|
16 | genDir?: string;
|
17 | basePath?: string;
|
18 | skipMetadataEmit?: boolean;
|
19 | strictMetadataEmit?: boolean;
|
20 | skipTemplateCodegen?: boolean;
|
21 | flatModulePrivateSymbolPrefix?: string;
|
22 | generateCodeForLibraries?: boolean;
|
23 | annotationsAs?: 'decorators' | 'static fields';
|
24 | trace?: boolean;
|
25 | disableExpressionLowering?: boolean;
|
26 | i18nInFormat?: string;
|
27 | i18nInFile?: string;
|
28 | i18nInMissingTranslations?: 'error' | 'warning' | 'ignore';
|
29 | /**
|
30 | * Whether to generate .ngsummary.ts files that allow to use AOTed artifacts
|
31 | * in JIT mode. This is off by default.
|
32 | */
|
33 | enableSummariesForJit?: boolean;
|
34 | /**
|
35 | * Whether to replace the `templateUrl` and `styleUrls` property in all
|
36 | * @Component decorators with inlined contents in `template` and `styles`
|
37 | * properties.
|
38 | * When enabled, the .js output of ngc will have no lazy-loaded `templateUrl`
|
39 | * or `styleUrl`s. Note that this requires that resources be available to
|
40 | * load statically at compile-time.
|
41 | */
|
42 | enableResourceInlining?: boolean;
|
43 | /**
|
44 | * Whether NGC should generate re-exports for external symbols which are referenced
|
45 | * in Angular metadata (e.g. @Component, @Inject, @ViewChild). This can be enabled in
|
46 | * order to avoid dynamically generated module dependencies which can break strict
|
47 | * dependency enforcements. This is not enabled by default.
|
48 | * Read more about this here: https://github.com/angular/angular/issues/25644.
|
49 | */
|
50 | createExternalSymbolFactoryReexports?: boolean;
|
51 | }
|
52 | export interface CompilerHost extends ts.CompilerHost, ExtendedTsCompilerHost {
|
53 | /**
|
54 | * Converts a module name that is used in an `import` to a file path.
|
55 | * I.e. `path/to/containingFile.ts` containing `import {...} from 'module-name'`.
|
56 | */
|
57 | moduleNameToFileName?(moduleName: string, containingFile: string): string | null;
|
58 | /**
|
59 | * Converts a file name into a representation that should be stored in a summary file.
|
60 | * This has to include changing the suffix as well.
|
61 | * E.g.
|
62 | * `some_file.ts` -> `some_file.d.ts`
|
63 | *
|
64 | * @param referringSrcFileName the soure file that refers to fileName
|
65 | */
|
66 | toSummaryFileName?(fileName: string, referringSrcFileName: string): string;
|
67 | /**
|
68 | * Converts a fileName that was processed by `toSummaryFileName` back into a real fileName
|
69 | * given the fileName of the library that is referrig to it.
|
70 | */
|
71 | fromSummaryFileName?(fileName: string, referringLibFileName: string): string;
|
72 | /**
|
73 | * Produce an AMD module name for the source file. Used in Bazel.
|
74 | *
|
75 | * An AMD module can have an arbitrary name, so that it is require'd by name
|
76 | * rather than by path. See https://requirejs.org/docs/whyamd.html#namedmodules
|
77 | */
|
78 | amdModuleName?(sf: ts.SourceFile): string | undefined;
|
79 | }
|
80 | export declare enum EmitFlags {
|
81 | DTS = 1,
|
82 | JS = 2,
|
83 | Metadata = 4,
|
84 | I18nBundle = 8,
|
85 | Codegen = 16,
|
86 | Default = 19,
|
87 | All = 31
|
88 | }
|
89 | export interface CustomTransformers {
|
90 | beforeTs?: ts.TransformerFactory<ts.SourceFile>[];
|
91 | afterTs?: ts.TransformerFactory<ts.SourceFile>[];
|
92 | }
|
93 | export interface TsEmitArguments {
|
94 | program: ts.Program;
|
95 | host: CompilerHost;
|
96 | options: CompilerOptions;
|
97 | targetSourceFile?: ts.SourceFile;
|
98 | writeFile?: ts.WriteFileCallback;
|
99 | cancellationToken?: ts.CancellationToken;
|
100 | emitOnlyDtsFiles?: boolean;
|
101 | customTransformers?: ts.CustomTransformers;
|
102 | }
|
103 | export interface TsEmitCallback {
|
104 | (args: TsEmitArguments): ts.EmitResult;
|
105 | }
|
106 | export interface TsMergeEmitResultsCallback {
|
107 | (results: ts.EmitResult[]): ts.EmitResult;
|
108 | }
|
109 | export interface LazyRoute {
|
110 | route: string;
|
111 | module: {
|
112 | name: string;
|
113 | filePath: string;
|
114 | };
|
115 | referencedModule: {
|
116 | name: string;
|
117 | filePath: string;
|
118 | };
|
119 | }
|
120 | export interface Program {
|
121 | /**
|
122 | * Retrieve the TypeScript program used to produce semantic diagnostics and emit the sources.
|
123 | *
|
124 | * Angular structural information is required to produce the program.
|
125 | */
|
126 | getTsProgram(): ts.Program;
|
127 | /**
|
128 | * Retrieve options diagnostics for the TypeScript options used to create the program. This is
|
129 | * faster than calling `getTsProgram().getOptionsDiagnostics()` since it does not need to
|
130 | * collect Angular structural information to produce the errors.
|
131 | */
|
132 | getTsOptionDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
|
133 | /**
|
134 | * Retrieve options diagnostics for the Angular options used to create the program.
|
135 | */
|
136 | getNgOptionDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
|
137 | /**
|
138 | * Retrieve the syntax diagnostics from TypeScript. This is faster than calling
|
139 | * `getTsProgram().getSyntacticDiagnostics()` since it does not need to collect Angular structural
|
140 | * information to produce the errors.
|
141 | */
|
142 | getTsSyntacticDiagnostics(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
|
143 | /**
|
144 | * Retrieve the diagnostics for the structure of an Angular application is correctly formed.
|
145 | * This includes validating Angular annotations and the syntax of referenced and imbedded HTML
|
146 | * and CSS.
|
147 | *
|
148 | * Note it is important to displaying TypeScript semantic diagnostics along with Angular
|
149 | * structural diagnostics as an error in the program structure might cause errors detected in
|
150 | * semantic analysis and a semantic error might cause errors in specifying the program structure.
|
151 | *
|
152 | * Angular structural information is required to produce these diagnostics.
|
153 | */
|
154 | getNgStructuralDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
|
155 | /**
|
156 | * Retrieve the semantic diagnostics from TypeScript. This is equivalent to calling
|
157 | * `getTsProgram().getSemanticDiagnostics()` directly and is included for completeness.
|
158 | */
|
159 | getTsSemanticDiagnostics(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
|
160 | /**
|
161 | * Retrieve the Angular semantic diagnostics.
|
162 | *
|
163 | * Angular structural information is required to produce these diagnostics.
|
164 | */
|
165 | getNgSemanticDiagnostics(fileName?: string, cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
|
166 | /**
|
167 | * Load Angular structural information asynchronously. If this method is not called then the
|
168 | * Angular structural information, including referenced HTML and CSS files, are loaded
|
169 | * synchronously. If the supplied Angular compiler host returns a promise from `loadResource()`
|
170 | * will produce a diagnostic error message or, `getTsProgram()` or `emit` to throw.
|
171 | */
|
172 | loadNgStructureAsync(): Promise<void>;
|
173 | /**
|
174 | * This method is obsolete and always returns an empty array.
|
175 | */
|
176 | listLazyRoutes(entryRoute?: string): LazyRoute[];
|
177 | /**
|
178 | * Emit the files requested by emitFlags implied by the program.
|
179 | *
|
180 | * Angular structural information is required to emit files.
|
181 | */
|
182 | emit({ emitFlags, cancellationToken, customTransformers, emitCallback, mergeEmitResultsCallback }?: {
|
183 | emitFlags?: EmitFlags;
|
184 | cancellationToken?: ts.CancellationToken;
|
185 | customTransformers?: CustomTransformers;
|
186 | emitCallback?: TsEmitCallback;
|
187 | mergeEmitResultsCallback?: TsMergeEmitResultsCallback;
|
188 | }): ts.EmitResult;
|
189 | }
|