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