aboutsummaryrefslogtreecommitdiff
path: root/src/context.ts
diff options
context:
space:
mode:
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