To be honest, I haven't been asked a lot of questions regarding pris-types.
So, this page is mostly made of questions I asked myself during development.
Yes, pretty much like you'd do for prop-types: using a Babel plugin.
Before running your function, the module requires PrisTypes and destructures all its fields:
const { PrisTypes, PrisMocks } = require('pris-types')
const { Boolean, RichText, /* ... */ } = PrisTypes
This means that instead of calling PrisTypes.foo you can import field types separately too:
import { PrisTypes: { RichText, Boolean } } from 'pris-types'
const title = RichText({ options: ['heading1'] })
undefined. Why?My guess is you did something like this, thinking it woud work:
import { PrisTypes } from 'pris-types'
const randomString = () => `...`
const bool = PrisTypes.Boolean({ placeholder: randomString() })
Unfortunately, pris-types evaluates your code in a certain context
and at the moment, this context cannot be extended.