5 ms·
I solved this using the ts-interface-builder and ts-interface-checker libraries and have been happy with the result. You write a plain TS type (rather than a cu
by alangpierce 7y ago
I solved this using the ts-interface-builder and ts-interface-checker libraries and have been happy with the result. You write a plain TS type (rather than a custom syntax like io-ts has) and then run a codegen step to make a runtime representation of the type. Then you can create a checker from that and do runtime type checking.
https://github.com/gristlabs/ts-interface-builder https://github.com/gristlabs/ts-interface-builder
https://github.com/gristlabs/ts-interface-checker https://github.com/gristlabs/ts-interface-checker
Example: https://github.com/alangpierce/sucrase/pull/468/files https://github.com/alangpierce/sucrase/pull/468/files