@angular/compiler-cli 17.3.1 → 17.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/{chunk-6X7GQ6BQ.js → chunk-6IQBXGRH.js} +591 -245
- package/bundles/chunk-6IQBXGRH.js.map +6 -0
- package/bundles/{chunk-3ESFLGKJ.js → chunk-7OQMTKOE.js} +254 -233
- package/bundles/chunk-7OQMTKOE.js.map +6 -0
- package/bundles/{chunk-OXIOYWLB.js → chunk-KP3UXB5C.js} +59 -57
- package/bundles/{chunk-OXIOYWLB.js.map → chunk-KP3UXB5C.js.map} +1 -1
- package/bundles/{chunk-VH6EDOMC.js → chunk-LHQ7WPU2.js} +2038 -858
- package/bundles/chunk-LHQ7WPU2.js.map +6 -0
- package/bundles/{chunk-F2QV65AH.js → chunk-VXEF7SDM.js} +2 -2
- package/bundles/{chunk-E5DF5SRS.js → chunk-ZS3FJJVW.js} +16 -16
- package/bundles/chunk-ZS3FJJVW.js.map +6 -0
- package/bundles/index.js +7 -5
- package/bundles/index.js.map +1 -1
- package/bundles/linker/babel/index.js +2 -2
- package/bundles/linker/index.js +2 -2
- package/bundles/private/migrations.js +2 -2
- package/bundles/private/tooling.js +3 -3
- package/bundles/src/bin/ng_xi18n.js +4 -4
- package/bundles/src/bin/ngc.js +4 -4
- package/bundles_metadata.json +1 -1
- package/index.d.ts +1 -0
- package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
- package/linker/src/file_linker/translator.d.ts +2 -2
- package/linker/src/linker_import_generator.d.ts +5 -5
- package/package.json +2 -2
- package/src/ngtsc/annotations/directive/index.d.ts +1 -0
- package/src/ngtsc/annotations/directive/src/initializer_function_access.d.ts +17 -0
- package/src/ngtsc/annotations/directive/src/initializer_functions.d.ts +10 -6
- package/src/ngtsc/annotations/directive/src/input_function.d.ts +1 -1
- package/src/ngtsc/annotations/directive/src/model_function.d.ts +1 -1
- package/src/ngtsc/annotations/directive/src/output_function.d.ts +1 -1
- package/src/ngtsc/annotations/directive/src/query_functions.d.ts +1 -1
- package/src/ngtsc/annotations/index.d.ts +1 -1
- package/src/ngtsc/diagnostics/src/error_code.d.ts +5 -0
- package/src/ngtsc/docs/src/entities.d.ts +36 -1
- package/src/ngtsc/docs/src/function_extractor.d.ts +3 -2
- package/src/ngtsc/docs/src/initializer_api_function_extractor.d.ts +24 -0
- package/src/ngtsc/imports/index.d.ts +1 -1
- package/src/ngtsc/imports/src/core.d.ts +0 -9
- package/src/ngtsc/imports/src/patch_alias_reference_resolution.d.ts +3 -1
- package/src/ngtsc/reflection/src/host.d.ts +13 -3
- package/src/ngtsc/reflection/src/typescript.d.ts +8 -1
- package/src/ngtsc/reflection/src/util.d.ts +6 -1
- package/src/ngtsc/transform/index.d.ts +0 -1
- package/src/ngtsc/transform/src/declaration.d.ts +1 -1
- package/src/ngtsc/translator/index.d.ts +2 -2
- package/src/ngtsc/translator/src/api/import_generator.d.ts +22 -10
- package/src/ngtsc/translator/src/import_manager/check_unique_identifier_name.d.ts +13 -0
- package/src/ngtsc/translator/src/import_manager/import_manager.d.ts +94 -0
- package/src/ngtsc/translator/src/import_manager/import_typescript_transform.d.ts +17 -0
- package/src/ngtsc/translator/src/import_manager/reuse_generated_imports.d.ts +32 -0
- package/src/ngtsc/translator/src/import_manager/reuse_source_file_imports.d.ts +38 -0
- package/src/ngtsc/translator/src/translator.d.ts +3 -2
- package/src/ngtsc/translator/src/type_translator.d.ts +1 -1
- package/src/ngtsc/translator/src/typescript_translator.d.ts +2 -2
- package/src/ngtsc/typecheck/src/reference_emit_environment.d.ts +1 -1
- package/src/ngtsc/typecheck/src/ts_util.d.ts +0 -2
- package/src/transformers/jit_transforms/initializer_api_transforms/transform_api.d.ts +4 -4
- package/bundles/chunk-3ESFLGKJ.js.map +0 -6
- package/bundles/chunk-6X7GQ6BQ.js.map +0 -6
- package/bundles/chunk-E5DF5SRS.js.map +0 -6
- package/bundles/chunk-VH6EDOMC.js.map +0 -6
- package/src/ngtsc/transform/src/utils.d.ts +0 -15
- package/src/ngtsc/translator/src/import_manager.d.ts +0 -47
- /package/bundles/{chunk-F2QV65AH.js.map → chunk-VXEF7SDM.js.map} +0 -0
package/index.d.ts
CHANGED
|
@@ -13,4 +13,5 @@ export { OptimizeFor } from './src/ngtsc/typecheck/api';
|
|
|
13
13
|
export { ConsoleLogger, Logger, LogLevel } from './src/ngtsc/logging';
|
|
14
14
|
export { NodeJSFileSystem } from './src/ngtsc/file_system';
|
|
15
15
|
export * from './src/ngtsc/docs/src/entities';
|
|
16
|
+
export * from './src/ngtsc/docs';
|
|
16
17
|
export { isLocalCompilationDiagnostics } from './src/ngtsc/diagnostics';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { MaybeForwardRefExpression, outputAst as o, R3DeclareDependencyMetadata, R3DependencyMetadata, R3Reference } from '@angular/compiler';
|
|
9
9
|
import { AstObject, AstValue } from '../../ast/ast_value';
|
|
10
|
-
export declare const PLACEHOLDER_VERSION = "17.3.
|
|
10
|
+
export declare const PLACEHOLDER_VERSION = "17.3.2";
|
|
11
11
|
export declare const SHOULD_USE_TEMPLATE_PIPELINE_FOR_LINKER = true;
|
|
12
12
|
export declare function wrapReference<TExpression>(wrapped: o.WrappedNodeExpr<TExpression>): R3Reference;
|
|
13
13
|
/**
|
|
@@ -17,9 +17,9 @@ export declare class Translator<TStatement, TExpression> {
|
|
|
17
17
|
/**
|
|
18
18
|
* Translate the given output AST in the context of an expression.
|
|
19
19
|
*/
|
|
20
|
-
translateExpression(expression: o.Expression, imports: ImportGenerator<TExpression>, options?: TranslatorOptions<TExpression>): TExpression;
|
|
20
|
+
translateExpression(expression: o.Expression, imports: ImportGenerator<null, TExpression>, options?: TranslatorOptions<TExpression>): TExpression;
|
|
21
21
|
/**
|
|
22
22
|
* Translate the given output AST in the context of a statement.
|
|
23
23
|
*/
|
|
24
|
-
translateStatement(statement: o.Statement, imports: ImportGenerator<TExpression>, options?: TranslatorOptions<TExpression>): TStatement;
|
|
24
|
+
translateStatement(statement: o.Statement, imports: ImportGenerator<null, TExpression>, options?: TranslatorOptions<TExpression>): TStatement;
|
|
25
25
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
-
import { ImportGenerator,
|
|
8
|
+
import { AstFactory, ImportGenerator, ImportRequest } from '../../src/ngtsc/translator';
|
|
9
9
|
/**
|
|
10
10
|
* A class that is used to generate imports when translating from Angular Output AST to an AST to
|
|
11
11
|
* render, such as Babel.
|
|
@@ -14,10 +14,10 @@ import { ImportGenerator, NamedImport } from '../../src/ngtsc/translator';
|
|
|
14
14
|
* must be achieved by property access on an `ng` namespace identifier, which is passed in via the
|
|
15
15
|
* constructor.
|
|
16
16
|
*/
|
|
17
|
-
export declare class LinkerImportGenerator<TExpression> implements ImportGenerator<TExpression> {
|
|
17
|
+
export declare class LinkerImportGenerator<TStatement, TExpression> implements ImportGenerator<null, TExpression> {
|
|
18
|
+
private factory;
|
|
18
19
|
private ngImport;
|
|
19
|
-
constructor(ngImport: TExpression);
|
|
20
|
-
|
|
21
|
-
generateNamedImport(moduleName: string, originalSymbol: string): NamedImport<TExpression>;
|
|
20
|
+
constructor(factory: AstFactory<TStatement, TExpression>, ngImport: TExpression);
|
|
21
|
+
addImport(request: ImportRequest<null>): TExpression;
|
|
22
22
|
private assertModuleName;
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/compiler-cli",
|
|
3
|
-
"version": "17.3.
|
|
3
|
+
"version": "17.3.2",
|
|
4
4
|
"description": "Angular - the compiler CLI for Node.js",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"yargs": "^17.2.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@angular/compiler": "17.3.
|
|
56
|
+
"@angular/compiler": "17.3.2",
|
|
57
57
|
"typescript": ">=5.2 <5.5"
|
|
58
58
|
},
|
|
59
59
|
"repository": {
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import { ClassMember } from '../../../reflection';
|
|
9
|
+
import { InitializerFunctionMetadata } from './initializer_functions';
|
|
10
|
+
/**
|
|
11
|
+
* Validates that the initializer member is compatible with the given class
|
|
12
|
+
* member in terms of field access and visibility.
|
|
13
|
+
*
|
|
14
|
+
* @throws {FatalDiagnosticError} If the recognized initializer API is
|
|
15
|
+
* incompatible.
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateAccessOfInitializerApiMember({ api, call }: InitializerFunctionMetadata, member: Pick<ClassMember, 'accessLevel'>): void;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import ts from 'typescript';
|
|
9
9
|
import { ImportedSymbolsTracker } from '../../../imports';
|
|
10
|
-
import {
|
|
10
|
+
import { ClassMemberAccessLevel, ReflectionHost } from '../../../reflection';
|
|
11
11
|
/**
|
|
12
12
|
* @fileoverview
|
|
13
13
|
*
|
|
@@ -20,14 +20,18 @@ import { ClassMember, ReflectionHost } from '../../../reflection';
|
|
|
20
20
|
* declared through initializer APIs.
|
|
21
21
|
*/
|
|
22
22
|
export interface InitializerApiFunction {
|
|
23
|
+
/** Module name where the initializer function is imported from. */
|
|
23
24
|
owningModule: '@angular/core' | '@angular/core/rxjs-interop';
|
|
25
|
+
/** Export name of the initializer function. */
|
|
24
26
|
functionName: ('input' | 'model' | 'output' | 'outputFromObservable' | 'viewChild' | 'viewChildren' | 'contentChild' | 'contentChildren');
|
|
27
|
+
/** Class member access levels compatible with the API. */
|
|
28
|
+
allowedAccessLevels: ClassMemberAccessLevel[];
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
31
|
* Metadata describing an Angular class member that was recognized through
|
|
28
32
|
* a function initializer. Like `input`, `input.required` or `viewChild`.
|
|
29
33
|
*/
|
|
30
|
-
interface InitializerFunctionMetadata {
|
|
34
|
+
export interface InitializerFunctionMetadata {
|
|
31
35
|
/** Initializer API function that was recognized. */
|
|
32
36
|
api: InitializerApiFunction;
|
|
33
37
|
/** Node referring to the call expression. */
|
|
@@ -36,13 +40,13 @@ interface InitializerFunctionMetadata {
|
|
|
36
40
|
isRequired: boolean;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
|
-
* Attempts to identify an Angular
|
|
40
|
-
* its initializer referring to a given initializer API function.
|
|
43
|
+
* Attempts to identify an Angular initializer function call.
|
|
41
44
|
*
|
|
42
45
|
* Note that multiple possible initializer API function names can be specified,
|
|
43
46
|
* allowing for checking multiple types in one pass.
|
|
47
|
+
*
|
|
48
|
+
* @returns The parsed initializer API, or null if none was found.
|
|
44
49
|
*/
|
|
45
|
-
export declare function
|
|
50
|
+
export declare function tryParseInitializerApi<Functions extends InitializerApiFunction[]>(functions: Functions, expression: ts.Expression, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): (InitializerFunctionMetadata & {
|
|
46
51
|
api: Functions[number];
|
|
47
52
|
} | null);
|
|
48
|
-
export {};
|
|
@@ -12,4 +12,4 @@ import { ClassMember, ReflectionHost } from '../../../reflection';
|
|
|
12
12
|
* Attempts to parse a signal input class member. Returns the parsed
|
|
13
13
|
* input mapping if possible.
|
|
14
14
|
*/
|
|
15
|
-
export declare function tryParseSignalInputMapping(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): InputMapping | null;
|
|
15
|
+
export declare function tryParseSignalInputMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): InputMapping | null;
|
|
@@ -11,4 +11,4 @@ import { ClassMember, ReflectionHost } from '../../../reflection';
|
|
|
11
11
|
/**
|
|
12
12
|
* Attempts to parse a model class member. Returns the parsed model mapping if possible.
|
|
13
13
|
*/
|
|
14
|
-
export declare function tryParseSignalModelMapping(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): ModelMapping | null;
|
|
14
|
+
export declare function tryParseSignalModelMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): ModelMapping | null;
|
|
@@ -13,7 +13,7 @@ import { ClassMember, ReflectionHost } from '../../../reflection';
|
|
|
13
13
|
* Attempts to parse a signal output class member. Returns the parsed
|
|
14
14
|
* input mapping if possible.
|
|
15
15
|
*/
|
|
16
|
-
export declare function tryParseInitializerBasedOutput(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
|
|
16
|
+
export declare function tryParseInitializerBasedOutput(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
|
|
17
17
|
call: ts.CallExpression;
|
|
18
18
|
metadata: InputOrOutput;
|
|
19
19
|
} | null;
|
|
@@ -19,7 +19,7 @@ export type QueryFunctionName = 'viewChild' | 'contentChild' | 'viewChildren' |
|
|
|
19
19
|
*
|
|
20
20
|
* @returns Resolved query metadata, or null if no query is declared.
|
|
21
21
|
*/
|
|
22
|
-
export declare function tryParseSignalQueryFromInitializer(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
|
|
22
|
+
export declare function tryParseSignalQueryFromInitializer(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
|
|
23
23
|
name: QueryFunctionName;
|
|
24
24
|
metadata: R3QueryMetadata;
|
|
25
25
|
call: ts.CallExpression;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { forwardRefResolver, getAngularDecorators, isAngularDecorator, NoopReferencesRegistry, ReferencesRegistry, ResourceLoader, ResourceLoaderContext } from './common';
|
|
9
9
|
export { ComponentDecoratorHandler } from './component';
|
|
10
|
-
export { DirectiveDecoratorHandler, queryDecoratorNames, QueryFunctionName, tryParseInitializerBasedOutput, tryParseSignalInputMapping, tryParseSignalModelMapping, tryParseSignalQueryFromInitializer } from './directive';
|
|
10
|
+
export { DirectiveDecoratorHandler, InitializerApiFunction, queryDecoratorNames, QueryFunctionName, tryParseInitializerApi, tryParseInitializerBasedOutput, tryParseSignalInputMapping, tryParseSignalModelMapping, tryParseSignalQueryFromInitializer } from './directive';
|
|
11
11
|
export { NgModuleDecoratorHandler } from './ng_module';
|
|
12
12
|
export { InjectableDecoratorHandler } from './src/injectable';
|
|
13
13
|
export { PipeDecoratorHandler } from './src/pipe';
|
|
@@ -37,6 +37,11 @@ export declare enum ErrorCode {
|
|
|
37
37
|
* function, but is still detected unexpectedly.
|
|
38
38
|
*/
|
|
39
39
|
INITIALIZER_API_NO_REQUIRED_FUNCTION = 1052,
|
|
40
|
+
/**
|
|
41
|
+
* Raised whenever an initializer API is used on a class member
|
|
42
|
+
* and the given access modifiers (e.g. `private`) are not allowed.
|
|
43
|
+
*/
|
|
44
|
+
INITIALIZER_API_DISALLOWED_MEMBER_VISIBILITY = 1053,
|
|
40
45
|
/**
|
|
41
46
|
* An Angular feature, like inputs, outputs or queries is incorrectly
|
|
42
47
|
* declared on a static member.
|
|
@@ -19,7 +19,8 @@ export declare enum EntryType {
|
|
|
19
19
|
NgModule = "ng_module",
|
|
20
20
|
Pipe = "pipe",
|
|
21
21
|
TypeAlias = "type_alias",
|
|
22
|
-
UndecoratedClass = "undecorated_class"
|
|
22
|
+
UndecoratedClass = "undecorated_class",
|
|
23
|
+
InitializerApiFunction = "initializer_api_function"
|
|
23
24
|
}
|
|
24
25
|
/** Types of class members */
|
|
25
26
|
export declare enum MemberType {
|
|
@@ -133,3 +134,37 @@ export interface ParameterEntry {
|
|
|
133
134
|
isOptional: boolean;
|
|
134
135
|
isRestParam: boolean;
|
|
135
136
|
}
|
|
137
|
+
/** Interface describing a function with overload signatures. */
|
|
138
|
+
export interface FunctionWithOverloads {
|
|
139
|
+
name: string;
|
|
140
|
+
signatures: FunctionEntry[];
|
|
141
|
+
implementation: FunctionEntry | null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Docs entry describing an initializer API function.
|
|
145
|
+
*
|
|
146
|
+
* An initializer API function is a function that is invoked as
|
|
147
|
+
* initializer of class members. The function may hold additional
|
|
148
|
+
* sub functions, like `.required`.
|
|
149
|
+
*
|
|
150
|
+
* Known popular initializer APIs are `input()`, `output()`, `model()`.
|
|
151
|
+
*
|
|
152
|
+
* Initializer APIs are often constructed typed in complex ways so this
|
|
153
|
+
* entry type allows for readable "parsing" and interpretation of such
|
|
154
|
+
* constructs. Initializer APIs are explicitly denoted via a JSDoc tag.
|
|
155
|
+
*/
|
|
156
|
+
export interface InitializerApiFunctionEntry extends DocEntry {
|
|
157
|
+
callFunction: FunctionWithOverloads;
|
|
158
|
+
subFunctions: FunctionWithOverloads[];
|
|
159
|
+
__docsMetadata__?: {
|
|
160
|
+
/**
|
|
161
|
+
* Whether types should be shown in the signature
|
|
162
|
+
* preview of docs.
|
|
163
|
+
*
|
|
164
|
+
* By default, for readability purposes, types are omitted, but
|
|
165
|
+
* shorter initializer API functions like `output` may decide to
|
|
166
|
+
* render these types.
|
|
167
|
+
*/
|
|
168
|
+
showTypesInSignaturePreview?: boolean;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import ts from 'typescript';
|
|
9
|
-
import { FunctionEntry } from './entities';
|
|
9
|
+
import { FunctionEntry, ParameterEntry } from './entities';
|
|
10
10
|
export type FunctionLike = ts.FunctionDeclaration | ts.MethodDeclaration | ts.MethodSignature | ts.CallSignatureDeclaration | ts.ConstructSignatureDeclaration;
|
|
11
11
|
export declare class FunctionExtractor {
|
|
12
12
|
private name;
|
|
@@ -14,8 +14,9 @@ export declare class FunctionExtractor {
|
|
|
14
14
|
private typeChecker;
|
|
15
15
|
constructor(name: string, declaration: FunctionLike, typeChecker: ts.TypeChecker);
|
|
16
16
|
extract(): FunctionEntry;
|
|
17
|
-
private extractAllParams;
|
|
18
17
|
/** Gets all overloads for the function (excluding this extractor's FunctionDeclaration). */
|
|
19
18
|
getOverloads(): ts.FunctionDeclaration[];
|
|
20
19
|
private getSymbol;
|
|
21
20
|
}
|
|
21
|
+
/** Extracts parameters of the given parameter declaration AST nodes. */
|
|
22
|
+
export declare function extractAllParams(params: ts.NodeArray<ts.ParameterDeclaration>, typeChecker: ts.TypeChecker): ParameterEntry[];
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import ts from 'typescript';
|
|
9
|
+
import { InitializerApiFunctionEntry } from './entities';
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether the given node corresponds to an initializer API function.
|
|
12
|
+
*
|
|
13
|
+
* An initializer API function is a function declaration or variable declaration
|
|
14
|
+
* that is explicitly annotated with `@initializerApiFunction`.
|
|
15
|
+
*
|
|
16
|
+
* Note: The node may be a function overload signature that is automatically
|
|
17
|
+
* resolved to its implementation to detect the JSDoc tag.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isInitializerApiFunction(node: ts.Node, typeChecker: ts.TypeChecker): node is ts.VariableDeclaration | ts.FunctionDeclaration;
|
|
20
|
+
/**
|
|
21
|
+
* Extracts the given node as initializer API function and returns
|
|
22
|
+
* a docs entry that can be rendered to represent the API function.
|
|
23
|
+
*/
|
|
24
|
+
export declare function extractInitializerApiFunction(node: ts.VariableDeclaration | ts.FunctionDeclaration, typeChecker: ts.TypeChecker): InitializerApiFunctionEntry;
|
|
@@ -12,7 +12,7 @@ export { DeferredSymbolTracker } from './src/deferred_symbol_tracker';
|
|
|
12
12
|
export { AbsoluteModuleStrategy, assertSuccessfulReferenceEmit, EmittedReference, FailedEmitResult, ImportedFile, ImportFlags, LocalIdentifierStrategy, LogicalProjectStrategy, ReferenceEmitKind, ReferenceEmitResult, ReferenceEmitStrategy, ReferenceEmitter, RelativePathStrategy, UnifiedModulesStrategy } from './src/emitter';
|
|
13
13
|
export { ImportedSymbolsTracker } from './src/imported_symbols_tracker';
|
|
14
14
|
export { LocalCompilationExtraImportsTracker } from './src/local_compilation_extra_imports_tracker';
|
|
15
|
-
export { isAliasImportDeclaration, loadIsReferencedAliasDeclarationPatch } from './src/patch_alias_reference_resolution';
|
|
15
|
+
export { AliasImportDeclaration, isAliasImportDeclaration, loadIsReferencedAliasDeclarationPatch } from './src/patch_alias_reference_resolution';
|
|
16
16
|
export { Reexport } from './src/reexport';
|
|
17
17
|
export { OwningModule, Reference } from './src/references';
|
|
18
18
|
export { ModuleResolver } from './src/resolver';
|
|
@@ -9,13 +9,6 @@
|
|
|
9
9
|
* Rewrites imports of symbols being written into generated code.
|
|
10
10
|
*/
|
|
11
11
|
export interface ImportRewriter {
|
|
12
|
-
/**
|
|
13
|
-
* Should the given symbol be imported at all?
|
|
14
|
-
*
|
|
15
|
-
* If `true`, the symbol should be imported from the given specifier. If `false`, the symbol
|
|
16
|
-
* should be referenced directly, without an import.
|
|
17
|
-
*/
|
|
18
|
-
shouldImportSymbol(symbol: string, specifier: string): boolean;
|
|
19
12
|
/**
|
|
20
13
|
* Optionally rewrite a reference to an imported symbol, changing either the binding prefix or the
|
|
21
14
|
* symbol name itself.
|
|
@@ -30,7 +23,6 @@ export interface ImportRewriter {
|
|
|
30
23
|
* `ImportRewriter` that does no rewriting.
|
|
31
24
|
*/
|
|
32
25
|
export declare class NoopImportRewriter implements ImportRewriter {
|
|
33
|
-
shouldImportSymbol(symbol: string, specifier: string): boolean;
|
|
34
26
|
rewriteSymbol(symbol: string, specifier: string): string;
|
|
35
27
|
rewriteSpecifier(specifier: string, inContextOfFile: string): string;
|
|
36
28
|
}
|
|
@@ -41,7 +33,6 @@ export declare class NoopImportRewriter implements ImportRewriter {
|
|
|
41
33
|
export declare class R3SymbolsImportRewriter implements ImportRewriter {
|
|
42
34
|
private r3SymbolsPath;
|
|
43
35
|
constructor(r3SymbolsPath: string);
|
|
44
|
-
shouldImportSymbol(symbol: string, specifier: string): boolean;
|
|
45
36
|
rewriteSymbol(symbol: string, specifier: string): string;
|
|
46
37
|
rewriteSpecifier(specifier: string, inContextOfFile: string): string;
|
|
47
38
|
}
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import ts from 'typescript';
|
|
9
|
+
/** Possible alias import declarations */
|
|
10
|
+
export type AliasImportDeclaration = ts.ImportSpecifier | ts.NamespaceImport | ts.ImportClause;
|
|
9
11
|
/**
|
|
10
12
|
* Patches the alias declaration reference resolution for a given transformation context
|
|
11
13
|
* so that TypeScript knows about the specified alias declarations being referenced.
|
|
@@ -58,4 +60,4 @@ export declare function loadIsReferencedAliasDeclarationPatch(context: ts.Transf
|
|
|
58
60
|
* declarations can be import specifiers, namespace imports or import clauses
|
|
59
61
|
* as these do not declare an actual symbol but just point to a target declaration.
|
|
60
62
|
*/
|
|
61
|
-
export declare function isAliasImportDeclaration(node: ts.Node): node is
|
|
63
|
+
export declare function isAliasImportDeclaration(node: ts.Node): node is AliasImportDeclaration;
|
|
@@ -77,6 +77,14 @@ export declare enum ClassMemberKind {
|
|
|
77
77
|
Property = 3,
|
|
78
78
|
Method = 4
|
|
79
79
|
}
|
|
80
|
+
/** Possible access levels of a class member. */
|
|
81
|
+
export declare enum ClassMemberAccessLevel {
|
|
82
|
+
PublicWritable = 0,
|
|
83
|
+
PublicReadonly = 1,
|
|
84
|
+
Protected = 2,
|
|
85
|
+
Private = 3,
|
|
86
|
+
EcmaScriptPrivate = 4
|
|
87
|
+
}
|
|
80
88
|
/**
|
|
81
89
|
* A member of a class, such as a property, method, or constructor.
|
|
82
90
|
*/
|
|
@@ -89,6 +97,8 @@ export interface ClassMember {
|
|
|
89
97
|
* Indication of which type of member this is (property, method, etc).
|
|
90
98
|
*/
|
|
91
99
|
kind: ClassMemberKind;
|
|
100
|
+
/** Access level describing the class member modifiers. */
|
|
101
|
+
accessLevel: ClassMemberAccessLevel;
|
|
92
102
|
/**
|
|
93
103
|
* TypeScript `ts.TypeNode` representing the type of the member, or `null` if not present or
|
|
94
104
|
* applicable.
|
|
@@ -99,13 +109,13 @@ export interface ClassMember {
|
|
|
99
109
|
*/
|
|
100
110
|
name: string;
|
|
101
111
|
/**
|
|
102
|
-
* TypeScript `ts.Identifier` or `ts.StringLiteral` representing the
|
|
103
|
-
* if no such node is present.
|
|
112
|
+
* TypeScript `ts.Identifier`, `ts.PrivateIdentifier`, or `ts.StringLiteral` representing the
|
|
113
|
+
* name of the member, or `null` if no such node is present.
|
|
104
114
|
*
|
|
105
115
|
* The `nameNode` is useful in writing references to this member that will be correctly source-
|
|
106
116
|
* mapped back to the original file.
|
|
107
117
|
*/
|
|
108
|
-
nameNode: ts.Identifier | ts.StringLiteral | null;
|
|
118
|
+
nameNode: ts.Identifier | ts.PrivateIdentifier | ts.StringLiteral | null;
|
|
109
119
|
/**
|
|
110
120
|
* TypeScript `ts.Expression` which represents the value of the member.
|
|
111
121
|
*
|
|
@@ -52,7 +52,6 @@ export declare class TypeScriptReflectionHost implements ReflectionHost {
|
|
|
52
52
|
*/
|
|
53
53
|
protected getDeclarationOfSymbol(symbol: ts.Symbol, originalId: ts.Identifier | null): Declaration | null;
|
|
54
54
|
private _reflectDecorator;
|
|
55
|
-
private _reflectMember;
|
|
56
55
|
/**
|
|
57
56
|
* Get the set of declarations declared in `file` which are exported.
|
|
58
57
|
*/
|
|
@@ -69,6 +68,14 @@ export declare function filterToMembersWithDecorator(members: ClassMember[], nam
|
|
|
69
68
|
member: ClassMember;
|
|
70
69
|
decorators: Decorator[];
|
|
71
70
|
}[];
|
|
71
|
+
/**
|
|
72
|
+
* Reflects a class element and returns static information about the
|
|
73
|
+
* class member.
|
|
74
|
+
*
|
|
75
|
+
* Note: Decorator information is not included in this helper as it relies
|
|
76
|
+
* on type checking to resolve originating import.
|
|
77
|
+
*/
|
|
78
|
+
export declare function reflectClassMember(node: ts.ClassElement): Omit<ClassMember, 'decorators'> | null;
|
|
72
79
|
export declare function findMember(members: ClassMember[], name: string, isStatic?: boolean): ClassMember | null;
|
|
73
80
|
export declare function reflectObjectLiteral(node: ts.ObjectLiteralExpression): Map<string, ts.Expression>;
|
|
74
81
|
/**
|
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
import ts from 'typescript';
|
|
9
|
-
import { ClassDeclaration } from './host';
|
|
9
|
+
import { ClassDeclaration, ClassMemberAccessLevel } from './host';
|
|
10
10
|
export declare function isNamedClassDeclaration(node: ts.Node): node is ClassDeclaration<ts.ClassDeclaration>;
|
|
11
11
|
export declare function isNamedFunctionDeclaration(node: ts.Node): node is ClassDeclaration<ts.FunctionDeclaration>;
|
|
12
12
|
export declare function isNamedVariableDeclaration(node: ts.Node): node is ClassDeclaration<ts.VariableDeclaration>;
|
|
13
|
+
/**
|
|
14
|
+
* Converts the given class member access level to a string.
|
|
15
|
+
* Useful fo error messages.
|
|
16
|
+
*/
|
|
17
|
+
export declare function classMemberAccessLevelToString(level: ClassMemberAccessLevel): string;
|
|
@@ -11,4 +11,3 @@ export { ClassRecord, TraitCompiler } from './src/compilation';
|
|
|
11
11
|
export { declarationTransformFactory, DtsTransformRegistry, IvyDeclarationDtsTransform } from './src/declaration';
|
|
12
12
|
export { AnalyzedTrait, PendingTrait, ResolvedTrait, SkippedTrait, Trait, TraitState } from './src/trait';
|
|
13
13
|
export { ivyTransformFactory } from './src/transform';
|
|
14
|
-
export { addImports } from './src/utils';
|
|
@@ -24,7 +24,7 @@ export declare class DtsTransformRegistry {
|
|
|
24
24
|
*/
|
|
25
25
|
getAllTransforms(sf: ts.SourceFile): DtsTransform[] | null;
|
|
26
26
|
}
|
|
27
|
-
export declare function declarationTransformFactory(transformRegistry: DtsTransformRegistry, reflector: ReflectionHost, refEmitter: ReferenceEmitter, importRewriter: ImportRewriter
|
|
27
|
+
export declare function declarationTransformFactory(transformRegistry: DtsTransformRegistry, reflector: ReflectionHost, refEmitter: ReferenceEmitter, importRewriter: ImportRewriter): ts.TransformerFactory<ts.SourceFile>;
|
|
28
28
|
export interface IvyDeclarationField {
|
|
29
29
|
name: string;
|
|
30
30
|
type: Type;
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
export { AstFactory, BinaryOperator, LeadingComment, ObjectLiteralProperty, SourceMapLocation, SourceMapRange, TemplateElement, TemplateLiteral, UnaryOperator, VariableDeclarationType } from './src/api/ast_factory';
|
|
9
|
-
export { ImportGenerator,
|
|
9
|
+
export { ImportGenerator, ImportRequest } from './src/api/import_generator';
|
|
10
10
|
export { Context } from './src/context';
|
|
11
|
-
export {
|
|
11
|
+
export { ImportManager, ImportManagerConfig, presetImportManagerForceNamespaceImports } from './src/import_manager/import_manager';
|
|
12
12
|
export { ExpressionTranslatorVisitor, RecordWrappedNodeFn, TranslatorOptions } from './src/translator';
|
|
13
13
|
export { canEmitType, TypeEmitter, TypeReferenceTranslator } from './src/type_emitter';
|
|
14
14
|
export { translateType } from './src/type_translator';
|
|
@@ -6,14 +6,27 @@
|
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* which has been registered through the ImportGenerator.
|
|
9
|
+
* A request to import a given symbol from the given module.
|
|
11
10
|
*/
|
|
12
|
-
export interface
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export interface ImportRequest<TFile> {
|
|
12
|
+
/**
|
|
13
|
+
* Name of the export to be imported.
|
|
14
|
+
* May be `null` if a namespace import is requested.
|
|
15
|
+
*/
|
|
16
|
+
exportSymbolName: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Module specifier to be imported.
|
|
19
|
+
* May be a module name, or a file-relative path.
|
|
20
|
+
*/
|
|
21
|
+
exportModuleSpecifier: string;
|
|
22
|
+
/**
|
|
23
|
+
* File for which the import is requested for. This may
|
|
24
|
+
* be used by import generators to re-use existing imports.
|
|
25
|
+
*
|
|
26
|
+
* Import managers may also allow this to be nullable if
|
|
27
|
+
* imports are never re-used. E.g. in the linker generator.
|
|
28
|
+
*/
|
|
29
|
+
requestedFile: TFile;
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Generate import information based on the context of the code being generated.
|
|
@@ -21,7 +34,6 @@ export interface NamedImport<TExpression> {
|
|
|
21
34
|
* Implementations of these methods return a specific identifier that corresponds to the imported
|
|
22
35
|
* module.
|
|
23
36
|
*/
|
|
24
|
-
export interface ImportGenerator<TExpression> {
|
|
25
|
-
|
|
26
|
-
generateNamedImport(moduleName: string, originalSymbol: string): NamedImport<TExpression>;
|
|
37
|
+
export interface ImportGenerator<TFile, TExpression> {
|
|
38
|
+
addImport(request: ImportRequest<TFile>): TExpression;
|
|
27
39
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
import type { ImportManagerConfig } from './import_manager';
|
|
9
|
+
/**
|
|
10
|
+
* Generates a helper for `ImportManagerConfig` to generate unique identifiers
|
|
11
|
+
* for a given source file.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createGenerateUniqueIdentifierHelper(): ImportManagerConfig['generateUniqueIdentifier'];
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
import ts from 'typescript';
|
|
9
|
+
import { AliasImportDeclaration, ImportRewriter } from '../../../imports';
|
|
10
|
+
import { ImportGenerator, ImportRequest } from '../api/import_generator';
|
|
11
|
+
/** Configuration for the import manager. */
|
|
12
|
+
export interface ImportManagerConfig {
|
|
13
|
+
generateUniqueIdentifier(file: ts.SourceFile, baseName: string): ts.Identifier | null;
|
|
14
|
+
shouldUseSingleQuotes(file: ts.SourceFile): boolean;
|
|
15
|
+
rewriter: ImportRewriter | null;
|
|
16
|
+
namespaceImportPrefix: string;
|
|
17
|
+
disableOriginalSourceFileReuse: boolean;
|
|
18
|
+
forceGenerateNamespacesForNewImports: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Preset configuration for forcing namespace imports.
|
|
22
|
+
*
|
|
23
|
+
* This preset is commonly used to avoid test differences to previous
|
|
24
|
+
* versions of the `ImportManager`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const presetImportManagerForceNamespaceImports: Partial<ImportManagerConfig>;
|
|
27
|
+
/** Branded string to identify a module name. */
|
|
28
|
+
export type ModuleName = string & {
|
|
29
|
+
__moduleName: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Import manager that can be used to conveniently and efficiently generate
|
|
33
|
+
* imports It efficiently re-uses existing source file imports, or previous
|
|
34
|
+
* generated imports.
|
|
35
|
+
*
|
|
36
|
+
* These capabilities are important for efficient TypeScript transforms that
|
|
37
|
+
* minimize structural changes to the dependency graph of source files, enabling
|
|
38
|
+
* as much incremental re-use as possible.
|
|
39
|
+
*
|
|
40
|
+
* Those imports may be inserted via a TypeScript transform, or via manual string
|
|
41
|
+
* manipulation using e.g. `magic-string`.
|
|
42
|
+
*/
|
|
43
|
+
export declare class ImportManager implements ImportGenerator<ts.SourceFile, ts.Identifier | ts.PropertyAccessExpression> {
|
|
44
|
+
private _config;
|
|
45
|
+
/** List of new imports that will be inserted into given source files. */
|
|
46
|
+
private newImports;
|
|
47
|
+
private nextUniqueIndex;
|
|
48
|
+
private config;
|
|
49
|
+
private reuseSourceFileImportsTracker;
|
|
50
|
+
private reuseGeneratedImportsTracker;
|
|
51
|
+
constructor(_config?: Partial<ImportManagerConfig>);
|
|
52
|
+
/** Adds a side-effect import for the given module. */
|
|
53
|
+
addSideEffectImport(requestedFile: ts.SourceFile, moduleSpecifier: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Adds an import to the given source-file and returns a TypeScript
|
|
56
|
+
* expression that can be used to access the newly imported symbol.
|
|
57
|
+
*/
|
|
58
|
+
addImport(request: ImportRequest<ts.SourceFile> & {
|
|
59
|
+
asTypeReference: true;
|
|
60
|
+
}): ts.Identifier | ts.QualifiedName;
|
|
61
|
+
addImport(request: ImportRequest<ts.SourceFile> & {
|
|
62
|
+
asTypeReference?: undefined;
|
|
63
|
+
}): ts.Identifier | ts.PropertyAccessExpression;
|
|
64
|
+
private _generateNewImport;
|
|
65
|
+
/**
|
|
66
|
+
* Finalizes the import manager by computing all necessary import changes
|
|
67
|
+
* and returning them.
|
|
68
|
+
*
|
|
69
|
+
* Changes are collected once at the end, after all imports are requested,
|
|
70
|
+
* because this simplifies building up changes to existing imports that need
|
|
71
|
+
* to be updated, and allows more trivial re-use of previous generated imports.
|
|
72
|
+
*/
|
|
73
|
+
finalize(): {
|
|
74
|
+
affectedFiles: Set<string>;
|
|
75
|
+
updatedImports: Map<ts.NamedImports, ts.NamedImports>;
|
|
76
|
+
newImports: Map<string, ts.ImportDeclaration[]>;
|
|
77
|
+
reusedOriginalAliasDeclarations: Set<AliasImportDeclaration>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Gets a TypeScript transform for the import manager.
|
|
81
|
+
*
|
|
82
|
+
* @param extraStatementsMap Additional set of statements to be inserted
|
|
83
|
+
* for given source files after their imports. E.g. top-level constants.
|
|
84
|
+
*/
|
|
85
|
+
toTsTransform(extraStatementsMap?: Map<string, ts.Statement[]>): ts.TransformerFactory<ts.SourceFile>;
|
|
86
|
+
/**
|
|
87
|
+
* Transforms a single file as a shorthand, using {@link toTsTransform}.
|
|
88
|
+
*
|
|
89
|
+
* @param extraStatementsMap Additional set of statements to be inserted
|
|
90
|
+
* for given source files after their imports. E.g. top-level constants.
|
|
91
|
+
*/
|
|
92
|
+
transformTsFile(ctx: ts.TransformationContext, file: ts.SourceFile, extraStatementsAfterImports?: ts.Statement[]): ts.SourceFile;
|
|
93
|
+
private _getNewImportsTrackerForFile;
|
|
94
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
import ts from 'typescript';
|
|
9
|
+
import type { ImportManager } from './import_manager';
|
|
10
|
+
/**
|
|
11
|
+
* Creates a TypeScript transform for the given import manager.
|
|
12
|
+
*
|
|
13
|
+
* - The transform updates existing imports with new symbols to be added.
|
|
14
|
+
* - The transform adds new necessary imports.
|
|
15
|
+
* - The transform inserts additional optional statements after imports.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTsTransformForImportManager(manager: ImportManager, extraStatementsForFiles?: Map<string, ts.Statement[]>): ts.TransformerFactory<ts.SourceFile>;
|