aboutsummaryrefslogtreecommitdiff
path: root/src/context.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-14 17:12:48 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-14 17:12:48 +0530
commitcd11925707c42843df195d9b2efb3c77b5de793b (patch)
tree0871b0041597096fdbf7c49416f96fa70da00e3c /src/context.ts
parentd362ef26db894ea52c6abd34489aa9efdbc0c89b (diff)
downloadts-types-lang-cd11925707c42843df195d9b2efb3c77b5de793b.tar.gz
ts-types-lang-cd11925707c42843df195d9b2efb3c77b5de793b.zip
feat: adds cleanup of result nodes
Diffstat (limited to 'src/context.ts')
-rw-r--r--src/context.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/context.ts b/src/context.ts
index fe33731..fab6653 100644
--- a/src/context.ts
+++ b/src/context.ts
@@ -56,6 +56,15 @@ export const createContext = (options: CtxOptions): Ctx => {
return [resultKey, node]
}
+ const removeResult = (key?: string) => {
+ if (!key) return
+ resultTypeNode
+ ?.asKind(SyntaxKind.TypeAliasDeclaration)
+ ?.getChildAtIndexIfKind(3, SyntaxKind.TypeLiteral)
+ ?.getProperty(key)
+ ?.remove()
+ }
+
const customEffects: Record<string, (args: Type[], ctx: Ctx) => any> = {}
const getTypeValue = (ty: Type | undefined): any => {
@@ -97,6 +106,7 @@ export const createContext = (options: CtxOptions): Ctx => {
createResult,
getResultExpr,
+ removeResult,
printResultNode: () => console.log(resultTypeNode?.print()),
addCustomEffect: (name, expr) => {