@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.
Files changed (65) hide show
  1. package/bundles/{chunk-6X7GQ6BQ.js → chunk-6IQBXGRH.js} +591 -245
  2. package/bundles/chunk-6IQBXGRH.js.map +6 -0
  3. package/bundles/{chunk-3ESFLGKJ.js → chunk-7OQMTKOE.js} +254 -233
  4. package/bundles/chunk-7OQMTKOE.js.map +6 -0
  5. package/bundles/{chunk-OXIOYWLB.js → chunk-KP3UXB5C.js} +59 -57
  6. package/bundles/{chunk-OXIOYWLB.js.map → chunk-KP3UXB5C.js.map} +1 -1
  7. package/bundles/{chunk-VH6EDOMC.js → chunk-LHQ7WPU2.js} +2038 -858
  8. package/bundles/chunk-LHQ7WPU2.js.map +6 -0
  9. package/bundles/{chunk-F2QV65AH.js → chunk-VXEF7SDM.js} +2 -2
  10. package/bundles/{chunk-E5DF5SRS.js → chunk-ZS3FJJVW.js} +16 -16
  11. package/bundles/chunk-ZS3FJJVW.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 +2 -2
  15. package/bundles/linker/index.js +2 -2
  16. package/bundles/private/migrations.js +2 -2
  17. package/bundles/private/tooling.js +3 -3
  18. package/bundles/src/bin/ng_xi18n.js +4 -4
  19. package/bundles/src/bin/ngc.js +4 -4
  20. package/bundles_metadata.json +1 -1
  21. package/index.d.ts +1 -0
  22. package/linker/src/file_linker/partial_linkers/util.d.ts +1 -1
  23. package/linker/src/file_linker/translator.d.ts +2 -2
  24. package/linker/src/linker_import_generator.d.ts +5 -5
  25. package/package.json +2 -2
  26. package/src/ngtsc/annotations/directive/index.d.ts +1 -0
  27. package/src/ngtsc/annotations/directive/src/initializer_function_access.d.ts +17 -0
  28. package/src/ngtsc/annotations/directive/src/initializer_functions.d.ts +10 -6
  29. package/src/ngtsc/annotations/directive/src/input_function.d.ts +1 -1
  30. package/src/ngtsc/annotations/directive/src/model_function.d.ts +1 -1
  31. package/src/ngtsc/annotations/directive/src/output_function.d.ts +1 -1
  32. package/src/ngtsc/annotations/directive/src/query_functions.d.ts +1 -1
  33. package/src/ngtsc/annotations/index.d.ts +1 -1
  34. package/src/ngtsc/diagnostics/src/error_code.d.ts +5 -0
  35. package/src/ngtsc/docs/src/entities.d.ts +36 -1
  36. package/src/ngtsc/docs/src/function_extractor.d.ts +3 -2
  37. package/src/ngtsc/docs/src/initializer_api_function_extractor.d.ts +24 -0
  38. package/src/ngtsc/imports/index.d.ts +1 -1
  39. package/src/ngtsc/imports/src/core.d.ts +0 -9
  40. package/src/ngtsc/imports/src/patch_alias_reference_resolution.d.ts +3 -1
  41. package/src/ngtsc/reflection/src/host.d.ts +13 -3
  42. package/src/ngtsc/reflection/src/typescript.d.ts +8 -1
  43. package/src/ngtsc/reflection/src/util.d.ts +6 -1
  44. package/src/ngtsc/transform/index.d.ts +0 -1
  45. package/src/ngtsc/transform/src/declaration.d.ts +1 -1
  46. package/src/ngtsc/translator/index.d.ts +2 -2
  47. package/src/ngtsc/translator/src/api/import_generator.d.ts +22 -10
  48. package/src/ngtsc/translator/src/import_manager/check_unique_identifier_name.d.ts +13 -0
  49. package/src/ngtsc/translator/src/import_manager/import_manager.d.ts +94 -0
  50. package/src/ngtsc/translator/src/import_manager/import_typescript_transform.d.ts +17 -0
  51. package/src/ngtsc/translator/src/import_manager/reuse_generated_imports.d.ts +32 -0
  52. package/src/ngtsc/translator/src/import_manager/reuse_source_file_imports.d.ts +38 -0
  53. package/src/ngtsc/translator/src/translator.d.ts +3 -2
  54. package/src/ngtsc/translator/src/type_translator.d.ts +1 -1
  55. package/src/ngtsc/translator/src/typescript_translator.d.ts +2 -2
  56. package/src/ngtsc/typecheck/src/reference_emit_environment.d.ts +1 -1
  57. package/src/ngtsc/typecheck/src/ts_util.d.ts +0 -2
  58. package/src/transformers/jit_transforms/initializer_api_transforms/transform_api.d.ts +4 -4
  59. package/bundles/chunk-3ESFLGKJ.js.map +0 -6
  60. package/bundles/chunk-6X7GQ6BQ.js.map +0 -6
  61. package/bundles/chunk-E5DF5SRS.js.map +0 -6
  62. package/bundles/chunk-VH6EDOMC.js.map +0 -6
  63. package/src/ngtsc/transform/src/utils.d.ts +0 -15
  64. package/src/ngtsc/translator/src/import_manager.d.ts +0 -47
  65. /package/bundles/{chunk-F2QV65AH.js.map → chunk-VXEF7SDM.js.map} +0 -0
@@ -0,0 +1,32 @@
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 { ImportRequest } from '../api/import_generator';
10
+ import type { ModuleName } from './import_manager';
11
+ /** Branded string identifying a hashed {@link ImportRequest}. */
12
+ type ImportRequestHash = string & {
13
+ __importHash: string;
14
+ };
15
+ /** Tracker capturing re-used generated imports. */
16
+ export interface ReuseGeneratedImportsTracker {
17
+ /**
18
+ * Map of previously resolved symbol imports. Cache can be re-used to return
19
+ * the same identifier without checking the source-file again.
20
+ */
21
+ directReuseCache: Map<ImportRequestHash, ts.Identifier | [ts.Identifier, ts.Identifier]>;
22
+ /**
23
+ * Map of module names and their potential namespace import
24
+ * identifiers. Allows efficient re-using of namespace imports.
25
+ */
26
+ namespaceImportReuseCache: Map<ModuleName, ts.Identifier>;
27
+ }
28
+ /** Attempts to efficiently re-use previous generated import requests. */
29
+ export declare function attemptToReuseGeneratedImports(tracker: ReuseGeneratedImportsTracker, request: ImportRequest<ts.SourceFile>): ts.Identifier | [ts.Identifier, ts.Identifier] | null;
30
+ /** Captures the given import request and its generated reference node/path for future re-use. */
31
+ export declare function captureGeneratedImport(request: ImportRequest<ts.SourceFile>, tracker: ReuseGeneratedImportsTracker, referenceNode: ts.Identifier | [ts.Identifier, ts.Identifier]): void;
32
+ export {};
@@ -0,0 +1,38 @@
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 } from '../../../imports';
10
+ import { ImportRequest } from '../api/import_generator';
11
+ /**
12
+ * Tracker necessary for enabling re-use of original source file imports.
13
+ *
14
+ * The tracker holds information about original source file imports that
15
+ * need to be updated, or import declarations/specifiers that are now
16
+ * referenced due to the import manager.
17
+ */
18
+ export interface ReuseExistingSourceFileImportsTracker {
19
+ /**
20
+ * Map of import declarations that need to be updated to include the
21
+ * given symbols.
22
+ */
23
+ updatedImports: Map<ts.ImportDeclaration, {
24
+ propertyName: ts.Identifier;
25
+ fileUniqueAlias: ts.Identifier | null;
26
+ }[]>;
27
+ /**
28
+ * Set of re-used alias import declarations.
29
+ *
30
+ * These are captured so that we can tell TypeScript to not elide these source file
31
+ * imports as we introduced references to them. More details: {@link AliasImportDeclaration}.
32
+ */
33
+ reusedAliasDeclarations: Set<AliasImportDeclaration>;
34
+ /** Generates a unique identifier for a name in the given file. */
35
+ generateUniqueIdentifier(file: ts.SourceFile, symbolName: string): ts.Identifier | null;
36
+ }
37
+ /** Attempts to re-use original source file imports for the given request. */
38
+ export declare function attemptToReuseExistingSourceFileImports(tracker: ReuseExistingSourceFileImportsTracker, sourceFile: ts.SourceFile, request: ImportRequest<ts.SourceFile>): ts.Identifier | [ts.Identifier, ts.Identifier] | null;
@@ -16,13 +16,14 @@ export interface TranslatorOptions<TExpression> {
16
16
  recordWrappedNode?: RecordWrappedNodeFn<TExpression>;
17
17
  annotateForClosureCompiler?: boolean;
18
18
  }
19
- export declare class ExpressionTranslatorVisitor<TStatement, TExpression> implements o.ExpressionVisitor, o.StatementVisitor {
19
+ export declare class ExpressionTranslatorVisitor<TFile, TStatement, TExpression> implements o.ExpressionVisitor, o.StatementVisitor {
20
20
  private factory;
21
21
  private imports;
22
+ private contextFile;
22
23
  private downlevelTaggedTemplates;
23
24
  private downlevelVariableDeclarations;
24
25
  private recordWrappedNode;
25
- constructor(factory: AstFactory<TStatement, TExpression>, imports: ImportGenerator<TExpression>, options: TranslatorOptions<TExpression>);
26
+ constructor(factory: AstFactory<TStatement, TExpression>, imports: ImportGenerator<TFile, TExpression>, contextFile: TFile, options: TranslatorOptions<TExpression>);
26
27
  visitDeclareVarStmt(stmt: o.DeclareVarStmt, context: Context): TStatement;
27
28
  visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, context: Context): TStatement;
28
29
  visitExpressionStmt(stmt: o.ExpressionStatement, context: Context): TStatement;
@@ -9,5 +9,5 @@ import * as o from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { ReferenceEmitter } from '../../imports';
11
11
  import { ReflectionHost } from '../../reflection';
12
- import { ImportManager } from './import_manager';
12
+ import { ImportManager } from './import_manager/import_manager';
13
13
  export declare function translateType(type: o.Type, contextFile: ts.SourceFile, reflector: ReflectionHost, refEmitter: ReferenceEmitter, imports: ImportManager): ts.TypeNode;
@@ -9,5 +9,5 @@ import * as o from '@angular/compiler';
9
9
  import ts from 'typescript';
10
10
  import { ImportGenerator } from './api/import_generator';
11
11
  import { TranslatorOptions } from './translator';
12
- export declare function translateExpression(expression: o.Expression, imports: ImportGenerator<ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Expression;
13
- export declare function translateStatement(statement: o.Statement, imports: ImportGenerator<ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Statement;
12
+ export declare function translateExpression(contextFile: ts.SourceFile, expression: o.Expression, imports: ImportGenerator<ts.SourceFile, ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Expression;
13
+ export declare function translateStatement(contextFile: ts.SourceFile, statement: o.Statement, imports: ImportGenerator<ts.SourceFile, ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Statement;
@@ -20,7 +20,7 @@ export declare class ReferenceEmitEnvironment {
20
20
  readonly importManager: ImportManager;
21
21
  protected refEmitter: ReferenceEmitter;
22
22
  readonly reflector: ReflectionHost;
23
- protected contextFile: ts.SourceFile;
23
+ contextFile: ts.SourceFile;
24
24
  constructor(importManager: ImportManager, refEmitter: ReferenceEmitter, reflector: ReflectionHost, contextFile: ts.SourceFile);
25
25
  canReferenceType(ref: Reference, flags?: ImportFlags): boolean;
26
26
  /**
@@ -6,7 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import ts from 'typescript';
9
- import { Import } from '../../translator';
10
9
  export declare function tsCastToAny(expr: ts.Expression): ts.Expression;
11
10
  /**
12
11
  * Create an expression which instantiates an element by its HTML tagName.
@@ -49,4 +48,3 @@ export declare function isAccessExpression(node: ts.Node): node is ts.ElementAcc
49
48
  * Creates a TypeScript node representing a numeric value.
50
49
  */
51
50
  export declare function tsNumericExpression(value: number): ts.NumericLiteral | ts.PrefixUnaryExpression;
52
- export declare function getImportString(imp: Import): string;
@@ -7,11 +7,11 @@
7
7
  */
8
8
  import ts from 'typescript';
9
9
  import { ImportedSymbolsTracker } from '../../../ngtsc/imports';
10
- import { Decorator, ReflectionHost } from '../../../ngtsc/reflection';
10
+ import { ClassMember, Decorator, ReflectionHost } from '../../../ngtsc/reflection';
11
11
  import { ImportManager } from '../../../ngtsc/translator';
12
12
  /** Function that can be used to transform class properties. */
13
- export type PropertyTransform = (node: ts.PropertyDeclaration & {
14
- name: ts.Identifier | ts.StringLiteralLike;
13
+ export type PropertyTransform = (member: Pick<ClassMember, 'name' | 'accessLevel' | 'value'> & {
14
+ node: ts.PropertyDeclaration;
15
15
  }, host: ReflectionHost, factory: ts.NodeFactory, importTracker: ImportedSymbolsTracker, importManager: ImportManager, classDecorator: Decorator, isCore: boolean) => ts.PropertyDeclaration;
16
16
  /**
17
17
  * Creates an import and access for a given Angular core import while
@@ -19,6 +19,6 @@ export type PropertyTransform = (node: ts.PropertyDeclaration & {
19
19
  * import in order to make the synthetic decorator compatible with the JIT
20
20
  * decorator downlevel transform.
21
21
  */
22
- export declare function createSyntheticAngularCoreDecoratorAccess(factory: ts.NodeFactory, importManager: ImportManager, ngClassDecorator: Decorator, decoratorName: string): ts.PropertyAccessExpression;
22
+ export declare function createSyntheticAngularCoreDecoratorAccess(factory: ts.NodeFactory, importManager: ImportManager, ngClassDecorator: Decorator, sourceFile: ts.SourceFile, decoratorName: string): ts.PropertyAccessExpression;
23
23
  /** Casts the given expression as `any`. */
24
24
  export declare function castAsAny(factory: ts.NodeFactory, expr: ts.Expression): ts.Expression;