I do agree that sticking to TSC keeps things a lot simpler, and that should be the default setup.
Pandora's box has been opened though. Majority of the JS community seem to have adopted Babel in their workflow.
Even as I question it, I must admit it's pretty sweet to have a transpiler in the buid toolchain. It frees one from the browser/backward compatibility question, more or less, and opens up the language to be extensible - for better or worse.
For example, Babel macros ¹ is an interesting concept, using the language to extend the language during compile time.
To bring it back to the topic at hand (PgTyped, Typesafe SQL) - one thing that I'd like to see in TSC is a way to output type definitions (either inlined metadata or external JSON schema), to be consumed for run-time type checking. That would "complete the circle" for me.
TypeScript "compiler plugins" seem to be on the roadmap, or at least under consideration ². Some may see that as opening a proverbial can of worms, down a similar road to Babel. I wouldn't disagree, but it'd be so useful!
Oh agreed on all fronts :). Being able to add plugins is amazing, and there have been times I've almost added ttypescript for its plugin support. But then I remember the road that leads you down, and avoid it.
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.
Thank 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.
Pandora's box has been opened though. Majority of the JS community seem to have adopted Babel in their workflow.
Even as I question it, I must admit it's pretty sweet to have a transpiler in the buid toolchain. It frees one from the browser/backward compatibility question, more or less, and opens up the language to be extensible - for better or worse.
For example, Babel macros ¹ is an interesting concept, using the language to extend the language during compile time.
To bring it back to the topic at hand (PgTyped, Typesafe SQL) - one thing that I'd like to see in TSC is a way to output type definitions (either inlined metadata or external JSON schema), to be consumed for run-time type checking. That would "complete the circle" for me.
TypeScript "compiler plugins" seem to be on the roadmap, or at least under consideration ². Some may see that as opening a proverbial can of worms, down a similar road to Babel. I wouldn't disagree, but it'd be so useful!
¹ https://github.com/kentcdodds/babel-plugin-macros
² https://github.com/Microsoft/TypeScript/issues/16607