fix(ivy): include type parameter for ngBaseDef
declaration (#31210)
When a class uses Angular decorators such as `@Input`, `@Output` and friends without an Angular class decorator, they are compiled into a static `ngBaseDef` field on the class, with the TypeScript declaration of the class being altered to declare the `ngBaseDef` field to be of type `ɵɵBaseDef`. This type however requires a generic type parameter that corresponds with the type of the class, however the compiler did not provide this type parameter. As a result, compiling a program where such invalid `ngBaseDef` declarations are present will result in compilation errors. This commit fixes the problem by providing the generic type parameter. Fixes #31160 PR Close #31210
This commit is contained in:
@ -151,6 +151,7 @@ export interface R3ComponentMetadataFacade extends R3DirectiveMetadataFacade {
|
||||
|
||||
export interface R3BaseMetadataFacade {
|
||||
name: string;
|
||||
type: any;
|
||||
propMetadata: {[key: string]: any[]};
|
||||
inputs?: {[key: string]: string | [string, string]};
|
||||
outputs?: {[key: string]: string};
|
||||
|
@ -142,6 +142,7 @@ export function compileDirectiveFromMetadata(
|
||||
|
||||
export interface R3BaseRefMetaData {
|
||||
name: string;
|
||||
type: o.Expression;
|
||||
typeSourceSpan: ParseSourceSpan;
|
||||
inputs?: {[key: string]: string | [string, string]};
|
||||
outputs?: {[key: string]: string};
|
||||
@ -188,7 +189,8 @@ export function compileBaseDefFromMetadata(
|
||||
}
|
||||
|
||||
const expression = o.importExpr(R3.defineBase).callFn([definitionMap.toLiteralMap()]);
|
||||
const type = new o.ExpressionType(o.importExpr(R3.BaseDef));
|
||||
const type = new o.ExpressionType(
|
||||
o.importExpr(R3.BaseDef), /* modifiers */ null, [o.expressionType(meta.type)]);
|
||||
|
||||
return {expression, type};
|
||||
}
|
||||
|
Reference in New Issue
Block a user