[Feature Request] A way to specify preference to emit typeof
a variable instead
#32977
Open
5 tasks done
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Search Terms
emit, typeof, variable
Suggestion
I'm just opening this issue so I have somewhere to refer to.
I don't necessarily think this is a good idea.
I'm just thinking about a problem I have aloud.
It would be nice if I had a way to annotate when I would prefer emit to use
typeof variable
instead of emitting thevariable
's type.It's just a preference. If such an emit can't be done, then it falls back to the default emit behaviour.
Use Cases
My use case is that one of my subprojects initially spent 15s on check but 45s on emit.
A lot of it is because it's expanding the type of some variables (110+ lines) when it can just use
typeof variable
(1 line)Right now, it's at 18s to check, 47s to emit.
If I can make it emit
typeof variable
for the parts where it is possible,I can probably reduce my emit size and time by a lot.
A SQL table has a bunch of columns, primary keys, candidate keys, etc.
For type-safe
JOIN
clauses and expressions in a query builder, these expressions, clauses, queries, etc. need to have information about the table(s) being used be part of their generic type param.However, because TS always expands the type as much as possible, I end up with 110+ lines when a simple
typeof myTable
ortypeof myTable.columns
ortypeof import("../table").myTable
ortypeof import("../table").myTable.columns
would do in most cases.I'm still trying to trim the amount of information each type needs about a table but there's just no escaping that a lot of information is still needed for SQL queries to be checked properly during compile-time.
Examples
See above suggestion.
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: