typescript-is
typescript-is copied to clipboard
runtime representation of types as objects
it would be cool if you could so something like this:
interface Foo {
foo: string
bar?: number
baz?: Bar | boolean
}
interface Bar {
foo: boolean
bar: any
}
const foo = getTypeDetails<Foo>()
and it gets transformed to something like:
const foo = {
foo: ['string'],
bar: ['number', 'undefined'],
baz: [
{ foo: 'boolean', bar: 'any' },
'boolean',
'undefined'
]
}
Indeed it's a nice idea, but I consider it out of scope for this project.
Something like this exists here: https://github.com/YousefED/typescript-json-schema or https://github.com/vega/ts-json-schema-generator
Thanks. I also found this project which seems more like what I have in mind https://github.com/awerlogus/io-ts-transformer, though it seems to be broken
Not sure how I missed it as it's mentioned in the readme here.