33 ms·
You might find io-ts [1] interesting. It allows to write composable parsers that do both runtime checks and have correct result types. Opt-in runtime checks fo
by alde 6y ago
You might find io-ts [1] interesting. It allows to write composable parsers that do both runtime checks and have correct result types.
Opt-in runtime checks for SQL queries are also on the roadmap for PgTyped. You are welcome to open an issue to track our progress there if you think this feature will be useful for you.
[1] https://github.com/gcanti/io-ts https://github.com/gcanti/io-ts
- lioeters 6y agoThank you - yes, I've dabbled with io-ts, though I'm still learning how to wield its power. > Opt-in runtime checks for SQL queries Ah right, I do see in the repo for PgTyped that it's on the roadmap. That does sound useful! I'm hoping that one of these days, TypeScript will support a more generic runtime type check, somehow closer to the language/TSC-level rather than userland libraries, plugins/transforms, or a parallel compiler/build step. At the moment, I use a fork of typescript-json-schema ¹ for my purposes. ¹ https://github.com/YousefED/typescript-json-schema https://github.com/YousefED/typescript-json-schema