3 ms·
I’d suggest generating code Write your interface in json or text proto then build it to ts interfaces and runtime checks.
by nkingsy 7y ago
I’d suggest generating code
Write your interface in json or text proto then build it to ts interfaces and runtime checks.
- aabbcc1241 7y agoAgree with the code generation approach. Otherwise you need to make sure the annotations are in sync with the type / class / interface. Typescript doesn't support macro currently, so code generation is the only way to programmatically create 'type-checked' code. Some cli-tool and library I'm using (available on npm): tsc-macro: https://github.com/beenotung/tsc-macro https://github.com/beenotung/tsc-macro gen-ts-type: https://github.com/beenotung/gen-ts-type https://github.com/beenotung/gen-ts-type ts-type-check: https://github.com/beenotung/ts-type-check https://github.com/beenotung/ts-type-check