给定以下类层次结构:
class Foo {
fooMember = 1;
}
class Bar extends Foo {
barMember = 2;
}
AST 输出@typescript-eslint/parser
extends Foo
将语句引用为superClass
具有以下属性的 a:
superClass: Identifier {
type: "Identifier",
name: "Foo",
range: [ 50 53 ]
}
是否可以从该条目中提取ClassDeclaration
对应的Foo
,如果可以,如何?
如果导入扩展类,同样的解决方案是否适用?
从概念上讲,这应该是可能的,因为 Typescript 可以正确推断错误,例如父子类之间的公私定义不匹配等。