From 7e571069bc640944a18bfbe56909df25d4dec911 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 19 May 2025 15:01:17 +0000 Subject: [PATCH] refactor(compiler): avoid duplication between `FactoryTarget` type (#61472) Avoids duplication of the `FactoryTarget` enums. This is necessary now because we are exposing the previously deeply-imported JIT facade now via the exports; and the typing integration tests surface a type conflict due to the different duplicated enums. PR Close #61472 --- packages/compiler/src/compiler.ts | 2 +- packages/compiler/src/injectable_compiler_2.ts | 2 +- packages/compiler/src/jit_compiler_facade.ts | 3 ++- packages/compiler/src/render3/partial/api.ts | 9 +-------- packages/compiler/src/render3/partial/factory.ts | 3 ++- packages/compiler/src/render3/r3_factory.ts | 9 +-------- 6 files changed, 8 insertions(+), 20 deletions(-) diff --git a/packages/compiler/src/compiler.ts b/packages/compiler/src/compiler.ts index 83173092df3..77b3a805c99 100644 --- a/packages/compiler/src/compiler.ts +++ b/packages/compiler/src/compiler.ts @@ -191,7 +191,6 @@ export { } from './render3/r3_class_metadata_compiler'; export { compileFactoryFunction, - FactoryTarget, R3DependencyMetadata, R3FactoryMetadata, } from './render3/r3_factory'; @@ -252,6 +251,7 @@ export {Version, escapeRegExp} from './util'; export * from './version'; export {outputAst}; export {CompilerFacadeImpl} from './jit_compiler_facade'; +export {FactoryTarget} from './compiler_facade_interface'; // This file only reexports content of the `src` folder. Keep it that way. diff --git a/packages/compiler/src/injectable_compiler_2.ts b/packages/compiler/src/injectable_compiler_2.ts index a8d7e74692e..f3e24d7b69b 100644 --- a/packages/compiler/src/injectable_compiler_2.ts +++ b/packages/compiler/src/injectable_compiler_2.ts @@ -6,10 +6,10 @@ * found in the LICENSE file at https://angular.dev/license */ +import {FactoryTarget} from './compiler_facade_interface'; import * as o from './output/output_ast'; import { compileFactoryFunction, - FactoryTarget, R3DependencyMetadata, R3FactoryDelegateType, R3FactoryMetadata, diff --git a/packages/compiler/src/jit_compiler_facade.ts b/packages/compiler/src/jit_compiler_facade.ts index e2208a0b062..a8eac5edaef 100644 --- a/packages/compiler/src/jit_compiler_facade.ts +++ b/packages/compiler/src/jit_compiler_facade.ts @@ -10,6 +10,7 @@ import { CompilerFacade, CoreEnvironment, ExportedCompilerFacade, + FactoryTarget, LegacyInputPartialMapping, OpaqueValue, R3ComponentMetadataFacade, @@ -57,7 +58,7 @@ import { import {JitEvaluator} from './output/output_jit'; import {ParseError, ParseSourceSpan, r3JitTypeSourceSpan} from './parse_util'; import {DeferredBlock} from './render3/r3_ast'; -import {compileFactoryFunction, FactoryTarget, R3DependencyMetadata} from './render3/r3_factory'; +import {compileFactoryFunction, R3DependencyMetadata} from './render3/r3_factory'; import {compileInjector, R3InjectorMetadata} from './render3/r3_injector_compiler'; import {R3JitReflector} from './render3/r3_jit'; import { diff --git a/packages/compiler/src/render3/partial/api.ts b/packages/compiler/src/render3/partial/api.ts index d4acf6a3f26..9bd1c7e07fd 100644 --- a/packages/compiler/src/render3/partial/api.ts +++ b/packages/compiler/src/render3/partial/api.ts @@ -5,6 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ +import {FactoryTarget} from '../../compiler_facade_interface'; import {ChangeDetectionStrategy, ViewEncapsulation} from '../../core'; import * as o from '../../output/output_ast'; @@ -443,14 +444,6 @@ export interface R3DeclareFactoryMetadata extends R3PartialDeclaration { target: FactoryTarget; } -export enum FactoryTarget { - Directive = 0, - Component = 1, - Injectable = 2, - Pipe = 3, - NgModule = 4, -} - /** * Describes the shape of the object that the `ɵɵngDeclareInjectable()` function accepts. * diff --git a/packages/compiler/src/render3/partial/factory.ts b/packages/compiler/src/render3/partial/factory.ts index 1d37a9d21d2..67352b591d2 100644 --- a/packages/compiler/src/render3/partial/factory.ts +++ b/packages/compiler/src/render3/partial/factory.ts @@ -5,8 +5,9 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ +import {FactoryTarget} from '../../compiler_facade_interface'; import * as o from '../../output/output_ast'; -import {createFactoryType, FactoryTarget, R3FactoryMetadata} from '../r3_factory'; +import {createFactoryType, R3FactoryMetadata} from '../r3_factory'; import {Identifiers as R3} from '../r3_identifiers'; import {R3CompiledExpression} from '../util'; import {DefinitionMap} from '../view/util'; diff --git a/packages/compiler/src/render3/r3_factory.ts b/packages/compiler/src/render3/r3_factory.ts index 97592f73db4..f5b81b9b49e 100644 --- a/packages/compiler/src/render3/r3_factory.ts +++ b/packages/compiler/src/render3/r3_factory.ts @@ -5,6 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ +import {FactoryTarget} from '../compiler_facade_interface'; import {InjectFlags} from '../core'; import * as o from '../output/output_ast'; import {Identifiers as R3} from '../render3/r3_identifiers'; @@ -64,14 +65,6 @@ export type R3FactoryMetadata = | R3DelegatedFnOrClassMetadata | R3ExpressionFactoryMetadata; -export enum FactoryTarget { - Directive = 0, - Component = 1, - Injectable = 2, - Pipe = 3, - NgModule = 4, -} - export interface R3DependencyMetadata { /** * An expression representing the token or value to be injected.