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.
But even TypeScript can infer types in many cases?