@angular/compiler-cli 13.1.1 → 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.
- package/bundles/{chunk-KWZNY2SK.js → chunk-5TY44ZS3.js} +96 -98
- package/bundles/chunk-5TY44ZS3.js.map +6 -0
- package/bundles/{chunk-TI3THPMZ.js → chunk-676MI6WZ.js} +39 -60
- package/bundles/chunk-676MI6WZ.js.map +6 -0
- package/bundles/{chunk-DJRTTRF3.js → chunk-6VRWTEQB.js} +61 -63
- package/bundles/chunk-6VRWTEQB.js.map +6 -0
- package/bundles/{chunk-X46CEINM.js → chunk-7PY7XEFH.js} +9 -9
- package/bundles/chunk-7PY7XEFH.js.map +6 -0
- package/bundles/{chunk-AUFNJGZ6.js → chunk-A5PL3TE6.js} +9 -9
- package/bundles/chunk-A5PL3TE6.js.map +6 -0
- package/bundles/{chunk-PF3ZPGF5.js → chunk-ADHVDA4A.js} +12 -12
- package/bundles/{chunk-PF3ZPGF5.js.map → chunk-ADHVDA4A.js.map} +1 -1
- package/bundles/{chunk-FXVUPJ6A.js → chunk-FUZ3CSDO.js} +330 -434
- package/bundles/chunk-FUZ3CSDO.js.map +6 -0
- package/bundles/{chunk-J6CW3T62.js → chunk-GLCRIILX.js} +5 -5
- package/bundles/{chunk-J6CW3T62.js.map → chunk-GLCRIILX.js.map} +0 -0
- package/bundles/{chunk-W5CGOJQ4.js → chunk-JOLPJ2E4.js} +16 -20
- package/bundles/chunk-JOLPJ2E4.js.map +6 -0
- package/bundles/{chunk-QFB4WK55.js → chunk-O4XVCXRT.js} +4 -4
- package/bundles/{chunk-QFB4WK55.js.map → chunk-O4XVCXRT.js.map} +0 -0
- package/bundles/{chunk-O5ZEI3UY.js → chunk-QBU7RUKB.js} +270 -100
- package/bundles/chunk-QBU7RUKB.js.map +6 -0
- package/bundles/{chunk-BPCUCINV.js → chunk-QDWL7SZJ.js} +2 -2
- package/bundles/{chunk-BPCUCINV.js.map → chunk-QDWL7SZJ.js.map} +0 -0
- package/bundles/{chunk-JTYUTYS2.js → chunk-SKBLJA43.js} +3 -3
- package/bundles/{chunk-JTYUTYS2.js.map → chunk-SKBLJA43.js.map} +0 -0
- package/bundles/{chunk-P5ZW5MI4.js → chunk-TUNE6DP3.js} +485 -350
- package/bundles/chunk-TUNE6DP3.js.map +6 -0
- package/bundles/{chunk-OOIW53QX.js → chunk-UESD6FVI.js} +39 -41
- package/bundles/chunk-UESD6FVI.js.map +6 -0
- package/bundles/{chunk-XA5IZLLC.js → chunk-WQ3TNYTD.js} +6 -6
- package/bundles/{chunk-XA5IZLLC.js.map → chunk-WQ3TNYTD.js.map} +0 -0
- package/bundles/index.js +14 -14
- package/bundles/index.js.map +1 -1
- package/bundles/linker/babel/index.js +85 -85
- package/bundles/linker/babel/index.js.map +1 -1
- package/bundles/linker/index.js +5 -5
- package/bundles/ngcc/index.js +13 -13
- package/bundles/ngcc/main-ngcc.js +14 -14
- package/bundles/ngcc/src/execution/cluster/ngcc_cluster_worker.js +14 -14
- package/bundles/ngcc/src/locking/lock_file_with_child_process/ngcc_lock_unlocker.js +5 -5
- package/bundles/private/bazel.js +2 -2
- package/bundles/private/localize.js +4 -4
- package/bundles/private/migrations.js +6 -6
- package/bundles/private/tooling.js +3 -3
- package/bundles/src/bin/ng_xi18n.js +11 -11
- package/bundles/src/bin/ngc.js +11 -11
- package/bundles/src/bin/ngc.js.map +1 -1
- package/bundles_metadata.json +1 -1
- package/index.d.ts +2 -0
- package/ngcc/src/packages/build_marker.d.ts +1 -1
- package/package.json +2 -2
- package/src/ngtsc/annotations/src/util.d.ts +1 -1
- package/src/ngtsc/core/api/src/options.d.ts +3 -2
- package/src/ngtsc/core/api/src/public_options.d.ts +38 -0
- package/src/ngtsc/diagnostics/index.d.ts +2 -1
- package/src/ngtsc/diagnostics/src/error.d.ts +1 -0
- package/src/ngtsc/diagnostics/src/error_code.d.ts +7 -0
- package/src/ngtsc/diagnostics/src/error_details_base_url.d.ts +1 -1
- package/src/ngtsc/diagnostics/src/extended_template_diagnostic_name.d.ts +21 -0
- package/src/ngtsc/file_system/src/compiler_host.d.ts +1 -0
- package/src/ngtsc/imports/index.d.ts +1 -1
- package/src/ngtsc/imports/src/emitter.d.ts +40 -8
- package/src/ngtsc/translator/src/translator.d.ts +0 -5
- package/src/ngtsc/translator/src/type_translator.d.ts +0 -2
- package/src/ngtsc/typecheck/extended/api/api.d.ts +30 -10
- package/src/ngtsc/typecheck/extended/checks/invalid_banana_in_box/index.d.ts +3 -14
- package/src/ngtsc/typecheck/extended/checks/nullish_coalescing_not_nullable/index.d.ts +3 -15
- package/src/ngtsc/typecheck/extended/index.d.ts +3 -0
- package/src/ngtsc/typecheck/extended/src/extended_template_checker.d.ts +5 -4
- package/src/ngtsc/typecheck/src/environment.d.ts +3 -1
- package/src/ngtsc/typecheck/src/tcb_util.d.ts +10 -2
- package/src/ngtsc/typecheck/src/type_constructor.d.ts +3 -2
- package/src/ngtsc/typecheck/src/type_emitter.d.ts +7 -21
- package/src/ngtsc/typecheck/src/type_parameter_emitter.d.ts +2 -2
- package/bundles/chunk-AUFNJGZ6.js.map +0 -6
- package/bundles/chunk-DJRTTRF3.js.map +0 -6
- package/bundles/chunk-FXVUPJ6A.js.map +0 -6
- package/bundles/chunk-KWZNY2SK.js.map +0 -6
- package/bundles/chunk-O5ZEI3UY.js.map +0 -6
- package/bundles/chunk-OOIW53QX.js.map +0 -6
- package/bundles/chunk-P5ZW5MI4.js.map +0 -6
- package/bundles/chunk-TI3THPMZ.js.map +0 -6
- package/bundles/chunk-W5CGOJQ4.js.map +0 -6
- package/bundles/chunk-X46CEINM.js.map +0 -6
package/index.d.ts
CHANGED
|
@@ -10,3 +10,5 @@ export * from './src/ngtsc/file_system';
|
|
|
10
10
|
export { NgTscPlugin } from './src/ngtsc/tsc_plugin';
|
|
11
11
|
export { NgtscProgram } from './src/ngtsc/program';
|
|
12
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';
|
|
@@ -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.
|
|
12
|
+
export declare const NGCC_VERSION = "13.1.2";
|
|
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.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/compiler-cli",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.2",
|
|
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.
|
|
69
|
+
"@angular/compiler": "13.1.2",
|
|
70
70
|
"typescript": ">=4.4.2 <4.6"
|
|
71
71
|
},
|
|
72
72
|
"repository": {
|
|
@@ -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).
|
|
@@ -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/
|
|
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
|
+
}
|
|
@@ -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):
|
|
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):
|
|
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):
|
|
179
|
+
emit(ref: Reference, context: ts.SourceFile, importFlags: ImportFlags): ReferenceEmitResult | null;
|
|
148
180
|
private getExportsOfModule;
|
|
149
|
-
protected enumerateExportsOfModule(specifier: string, fromFile: string): ModuleExports
|
|
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):
|
|
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):
|
|
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
|
|
@@ -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 {
|
|
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<
|
|
18
|
+
export interface TemplateCheck<Code extends ErrorCode> {
|
|
18
19
|
/** Unique template check code, used for configuration and searching the error. */
|
|
19
|
-
code:
|
|
20
|
+
code: Code;
|
|
20
21
|
/** Runs check and returns information about the diagnostics to be generated. */
|
|
21
|
-
run(ctx: TemplateContext
|
|
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<
|
|
39
|
-
abstract code:
|
|
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
|
|
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
|
|
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 {
|
|
10
|
-
import
|
|
11
|
-
|
|
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 {
|
|
10
|
-
import
|
|
11
|
-
|
|
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 {
|
|
10
|
+
import { NgCompilerOptions } from '../../../core/api';
|
|
11
|
+
import { ErrorCode, ExtendedTemplateDiagnosticName } from '../../../diagnostics';
|
|
11
12
|
import { TemplateDiagnostic, TemplateTypeChecker } from '../../api';
|
|
12
|
-
import { ExtendedTemplateChecker,
|
|
13
|
+
import { ExtendedTemplateChecker, TemplateCheckFactory } from '../api';
|
|
13
14
|
export declare class ExtendedTemplateCheckerImpl implements ExtendedTemplateChecker {
|
|
15
|
+
private readonly partialCtx;
|
|
14
16
|
private readonly templateChecks;
|
|
15
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
|
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,
|
|
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
|
-
|
|
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
|
|
31
|
+
private translateTypeReference;
|
|
32
32
|
private isLocalTypeParameter;
|
|
33
33
|
}
|