From cd11925707c42843df195d9b2efb3c77b5de793b Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 14 Jan 2023 17:12:48 +0530 Subject: feat: adds cleanup of result nodes --- src/context.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/context.ts') 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 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) => { -- cgit v1.3.1