@angular/compiler-cli 13.1.0-next.2 → 13.1.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 (129) hide show
  1. package/bundles/{chunk-2DL256T3.js → chunk-5TY44ZS3.js} +426 -434
  2. package/bundles/chunk-5TY44ZS3.js.map +6 -0
  3. package/bundles/{chunk-EP5JHXG2.js → chunk-676MI6WZ.js} +33 -54
  4. package/bundles/chunk-676MI6WZ.js.map +6 -0
  5. package/bundles/{chunk-WOC6KEUY.js → chunk-6VRWTEQB.js} +28 -30
  6. package/bundles/chunk-6VRWTEQB.js.map +6 -0
  7. package/bundles/{chunk-S3QIIFH7.js → chunk-7PY7XEFH.js} +9 -6
  8. package/bundles/chunk-7PY7XEFH.js.map +6 -0
  9. package/bundles/{chunk-PBA67OV4.js → chunk-A5PL3TE6.js} +30 -6
  10. package/bundles/chunk-A5PL3TE6.js.map +6 -0
  11. package/bundles/{chunk-QL6ZC3U3.js → chunk-ADHVDA4A.js} +6 -6
  12. package/bundles/{chunk-QL6ZC3U3.js.map → chunk-ADHVDA4A.js.map} +1 -1
  13. package/bundles/{chunk-MIQ5UCHZ.js → chunk-FUZ3CSDO.js} +306 -389
  14. package/bundles/chunk-FUZ3CSDO.js.map +6 -0
  15. package/bundles/{chunk-BUHTODFL.js → chunk-JOLPJ2E4.js} +21 -19
  16. package/bundles/chunk-JOLPJ2E4.js.map +6 -0
  17. package/bundles/{chunk-UMUIU7TE.js → chunk-O4XVCXRT.js} +2 -2
  18. package/bundles/{chunk-UMUIU7TE.js.map → chunk-O4XVCXRT.js.map} +0 -0
  19. package/bundles/{chunk-WYO7JO2T.js → chunk-QBU7RUKB.js} +259 -85
  20. package/bundles/chunk-QBU7RUKB.js.map +6 -0
  21. package/bundles/{chunk-VKIZ4TCJ.js → chunk-TUNE6DP3.js} +6370 -10786
  22. package/bundles/chunk-TUNE6DP3.js.map +6 -0
  23. package/bundles/{chunk-JNWO3JB2.js → chunk-UESD6FVI.js} +13 -15
  24. package/bundles/chunk-UESD6FVI.js.map +6 -0
  25. package/bundles/{chunk-XA5IZLLC.js → chunk-WQ3TNYTD.js} +6 -6
  26. package/bundles/{chunk-XA5IZLLC.js.map → chunk-WQ3TNYTD.js.map} +0 -0
  27. package/bundles/index.js +9 -73
  28. package/bundles/index.js.map +2 -2
  29. package/bundles/linker/babel/index.js +77 -77
  30. package/bundles/linker/babel/index.js.map +1 -1
  31. package/bundles/linker/index.js +5 -5
  32. package/bundles/ngcc/index.js +9 -10
  33. package/bundles/ngcc/index.js.map +1 -1
  34. package/bundles/ngcc/main-ngcc.js +10 -11
  35. package/bundles/ngcc/main-ngcc.js.map +1 -1
  36. package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +9 -10
  37. package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js.map +1 -1
  38. package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js +2 -2
  39. package/bundles/private/bazel.js +1 -1
  40. package/bundles/private/localize.js +3 -3
  41. package/bundles/private/migrations.js +5 -5
  42. package/bundles/private/tooling.js +3 -4
  43. package/bundles/src/bin/ng_xi18n.js +7 -8
  44. package/bundles/src/bin/ng_xi18n.js.map +1 -1
  45. package/bundles/src/bin/ngc.js +9 -10
  46. package/bundles/src/bin/ngc.js.map +1 -1
  47. package/bundles_metadata.json +1 -1
  48. package/index.d.ts +2 -3
  49. package/ngcc/src/host/delegating_host.d.ts +1 -2
  50. package/ngcc/src/host/esm2015_host.d.ts +1 -8
  51. package/ngcc/src/host/ngcc_host.d.ts +0 -13
  52. package/ngcc/src/host/umd_host.d.ts +3 -0
  53. package/ngcc/src/packages/build_marker.d.ts +1 -1
  54. package/ngcc/src/packages/transformer.d.ts +0 -2
  55. package/ngcc/src/rendering/esm_rendering_formatter.d.ts +1 -5
  56. package/ngcc/src/rendering/renderer.d.ts +2 -3
  57. package/ngcc/src/rendering/rendering_formatter.d.ts +0 -2
  58. package/ngcc/src/utils.d.ts +0 -7
  59. package/package.json +3 -3
  60. package/src/main.d.ts +3 -3
  61. package/src/ngtsc/annotations/src/util.d.ts +1 -1
  62. package/src/ngtsc/core/api/src/options.d.ts +3 -2
  63. package/src/ngtsc/core/api/src/public_options.d.ts +38 -0
  64. package/src/ngtsc/core/src/host.d.ts +2 -1
  65. package/src/ngtsc/diagnostics/index.d.ts +2 -1
  66. package/src/ngtsc/diagnostics/src/error.d.ts +1 -0
  67. package/src/ngtsc/diagnostics/src/error_code.d.ts +7 -0
  68. package/src/ngtsc/diagnostics/src/error_details_base_url.d.ts +1 -1
  69. package/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.d.ts +21 -0
  70. package/src/ngtsc/file_system/src/compiler_host.d.ts +1 -0
  71. package/src/ngtsc/imports/index.d.ts +1 -1
  72. package/src/ngtsc/imports/src/emitter.d.ts +40 -8
  73. package/src/ngtsc/partial_evaluator/src/builtin.d.ts +5 -0
  74. package/src/ngtsc/program.d.ts +3 -6
  75. package/src/ngtsc/program_driver/src/ts_create_program_driver.d.ts +2 -1
  76. package/src/ngtsc/reflection/src/host.d.ts +1 -1
  77. package/src/ngtsc/translator/src/translator.d.ts +0 -5
  78. package/src/ngtsc/translator/src/type_translator.d.ts +0 -2
  79. package/src/ngtsc/typecheck/extended/api/api.d.ts +30 -10
  80. package/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.d.ts +3 -14
  81. package/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.d.ts +3 -15
  82. package/src/ngtsc/typecheck/extended/index.d.ts +3 -0
  83. package/src/ngtsc/typecheck/extended/src/extended_template_checker.d.ts +5 -4
  84. package/src/ngtsc/typecheck/src/environment.d.ts +3 -1
  85. package/src/ngtsc/typecheck/src/tcb_util.d.ts +10 -2
  86. package/src/ngtsc/typecheck/src/type_constructor.d.ts +3 -2
  87. package/src/ngtsc/typecheck/src/type_emitter.d.ts +7 -21
  88. package/src/ngtsc/typecheck/src/type_parameter_emitter.d.ts +2 -2
  89. package/src/ngtsc/util/src/typescript.d.ts +5 -0
  90. package/src/perform_compile.d.ts +5 -10
  91. package/src/perform_watch.d.ts +4 -4
  92. package/src/transformers/api.d.ts +3 -30
  93. package/src/transformers/compiler_host.d.ts +1 -97
  94. package/src/transformers/program.d.ts +0 -19
  95. package/src/transformers/util.d.ts +1 -20
  96. package/src/{diagnostics/typescript_version.d.ts → version_helpers.d.ts} +1 -1
  97. package/bundles/chunk-2DL256T3.js.map +0 -6
  98. package/bundles/chunk-ACINBTQB.js +0 -43
  99. package/bundles/chunk-ACINBTQB.js.map +0 -6
  100. package/bundles/chunk-BUHTODFL.js.map +0 -6
  101. package/bundles/chunk-EP5JHXG2.js.map +0 -6
  102. package/bundles/chunk-JNWO3JB2.js.map +0 -6
  103. package/bundles/chunk-MIQ5UCHZ.js.map +0 -6
  104. package/bundles/chunk-PBA67OV4.js.map +0 -6
  105. package/bundles/chunk-S3QIIFH7.js.map +0 -6
  106. package/bundles/chunk-VKIZ4TCJ.js.map +0 -6
  107. package/bundles/chunk-WOC6KEUY.js.map +0 -6
  108. package/bundles/chunk-WYO7JO2T.js.map +0 -6
  109. package/ngcc/src/analysis/switch_marker_analyzer.d.ts +0 -35
  110. package/src/diagnostics/translate_diagnostics.d.ts +0 -18
  111. package/src/language_services.d.ts +0 -11
  112. package/src/metadata/bundle_index_host.d.ts +0 -16
  113. package/src/metadata/bundler.d.ts +0 -66
  114. package/src/metadata/collector.d.ts +0 -44
  115. package/src/metadata/evaluator.d.ts +0 -58
  116. package/src/metadata/index.d.ts +0 -11
  117. package/src/metadata/index_writer.d.ts +0 -10
  118. package/src/metadata/schema.d.ts +0 -182
  119. package/src/metadata/symbols.d.ts +0 -22
  120. package/src/ngtsc/switch/index.d.ts +0 -9
  121. package/src/ngtsc/switch/src/switch.d.ts +0 -10
  122. package/src/transformers/inline_resources.d.ts +0 -26
  123. package/src/transformers/lower_expressions.d.ts +0 -30
  124. package/src/transformers/metadata_cache.d.ts +0 -27
  125. package/src/transformers/metadata_reader.d.ts +0 -19
  126. package/src/transformers/node_emitter.d.ts +0 -105
  127. package/src/transformers/node_emitter_transform.d.ts +0 -19
  128. package/src/transformers/r3_metadata_transform.d.ts +0 -16
  129. package/src/transformers/r3_transform.d.ts +0 -16
@@ -30,8 +30,6 @@ export declare class TypeTranslatorVisitor implements o.ExpressionVisitor, o.Typ
30
30
  visitExternalExpr(ast: o.ExternalExpr, context: Context): ts.EntityName | ts.TypeReferenceNode;
31
31
  visitConditionalExpr(ast: o.ConditionalExpr, context: Context): void;
32
32
  visitNotExpr(ast: o.NotExpr, context: Context): void;
33
- visitAssertNotNullExpr(ast: o.AssertNotNull, context: Context): void;
34
- visitCastExpr(ast: o.CastExpr, context: Context): void;
35
33
  visitFunctionExpr(ast: o.FunctionExpr, context: Context): void;
36
34
  visitUnaryOperatorExpr(ast: o.UnaryOperatorExpr, context: Context): void;
37
35
  visitBinaryOperatorExpr(ast: o.BinaryOperatorExpr, context: Context): void;
@@ -6,24 +6,25 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/typecheck/extended/api/api" />
9
- import { AST, TmplAstNode } from '@angular/compiler';
9
+ import { AST, ParseSourceSpan, TmplAstNode } from '@angular/compiler';
10
10
  import ts from 'typescript';
11
- import { ErrorCode } from '../../../diagnostics';
11
+ import { NgCompilerOptions } from '../../../core/api';
12
+ import { ErrorCode, ExtendedTemplateDiagnosticName } from '../../../diagnostics';
12
13
  import { NgTemplateDiagnostic, TemplateTypeChecker } from '../../api';
13
14
  /**
14
15
  * A Template Check receives information about the template it's checking and returns
15
16
  * information about the diagnostics to be generated.
16
17
  */
17
- export interface TemplateCheck<T extends ErrorCode> {
18
+ export interface TemplateCheck<Code extends ErrorCode> {
18
19
  /** Unique template check code, used for configuration and searching the error. */
19
- code: T;
20
+ code: Code;
20
21
  /** Runs check and returns information about the diagnostics to be generated. */
21
- run(ctx: TemplateContext, component: ts.ClassDeclaration, template: TmplAstNode[]): NgTemplateDiagnostic<T>[];
22
+ run(ctx: TemplateContext<Code>, component: ts.ClassDeclaration, template: TmplAstNode[]): NgTemplateDiagnostic<Code>[];
22
23
  }
23
24
  /**
24
25
  * The TemplateContext provided to a Template Check to get diagnostic information.
25
26
  */
26
- export interface TemplateContext {
27
+ export interface TemplateContext<Code extends ErrorCode> {
27
28
  /** Interface that provides information about template nodes. */
28
29
  templateTypeChecker: TemplateTypeChecker;
29
30
  /**
@@ -31,20 +32,39 @@ export interface TemplateContext {
31
32
  * in the template (it is not to query types outside the Angular component).
32
33
  */
33
34
  typeChecker: ts.TypeChecker;
35
+ /**
36
+ * Creates a template diagnostic with the given information for the template being processed and
37
+ * using the diagnostic category configured for the extended template diagnostic.
38
+ */
39
+ makeTemplateDiagnostic(sourceSpan: ParseSourceSpan, message: string, relatedInformation?: {
40
+ text: string;
41
+ start: number;
42
+ end: number;
43
+ sourceFile: ts.SourceFile;
44
+ }[]): NgTemplateDiagnostic<Code>;
45
+ }
46
+ /**
47
+ * A factory which creates a template check for a particular code and name. This binds the two
48
+ * together and associates them with a specific `TemplateCheck`.
49
+ */
50
+ export interface TemplateCheckFactory<Code extends ErrorCode, Name extends ExtendedTemplateDiagnosticName> {
51
+ code: Code;
52
+ name: Name;
53
+ create(options: NgCompilerOptions): TemplateCheck<Code> | null;
34
54
  }
35
55
  /**
36
56
  * This abstract class provides a base implementation for the run method.
37
57
  */
38
- export declare abstract class TemplateCheckWithVisitor<T extends ErrorCode> implements TemplateCheck<T> {
39
- abstract code: T;
58
+ export declare abstract class TemplateCheckWithVisitor<Code extends ErrorCode> implements TemplateCheck<Code> {
59
+ abstract code: Code;
40
60
  /**
41
61
  * Base implementation for run function, visits all nodes in template and calls
42
62
  * `visitNode()` for each one.
43
63
  */
44
- run(ctx: TemplateContext, component: ts.ClassDeclaration, template: TmplAstNode[]): NgTemplateDiagnostic<T>[];
64
+ run(ctx: TemplateContext<Code>, component: ts.ClassDeclaration, template: TmplAstNode[]): NgTemplateDiagnostic<Code>[];
45
65
  /**
46
66
  * Visit a TmplAstNode or AST node of the template. Authors should override this
47
67
  * method to implement the check and return diagnostics.
48
68
  */
49
- abstract visitNode(ctx: TemplateContext, component: ts.ClassDeclaration, node: TmplAstNode | AST): NgTemplateDiagnostic<T>[];
69
+ abstract visitNode(ctx: TemplateContext<Code>, component: ts.ClassDeclaration, node: TmplAstNode | AST): NgTemplateDiagnostic<Code>[];
50
70
  }
@@ -6,17 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box" />
9
- import { AST, TmplAstNode } from '@angular/compiler';
10
- import ts from 'typescript';
11
- import { ErrorCode } from '../../../../diagnostics';
12
- import { NgTemplateDiagnostic } from '../../../api';
13
- import { TemplateCheckWithVisitor, TemplateContext } from '../../api';
14
- /**
15
- * Ensures the two-way binding syntax is correct.
16
- * Parentheses should be inside the brackets "[()]".
17
- * Will return diagnostic information when "([])" is found.
18
- */
19
- export declare class InvalidBananaInBoxCheck extends TemplateCheckWithVisitor<ErrorCode.INVALID_BANANA_IN_BOX> {
20
- code: ErrorCode.INVALID_BANANA_IN_BOX;
21
- visitNode(ctx: TemplateContext, component: ts.ClassDeclaration, node: TmplAstNode | AST): NgTemplateDiagnostic<ErrorCode.INVALID_BANANA_IN_BOX>[];
22
- }
9
+ import { ErrorCode, ExtendedTemplateDiagnosticName } from '../../../../diagnostics';
10
+ import { TemplateCheckFactory } from '../../api';
11
+ export declare const factory: TemplateCheckFactory<ErrorCode.INVALID_BANANA_IN_BOX, ExtendedTemplateDiagnosticName.INVALID_BANANA_IN_BOX>;
@@ -6,18 +6,6 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable" />
9
- import { AST, TmplAstNode } from '@angular/compiler';
10
- import ts from 'typescript';
11
- import { ErrorCode } from '../../../../diagnostics';
12
- import { NgTemplateDiagnostic } from '../../../api';
13
- import { TemplateCheckWithVisitor, TemplateContext } from '../../api';
14
- /**
15
- * Ensures the left side of a nullish coalescing operation is nullable.
16
- * Returns diagnostics for the cases where the operator is useless.
17
- * This check should only be use if `strictNullChecks` is enabled,
18
- * otherwise it would produce inaccurate results.
19
- */
20
- export declare class NullishCoalescingNotNullableCheck extends TemplateCheckWithVisitor<ErrorCode.NULLISH_COALESCING_NOT_NULLABLE> {
21
- code: ErrorCode.NULLISH_COALESCING_NOT_NULLABLE;
22
- visitNode(ctx: TemplateContext, component: ts.ClassDeclaration, node: TmplAstNode | AST): NgTemplateDiagnostic<ErrorCode.NULLISH_COALESCING_NOT_NULLABLE>[];
23
- }
9
+ import { ErrorCode, ExtendedTemplateDiagnosticName } from '../../../../diagnostics';
10
+ import { TemplateCheckFactory } from '../../api';
11
+ export declare const factory: TemplateCheckFactory<ErrorCode.NULLISH_COALESCING_NOT_NULLABLE, ExtendedTemplateDiagnosticName.NULLISH_COALESCING_NOT_NULLABLE>;
@@ -6,4 +6,7 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/typecheck/extended" />
9
+ import { ErrorCode, ExtendedTemplateDiagnosticName } from '../../diagnostics';
10
+ import { TemplateCheckFactory } from './api';
9
11
  export { ExtendedTemplateCheckerImpl } from './src/extended_template_checker';
12
+ export declare const ALL_DIAGNOSTIC_FACTORIES: readonly TemplateCheckFactory<ErrorCode, ExtendedTemplateDiagnosticName>[];
@@ -7,12 +7,13 @@
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/typecheck/extended/src/extended_template_checker" />
9
9
  import ts from 'typescript';
10
- import { ErrorCode } from '../../../diagnostics';
10
+ import { NgCompilerOptions } from '../../../core/api';
11
+ import { ErrorCode, ExtendedTemplateDiagnosticName } from '../../../diagnostics';
11
12
  import { TemplateDiagnostic, TemplateTypeChecker } from '../../api';
12
- import { ExtendedTemplateChecker, TemplateCheck } from '../api';
13
+ import { ExtendedTemplateChecker, TemplateCheckFactory } from '../api';
13
14
  export declare class ExtendedTemplateCheckerImpl implements ExtendedTemplateChecker {
15
+ private readonly partialCtx;
14
16
  private readonly templateChecks;
15
- private ctx;
16
- constructor(templateTypeChecker: TemplateTypeChecker, typeChecker: ts.TypeChecker, templateChecks: TemplateCheck<ErrorCode>[]);
17
+ constructor(templateTypeChecker: TemplateTypeChecker, typeChecker: ts.TypeChecker, templateCheckFactories: readonly TemplateCheckFactory<ErrorCode, ExtendedTemplateDiagnosticName>[], options: NgCompilerOptions);
17
18
  getDiagnosticsForComponent(component: ts.ClassDeclaration): TemplateDiagnostic[];
18
19
  }
@@ -12,6 +12,7 @@ import { Reference, ReferenceEmitter } from '../../imports';
12
12
  import { ClassDeclaration, ReflectionHost } from '../../reflection';
13
13
  import { ImportManager } from '../../translator';
14
14
  import { TypeCheckableDirectiveMeta, TypeCheckingConfig } from '../api';
15
+ import { ReferenceEmitEnvironment } from './tcb_util';
15
16
  /**
16
17
  * A context which hosts one or more Type Check Blocks (TCBs).
17
18
  *
@@ -23,7 +24,7 @@ import { TypeCheckableDirectiveMeta, TypeCheckingConfig } from '../api';
23
24
  * `Environment` can be used in a standalone fashion, or can be extended to support more specialized
24
25
  * usage.
25
26
  */
26
- export declare class Environment {
27
+ export declare class Environment implements ReferenceEmitEnvironment {
27
28
  readonly config: TypeCheckingConfig;
28
29
  protected importManager: ImportManager;
29
30
  private refEmitter;
@@ -49,6 +50,7 @@ export declare class Environment {
49
50
  * This may involve importing the node into the file if it's not declared there already.
50
51
  */
51
52
  reference(ref: Reference<ClassDeclaration<ts.ClassDeclaration>>): ts.Expression;
53
+ canReferenceType(ref: Reference): boolean;
52
54
  /**
53
55
  * Generate a `ts.TypeNode` that references the given node as a type.
54
56
  *
@@ -11,6 +11,14 @@ import ts from 'typescript';
11
11
  import { ClassDeclaration, ReflectionHost } from '../../../../src/ngtsc/reflection';
12
12
  import { Reference } from '../../imports';
13
13
  import { FullTemplateMapping, SourceLocation, TemplateId, TemplateSourceMapping } from '../api';
14
+ /**
15
+ * Represents the origin environment from where reference will be emitted. This interface exists
16
+ * as an indirection for the `Environment` type, which would otherwise introduce a (type-only)
17
+ * import cycle.
18
+ */
19
+ export interface ReferenceEmitEnvironment {
20
+ canReferenceType(ref: Reference): boolean;
21
+ }
14
22
  /**
15
23
  * Adapter interface which allows the template type-checking diagnostics code to interpret offsets
16
24
  * in a TCB and map them back to original locations in the template.
@@ -50,7 +58,7 @@ export declare enum TcbInliningRequirement {
50
58
  */
51
59
  None = 2
52
60
  }
53
- export declare function requiresInlineTypeCheckBlock(node: ClassDeclaration<ts.ClassDeclaration>, usedPipes: Map<string, Reference<ClassDeclaration<ts.ClassDeclaration>>>, reflector: ReflectionHost): TcbInliningRequirement;
61
+ export declare function requiresInlineTypeCheckBlock(node: ClassDeclaration<ts.ClassDeclaration>, env: ReferenceEmitEnvironment, usedPipes: Map<string, Reference<ClassDeclaration<ts.ClassDeclaration>>>, reflector: ReflectionHost): TcbInliningRequirement;
54
62
  /** Maps a shim position back to a template location. */
55
63
  export declare function getTemplateMapping(shimSf: ts.SourceFile, position: number, resolver: TemplateSourceResolver, isDiagnosticRequest: boolean): FullTemplateMapping | null;
56
64
  export declare function findTypeCheckBlock(file: ts.SourceFile, id: TemplateId, isDiagnosticRequest: boolean): ts.Node | null;
@@ -61,4 +69,4 @@ export declare function findTypeCheckBlock(file: ts.SourceFile, id: TemplateId,
61
69
  * returns null.
62
70
  */
63
71
  export declare function findSourceLocation(node: ts.Node, sourceFile: ts.SourceFile, isDiagnosticsRequest: boolean): SourceLocation | null;
64
- export declare function checkIfGenericTypeBoundsAreContextFree(node: ClassDeclaration<ts.ClassDeclaration>, reflector: ReflectionHost): boolean;
72
+ export declare function checkIfGenericTypeBoundsCanBeEmitted(node: ClassDeclaration<ts.ClassDeclaration>, reflector: ReflectionHost, env: ReferenceEmitEnvironment): boolean;
@@ -9,7 +9,8 @@
9
9
  import ts from 'typescript';
10
10
  import { ClassDeclaration, ReflectionHost } from '../../reflection';
11
11
  import { TypeCtorMetadata } from '../api';
12
- export declare function generateTypeCtorDeclarationFn(node: ClassDeclaration<ts.ClassDeclaration>, meta: TypeCtorMetadata, nodeTypeRef: ts.EntityName, typeParams: ts.TypeParameterDeclaration[] | undefined, reflector: ReflectionHost): ts.Statement;
12
+ import { ReferenceEmitEnvironment } from './tcb_util';
13
+ export declare function generateTypeCtorDeclarationFn(node: ClassDeclaration<ts.ClassDeclaration>, meta: TypeCtorMetadata, nodeTypeRef: ts.EntityName, typeParams: ts.TypeParameterDeclaration[] | undefined): ts.Statement;
13
14
  /**
14
15
  * Generate an inline type constructor for the given class and metadata.
15
16
  *
@@ -46,4 +47,4 @@ export declare function generateTypeCtorDeclarationFn(node: ClassDeclaration<ts.
46
47
  * @returns a `ts.MethodDeclaration` for the type constructor.
47
48
  */
48
49
  export declare function generateInlineTypeCtor(node: ClassDeclaration<ts.ClassDeclaration>, meta: TypeCtorMetadata): ts.MethodDeclaration;
49
- export declare function requiresInlineTypeCtor(node: ClassDeclaration<ts.ClassDeclaration>, host: ReflectionHost): boolean;
50
+ export declare function requiresInlineTypeCtor(node: ClassDeclaration<ts.ClassDeclaration>, host: ReflectionHost, env: ReferenceEmitEnvironment): boolean;
@@ -7,18 +7,12 @@
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
9
  import ts from 'typescript';
10
- import { Reference } from '../../imports';
11
10
  /**
12
- * A resolved type reference can either be a `Reference`, the original `ts.TypeReferenceNode` itself
13
- * or null. A value of null indicates that no reference could be resolved or that the reference can
14
- * not be emitted.
11
+ * A type reference resolver function is responsible for translating a type reference from the
12
+ * origin source file into a type reference that is valid in the desired source file. If the type
13
+ * cannot be translated to the desired source file, then null can be returned.
15
14
  */
16
- export declare type ResolvedTypeReference = Reference | ts.TypeReferenceNode | null;
17
- /**
18
- * A type reference resolver function is responsible for finding the declaration of the type
19
- * reference and verifying whether it can be emitted.
20
- */
21
- export declare type TypeReferenceResolver = (type: ts.TypeReferenceNode) => ResolvedTypeReference;
15
+ export declare type TypeReferenceTranslator = (type: ts.TypeReferenceNode) => ts.TypeReferenceNode | null;
22
16
  /**
23
17
  * Determines whether the provided type can be emitted, which means that it can be safely emitted
24
18
  * into a different location.
@@ -27,7 +21,7 @@ export declare type TypeReferenceResolver = (type: ts.TypeReferenceNode) => Reso
27
21
  * function returns false, then using the `TypeEmitter` should not be attempted as it is known to
28
22
  * fail.
29
23
  */
30
- export declare function canEmitType(type: ts.TypeNode, resolver: TypeReferenceResolver): boolean;
24
+ export declare function canEmitType(type: ts.TypeNode, canEmit: (type: ts.TypeReferenceNode) => boolean): boolean;
31
25
  /**
32
26
  * Given a `ts.TypeNode`, this class derives an equivalent `ts.TypeNode` that has been emitted into
33
27
  * a different context.
@@ -58,16 +52,8 @@ export declare function canEmitType(type: ts.TypeNode, resolver: TypeReferenceRe
58
52
  * referring to the namespace import that was created.
59
53
  */
60
54
  export declare class TypeEmitter {
61
- /**
62
- * Resolver function that computes a `Reference` corresponding with a `ts.TypeReferenceNode`.
63
- */
64
- private resolver;
65
- /**
66
- * Given a `Reference`, this function is responsible for the actual emitting work. It should
67
- * produce a `ts.TypeNode` that is valid within the desired context.
68
- */
69
- private emitReference;
70
- constructor(resolver: TypeReferenceResolver, emitReference: (ref: Reference) => ts.TypeNode);
55
+ private translator;
56
+ constructor(translator: TypeReferenceTranslator);
71
57
  emitType(type: ts.TypeNode): ts.TypeNode;
72
58
  private emitTypeReference;
73
59
  }
@@ -21,13 +21,13 @@ export declare class TypeParameterEmitter {
21
21
  * `emit` is known to succeed. Vice versa, if false is returned then `emit` should not be
22
22
  * called, as it would fail.
23
23
  */
24
- canEmit(): boolean;
24
+ canEmit(canEmitReference: (ref: Reference) => boolean): boolean;
25
25
  private canEmitType;
26
26
  /**
27
27
  * Emits the type parameters using the provided emitter function for `Reference`s.
28
28
  */
29
29
  emit(emitReference: (ref: Reference) => ts.TypeNode): ts.TypeParameterDeclaration[] | undefined;
30
30
  private resolveTypeReference;
31
- private isTopLevelExport;
31
+ private translateTypeReference;
32
32
  private isLocalTypeParameter;
33
33
  }
@@ -62,3 +62,8 @@ export declare type RequiredDelegations<T> = {
62
62
  * Obtains the non-redirected source file for `sf`.
63
63
  */
64
64
  export declare function toUnredirectedSourceFile(sf: ts.SourceFile): ts.SourceFile;
65
+ /**
66
+ * Backwards-compatible version of `ts.createExportSpecifier`
67
+ * to handle a breaking change between 4.4 and 4.5.
68
+ */
69
+ export declare function createExportSpecifier(propertyName: string | ts.Identifier | undefined, name: string | ts.Identifier, isTypeOnly?: boolean): ts.ExportSpecifier;
@@ -6,15 +6,10 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/perform_compile" />
9
- import { Position } from '@angular/compiler';
10
9
  import ts from 'typescript';
11
10
  import { AbsoluteFsPath, ReadonlyFileSystem } from '../src/ngtsc/file_system';
12
11
  import * as api from './transformers/api';
13
- export declare type Diagnostics = ReadonlyArray<ts.Diagnostic | api.Diagnostic>;
14
- export declare function formatDiagnosticPosition(position: Position, host?: ts.FormatDiagnosticsHost): string;
15
- export declare function flattenDiagnosticMessageChain(chain: api.DiagnosticMessageChain, host?: ts.FormatDiagnosticsHost, indent?: number): string;
16
- export declare function formatDiagnostic(diagnostic: api.Diagnostic, host?: ts.FormatDiagnosticsHost): string;
17
- export declare function formatDiagnostics(diags: Diagnostics, host?: ts.FormatDiagnosticsHost): string;
12
+ export declare function formatDiagnostics(diags: ReadonlyArray<ts.Diagnostic>, host?: ts.FormatDiagnosticsHost): string;
18
13
  /** Used to read configuration files. */
19
14
  export declare type ConfigurationHost = Pick<ReadonlyFileSystem, 'readFile' | 'exists' | 'lstat' | 'resolve' | 'join' | 'dirname' | 'extname' | 'pwd'>;
20
15
  export interface ParsedConfiguration {
@@ -31,11 +26,11 @@ export declare function calcProjectFileAndBasePath(project: string, host?: Confi
31
26
  };
32
27
  export declare function readConfiguration(project: string, existingOptions?: api.CompilerOptions, host?: ConfigurationHost): ParsedConfiguration;
33
28
  export interface PerformCompilationResult {
34
- diagnostics: Diagnostics;
29
+ diagnostics: ReadonlyArray<ts.Diagnostic>;
35
30
  program?: api.Program;
36
31
  emitResult?: ts.EmitResult;
37
32
  }
38
- export declare function exitCodeFromResult(diags: Diagnostics | undefined): number;
33
+ export declare function exitCodeFromResult(diags: ReadonlyArray<ts.Diagnostic> | undefined): number;
39
34
  export declare function performCompilation({ rootNames, options, host, oldProgram, emitCallback, mergeEmitResultsCallback, gatherDiagnostics, customTransformers, emitFlags, modifiedResourceFiles }: {
40
35
  rootNames: string[];
41
36
  options: api.CompilerOptions;
@@ -43,9 +38,9 @@ export declare function performCompilation({ rootNames, options, host, oldProgra
43
38
  oldProgram?: api.Program;
44
39
  emitCallback?: api.TsEmitCallback;
45
40
  mergeEmitResultsCallback?: api.TsMergeEmitResultsCallback;
46
- gatherDiagnostics?: (program: api.Program) => Diagnostics;
41
+ gatherDiagnostics?: (program: api.Program) => ReadonlyArray<ts.Diagnostic>;
47
42
  customTransformers?: api.CustomTransformers;
48
43
  emitFlags?: api.EmitFlags;
49
44
  modifiedResourceFiles?: Set<string> | null;
50
45
  }): PerformCompilationResult;
51
- export declare function defaultGatherDiagnostics(program: api.Program): Diagnostics;
46
+ export declare function defaultGatherDiagnostics(program: api.Program): ReadonlyArray<ts.Diagnostic>;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/perform_watch" />
9
9
  import ts from 'typescript';
10
- import { Diagnostics, ParsedConfiguration } from './perform_compile';
10
+ import { ParsedConfiguration } from './perform_compile';
11
11
  import * as api from './transformers/api';
12
12
  export declare enum FileChangeEvent {
13
13
  Change = 0,
@@ -15,7 +15,7 @@ export declare enum FileChangeEvent {
15
15
  CreateDeleteDir = 2
16
16
  }
17
17
  export interface PerformWatchHost {
18
- reportDiagnostics(diagnostics: Diagnostics): void;
18
+ reportDiagnostics(diagnostics: ReadonlyArray<ts.Diagnostic>): void;
19
19
  readConfiguration(): ParsedConfiguration;
20
20
  createCompilerHost(options: api.CompilerOptions): api.CompilerHost;
21
21
  createEmitCallback(options: api.CompilerOptions): api.TsEmitCallback | undefined;
@@ -25,12 +25,12 @@ export interface PerformWatchHost {
25
25
  setTimeout(callback: () => void, ms: number): any;
26
26
  clearTimeout(timeoutId: any): void;
27
27
  }
28
- export declare function createPerformWatchHost(configFileName: string, reportDiagnostics: (diagnostics: Diagnostics) => void, existingOptions?: ts.CompilerOptions, createEmitCallback?: (options: api.CompilerOptions) => api.TsEmitCallback | undefined): PerformWatchHost;
28
+ export declare function createPerformWatchHost(configFileName: string, reportDiagnostics: (diagnostics: ReadonlyArray<ts.Diagnostic>) => void, existingOptions?: ts.CompilerOptions, createEmitCallback?: (options: api.CompilerOptions) => api.TsEmitCallback | undefined): PerformWatchHost;
29
29
  /**
30
30
  * The logic in this function is adapted from `tsc.ts` from TypeScript.
31
31
  */
32
32
  export declare function performWatchCompilation(host: PerformWatchHost): {
33
33
  close: () => void;
34
34
  ready: (cb: () => void) => void;
35
- firstCompileResult: Diagnostics;
35
+ firstCompileResult: ReadonlyArray<ts.Diagnostic>;
36
36
  };
@@ -6,28 +6,12 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/transformers/api" />
9
- import { ParseSourceSpan, Position } from '@angular/compiler';
10
9
  import ts from 'typescript';
11
10
  import { ExtendedTsCompilerHost, NgCompilerOptions } from '../ngtsc/core/api';
12
11
  export declare const DEFAULT_ERROR_CODE = 100;
13
12
  export declare const UNKNOWN_ERROR_CODE = 500;
14
13
  export declare const SOURCE: "angular";
15
- export interface DiagnosticMessageChain {
16
- messageText: string;
17
- position?: Position;
18
- next?: DiagnosticMessageChain[];
19
- }
20
- export interface Diagnostic {
21
- messageText: string;
22
- span?: ParseSourceSpan;
23
- position?: Position;
24
- chain?: DiagnosticMessageChain;
25
- category: ts.DiagnosticCategory;
26
- code: number;
27
- source: 'angular';
28
- }
29
14
  export declare function isTsDiagnostic(diagnostic: any): diagnostic is ts.Diagnostic;
30
- export declare function isNgDiagnostic(diagnostic: any): diagnostic is Diagnostic;
31
15
  export interface CompilerOptions extends NgCompilerOptions, ts.CompilerOptions {
32
16
  genDir?: string;
33
17
  basePath?: string;
@@ -122,11 +106,6 @@ export interface TsEmitCallback {
122
106
  export interface TsMergeEmitResultsCallback {
123
107
  (results: ts.EmitResult[]): ts.EmitResult;
124
108
  }
125
- export interface LibrarySummary {
126
- fileName: string;
127
- text: string;
128
- sourceFile?: ts.SourceFile;
129
- }
130
109
  export interface LazyRoute {
131
110
  route: string;
132
111
  module: {
@@ -154,7 +133,7 @@ export interface Program {
154
133
  /**
155
134
  * Retrieve options diagnostics for the Angular options used to create the program.
156
135
  */
157
- getNgOptionDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic | Diagnostic>;
136
+ getNgOptionDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
158
137
  /**
159
138
  * Retrieve the syntax diagnostics from TypeScript. This is faster than calling
160
139
  * `getTsProgram().getSyntacticDiagnostics()` since it does not need to collect Angular structural
@@ -172,7 +151,7 @@ export interface Program {
172
151
  *
173
152
  * Angular structural information is required to produce these diagnostics.
174
153
  */
175
- getNgStructuralDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<Diagnostic>;
154
+ getNgStructuralDiagnostics(cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
176
155
  /**
177
156
  * Retrieve the semantic diagnostics from TypeScript. This is equivalent to calling
178
157
  * `getTsProgram().getSemanticDiagnostics()` directly and is included for completeness.
@@ -183,7 +162,7 @@ export interface Program {
183
162
  *
184
163
  * Angular structural information is required to produce these diagnostics.
185
164
  */
186
- getNgSemanticDiagnostics(fileName?: string, cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic | Diagnostic>;
165
+ getNgSemanticDiagnostics(fileName?: string, cancellationToken?: ts.CancellationToken): ReadonlyArray<ts.Diagnostic>;
187
166
  /**
188
167
  * Load Angular structural information asynchronously. If this method is not called then the
189
168
  * Angular structural information, including referenced HTML and CSS files, are loaded
@@ -207,10 +186,4 @@ export interface Program {
207
186
  emitCallback?: TsEmitCallback;
208
187
  mergeEmitResultsCallback?: TsMergeEmitResultsCallback;
209
188
  }): ts.EmitResult;
210
- /**
211
- * Returns the .d.ts / .ngsummary.json / .ngfactory.d.ts files of libraries that have been emitted
212
- * in this program or previous programs with paths that emulate the fact that these libraries
213
- * have been compiled before with no outDir.
214
- */
215
- getLibrarySummaries(): Map<string, LibrarySummary>;
216
189
  }
@@ -6,106 +6,10 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/transformers/compiler_host" />
9
- import { AotCompilerHost, GeneratedFile, ParseSourceSpan } from '@angular/compiler';
10
9
  import ts from 'typescript';
11
- import { TypeCheckHost } from '../diagnostics/translate_diagnostics';
12
- import { ModuleMetadata } from '../metadata/index';
13
- import { CompilerHost, CompilerOptions, LibrarySummary } from './api';
10
+ import { CompilerHost, CompilerOptions } from './api';
14
11
  export declare function setWrapHostForTest(wrapFn: ((host: ts.CompilerHost) => ts.CompilerHost) | null): void;
15
12
  export declare function createCompilerHost({ options, tsHost }: {
16
13
  options: CompilerOptions;
17
14
  tsHost?: ts.CompilerHost;
18
15
  }): CompilerHost;
19
- export interface MetadataProvider {
20
- getMetadata(sourceFile: ts.SourceFile): ModuleMetadata | undefined;
21
- }
22
- export interface CodeGenerator {
23
- generateFile(genFileName: string, baseFileName?: string): GeneratedFile;
24
- findGeneratedFileNames(fileName: string): string[];
25
- }
26
- /**
27
- * Implements the following hosts based on an api.CompilerHost:
28
- * - ts.CompilerHost to be consumed by a ts.Program
29
- * - AotCompilerHost for @angular/compiler
30
- * - TypeCheckHost for mapping ts errors to ng errors (via translateDiagnostics)
31
- */
32
- export declare class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHost, AotCompilerHost, TypeCheckHost {
33
- private rootFiles;
34
- private options;
35
- private context;
36
- private metadataProvider;
37
- private codeGenerator;
38
- private librarySummaries;
39
- private metadataReaderCache;
40
- private fileNameToModuleNameCache;
41
- private flatModuleIndexCache;
42
- private flatModuleIndexNames;
43
- private flatModuleIndexRedirectNames;
44
- private rootDirs;
45
- private moduleResolutionCache;
46
- private originalSourceFiles;
47
- private originalFileExistsCache;
48
- private generatedSourceFiles;
49
- private generatedCodeFor;
50
- private emitter;
51
- private metadataReaderHost;
52
- getCancellationToken: () => ts.CancellationToken;
53
- getDefaultLibLocation: () => string;
54
- trace: (s: string) => void;
55
- getDirectories: (path: string) => string[];
56
- resolveTypeReferenceDirectives?: (names: string[], containingFile: string) => ts.ResolvedTypeReferenceDirective[];
57
- directoryExists?: (directoryName: string) => boolean;
58
- constructor(rootFiles: ReadonlyArray<string>, options: CompilerOptions, context: CompilerHost, metadataProvider: MetadataProvider, codeGenerator: CodeGenerator, librarySummaries?: Map<string, LibrarySummary>);
59
- private resolveModuleName;
60
- resolveModuleNames(moduleNames: string[], containingFile: string): ts.ResolvedModule[];
61
- moduleNameToFileName(m: string, containingFile?: string): string | null;
62
- /**
63
- * We want a moduleId that will appear in import statements in the generated code
64
- * which will be written to `containingFile`.
65
- *
66
- * Note that we also generate files for files in node_modules, as libraries
67
- * only ship .metadata.json files but not the generated code.
68
- *
69
- * Logic:
70
- * 1. if the importedFile and the containingFile are from the project sources
71
- * or from the same node_modules package, use a relative path
72
- * 2. if the importedFile is in a node_modules package,
73
- * use a path that starts with the package name.
74
- * 3. Error if the containingFile is in the node_modules package
75
- * and the importedFile is in the project soures,
76
- * as that is a violation of the principle that node_modules packages cannot
77
- * import project sources.
78
- */
79
- fileNameToModuleName(importedFile: string, containingFile: string): string;
80
- resourceNameToFileName(resourceName: string, containingFile: string): string | null;
81
- toSummaryFileName(fileName: string, referringSrcFileName: string): string;
82
- fromSummaryFileName(fileName: string, referringLibFileName: string): string;
83
- parseSourceSpanOf(fileName: string, line: number, character: number): ParseSourceSpan | null;
84
- private getOriginalSourceFile;
85
- updateGeneratedFile(genFile: GeneratedFile): ts.SourceFile;
86
- private addGeneratedFile;
87
- shouldGenerateFile(fileName: string): {
88
- generate: boolean;
89
- baseFileName?: string;
90
- };
91
- shouldGenerateFilesFor(fileName: string): string | boolean | null;
92
- getSourceFile(fileName: string, languageVersion: ts.ScriptTarget, onError?: ((message: string) => void) | undefined): ts.SourceFile;
93
- private getGeneratedFile;
94
- private originalFileExists;
95
- fileExists(fileName: string): boolean;
96
- loadSummary(filePath: string): string | null;
97
- isSourceFile(filePath: string): boolean;
98
- readFile(fileName: string): string | undefined;
99
- getMetadataFor(filePath: string): ModuleMetadata[] | undefined;
100
- loadResource(filePath: string): Promise<string> | string;
101
- getOutputName(filePath: string): string;
102
- private hasBundleIndex;
103
- getDefaultLibFileName: (options: ts.CompilerOptions) => string;
104
- getCurrentDirectory: () => string;
105
- getCanonicalFileName: (fileName: string) => string;
106
- useCaseSensitiveFileNames: () => boolean;
107
- getNewLine: () => string;
108
- realpath: (p: string) => string;
109
- writeFile: ts.WriteFileCallback;
110
- }
111
- export declare function getOriginalReferences(sourceFile: ts.SourceFile): ts.FileReference[] | undefined;
@@ -6,29 +6,10 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/transformers/program" />
9
- import * as path from 'path';
10
- import ts from 'typescript';
11
9
  import { CompilerHost, CompilerOptions, Program } from './api';
12
- export declare function setTempProgramHandlerForTest(handler: (program: ts.Program) => void): void;
13
- export declare function resetTempProgramHandlerForTest(): void;
14
10
  export declare function createProgram({ rootNames, options, host, oldProgram }: {
15
11
  rootNames: ReadonlyArray<string>;
16
12
  options: CompilerOptions;
17
13
  host: CompilerHost;
18
14
  oldProgram?: Program;
19
15
  }): Program;
20
- /**
21
- * Returns a function that can adjust a path from source path to out path,
22
- * based on an existing mapping from source to out path.
23
- *
24
- * TODO(tbosch): talk to the TypeScript team to expose their logic for calculating the `rootDir`
25
- * if none was specified.
26
- *
27
- * Note: This function works on normalized paths from typescript but should always return
28
- * POSIX normalized paths for output paths.
29
- */
30
- export declare function createSrcToOutPathMapper(outDir: string | undefined, sampleSrcFileName: string | undefined, sampleOutFileName: string | undefined, host?: {
31
- dirname: typeof path.dirname;
32
- resolve: typeof path.resolve;
33
- relative: typeof path.relative;
34
- }): (srcFileName: string) => string;
@@ -7,28 +7,9 @@
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/transformers/util" />
9
9
  import ts from 'typescript';
10
- import { CompilerOptions, Diagnostic } from './api';
11
10
  export declare const GENERATED_FILES: RegExp;
12
- export declare const DTS: RegExp;
13
- export declare const TS: RegExp;
14
- export declare const enum StructureIsReused {
15
- Not = 0,
16
- SafeModules = 1,
17
- Completely = 2
18
- }
19
- export declare function tsStructureIsReused(program: ts.Program): StructureIsReused;
20
11
  export declare function error(msg: string): never;
21
- export declare function userError(msg: string): never;
22
- export declare function createMessageDiagnostic(messageText: string): ts.Diagnostic & Diagnostic;
23
- export declare function isInRootDir(fileName: string, options: CompilerOptions): string | true | null;
24
- export declare function relativeToRootDirs(filePath: string, rootDirs: string[]): string;
25
- /**
26
- * Converts a ng.Diagnostic into a ts.Diagnostic.
27
- * This looses some information, and also uses an incomplete object as `file`.
28
- *
29
- * I.e. only use this where the API allows only a ts.Diagnostic.
30
- */
31
- export declare function ngToTsDiagnostic(ng: Diagnostic): ts.Diagnostic;
12
+ export declare function createMessageDiagnostic(messageText: string): ts.Diagnostic;
32
13
  /**
33
14
  * Strip multiline comment start and end markers from the `commentText` string.
34
15
  *