1 | /// <amd-module name="@angular/compiler-cli/ngcc/src/rendering/esm_rendering_formatter" />
|
---|
2 | /**
|
---|
3 | * @license
|
---|
4 | * Copyright Google LLC All Rights Reserved.
|
---|
5 | *
|
---|
6 | * Use of this source code is governed by an MIT-style license that can be
|
---|
7 | * found in the LICENSE file at https://angular.io/license
|
---|
8 | */
|
---|
9 | import { Statement } from '@angular/compiler';
|
---|
10 | import MagicString from 'magic-string';
|
---|
11 | import * as ts from 'typescript';
|
---|
12 | import { AbsoluteFsPath, PathManipulation } from '../../../src/ngtsc/file_system';
|
---|
13 | import { Reexport } from '../../../src/ngtsc/imports';
|
---|
14 | import { Import, ImportManager } from '../../../src/ngtsc/translator';
|
---|
15 | import { ModuleWithProvidersInfo } from '../analysis/module_with_providers_analyzer';
|
---|
16 | import { ExportInfo } from '../analysis/private_declarations_analyzer';
|
---|
17 | import { CompiledClass } from '../analysis/types';
|
---|
18 | import { NgccReflectionHost, SwitchableVariableDeclaration } from '../host/ngcc_host';
|
---|
19 | import { RedundantDecoratorMap, RenderingFormatter } from './rendering_formatter';
|
---|
20 | /**
|
---|
21 | * A RenderingFormatter that works with ECMAScript Module import and export statements.
|
---|
22 | */
|
---|
23 | export declare class EsmRenderingFormatter implements RenderingFormatter {
|
---|
24 | protected fs: PathManipulation;
|
---|
25 | protected host: NgccReflectionHost;
|
---|
26 | protected isCore: boolean;
|
---|
27 | protected printer: ts.Printer;
|
---|
28 | constructor(fs: PathManipulation, host: NgccReflectionHost, isCore: boolean);
|
---|
29 | /**
|
---|
30 | * Add the imports at the top of the file, after any imports that are already there.
|
---|
31 | */
|
---|
32 | addImports(output: MagicString, imports: Import[], sf: ts.SourceFile): void;
|
---|
33 | /**
|
---|
34 | * Add the exports to the end of the file.
|
---|
35 | */
|
---|
36 | addExports(output: MagicString, entryPointBasePath: AbsoluteFsPath, exports: ExportInfo[], importManager: ImportManager, file: ts.SourceFile): void;
|
---|
37 | /**
|
---|
38 | * Add plain exports to the end of the file.
|
---|
39 | *
|
---|
40 | * Unlike `addExports`, direct exports go directly in a .js and .d.ts file and don't get added to
|
---|
41 | * an entrypoint.
|
---|
42 | */
|
---|
43 | addDirectExports(output: MagicString, exports: Reexport[], importManager: ImportManager, file: ts.SourceFile): void;
|
---|
44 | /**
|
---|
45 | * Add the constants directly after the imports.
|
---|
46 | */
|
---|
47 | addConstants(output: MagicString, constants: string, file: ts.SourceFile): void;
|
---|
48 | /**
|
---|
49 | * Add the definitions directly after their decorated class.
|
---|
50 | */
|
---|
51 | addDefinitions(output: MagicString, compiledClass: CompiledClass, definitions: string): void;
|
---|
52 | /**
|
---|
53 | * Add the adjacent statements after all static properties of the class.
|
---|
54 | */
|
---|
55 | addAdjacentStatements(output: MagicString, compiledClass: CompiledClass, statements: string): void;
|
---|
56 | /**
|
---|
57 | * Remove static decorator properties from classes.
|
---|
58 | */
|
---|
59 | removeDecorators(output: MagicString, decoratorsToRemove: RedundantDecoratorMap): void;
|
---|
60 | /**
|
---|
61 | * Rewrite the IVY switch markers to indicate we are in IVY mode.
|
---|
62 | */
|
---|
63 | rewriteSwitchableDeclarations(outputText: MagicString, sourceFile: ts.SourceFile, declarations: SwitchableVariableDeclaration[]): void;
|
---|
64 | /**
|
---|
65 | * Add the type parameters to the appropriate functions that return `ModuleWithProviders`
|
---|
66 | * structures.
|
---|
67 | *
|
---|
68 | * This function will only get called on typings files.
|
---|
69 | */
|
---|
70 | addModuleWithProvidersParams(outputText: MagicString, moduleWithProviders: ModuleWithProvidersInfo[], importManager: ImportManager): void;
|
---|
71 | /**
|
---|
72 | * Convert a `Statement` to JavaScript code in a format suitable for rendering by this formatter.
|
---|
73 | *
|
---|
74 | * @param stmt The `Statement` to print.
|
---|
75 | * @param sourceFile A `ts.SourceFile` that provides context for the statement. See
|
---|
76 | * `ts.Printer#printNode()` for more info.
|
---|
77 | * @param importManager The `ImportManager` to use for managing imports.
|
---|
78 | *
|
---|
79 | * @return The JavaScript code corresponding to `stmt` (in the appropriate format).
|
---|
80 | */
|
---|
81 | printStatement(stmt: Statement, sourceFile: ts.SourceFile, importManager: ImportManager): string;
|
---|
82 | protected findEndOfImports(sf: ts.SourceFile): number;
|
---|
83 | /**
|
---|
84 | * Check whether the given type is the core Angular `ModuleWithProviders` interface.
|
---|
85 | * @param typeName The type to check.
|
---|
86 | * @returns true if the type is the core Angular `ModuleWithProviders` interface.
|
---|
87 | */
|
---|
88 | private isCoreModuleWithProvidersType;
|
---|
89 | }
|
---|