我有以下的AST:
import { factory as f } from 'typescript'
const typeDeclaration = f.createTypeAliasDeclaration(
[],
[],
'TestType',
[],
f.createTypeLiteralNode([
f.createPropertySignature([], 'str', undefined, f.createKeywordTypeNode(SyntaxKind.StringKeyword)),
]),
)
这代表:
type TestType = {
str: string
}
我该如何构建一个表示此代码的AST?注释是否包含在AST中?
/* Some comment on type */
type TestType = {
/* Some comment on property */
str: string
}
我看到factory对象提供了许多创建文档注释的方法,但我没有找到如何使用它们的示例。
如果只能采用文档注释格式,我也对其示例感兴趣:
/** Some comment on type */
type TestType = {
/** Some comment on property */
str: string
}