-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea: Can declaration emit synthesize type aliases? #44045
Comments
With #44044, this is part of a larger discussion of how we could reduce the size of declaration files to make them faster to read and write (ideally, without sacrificing readability). |
#30979 is along the lines of what I think we'd prefer to see |
@weswigham What's the scope of those inline type aliases? Being able to use them across multiple declarations seems key to reducing declaration file size. |
In that case, within a given type node, so you can serialize a recursive or self-referential type. (Which today usually expand till they hit a depth limiter) |
Reviving this idea. I am discovering we're having similar issues specifically with the io-ts library (similar to zod which I believe has the same issues) where the type derived from the codec expands everywhere its referenced instead of using a simpler named type. Some of our emitted definition files are tens of MB with repetitive type expansion. Using explicit types reduces the files back to expected sizes but defeats the purpose of being able to infer the types. |
Object types can be very large and in (e.g.) a react project that makes heavy use of type inference, it's not uncommon to have to refer to a type that is either not imported or is simply anonymous (e.g. a props type). When these appear in multiple places in a declaration file, they tend to expand it considerably. Perhaps we could just synthesize type aliases for them?
type id =
andid
at the use site)The text was updated successfully, but these errors were encountered: