fix(ivy): types in .d.ts files should account for generics (#24862)

Ivy definition types have a generic type which specifies the return
type of the factory function. For example:

static ngDirectiveDef<NgForOf, '[ngFor][ngForOf]'>

However, in this case NgForOf itself has a type parameter <T>. Thus,
writing the above is incorrect.

This commit modifies ngtsc to understand the genericness of NgForOf and
to write the following:

static ngDirectiveDef<NgForOf<any>, '[ngFor][ngForOf]'>

PR Close #24862
This commit is contained in:
Alex Rickabaugh
2018-07-13 14:49:01 -07:00
committed by Victor Berchet
parent 2b8b647006
commit 41ef75869c
8 changed files with 53 additions and 12 deletions

View File

@ -305,8 +305,14 @@ export class TypeTranslatorVisitor implements ExpressionVisitor, TypeVisitor {
}
}
visitExpressionType(type: ExpressionType, context: Context): any {
return type.value.visitExpression(this, context);
visitExpressionType(type: ExpressionType, context: Context): string {
const exprStr = type.value.visitExpression(this, context);
if (type.typeParams !== null) {
const typeSegments = type.typeParams.map(param => param.visitType(this, context));
return `${exprStr}<${typeSegments.join(',')}>`;
} else {
return exprStr;
}
}
visitArrayType(type: ArrayType, context: Context): string {