aboutsummaryrefslogtreecommitdiff
path: root/src/types.ts
blob: 7be4c98e05d839bbb2b90e03c5939abda64a1892 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {
  ExportedDeclarations,
  Node,
  SourceFile,
  Type,
  TypeChecker,
} from 'ts-morph'

export interface Ctx {
  sourceFile: SourceFile
  typeChecker: TypeChecker
  entryPoint: ExportedDeclarations
  typeToString: (ty: Type | undefined) => string
  getTypeValue: (ty: Type | undefined) => any

  createResult: (ty: string) => [string, Node | undefined]
  removeResult: (key?: string) => void
  getResultExpr: (key?: string) => string
  printResultNode: () => void

  currentEnv: string
  setEnv: (e: string) => void

  createRef: (ty: string) => string
  getRef: (key: string) => any
  setRef: (key: string, ty: string) => void
  deleteRef: (key: string) => void

  addCustomEffect: (name: string, expr: string) => void
  runCustomEffect: (name: string, args: Type[]) => Promise<string[]>
  hasCustomEffect: (name: string) => boolean

  evaluateType: (ctx: Ctx, effTyp: Type) => Promise<string[]>

  withScope: (fn: () => Promise<string[]>) => () => Promise<string[]>
  newScope: () => void
  clearScope: () => void
  addToScope: (name: string, resKey: string) => void
  getKeyInScope: (name: string) => string | undefined
}