fix(ngcc): avoid warning when reflecting on index signature member (#33198)
Previously, when `ngcc` was reflecting on class members it did not account for the fact that a member could be of the kind `IndexSignature`. This can happen, for example, on abstract classes (as is the case for [JsonCallbackContext][1]). Trying to reflect on such members (and failing to recognize their kind), resulted in warnings, such as: ``` Warning: Unknown member type: "[key: string]: (data: any) => void; ``` While these warnings are harmless, they can be confusing and worrisome for users. This commit avoids such warnings by detecting class members of the `IndexSignature` kind and ignoring them. [1]: https://github.com/angular/angular/blob/4659cc26e/packages/common/http/src/jsonp.ts#L39 PR Close #33198
This commit is contained in:

committed by
Matias Niemelä

parent
bb53b6549c
commit
78214e72ea
@ -1778,7 +1778,10 @@ function isNamedDeclaration(node: ts.Declaration): node is ts.NamedDeclaration&
|
||||
|
||||
function isClassMemberType(node: ts.Declaration): node is ts.ClassElement|
|
||||
ts.PropertyAccessExpression|ts.BinaryExpression {
|
||||
return ts.isClassElement(node) || isPropertyAccess(node) || ts.isBinaryExpression(node);
|
||||
return (ts.isClassElement(node) || isPropertyAccess(node) || ts.isBinaryExpression(node)) &&
|
||||
// Additionally, ensure `node` is not an index signature, for example on an abstract class:
|
||||
// `abstract class Foo { [key: string]: any; }`
|
||||
!ts.isIndexSignatureDeclaration(node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user