write-ts
v0.5.0
Published
This package is a wrapper for typescript compiler to make code generation easy
Downloads
2
Maintainers
Readme
write-ts
Some Example
to define query for a type from another type
const a = factory.createTypeQueryNode(new IdentifierGenerator("someName").generate())
// typeof someName
to define a type as a literal definition
const a = factory.createTypeLiteralNode(undefined)
// = {your definition comes here}
to define a type using keyof / readonly / unique
const a = factory.createTypeOperatorNode(SyntaxKind.KeyOfKeyword,)
// = keyof/readonly/unique ...
to define
const a = factory.createTypePredicateNode(undefined, "someName",undefined)
// someName is ...
to define a literal type
ts.factory.createTypeLiteralNode(
[
ts.factory.createPropertySignature(
undefined,
"propertySignatureName",
undefined,
ts.factory.createTypeReferenceNode("tttttttttt")
)
]
)
// result
// {
// propertySignatureName: tttttttttt;·
// }