Here is an approach that defines all valid (non-functional) values, and then uses a recursive definition. I think it works for my business and, hopefully, for everyone who comes across this issue.
Typescript example Playground
type NoFunctionValue =
boolean
| string
| number
| null
| undefined
| NoFunctionObject
| NoFunctionArray
interface NoFunctionObject {
[key: string]: NoFunctionValue
}
interface NoFunctionArray extends Array<NoFunctionValue> { }
const text: NoFunctionObject = {
bool: true,
str: 'string',
num: 7,
nul: null,
undef: undefined,
arr: [true, 'string', 7, null, undefined],
obj: {
bool: true,
str: 'string',
num: 7,
nul: null,
undef: undefined,
arr: [true, 'string', 7, null, undefined]
}
}
source
share