diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-01-13 19:21:41 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-01-13 19:21:41 +0530 |
| commit | 8ba316461d2dc0a1372af16836ce14ceabc2bf4f (patch) | |
| tree | afcd80654b1e83fe78fcb4bf69a71f730ee3e299 /src/context.ts | |
| parent | fe710f58a982e31e64c02d887567bcd9a4108b24 (diff) | |
| download | ts-types-lang-8ba316461d2dc0a1372af16836ce14ceabc2bf4f.tar.gz ts-types-lang-8ba316461d2dc0a1372af16836ce14ceabc2bf4f.zip | |
feat: adds test to stdlib + refactors runtime environment
Diffstat (limited to '')
| -rw-r--r-- | src/context.ts | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/context.ts b/src/context.ts index 6b7875c..485083a 100644 --- a/src/context.ts +++ b/src/context.ts @@ -2,6 +2,7 @@ import { Project, ScriptTarget, Type, Node, SyntaxKind } from 'ts-morph' import path from 'path' import { v4 as uuid } from 'uuid' import { Ctx } from './types' +import { evaluateType } from './eval' const RESULT_TYPE_NAME = '__$result' @@ -72,6 +73,9 @@ export const createContext = (options: CtxOptions): Ctx => { return key } + let currentEnv = 'node' + const setEnv = (e: string) => (currentEnv = e) + const ctx: Ctx = { sourceFile, typeChecker, @@ -79,6 +83,9 @@ export const createContext = (options: CtxOptions): Ctx => { typeToString, getTypeValue, + get currentEnv() { return currentEnv }, + setEnv, + createRef, getRef: (k: string) => refMap.get(k), setRef: (k: string, ty: string) => refMap.set(k, ty), @@ -101,6 +108,8 @@ export const createContext = (options: CtxOptions): Ctx => { return [] }, hasCustomEffect: (name) => customEffects[name] !== undefined, + + evaluateType, } return ctx |
