aboutsummaryrefslogtreecommitdiff
path: root/src/context.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-13 19:21:41 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-13 19:21:41 +0530
commit8ba316461d2dc0a1372af16836ce14ceabc2bf4f (patch)
treeafcd80654b1e83fe78fcb4bf69a71f730ee3e299 /src/context.ts
parentfe710f58a982e31e64c02d887567bcd9a4108b24 (diff)
downloadts-types-lang-8ba316461d2dc0a1372af16836ce14ceabc2bf4f.tar.gz
ts-types-lang-8ba316461d2dc0a1372af16836ce14ceabc2bf4f.zip
feat: adds test to stdlib + refactors runtime environment
Diffstat (limited to 'src/context.ts')
-rw-r--r--src/context.ts9
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