@angular/compiler-cli 18.0.0-next.0 → 18.0.0-next.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.
Files changed (81) hide show
  1. package/bundles/{chunk-NB6ZWAGP.js → chunk-32GYU5L6.js} +60 -21
  2. package/bundles/chunk-32GYU5L6.js.map +6 -0
  3. package/bundles/{chunk-4A7ZWBEL.js → chunk-4CJL5R2P.js} +59 -57
  4. package/bundles/{chunk-4A7ZWBEL.js.map → chunk-4CJL5R2P.js.map} +1 -1
  5. package/bundles/{chunk-A46CQFUG.js → chunk-MTZKBEZU.js} +276 -245
  6. package/bundles/chunk-MTZKBEZU.js.map +6 -0
  7. package/bundles/{chunk-6X7GQ6BQ.js → chunk-NPXXJQN4.js} +603 -245
  8. package/bundles/chunk-NPXXJQN4.js.map +6 -0
  9. package/bundles/{chunk-64VF23SF.js → chunk-VFVLP7AO.js} +2 -2
  10. package/bundles/{chunk-SQY7XLGB.js → chunk-YMLYBTFV.js} +2225 -904
  11. package/bundles/chunk-YMLYBTFV.js.map +6 -0
  12. package/bundles/index.js +7 -5
  13. package/bundles/index.js.map +1 -1
  14. package/bundles/linker/babel/index.js +10 -3
  15. package/bundles/linker/babel/index.js.map +1 -1
  16. package/bundles/linker/index.js +2 -2
  17. package/bundles/private/migrations.js +2 -2
  18. package/bundles/private/tooling.js +3 -3
  19. package/bundles/src/bin/ng_xi18n.js +4 -4
  20. package/bundles/src/bin/ngc.js +4 -4
  21. package/bundles_metadata.json +1 -1
  22. package/index.d.ts +1 -0
  23. package/linker/babel/src/ast/babel_ast_host.d.ts +2 -1
  24. package/linker/src/ast/ast_host.d.ts +4 -0
  25. package/linker/src/ast/ast_value.d.ts +5 -0
  26. package/linker/src/ast/typescript/typescript_ast_host.d.ts +1 -0
  27. package/linker/src/file_linker/partial_linkers/partial_class_metadata_async_linker_1.d.ts +16 -0
  28. package/linker/src/file_linker/partial_linkers/partial_linker_selector.d.ts +1 -0
  29. package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
  30. package/linker/src/file_linker/translator.d.ts +2 -2
  31. package/linker/src/linker_import_generator.d.ts +5 -5
  32. package/package.json +4 -4
  33. package/src/ngtsc/annotations/component/src/handler.d.ts +1 -1
  34. package/src/ngtsc/annotations/directive/index.d.ts +1 -0
  35. package/src/ngtsc/annotations/directive/src/initializer_function_access.d.ts +17 -0
  36. package/src/ngtsc/annotations/directive/src/initializer_functions.d.ts +10 -6
  37. package/src/ngtsc/annotations/directive/src/input_function.d.ts +4 -1
  38. package/src/ngtsc/annotations/directive/src/model_function.d.ts +4 -1
  39. package/src/ngtsc/annotations/directive/src/output_function.d.ts +4 -1
  40. package/src/ngtsc/annotations/directive/src/query_functions.d.ts +8 -2
  41. package/src/ngtsc/annotations/index.d.ts +1 -1
  42. package/src/ngtsc/core/src/core_version.d.ts +11 -0
  43. package/src/ngtsc/diagnostics/src/error_code.d.ts +19 -0
  44. package/src/ngtsc/docs/src/entities.d.ts +36 -1
  45. package/src/ngtsc/docs/src/function_extractor.d.ts +3 -2
  46. package/src/ngtsc/docs/src/initializer_api_function_extractor.d.ts +24 -0
  47. package/src/ngtsc/docs/src/internal.d.ts +8 -0
  48. package/src/ngtsc/imports/index.d.ts +1 -1
  49. package/src/ngtsc/imports/src/core.d.ts +0 -9
  50. package/src/ngtsc/imports/src/imported_symbols_tracker.d.ts +13 -0
  51. package/src/ngtsc/imports/src/patch_alias_reference_resolution.d.ts +3 -1
  52. package/src/ngtsc/reflection/src/host.d.ts +13 -3
  53. package/src/ngtsc/reflection/src/typescript.d.ts +8 -1
  54. package/src/ngtsc/reflection/src/util.d.ts +6 -1
  55. package/src/ngtsc/transform/index.d.ts +0 -1
  56. package/src/ngtsc/transform/src/declaration.d.ts +1 -1
  57. package/src/ngtsc/translator/index.d.ts +2 -2
  58. package/src/ngtsc/translator/src/api/import_generator.d.ts +22 -10
  59. package/src/ngtsc/translator/src/import_manager/check_unique_identifier_name.d.ts +13 -0
  60. package/src/ngtsc/translator/src/import_manager/import_manager.d.ts +94 -0
  61. package/src/ngtsc/translator/src/import_manager/import_typescript_transform.d.ts +17 -0
  62. package/src/ngtsc/translator/src/import_manager/reuse_generated_imports.d.ts +32 -0
  63. package/src/ngtsc/translator/src/import_manager/reuse_source_file_imports.d.ts +38 -0
  64. package/src/ngtsc/translator/src/translator.d.ts +3 -2
  65. package/src/ngtsc/translator/src/type_translator.d.ts +1 -1
  66. package/src/ngtsc/translator/src/typescript_translator.d.ts +2 -2
  67. package/src/ngtsc/typecheck/src/oob.d.ts +3 -3
  68. package/src/ngtsc/typecheck/src/reference_emit_environment.d.ts +1 -1
  69. package/src/ngtsc/typecheck/src/ts_util.d.ts +0 -2
  70. package/src/ngtsc/validation/index.d.ts +8 -0
  71. package/src/ngtsc/validation/src/rules/api.d.ts +24 -0
  72. package/src/ngtsc/validation/src/rules/initializer_api_usage_rule.d.ts +21 -0
  73. package/src/ngtsc/validation/src/source_file_validator.d.ts +22 -0
  74. package/src/transformers/jit_transforms/initializer_api_transforms/transform_api.d.ts +4 -4
  75. package/bundles/chunk-6X7GQ6BQ.js.map +0 -6
  76. package/bundles/chunk-A46CQFUG.js.map +0 -6
  77. package/bundles/chunk-NB6ZWAGP.js.map +0 -6
  78. package/bundles/chunk-SQY7XLGB.js.map +0 -6
  79. package/src/ngtsc/transform/src/utils.d.ts +0 -15
  80. package/src/ngtsc/translator/src/import_manager.d.ts +0 -47
  81. /package/bundles/{chunk-64VF23SF.js.map → chunk-VFVLP7AO.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, absoluteFrom } 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';
@@ -24,8 +24,9 @@ export declare class BabelAstHost implements AstHost<t.Expression> {
24
24
  parseArrayLiteral(array: t.Expression): t.Expression[];
25
25
  isObjectLiteral: typeof t.isObjectExpression;
26
26
  parseObjectLiteral(obj: t.Expression): Map<string, t.Expression>;
27
- isFunctionExpression(node: t.Expression): node is Extract<t.Function, t.Expression>;
27
+ isFunctionExpression(node: t.Expression): node is Extract<t.Function | t.ArrowFunctionExpression, t.Expression>;
28
28
  parseReturnValue(fn: t.Expression): t.Expression;
29
+ parseParameters(fn: t.Expression): t.Expression[];
29
30
  isCallExpression: typeof t.isCallExpression;
30
31
  parseCallee(call: t.Expression): t.Expression;
31
32
  parseArguments(call: t.Expression): t.Expression[];
@@ -76,6 +76,10 @@ export interface AstHost<TExpression> {
76
76
  * statement, extracting the returned expression, or throw if it is not possible.
77
77
  */
78
78
  parseReturnValue(fn: TExpression): TExpression;
79
+ /**
80
+ * Returns the parameter expressions for the function, or throw if it is not a function.
81
+ */
82
+ parseParameters(fn: TExpression): TExpression[];
79
83
  /**
80
84
  * Return true if the given expression is a call expression, or false otherwise.
81
85
  */
@@ -188,6 +188,11 @@ export declare class AstValue<T, TExpression> {
188
188
  * it is not a function expression.
189
189
  */
190
190
  getFunctionReturnValue<R>(this: ConformsTo<this, T, Function>): AstValue<R, TExpression>;
191
+ /**
192
+ * Extract the parameters from this value as a function expression, or error if it is not a
193
+ * function expression.
194
+ */
195
+ getFunctionParameters<R>(this: ConformsTo<this, T, Function>): AstValue<R, TExpression>[];
191
196
  isCallExpression(): boolean;
192
197
  getCallee(): AstValue<unknown, TExpression>;
193
198
  getArguments(): AstValue<unknown, TExpression>[];
@@ -31,6 +31,7 @@ export declare class TypeScriptAstHost implements AstHost<ts.Expression> {
31
31
  parseObjectLiteral(obj: ts.Expression): Map<string, ts.Expression>;
32
32
  isFunctionExpression(node: ts.Expression): node is ts.FunctionExpression | ts.ArrowFunction;
33
33
  parseReturnValue(fn: ts.Expression): ts.Expression;
34
+ parseParameters(fn: ts.Expression): ts.Expression[];
34
35
  isCallExpression: typeof ts.isCallExpression;
35
36
  parseCallee(call: ts.Expression): ts.Expression;
36
37
  parseArguments(call: ts.Expression): ts.Expression[];
@@ -0,0 +1,16 @@
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 { ConstantPool, R3DeclareClassMetadataAsync } from '@angular/compiler';
9
+ import { AstObject } from '../../ast/ast_value';
10
+ import { LinkedDefinition, PartialLinker } from './partial_linker';
11
+ /**
12
+ * A `PartialLinker` that is designed to process `ɵɵngDeclareClassMetadataAsync()` call expressions.
13
+ */
14
+ export declare class PartialClassMetadataAsyncLinkerVersion1<TExpression> implements PartialLinker<TExpression> {
15
+ linkPartialDeclaration(constantPool: ConstantPool, metaObj: AstObject<R3DeclareClassMetadataAsync, TExpression>): LinkedDefinition;
16
+ }
@@ -18,6 +18,7 @@ export declare const ɵɵngDeclareInjectable = "\u0275\u0275ngDeclareInjectable"
18
18
  export declare const ɵɵngDeclareInjector = "\u0275\u0275ngDeclareInjector";
19
19
  export declare const ɵɵngDeclareNgModule = "\u0275\u0275ngDeclareNgModule";
20
20
  export declare const ɵɵngDeclarePipe = "\u0275\u0275ngDeclarePipe";
21
+ export declare const ɵɵngDeclareClassMetadataAsync = "\u0275\u0275ngDeclareClassMetadataAsync";
21
22
  export declare const declarationFunctions: string[];
22
23
  export interface LinkerRange<TExpression> {
23
24
  range: semver.Range;
@@ -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 = "18.0.0-next.0";
10
+ export declare const PLACEHOLDER_VERSION = "18.0.0-next.2";
11
11
  export declare function wrapReference<TExpression>(wrapped: o.WrappedNodeExpr<TExpression>): R3Reference;
12
12
  /**
13
13
  * Parses the value of an enum from the AST value's symbol name.
@@ -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, NamedImport } from '../../src/ngtsc/translator';
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
- generateNamespaceImport(moduleName: string): TExpression;
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": "18.0.0-next.0",
3
+ "version": "18.0.0-next.2",
4
4
  "description": "Angular - the compiler CLI for Node.js",
5
5
  "typings": "index.d.ts",
6
6
  "bin": {
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@babel/core": "7.23.9",
46
+ "@babel/core": "7.24.1",
47
47
  "@jridgewell/sourcemap-codec": "^1.4.14",
48
48
  "reflect-metadata": "^0.2.0",
49
49
  "chokidar": "^3.0.0",
@@ -53,8 +53,8 @@
53
53
  "yargs": "^17.2.1"
54
54
  },
55
55
  "peerDependencies": {
56
- "@angular/compiler": "18.0.0-next.0",
57
- "typescript": ">=5.2 <5.5"
56
+ "@angular/compiler": "18.0.0-next.2",
57
+ "typescript": ">=5.4 <5.5"
58
58
  },
59
59
  "repository": {
60
60
  "type": "git",
@@ -102,7 +102,7 @@ export declare class ComponentDecoratorHandler implements DecoratorHandler<Decor
102
102
  * Computes a list of deferrable symbols based on dependencies from
103
103
  * the `@Component.imports` field and their usage in `@defer` blocks.
104
104
  */
105
- private collectDeferredSymbols;
105
+ private resolveAllDeferredDependencies;
106
106
  /**
107
107
  * Collects deferrable symbols from the `@Component.deferredImports` field.
108
108
  */
@@ -12,3 +12,4 @@ export * from './src/input_function';
12
12
  export * from './src/output_function';
13
13
  export * from './src/query_functions';
14
14
  export * from './src/model_function';
15
+ export * from './src/initializer_functions';
@@ -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 { ClassMember, ReflectionHost } from '../../../reflection';
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 class member that is declared via
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 tryParseInitializerApiMember<Functions extends InitializerApiFunction[]>(functions: Functions, member: Pick<ClassMember, 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): (InitializerFunctionMetadata & {
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 {};
@@ -8,8 +8,11 @@
8
8
  import { ImportedSymbolsTracker } from '../../../imports';
9
9
  import { InputMapping } from '../../../metadata';
10
10
  import { ClassMember, ReflectionHost } from '../../../reflection';
11
+ import { InitializerApiFunction } from './initializer_functions';
12
+ /** Represents a function that can declare an input. */
13
+ export declare const INPUT_INITIALIZER_FN: InitializerApiFunction;
11
14
  /**
12
15
  * Attempts to parse a signal input class member. Returns the parsed
13
16
  * input mapping if possible.
14
17
  */
15
- export declare function tryParseSignalInputMapping(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): InputMapping | null;
18
+ export declare function tryParseSignalInputMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): InputMapping | null;
@@ -8,7 +8,10 @@
8
8
  import { ImportedSymbolsTracker } from '../../../imports';
9
9
  import { ModelMapping } from '../../../metadata';
10
10
  import { ClassMember, ReflectionHost } from '../../../reflection';
11
+ import { InitializerApiFunction } from './initializer_functions';
12
+ /** Represents a function that can declare a model. */
13
+ export declare const MODEL_INITIALIZER_FN: InitializerApiFunction;
11
14
  /**
12
15
  * Attempts to parse a model class member. Returns the parsed model mapping if possible.
13
16
  */
14
- export declare function tryParseSignalModelMapping(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): ModelMapping | null;
17
+ export declare function tryParseSignalModelMapping(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): ModelMapping | null;
@@ -9,11 +9,14 @@ import ts from 'typescript';
9
9
  import { ImportedSymbolsTracker } from '../../../imports';
10
10
  import { InputOrOutput } from '../../../metadata';
11
11
  import { ClassMember, ReflectionHost } from '../../../reflection';
12
+ import { InitializerApiFunction } from './initializer_functions';
13
+ /** Possible functions that can declare an output. */
14
+ export declare const OUTPUT_INITIALIZER_FNS: InitializerApiFunction[];
12
15
  /**
13
16
  * Attempts to parse a signal output class member. Returns the parsed
14
17
  * input mapping if possible.
15
18
  */
16
- export declare function tryParseInitializerBasedOutput(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
19
+ export declare function tryParseInitializerBasedOutput(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
17
20
  call: ts.CallExpression;
18
21
  metadata: InputOrOutput;
19
22
  } | null;
@@ -8,9 +8,15 @@
8
8
  import { R3QueryMetadata } from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { ImportedSymbolsTracker } from '../../../imports';
11
- import { ClassMember, ReflectionHost } from '../../../reflection';
11
+ import { ClassMember, ClassMemberAccessLevel, ReflectionHost } from '../../../reflection';
12
12
  /** Possible query initializer API functions. */
13
13
  export type QueryFunctionName = 'viewChild' | 'contentChild' | 'viewChildren' | 'contentChildren';
14
+ /** Possible query initializer API functions. */
15
+ export declare const QUERY_INITIALIZER_FNS: {
16
+ functionName: QueryFunctionName;
17
+ owningModule: "@angular/core";
18
+ allowedAccessLevels: ClassMemberAccessLevel[];
19
+ }[];
14
20
  /**
15
21
  * Attempts to detect a possible query definition for the given class member.
16
22
  *
@@ -19,7 +25,7 @@ export type QueryFunctionName = 'viewChild' | 'contentChild' | 'viewChildren' |
19
25
  *
20
26
  * @returns Resolved query metadata, or null if no query is declared.
21
27
  */
22
- export declare function tryParseSignalQueryFromInitializer(member: Pick<ClassMember, 'name' | 'value'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
28
+ export declare function tryParseSignalQueryFromInitializer(member: Pick<ClassMember, 'name' | 'value' | 'accessLevel'>, reflector: ReflectionHost, importTracker: ImportedSymbolsTracker): {
23
29
  name: QueryFunctionName;
24
30
  metadata: R3QueryMetadata;
25
31
  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, INPUT_INITIALIZER_FN, MODEL_INITIALIZER_FN, OUTPUT_INITIALIZER_FNS, QUERY_INITIALIZER_FNS, 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';
@@ -0,0 +1,11 @@
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 { ExternalReference } from '@angular/compiler';
9
+ import ts from 'typescript';
10
+ export declare function coreHasSymbol(program: ts.Program, symbol: ExternalReference): boolean | null;
11
+ export declare function isMaybeCore(sf: ts.SourceFile): boolean;
@@ -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.
@@ -387,6 +392,20 @@ export declare enum ErrorCode {
387
392
  * ```
388
393
  */
389
394
  INTERPOLATED_SIGNAL_NOT_INVOKED = 8109,
395
+ /**
396
+ * Initializer-based APIs can only be invoked from inside of an initializer.
397
+ *
398
+ * ```
399
+ * // Allowed
400
+ * myInput = input();
401
+ *
402
+ * // Not allowed
403
+ * function myInput() {
404
+ * return input();
405
+ * }
406
+ * ```
407
+ */
408
+ UNSUPPORTED_INITIALIZER_API_USAGE = 8110,
390
409
  /**
391
410
  * The template type-checking engine would need to generate an inline type check block for a
392
411
  * component, but the current type-checking environment doesn't support it.
@@ -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;
@@ -0,0 +1,8 @@
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
+ export {};
@@ -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
  }
@@ -32,6 +32,19 @@ export declare class ImportedSymbolsTracker {
32
32
  * @param moduleName Module from which the namespace is imported.
33
33
  */
34
34
  isPotentialReferenceToNamespaceImport(node: ts.Identifier, moduleName: string): boolean;
35
+ /**
36
+ * Checks if a file has a named imported of a certain symbol.
37
+ * @param sourceFile File to be checked.
38
+ * @param exportedName Name of the exported symbol that is being checked.
39
+ * @param moduleName Module that exports the symbol.
40
+ */
41
+ hasNamedImport(sourceFile: ts.SourceFile, exportedName: string, moduleName: string): boolean;
42
+ /**
43
+ * Checks if a file has namespace imports of a certain symbol.
44
+ * @param sourceFile File to be checked.
45
+ * @param moduleName Module whose namespace import is being searched for.
46
+ */
47
+ hasNamespaceImport(sourceFile: ts.SourceFile, moduleName: string): boolean;
35
48
  /** Scans a `SourceFile` for import statements and caches them for later use. */
36
49
  private scanImports;
37
50
  }
@@ -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 ts.ImportSpecifier | ts.NamespaceImport | ts.ImportClause;
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 name of the member, or `null`
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';