3 ms·
There is an implementation of SQL that operates on a table shaped type, entirely at type level. For your amusement: https://github.com/codemix/ts-sql https://gi
by jitl 3y ago
There is an implementation of SQL that operates on a table shaped type, entirely at type level. For your amusement: https://github.com/codemix/ts-sql https://github.com/codemix/ts-sql
There are a bunch of more practical takes that codegen types from your database and generate types for your queries, eg: https://github.com/adelsz/pgtyped https://github.com/adelsz/pgtyped
To me the second approach seems much more pragmatic because you don’t need to run a SQL parser in your typechecker interpreter on every build
- taeric 3y agoCool! I'm not sure how I feel on the idea of keeping it out of the "typechecker." At large, the amount of work being done by what we call the compiler nowadays is already far more than folks would have called for decades ago. I don't know that I think there is a solid line of "this should never happen during compilation." Your implication that it is a tradeoff, btw, I fully endorse/agree with. And I know there will be pathological projects out there where the code gen will take ages to complete. I'd hazard a guess that most people wouldn't notice the codegen happening on every build for most projects. Especially on modern build machines.