I'm not saying that this is a solved problem today. And yeah, llms are also helpul here.
What I meant is that this can be solved by a good language. But you would have to use F# (or another language with a feature like type providers) on the frontend.
Typescript can infer a lot of types, but you cannot read an SQL file at compiletime (with custom logic) and make it generate types that you can then use.
You have to generate those types as source code (like you basically do with the llm).
In F# and other languages, you can generate those types on the fly and use them. It can even go as far as describing errors with sql columns. Then, if there is any mismatch, the project won't compile. And if you add a new field, the code and validation will automatically work.
What I meant is that this can be solved by a good language. But you would have to use F# (or another language with a feature like type providers) on the frontend.