From a22f1428b7656cc85a8f9dcea0c174ff93002a97 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 22 Jul 2024 14:36:55 +0000 Subject: [PATCH] refactor(compiler): support use of poisoned data as private compiler option (#57082) This allows use of poisoned data for migrations. Right now, migrations often enable this flag by creating some deeper structures of the Angular compiler, but with this change it's easier to enable as a private compiler option. This is helpful for migrations, specifically the signal input migration as it allows us to generate as much TCB code as possible, for reference resolution. PR Close #57082 --- packages/compiler-cli/src/ngtsc/core/api/src/options.ts | 6 ++++++ packages/compiler-cli/src/ngtsc/core/src/compiler.ts | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/compiler-cli/src/ngtsc/core/api/src/options.ts b/packages/compiler-cli/src/ngtsc/core/api/src/options.ts index b0878179a58..113f16af74f 100644 --- a/packages/compiler-cli/src/ngtsc/core/api/src/options.ts +++ b/packages/compiler-cli/src/ngtsc/core/api/src/options.ts @@ -37,6 +37,12 @@ export interface TestOnlyOptions { */ _enableTemplateTypeChecker?: boolean; + /** + * Whether components that are poisoned should still be processed. + * E.g. for generation of type check blocks and diagnostics. + */ + _compilePoisedComponents?: boolean; + /** * An option to enable ngtsc's internal performance tracing. * diff --git a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts index 20d03cd6041..97f4be25ff1 100644 --- a/packages/compiler-cli/src/ngtsc/core/src/compiler.ts +++ b/packages/compiler-cli/src/ngtsc/core/src/compiler.ts @@ -454,8 +454,9 @@ export class NgCompiler { private livePerfRecorder: ActivePerfRecorder, ) { this.delegatingPerfRecorder = new DelegatingPerfRecorder(this.perfRecorder); + this.usePoisonedData = usePoisonedData || !!options._compilePoisedComponents; this.enableTemplateTypeChecker = - enableTemplateTypeChecker || (options['_enableTemplateTypeChecker'] ?? false); + enableTemplateTypeChecker || !!options._enableTemplateTypeChecker; // TODO(crisbeto): remove this flag and base `enableBlockSyntax` on the `angularCoreVersion`. this.enableBlockSyntax = options['_enableBlockSyntax'] ?? true; this.enableLetSyntax = options['_enableLetSyntax'] ?? true;