fix(ivy): allow abstract directives to have an invalid constructor (#32987)
For abstract directives, i.e. directives without a selector, it may happen that their constructor is called explicitly from a subclass, hence its parameters are not required to be valid for Angular's DI purposes. Prior to this commit however, having an abstract directive with a constructor that has parameters that are not eligible for Angular's DI would produce a compilation error. A similar scenario may occur for `@Injectable`s, where an explicit `use*` definition allows for the constructor to be irrelevant. For example, the situation where `useFactory` is specified allows for the constructor to be called explicitly with any value, so its constructor parameters are not required to be valid. For `@Injectable`s this is handled by generating a DI factory function that throws. This commit implements the same solution for abstract directives, such that a compilation error is avoided while still producing an error at runtime if the type is instantiated implicitly by Angular's DI mechanism. Fixes #32981 PR Close #32987
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import * as core from '../../core/src/compiler/compiler_facade_interface';
|
||||
import {R3ResolvedDependencyType} from '../public_api';
|
||||
import {R3FactoryTarget, R3ResolvedDependencyType} from '../public_api';
|
||||
import * as compiler from '../src/compiler_facade_interface';
|
||||
|
||||
/**
|
||||
@ -60,6 +60,15 @@ const coreR3ResolvedDependencyType3: core.R3ResolvedDependencyType =
|
||||
const compilerR3ResolvedDependencyType3: compiler.R3ResolvedDependencyType =
|
||||
null !as R3ResolvedDependencyType;
|
||||
|
||||
const coreR3FactoryTarget: core.R3FactoryTarget = null !as compiler.R3FactoryTarget;
|
||||
const compilerR3FactoryTarget: compiler.R3FactoryTarget = null !as core.R3FactoryTarget;
|
||||
|
||||
const coreR3FactoryTarget2: R3FactoryTarget = null !as core.R3FactoryTarget;
|
||||
const compilerR3FactoryTarget2: R3FactoryTarget = null !as core.R3FactoryTarget;
|
||||
|
||||
const coreR3FactoryTarget3: core.R3FactoryTarget = null !as R3FactoryTarget;
|
||||
const compilerR3FactoryTarget3: compiler.R3FactoryTarget = null !as R3FactoryTarget;
|
||||
|
||||
const coreR3DependencyMetadataFacade: core.R3DependencyMetadataFacade =
|
||||
null !as compiler.R3DependencyMetadataFacade;
|
||||
const compilerR3DependencyMetadataFacade: compiler.R3DependencyMetadataFacade =
|
||||
|
Reference in New Issue
Block a user