@angular/compiler-cli 13.1.0-next.3 → 13.1.3

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 (96) hide show
  1. package/bundles/{chunk-UMUIU7TE.js → chunk-7UHLQOIO.js} +4 -4
  2. package/bundles/{chunk-UMUIU7TE.js.map → chunk-7UHLQOIO.js.map} +0 -0
  3. package/bundles/{chunk-QDWL7SZJ.js → chunk-BPCUCINV.js} +2 -2
  4. package/bundles/{chunk-QDWL7SZJ.js.map → chunk-BPCUCINV.js.map} +0 -0
  5. package/bundles/{chunk-COAETSNP.js → chunk-CKZCKW5B.js} +785 -1129
  6. package/bundles/chunk-CKZCKW5B.js.map +6 -0
  7. package/bundles/{chunk-GLCRIILX.js → chunk-J6CW3T62.js} +5 -5
  8. package/bundles/{chunk-GLCRIILX.js.map → chunk-J6CW3T62.js.map} +0 -0
  9. package/bundles/{chunk-SKBLJA43.js → chunk-JTYUTYS2.js} +3 -3
  10. package/bundles/{chunk-SKBLJA43.js.map → chunk-JTYUTYS2.js.map} +0 -0
  11. package/bundles/{chunk-UIKTHF6Z.js → chunk-K5FPDA5B.js} +61 -63
  12. package/bundles/chunk-K5FPDA5B.js.map +6 -0
  13. package/bundles/{chunk-MFCLQBFK.js → chunk-KU4D2JVX.js} +39 -41
  14. package/bundles/chunk-KU4D2JVX.js.map +6 -0
  15. package/bundles/{chunk-7HVF6UHR.js → chunk-KXVQ4SSM.js} +24 -22
  16. package/bundles/chunk-KXVQ4SSM.js.map +6 -0
  17. package/bundles/{chunk-IESRH26X.js → chunk-L23I4NJT.js} +744 -434
  18. package/bundles/chunk-L23I4NJT.js.map +6 -0
  19. package/bundles/{chunk-QL6ZC3U3.js → chunk-RDTZZXLZ.js} +12 -12
  20. package/bundles/{chunk-QL6ZC3U3.js.map → chunk-RDTZZXLZ.js.map} +1 -1
  21. package/bundles/{chunk-EP5JHXG2.js → chunk-RGGJJ7ZZ.js} +39 -60
  22. package/bundles/chunk-RGGJJ7ZZ.js.map +6 -0
  23. package/bundles/{chunk-JJMLEEKA.js → chunk-RNVIUKDY.js} +9 -9
  24. package/bundles/chunk-RNVIUKDY.js.map +6 -0
  25. package/bundles/{chunk-HDZS2JG2.js → chunk-VUEDWBJP.js} +270 -100
  26. package/bundles/chunk-VUEDWBJP.js.map +6 -0
  27. package/bundles/{chunk-XA5IZLLC.js → chunk-WQ3TNYTD.js} +6 -6
  28. package/bundles/{chunk-XA5IZLLC.js.map → chunk-WQ3TNYTD.js.map} +0 -0
  29. package/bundles/{chunk-4EDYFHXN.js → chunk-XXMNTCYN.js} +9 -9
  30. package/bundles/chunk-XXMNTCYN.js.map +6 -0
  31. package/bundles/{chunk-7HBAJSZA.js → chunk-ZLL7BXGD.js} +228 -190
  32. package/bundles/chunk-ZLL7BXGD.js.map +6 -0
  33. package/bundles/index.js +16 -30
  34. package/bundles/index.js.map +2 -2
  35. package/bundles/linker/babel/index.js +85 -85
  36. package/bundles/linker/babel/index.js.map +1 -1
  37. package/bundles/linker/index.js +5 -5
  38. package/bundles/ngcc/index.js +13 -13
  39. package/bundles/ngcc/main-ngcc.js +14 -14
  40. package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +14 -14
  41. package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js +5 -5
  42. package/bundles/private/bazel.js +2 -2
  43. package/bundles/private/localize.js +4 -4
  44. package/bundles/private/migrations.js +6 -6
  45. package/bundles/private/tooling.js +3 -3
  46. package/bundles/src/bin/ng_xi18n.js +11 -11
  47. package/bundles/src/bin/ngc.js +11 -11
  48. package/bundles/src/bin/ngc.js.map +1 -1
  49. package/bundles_metadata.json +1 -1
  50. package/index.d.ts +2 -2
  51. package/ngcc/src/packages/adjust_cjs_umd_exports.d.ts +17 -0
  52. package/ngcc/src/packages/build_marker.d.ts +1 -1
  53. package/ngcc/src/packages/source_file_cache.d.ts +2 -1
  54. package/package.json +2 -2
  55. package/src/main.d.ts +3 -3
  56. package/src/ngtsc/annotations/src/util.d.ts +1 -1
  57. package/src/ngtsc/core/api/src/options.d.ts +3 -2
  58. package/src/ngtsc/core/api/src/public_options.d.ts +38 -0
  59. package/src/ngtsc/core/src/host.d.ts +1 -1
  60. package/src/ngtsc/diagnostics/index.d.ts +2 -1
  61. package/src/ngtsc/diagnostics/src/error.d.ts +1 -0
  62. package/src/ngtsc/diagnostics/src/error_code.d.ts +7 -0
  63. package/src/ngtsc/diagnostics/src/error_details_base_url.d.ts +1 -1
  64. package/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.d.ts +21 -0
  65. package/src/ngtsc/file_system/src/compiler_host.d.ts +1 -0
  66. package/src/ngtsc/imports/index.d.ts +1 -1
  67. package/src/ngtsc/imports/src/emitter.d.ts +40 -8
  68. package/src/ngtsc/program.d.ts +3 -6
  69. package/src/ngtsc/program_driver/src/ts_create_program_driver.d.ts +1 -1
  70. package/src/ngtsc/translator/src/translator.d.ts +0 -5
  71. package/src/ngtsc/translator/src/type_translator.d.ts +0 -2
  72. package/src/ngtsc/typecheck/extended/api/api.d.ts +30 -10
  73. package/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.d.ts +3 -14
  74. package/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.d.ts +3 -15
  75. package/src/ngtsc/typecheck/extended/index.d.ts +3 -0
  76. package/src/ngtsc/typecheck/extended/src/extended_template_checker.d.ts +5 -4
  77. package/src/ngtsc/typecheck/src/environment.d.ts +3 -1
  78. package/src/ngtsc/typecheck/src/tcb_util.d.ts +10 -2
  79. package/src/ngtsc/typecheck/src/type_constructor.d.ts +3 -2
  80. package/src/ngtsc/typecheck/src/type_emitter.d.ts +7 -21
  81. package/src/ngtsc/typecheck/src/type_parameter_emitter.d.ts +2 -2
  82. package/src/ngtsc/util/src/typescript.d.ts +0 -5
  83. package/src/perform_compile.d.ts +5 -10
  84. package/src/perform_watch.d.ts +4 -4
  85. package/src/transformers/api.d.ts +3 -30
  86. package/src/transformers/util.d.ts +4 -6
  87. package/bundles/chunk-4EDYFHXN.js.map +0 -6
  88. package/bundles/chunk-7HBAJSZA.js.map +0 -6
  89. package/bundles/chunk-7HVF6UHR.js.map +0 -6
  90. package/bundles/chunk-COAETSNP.js.map +0 -6
  91. package/bundles/chunk-EP5JHXG2.js.map +0 -6
  92. package/bundles/chunk-HDZS2JG2.js.map +0 -6
  93. package/bundles/chunk-IESRH26X.js.map +0 -6
  94. package/bundles/chunk-JJMLEEKA.js.map +0 -6
  95. package/bundles/chunk-MFCLQBFK.js.map +0 -6
  96. package/bundles/chunk-UIKTHF6Z.js.map +0 -6
package/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  /// <amd-module name="@angular/compiler-cli" />
2
- export { AotCompilerHost, AotCompilerHost as StaticReflectorHost, StaticReflector, StaticSymbol } from '@angular/compiler';
3
2
  export { VERSION } from './src/version';
4
3
  export * from './src/transformers/api';
5
4
  export * from './src/transformers/entry_points';
6
5
  export * from './src/perform_compile';
7
6
  export { CompilerOptions as AngularCompilerOptions } from './src/transformers/api';
8
- export { ngToTsDiagnostic } from './src/transformers/util';
9
7
  export * from './private/tooling';
10
8
  export * from './src/ngtsc/logging';
11
9
  export * from './src/ngtsc/file_system';
12
10
  export { NgTscPlugin } from './src/ngtsc/tsc_plugin';
13
11
  export { NgtscProgram } from './src/ngtsc/program';
14
12
  export { OptimizeFor } from './src/ngtsc/typecheck/api';
13
+ export { ConsoleLogger, Logger, LogLevel } from './src/ngtsc/logging';
14
+ export { NodeJSFileSystem } from './src/ngtsc/file_system';
@@ -0,0 +1,17 @@
1
+ /// <amd-module name="@angular/compiler-cli/ngcc/src/packages/adjust_cjs_umd_exports" />
2
+ /**
3
+ * UMD/CJS bundles generated by Rollup may be using an element access expression like
4
+ * `exports["ɵa"]` for declaring and exporting classes, instead of a property access like
5
+ * `exports.ɵa`. The element access syntax introduces a problem for ngcc, where it wouldn't consider
6
+ * such export as class declaration, causing them to be skipped. The ngtsc compiler is implemented
7
+ * with the assumption that all class declarations use a `ts.Identifier` as name, whereas the
8
+ * element access is using a string literal for the declared name. This makes it troublesome for
9
+ * ngcc to support this syntax form in UMD bundles.
10
+ *
11
+ * To work around the problem, this function transforms these access expressions into regular
12
+ * property accesses. The source text is parsed to an AST to allow finding the element accesses in a
13
+ * robust way, after which the affected text ranges are replaced with property accesses in the
14
+ * original source text. These replacement operations are faster than applying an AST transform and
15
+ * going through a `ts.Printer` to print the text back out.
16
+ */
17
+ export declare function adjustElementAccessExports(sourceText: string): string;
@@ -9,7 +9,7 @@
9
9
  import { AbsoluteFsPath } from '../../../src/ngtsc/file_system';
10
10
  import { PackageJsonUpdater } from '../writing/package_json_updater';
11
11
  import { EntryPointPackageJson, PackageJsonFormatProperties } from './entry_point';
12
- export declare const NGCC_VERSION = "13.1.0-next.3";
12
+ export declare const NGCC_VERSION = "13.1.3";
13
13
  /**
14
14
  * Returns true if there is a format in this entry-point that was compiled with an outdated version
15
15
  * of ngcc.
@@ -77,8 +77,9 @@ export declare function isAngularDts(absPath: AbsoluteFsPath, fs: ReadonlyFileSy
77
77
  export declare class EntryPointFileCache {
78
78
  private fs;
79
79
  private sharedFileCache;
80
+ private processSourceText;
80
81
  private readonly sfCache;
81
- constructor(fs: ReadonlyFileSystem, sharedFileCache: SharedFileCache);
82
+ constructor(fs: ReadonlyFileSystem, sharedFileCache: SharedFileCache, processSourceText: (sourceText: string) => string);
82
83
  /**
83
84
  * Returns and caches a parsed `ts.SourceFile` for the provided `fileName`. If the `fileName` is
84
85
  * cached in the shared file cache, that result is used. Otherwise, the source file is cached
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/compiler-cli",
3
- "version": "13.1.0-next.3",
3
+ "version": "13.1.3",
4
4
  "description": "Angular - the compiler CLI for Node.js",
5
5
  "typings": "index.d.ts",
6
6
  "bin": {
@@ -66,7 +66,7 @@
66
66
  "yargs": "^17.2.1"
67
67
  },
68
68
  "peerDependencies": {
69
- "@angular/compiler": "13.1.0-next.3",
69
+ "@angular/compiler": "13.1.3",
70
70
  "typescript": ">=4.4.2 <4.6"
71
71
  },
72
72
  "repository": {
package/src/main.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/main" />
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
  declare type TsickleModule = typeof import('tsickle');
13
13
  export declare function main(args: string[], consoleError?: (s: string) => void, config?: NgcParsedConfiguration, customTransformers?: api.CustomTransformers, programReuse?: {
@@ -17,7 +17,7 @@ export declare function mainDiagnosticsForTest(args: string[], config?: NgcParse
17
17
  program: api.Program | undefined;
18
18
  }, modifiedResourceFiles?: Set<string> | null, tsickle?: TsickleModule): {
19
19
  exitCode: number;
20
- diagnostics: ReadonlyArray<ts.Diagnostic | api.Diagnostic>;
20
+ diagnostics: ReadonlyArray<ts.Diagnostic>;
21
21
  };
22
22
  export interface NgcParsedConfiguration extends ParsedConfiguration {
23
23
  watch?: boolean;
@@ -27,6 +27,6 @@ export declare function readCommandLineAndConfiguration(args: string[], existing
27
27
  export declare function watchMode(project: string, options: api.CompilerOptions, consoleError: (s: string) => void): {
28
28
  close: () => void;
29
29
  ready: (cb: () => void) => void;
30
- firstCompileResult: Diagnostics;
30
+ firstCompileResult: readonly ts.Diagnostic[];
31
31
  };
32
32
  export {};
@@ -50,7 +50,7 @@ export declare function getValidConstructorDependencies(clazz: ClassDeclaration,
50
50
  * deps.
51
51
  */
52
52
  export declare function validateConstructorDependencies(clazz: ClassDeclaration, deps: ConstructorDeps | null): R3DependencyMetadata[] | null;
53
- export declare function toR3Reference(valueRef: Reference, typeRef: Reference, valueContext: ts.SourceFile, typeContext: ts.SourceFile, refEmitter: ReferenceEmitter): R3Reference;
53
+ export declare function toR3Reference(origin: ts.Node, valueRef: Reference, typeRef: Reference, valueContext: ts.SourceFile, typeContext: ts.SourceFile, refEmitter: ReferenceEmitter): R3Reference;
54
54
  export declare function isAngularCore(decorator: Decorator): decorator is Decorator & {
55
55
  import: Import;
56
56
  };
@@ -7,7 +7,7 @@
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/core/api/src/options" />
9
9
  import ts from 'typescript';
10
- import { BazelAndG3Options, I18nOptions, LegacyNgcOptions, MiscOptions, NgcCompatibilityOptions, StrictTemplateOptions, TargetOptions } from './public_options';
10
+ import { BazelAndG3Options, DiagnosticOptions, I18nOptions, LegacyNgcOptions, MiscOptions, NgcCompatibilityOptions, StrictTemplateOptions, TargetOptions } from './public_options';
11
11
  /**
12
12
  * Non-public options which are useful during testing of the compiler.
13
13
  */
@@ -37,5 +37,6 @@ export interface InternalOptions {
37
37
  *
38
38
  * Also includes a few miscellaneous options.
39
39
  */
40
- export interface NgCompilerOptions extends ts.CompilerOptions, LegacyNgcOptions, BazelAndG3Options, NgcCompatibilityOptions, StrictTemplateOptions, TestOnlyOptions, I18nOptions, TargetOptions, InternalOptions, MiscOptions {
40
+ export interface NgCompilerOptions extends ts.CompilerOptions, LegacyNgcOptions, BazelAndG3Options, DiagnosticOptions, NgcCompatibilityOptions, StrictTemplateOptions, TestOnlyOptions, I18nOptions, TargetOptions, InternalOptions, MiscOptions {
41
+ [prop: string]: any;
41
42
  }
@@ -6,6 +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/core/api/src/public_options" />
9
+ import { ExtendedTemplateDiagnosticName } from '../../../../ngtsc/diagnostics';
9
10
  /**
10
11
  * Options supported by the legacy View Engine compiler, which are still consumed by the Angular Ivy
11
12
  * compiler for backwards compatibility.
@@ -237,6 +238,43 @@ export interface StrictTemplateOptions {
237
238
  */
238
239
  strictLiteralTypes?: boolean;
239
240
  }
241
+ /**
242
+ * A label referring to a `ts.DiagnosticCategory` or `'suppress'`, meaning the associated diagnostic
243
+ * should not be displayed at all.
244
+ *
245
+ * @publicApi
246
+ */
247
+ export declare enum DiagnosticCategoryLabel {
248
+ /** Treat the diagnostic as a warning, don't fail the compilation. */
249
+ Warning = "warning",
250
+ /** Treat the diagnostic as a hard error, fail the compilation. */
251
+ Error = "error",
252
+ /** Ignore the diagnostic altogether. */
253
+ Suppress = "suppress"
254
+ }
255
+ /**
256
+ * Options which control how diagnostics are emitted from the compiler.
257
+ *
258
+ * @publicApi
259
+ */
260
+ export interface DiagnosticOptions {
261
+ /** Options which control how diagnostics are emitted from the compiler. */
262
+ extendedDiagnostics?: {
263
+ /**
264
+ * The category to use for configurable diagnostics which are not overridden by `checks`. Uses
265
+ * `warning` by default.
266
+ */
267
+ defaultCategory?: DiagnosticCategoryLabel;
268
+ /**
269
+ * A map of each extended template diagnostic's name to its category. This can be expanded in
270
+ * the future with more information for each check or for additional diagnostics not part of the
271
+ * extended template diagnostics system.
272
+ */
273
+ checks?: {
274
+ [Name in ExtendedTemplateDiagnosticName]?: DiagnosticCategoryLabel;
275
+ };
276
+ };
277
+ }
240
278
  /**
241
279
  * Options which control behavior useful for "monorepo" build cases using Bazel (such as the
242
280
  * internal Google monorepo, g3).
@@ -48,7 +48,7 @@ export declare class DelegatingCompilerHost implements Omit<RequiredDelegations<
48
48
  trace: ((s: string) => void) | undefined;
49
49
  useCaseSensitiveFileNames: () => boolean;
50
50
  writeFile: ts.WriteFileCallback;
51
- getModuleResolutionCache: any;
51
+ getModuleResolutionCache: (() => ts.ModuleResolutionCache | undefined) | undefined;
52
52
  }
53
53
  /**
54
54
  * A wrapper around `ts.CompilerHost` (plus any extension methods from `ExtendedTsCompilerHost`).
@@ -7,7 +7,8 @@
7
7
  */
8
8
  /// <amd-module name="@angular/compiler-cli/src/ngtsc/diagnostics" />
9
9
  export { COMPILER_ERRORS_WITH_GUIDES } from './src/docs';
10
- export { FatalDiagnosticError, isFatalDiagnosticError, makeDiagnostic, makeRelatedInformation } from './src/error';
10
+ export { FatalDiagnosticError, isFatalDiagnosticError, makeDiagnostic, makeDiagnosticChain, makeRelatedInformation } from './src/error';
11
11
  export { ErrorCode } from './src/error_code';
12
12
  export { ERROR_DETAILS_PAGE_BASE_URL } from './src/error_details_base_url';
13
+ export { ExtendedTemplateDiagnosticName } from './src/extended_template_diagnostic_name';
13
14
  export { ngErrorCode, replaceTsWithNgInErrors } from './src/util';
@@ -17,5 +17,6 @@ export declare class FatalDiagnosticError {
17
17
  toDiagnostic(): ts.DiagnosticWithLocation;
18
18
  }
19
19
  export declare function makeDiagnostic(code: ErrorCode, node: ts.Node, messageText: string | ts.DiagnosticMessageChain, relatedInformation?: ts.DiagnosticRelatedInformation[]): ts.DiagnosticWithLocation;
20
+ export declare function makeDiagnosticChain(messageText: string, next?: ts.DiagnosticMessageChain[]): ts.DiagnosticMessageChain;
20
21
  export declare function makeRelatedInformation(node: ts.Node, messageText: string): ts.DiagnosticRelatedInformation;
21
22
  export declare function isFatalDiagnosticError(err: any): err is FatalDiagnosticError;
@@ -54,8 +54,15 @@ export declare enum ErrorCode {
54
54
  * created that cannot be handled, such as in partial compilation mode.
55
55
  */
56
56
  IMPORT_CYCLE_DETECTED = 3003,
57
+ /**
58
+ * Raised when the compiler is unable to generate an import statement for a reference.
59
+ */
60
+ IMPORT_GENERATION_FAILURE = 3004,
57
61
  CONFIG_FLAT_MODULE_NO_INDEX = 4001,
58
62
  CONFIG_STRICT_TEMPLATES_IMPLIES_FULL_TEMPLATE_TYPECHECK = 4002,
63
+ CONFIG_EXTENDED_DIAGNOSTICS_IMPLIES_STRICT_TEMPLATES = 4003,
64
+ CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CATEGORY_LABEL = 4004,
65
+ CONFIG_EXTENDED_DIAGNOSTICS_UNKNOWN_CHECK = 4005,
59
66
  /**
60
67
  * Raised when a host expression has a parse error, such as a host listener or host binding
61
68
  * expression containing a pipe.
@@ -11,6 +11,6 @@
11
11
  *
12
12
  * Keep the files below in full sync:
13
13
  * - packages/compiler-cli/src/ngtsc/diagnostics/src/error_details_base_url.ts
14
- * - packages/core/src/render3/error_details_base_url.ts
14
+ * - packages/core/src/error_details_base_url.ts
15
15
  */
16
16
  export declare const ERROR_DETAILS_PAGE_BASE_URL = "https://angular.io/errors";
@@ -0,0 +1,21 @@
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
+ /// <amd-module name="@angular/compiler-cli/src/ngtsc/diagnostics/src/extended_template_diagnostic_name" />
9
+ /**
10
+ * Enum holding the name of each extended template diagnostic. The name is used as a user-meaningful
11
+ * value for configuring the diagnostic in the project's options.
12
+ *
13
+ * See the corresponding `ErrorCode` for documentation about each specific error.
14
+ * packages/compiler-cli/src/ngtsc/diagnostics/src/error_code.ts
15
+ *
16
+ * @publicApi
17
+ */
18
+ export declare enum ExtendedTemplateDiagnosticName {
19
+ INVALID_BANANA_IN_BOX = "invalidBananaInBox",
20
+ NULLISH_COALESCING_NOT_NULLABLE = "nullishCoalescingNotNullable"
21
+ }
@@ -22,4 +22,5 @@ export declare class NgtscCompilerHost implements ts.CompilerHost {
22
22
  getNewLine(): string;
23
23
  fileExists(fileName: string): boolean;
24
24
  readFile(fileName: string): string | undefined;
25
+ realpath(path: string): string;
25
26
  }
@@ -9,7 +9,7 @@
9
9
  export { AliasingHost, AliasStrategy, PrivateExportAliasingHost, UnifiedModulesAliasingHost } from './src/alias';
10
10
  export { ImportRewriter, NoopImportRewriter, R3SymbolsImportRewriter, validateAndRewriteCoreSymbol } from './src/core';
11
11
  export { DefaultImportTracker } from './src/default';
12
- export { AbsoluteModuleStrategy, EmittedReference, ImportedFile, ImportFlags, LocalIdentifierStrategy, LogicalProjectStrategy, ReferenceEmitStrategy, ReferenceEmitter, RelativePathStrategy, UnifiedModulesStrategy } from './src/emitter';
12
+ export { AbsoluteModuleStrategy, assertSuccessfulReferenceEmit, EmittedReference, FailedEmitResult, ImportedFile, ImportFlags, LocalIdentifierStrategy, LogicalProjectStrategy, ReferenceEmitKind, ReferenceEmitResult, ReferenceEmitStrategy, ReferenceEmitter, RelativePathStrategy, UnifiedModulesStrategy } from './src/emitter';
13
13
  export { Reexport } from './src/reexport';
14
14
  export { OwningModule, Reference } from './src/references';
15
15
  export { ModuleResolver } from './src/resolver';
@@ -51,11 +51,16 @@ export declare enum ImportFlags {
51
51
  * an import then `null` should be used.
52
52
  */
53
53
  export declare type ImportedFile = ts.SourceFile | 'unknown' | null;
54
+ export declare const enum ReferenceEmitKind {
55
+ Success = 0,
56
+ Failed = 1
57
+ }
54
58
  /**
55
59
  * Represents the emitted expression of a `Reference` that is valid in the source file it was
56
60
  * emitted from.
57
61
  */
58
62
  export interface EmittedReference {
63
+ kind: ReferenceEmitKind.Success;
59
64
  /**
60
65
  * The expression that refers to `Reference`.
61
66
  */
@@ -68,6 +73,33 @@ export interface EmittedReference {
68
73
  */
69
74
  importedFile: ImportedFile;
70
75
  }
76
+ /**
77
+ * Represents a failure to emit a `Reference` into a different source file.
78
+ */
79
+ export interface FailedEmitResult {
80
+ kind: ReferenceEmitKind.Failed;
81
+ /**
82
+ * The reference that could not be emitted.
83
+ */
84
+ ref: Reference;
85
+ /**
86
+ * The source file into which the reference was requested to be emitted.
87
+ */
88
+ context: ts.SourceFile;
89
+ /**
90
+ * Describes why the reference could not be emitted. This may be shown in a diagnostic.
91
+ */
92
+ reason: string;
93
+ }
94
+ export declare type ReferenceEmitResult = EmittedReference | FailedEmitResult;
95
+ /**
96
+ * Verifies that a reference was emitted successfully, or raises a `FatalDiagnosticError` otherwise.
97
+ * @param result The emit result that should have been successful.
98
+ * @param origin The node that is used to report the failure diagnostic.
99
+ * @param typeKind The kind of the symbol that the reference represents, e.g. 'component' or
100
+ * 'class'.
101
+ */
102
+ export declare function assertSuccessfulReferenceEmit(result: ReferenceEmitResult, origin: ts.Node, typeKind: string): asserts result is EmittedReference;
71
103
  /**
72
104
  * A particular strategy for generating an expression which refers to a `Reference`.
73
105
  *
@@ -91,7 +123,7 @@ export interface ReferenceEmitStrategy {
91
123
  * @returns an `EmittedReference` which refers to the `Reference`, or `null` if none can be
92
124
  * generated
93
125
  */
94
- emit(ref: Reference, context: ts.SourceFile, importFlags: ImportFlags): EmittedReference | null;
126
+ emit(ref: Reference, context: ts.SourceFile, importFlags: ImportFlags): ReferenceEmitResult | null;
95
127
  }
96
128
  /**
97
129
  * Generates `Expression`s which refer to `Reference`s in a given context.
@@ -102,7 +134,7 @@ export interface ReferenceEmitStrategy {
102
134
  export declare class ReferenceEmitter {
103
135
  private strategies;
104
136
  constructor(strategies: ReferenceEmitStrategy[]);
105
- emit(ref: Reference, context: ts.SourceFile, importFlags?: ImportFlags): EmittedReference;
137
+ emit(ref: Reference, context: ts.SourceFile, importFlags?: ImportFlags): ReferenceEmitResult;
106
138
  }
107
139
  /**
108
140
  * A `ReferenceEmitStrategy` which will refer to declarations by any local `ts.Identifier`s, if
@@ -118,11 +150,11 @@ interface ModuleExports {
118
150
  /**
119
151
  * The source file of the module.
120
152
  */
121
- module: ts.SourceFile;
153
+ module: ts.SourceFile | null;
122
154
  /**
123
155
  * The map of declarations to their exported name.
124
156
  */
125
- exportMap: Map<DeclarationNode, string>;
157
+ exportMap: Map<DeclarationNode, string> | null;
126
158
  }
127
159
  /**
128
160
  * A `ReferenceEmitStrategy` which will refer to declarations that come from `node_modules` using
@@ -144,9 +176,9 @@ export declare class AbsoluteModuleStrategy implements ReferenceEmitStrategy {
144
176
  */
145
177
  private moduleExportsCache;
146
178
  constructor(program: ts.Program, checker: ts.TypeChecker, moduleResolver: ModuleResolver, reflectionHost: ReflectionHost);
147
- emit(ref: Reference, context: ts.SourceFile, importFlags: ImportFlags): EmittedReference | null;
179
+ emit(ref: Reference, context: ts.SourceFile, importFlags: ImportFlags): ReferenceEmitResult | null;
148
180
  private getExportsOfModule;
149
- protected enumerateExportsOfModule(specifier: string, fromFile: string): ModuleExports | null;
181
+ protected enumerateExportsOfModule(specifier: string, fromFile: string): ModuleExports;
150
182
  }
151
183
  /**
152
184
  * A `ReferenceEmitStrategy` which will refer to declarations via relative paths, provided they're
@@ -160,7 +192,7 @@ export declare class LogicalProjectStrategy implements ReferenceEmitStrategy {
160
192
  private reflector;
161
193
  private logicalFs;
162
194
  constructor(reflector: ReflectionHost, logicalFs: LogicalFileSystem);
163
- emit(ref: Reference, context: ts.SourceFile): EmittedReference | null;
195
+ emit(ref: Reference, context: ts.SourceFile): ReferenceEmitResult | null;
164
196
  }
165
197
  /**
166
198
  * A `ReferenceEmitStrategy` which constructs relatives paths between `ts.SourceFile`s.
@@ -171,7 +203,7 @@ export declare class LogicalProjectStrategy implements ReferenceEmitStrategy {
171
203
  export declare class RelativePathStrategy implements ReferenceEmitStrategy {
172
204
  private reflector;
173
205
  constructor(reflector: ReflectionHost);
174
- emit(ref: Reference, context: ts.SourceFile): EmittedReference | null;
206
+ emit(ref: Reference, context: ts.SourceFile): ReferenceEmitResult | null;
175
207
  }
176
208
  /**
177
209
  * A `ReferenceEmitStrategy` which uses a `UnifiedModulesHost` to generate absolute import
@@ -6,7 +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/program" />
9
- import { GeneratedFile } from '@angular/compiler';
10
9
  import ts from 'typescript';
11
10
  import * as api from '../transformers/api';
12
11
  import { NgCompiler } from './core';
@@ -33,9 +32,9 @@ export declare class NgtscProgram implements api.Program {
33
32
  getTsOptionDiagnostics(cancellationToken?: ts.CancellationToken | undefined): readonly ts.Diagnostic[];
34
33
  getTsSyntacticDiagnostics(sourceFile?: ts.SourceFile | undefined, cancellationToken?: ts.CancellationToken | undefined): readonly ts.Diagnostic[];
35
34
  getTsSemanticDiagnostics(sourceFile?: ts.SourceFile | undefined, cancellationToken?: ts.CancellationToken | undefined): readonly ts.Diagnostic[];
36
- getNgOptionDiagnostics(cancellationToken?: ts.CancellationToken | undefined): readonly (ts.Diagnostic | api.Diagnostic)[];
37
- getNgStructuralDiagnostics(cancellationToken?: ts.CancellationToken | undefined): readonly api.Diagnostic[];
38
- getNgSemanticDiagnostics(fileName?: string | undefined, cancellationToken?: ts.CancellationToken | undefined): readonly (ts.Diagnostic | api.Diagnostic)[];
35
+ getNgOptionDiagnostics(cancellationToken?: ts.CancellationToken | undefined): readonly ts.Diagnostic[];
36
+ getNgStructuralDiagnostics(cancellationToken?: ts.CancellationToken | undefined): readonly ts.Diagnostic[];
37
+ getNgSemanticDiagnostics(fileName?: string | undefined, cancellationToken?: ts.CancellationToken | undefined): readonly ts.Diagnostic[];
39
38
  /**
40
39
  * Ensure that the `NgCompiler` has properly analyzed the program, and allow for the asynchronous
41
40
  * loading of any resources during the process.
@@ -54,7 +53,5 @@ export declare class NgtscProgram implements api.Program {
54
53
  mergeEmitResultsCallback?: api.TsMergeEmitResultsCallback | undefined;
55
54
  } | undefined): ts.EmitResult;
56
55
  getIndexedComponents(): Map<DeclarationNode, IndexedComponent>;
57
- getLibrarySummaries(): Map<string, api.LibrarySummary>;
58
- getEmittedGeneratedFiles(): Map<string, GeneratedFile>;
59
56
  getEmittedSourceFiles(): Map<string, ts.SourceFile>;
60
57
  }
@@ -40,7 +40,7 @@ export declare class DelegatingCompilerHost implements Omit<RequiredDelegations<
40
40
  resolveTypeReferenceDirectives: ((typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference: ts.ResolvedProjectReference | undefined, options: ts.CompilerOptions) => (ts.ResolvedTypeReferenceDirective | undefined)[]) | undefined;
41
41
  trace: ((s: string) => void) | undefined;
42
42
  useCaseSensitiveFileNames: () => boolean;
43
- getModuleResolutionCache: any;
43
+ getModuleResolutionCache: (() => ts.ModuleResolutionCache | undefined) | undefined;
44
44
  }
45
45
  /**
46
46
  * Updates a `ts.Program` instance with a new one that incorporates specific changes, using the
@@ -28,10 +28,7 @@ export declare class ExpressionTranslatorVisitor<TStatement, TExpression> implem
28
28
  visitDeclareFunctionStmt(stmt: o.DeclareFunctionStmt, context: Context): TStatement;
29
29
  visitExpressionStmt(stmt: o.ExpressionStatement, context: Context): TStatement;
30
30
  visitReturnStmt(stmt: o.ReturnStatement, context: Context): TStatement;
31
- visitDeclareClassStmt(_stmt: o.ClassStmt, _context: Context): never;
32
31
  visitIfStmt(stmt: o.IfStmt, context: Context): TStatement;
33
- visitTryCatchStmt(_stmt: o.TryCatchStmt, _context: Context): never;
34
- visitThrowStmt(stmt: o.ThrowStmt, context: Context): TStatement;
35
32
  visitReadVarExpr(ast: o.ReadVarExpr, _context: Context): TExpression;
36
33
  visitWriteVarExpr(expr: o.WriteVarExpr, context: Context): TExpression;
37
34
  visitWriteKeyExpr(expr: o.WriteKeyExpr, context: Context): TExpression;
@@ -50,8 +47,6 @@ export declare class ExpressionTranslatorVisitor<TStatement, TExpression> implem
50
47
  visitExternalExpr(ast: o.ExternalExpr, _context: Context): TExpression;
51
48
  visitConditionalExpr(ast: o.ConditionalExpr, context: Context): TExpression;
52
49
  visitNotExpr(ast: o.NotExpr, context: Context): TExpression;
53
- visitAssertNotNullExpr(ast: o.AssertNotNull, context: Context): TExpression;
54
- visitCastExpr(ast: o.CastExpr, context: Context): TExpression;
55
50
  visitFunctionExpr(ast: o.FunctionExpr, context: Context): TExpression;
56
51
  visitBinaryOperatorExpr(ast: o.BinaryOperatorExpr, context: Context): TExpression;
57
52
  visitReadPropExpr(ast: o.ReadPropExpr, context: Context): TExpression;
@@ -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
  }