refactor(ivy): use ReflectionHost to find base classes (#31544)
When analyzing components, directives, etc we capture its base class. Previously this assumed that the code is in TS format, which is not always the case (e.g. ngcc). Now this code is replaced with a call to `ReflectionHost.getBaseClassExpression()`, which abstracts the work of finding the base class. PR Close #31544
This commit is contained in:
parent
8a470b9af9
commit
c038992fae
|
@ -317,17 +317,13 @@ export function readBaseClass(
|
|||
return reflector.hasBaseClass(node) ? 'dynamic' : null;
|
||||
}
|
||||
|
||||
if (node.heritageClauses !== undefined) {
|
||||
for (const clause of node.heritageClauses) {
|
||||
if (clause.token === ts.SyntaxKind.ExtendsKeyword) {
|
||||
// The class has a base class. Figure out whether it's resolvable or not.
|
||||
const baseClass = evaluator.evaluate(clause.types[0].expression);
|
||||
if (baseClass instanceof Reference && isNamedClassDeclaration(baseClass.node)) {
|
||||
return baseClass as Reference<ClassDeclaration>;
|
||||
} else {
|
||||
return 'dynamic';
|
||||
}
|
||||
}
|
||||
const baseExpression = reflector.getBaseClassExpression(node);
|
||||
if (baseExpression !== null) {
|
||||
const baseClass = evaluator.evaluate(baseExpression);
|
||||
if (baseClass instanceof Reference && isNamedClassDeclaration(baseClass.node)) {
|
||||
return baseClass as Reference<ClassDeclaration>;
|
||||
} else {
|
||||
return 'dynamic';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue