You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The suggestion is to add a keyword that says "I don't need to specify this optional type parameter, I am only passing by to a later one, please resolve to whatever the fallbace default type
π Motivating Example
Considering the case:
importexpressfrom'express'interfaceCreateUserParams{name: stringage: number}exporttypeCreateUserRequest=express.Request<Record<string,string>,// β unrelated, but there's no way if skipping thisany,// β could've specified it, but decided to not botherCreateUserParams// β actually what is needed and relevant>
All of the type parameters of express.Request are optional. In the case when I only need to specify the third parameter, there is no way of skipping the first two. Instead, I have to go to the definition, see what the fallback type is, and provide the fallback type here explicitly; this gets words if the fallback type isn't exported.
Sometimes this can be mitigated by a better design, sometimes not.
The suggestion is to add a keyword (e.g., CSS's unset or SQL's default) that would do the lookup itself:
π Search Terms
unset type parameter default
β Viability Checklist
β Suggestion
The suggestion is to add a keyword that says "I don't need to specify this optional type parameter, I am only passing by to a later one, please resolve to whatever the fallbace default type
π Motivating Example
Considering the case:
Try it.
All of the type parameters of
express.Request
are optional. In the case when I only need to specify the third parameter, there is no way of skipping the first two. Instead, I have to go to the definition, see what the fallback type is, and provide the fallback type here explicitly; this gets words if the fallback type isn't exported.Sometimes this can be mitigated by a better design, sometimes not.
The suggestion is to add a keyword (e.g., CSS's
unset
or SQL'sdefault
) that would do the lookup itself:This might be a breaking change for codebases where
unset
is an existing identifier. If that's a concern, consider?
as the keyword:π» Use Cases
The text was updated successfully, but these errors were encountered: