【发布时间】:2021-01-10 01:16:01
【问题描述】:
我正在尝试解析一些打字稿文件以生成一些特定的文档,为此我需要找到属于特定类的所有子类。
我尝试使用这里提出的代码:https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#using-the-type-checker
但它没有指定父类名(或类型)
/**
* Documentation for C
*/
export class C {
/**
* constructor documentation
* @param a my parameter documentation
* @param b another parameter documentation
*/
constructor(a: string, b: C) { }
}
export class D extends C{
}
输出:
[
{
"name": "C",
"documentation": "Documentation for C",
"type": "typeof C",
"constructors": [
{
"parameters": [
{
"name": "a",
"documentation": "my parameter documentation",
"type": "string"
},
{
"name": "b",
"documentation": "another parameter documentation",
"type": "C"
}
],
"returnType": "C",
"documentation": "constructor documentation"
}
]
},
{
"name": "D",
"documentation": "",
"type": "typeof D",
"constructors": [
{
"parameters": [
{
"name": "a",
"documentation": "my parameter documentation",
"type": "string"
},
{
"name": "b",
"documentation": "another parameter documentation",
"type": "C"
}
],
"returnType": "D",
"documentation": "constructor documentation"
}
]
}
]
但我想要这样的东西:
[
/** C declaration **/
{
"name": "D",
"documentation": "",
"type": "C", // because extends C
"parent": "C", // Or like this
"constructors": [
{
"parameters": [
{
"name": "a",
"documentation": "my parameter documentation",
"type": "string"
},
{
"name": "b",
"documentation": "another parameter documentation",
"type": "C"
}
],
"returnType": "D",
"documentation": "constructor documentation"
}
]
}
]
我试图找到有关解析打字稿的文档。如果有人有任何链接或想法,那将是非常可观的!
【问题讨论】:
标签: typescript