I have the following ast:
import { factory as f } from 'typescript'
const typeDeclaration = f.createTypeAliasDeclaration(
[],
[],
'TestType',
[],
f.createTypeLiteralNode([
f.createPropertySignature([], 'str', undefined, f.createKeywordTypeNode(SyntaxKind.StringKeyword)),
]),
)
Which represents:
type TestType = {
str: string
}
How would I build an AST representing this code? Are comments even part of the AST?
/* Some comment on type */
type TestType = {
/* Some comment on property */
str: string
}
I have seen there are many methods available on the factory object for creating doc-comments, but I haven't found any examples on how to use them.
In case it's only possible in doc-comment format I'd be interested in examples for that too:
/** Some comment on type */
type TestType = {
/** Some comment on property */
str: string
}