Export type to JSON and share it

Hello, I have two TS programs that should cooperate (A B), B import types and validates data, and A creates and "saves" the types. A rough idea

// Program A
import { type } from 'arktype' 

const a = type({
  name: 'string'
})

const b = type({
  userData: a,
  random: 'number'
})

// Somehow export the type as JSON?
fs.writeFileSync("schema.json", JSON.stringify(b))


// Program B
import { type } from 'arktype' 

const definition = JSON.stringify(fs.readFileSync("schema.json").toString())

const validator = type(definition)

const { data, problems } = validator({
  userData: {
    name: "Jacob"
  },
  random: 5
})


Is this possible with the current API?
Was this page helpful?