Proposed syntax: Omitting angle brackets for generic types with 1 param #34165
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Suggestion
An idea for TypeScript
Search Terms
Suggestion
Support a simplified syntax for generic types that have only 1 type parameter. Specifically,
Partial<Foo>
could also be written asPartial Foo
.Use Cases
<>
) there should be no breaking change in code or workflows.<>
in general, but for sufficiently nested types it can severely affect readability.Examples
Simple:
Partial<Foo>
Partial Foo
NonNullable<string>
NonNullable string
Set<number>
Set number
Complex:
Array<Promise<{}>>
Array Promise {}
NonNullable<Partial<Config>[T]>
(from #31675)NonNullable Partial<Config>[T]
orNonNullable (Partial Config)[T]
Promise<NonNullable<Partial<Record<string, any>>>>>
Promise NonNullable Partial Record<string, any>
The following would be disallowed, namely because they involve types with 2 or more generic parameters:
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: