diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-13 19:40:15 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-13 19:59:56 +0530 |
| commit | 42f8c401dc9519bc8b2d386ce9eda072144a46d0 (patch) | |
| tree | e886538eccbd47beaaf27deff69267bd8c7dd67d /src/eval.ts | |
| parent | 8ba316461d2dc0a1372af16836ce14ceabc2bf4f (diff) | |
| download | ts-types-lang-42f8c401dc9519bc8b2d386ce9eda072144a46d0.tar.gz ts-types-lang-42f8c401dc9519bc8b2d386ce9eda072144a46d0.zip | |
feat: refactors test runner
Diffstat (limited to 'src/eval.ts')
| -rw-r--r-- | src/eval.ts | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/eval.ts b/src/eval.ts index fdffed7..2b93e49 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -6,7 +6,7 @@ import * as builtins from './eval-env/builtins' type EffDefn = { default: (ctx: Ctx, args: Type[]) => Record<string, () => Promise<string[]>>, - cleanup: () => void, + cleanup?: () => void, } const mergeEffDefns = (a: EffDefn, b: EffDefn): EffDefn => ({ default: (ctx: Ctx, args: Type[]) => ({ @@ -14,13 +14,13 @@ const mergeEffDefns = (a: EffDefn, b: EffDefn): EffDefn => ({ ...b.default(ctx, args), }), cleanup: () => { - a.cleanup() - b.cleanup() + a.cleanup?.() + b.cleanup?.() }, }) -const cleanupActions = new Set<() => void>() -export const cleanup = () => cleanupActions.forEach(f => f()) +const cleanupActions = new Set<undefined | (() => void)>() +export const cleanup = () => cleanupActions.forEach(f => f?.()) let prevEnv: string @@ -28,6 +28,7 @@ export const evaluateType = async ( ctx: Ctx, effTyp: Type ): Promise<string[]> => { + // TODO: base type check const name = effTyp.getSymbol()?.getName() const args = effTyp.getTypeArguments() @@ -67,11 +68,3 @@ export const evaluateType = async ( }, }) } - -export const evalList = async (ctx: Ctx, effectTyps: Type[]) => { - const effectResults: string[] = [] - for (const item of effectTyps ?? []) { - effectResults.push(...(await evaluateType(ctx, item))) - } - return effectResults -} |
