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
When writing a complex type, often the code becomes a "type spaghetti", being hard and time consuming to identify what all those AAA<BBBBB[] extends ? BB: >... and it is even worse when we have to use a same lengthy type that is used in more than once place inside a generic type.
My suggestion is to create a new Typescript keyword, the alias or something like that, that would work like a "local const" for types or a simple type replacer. Like C macros for types.
Use Cases
Would reduce code size and the time to understand the code, and improve code readability and comprehension.
It is possible to create auxiliary types, but being a type necessarily generic, we still have to pass the generic types for every time we call them.
Even reducing the generic types to the famous T,Q,U,P etc, which reduces the code length but also makes it more hard to understand what each type is for, still isn't good to use <T, Q, P, X> for each time you want to mention the generic types.
A thing to think about this is: what should be the scope of those alias? Should they work/apply anywhere inside the type definition? Local inside (), {}, <>?
The text was updated successfully, but these errors were encountered:
Search Terms
alias, type alias
Suggestion
When writing a complex type, often the code becomes a "type spaghetti", being hard and time consuming to identify what all those AAA<BBBBB[] extends ? BB: >... and it is even worse when we have to use a same lengthy type that is used in more than once place inside a generic type.
My suggestion is to create a new Typescript keyword, the
alias
or something like that, that would work like a "local const" for types or a simple type replacer. Like C macros for types.Use Cases
Would reduce code size and the time to understand the code, and improve code readability and comprehension.
It is possible to create auxiliary types, but being a type necessarily generic, we still have to pass the generic types for every time we call them.
Examples
Even reducing the generic types to the famous T,Q,U,P etc, which reduces the code length but also makes it more hard to understand what each type is for, still isn't good to use <T, Q, P, X> for each time you want to mention the generic types.
Here is my suggestion:
Or using letters for types
It would also fit well in recursive types.
Checklist
My suggestion meets these guidelines:
Maybe it could accept generics too.
A thing to think about this is: what should be the scope of those alias? Should they work/apply anywhere inside the type definition? Local inside (), {}, <>?
The text was updated successfully, but these errors were encountered: