Allow customization of type display format in hover tooltips #59370
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
π Search Terms
β Viability Checklist
β Suggestion
In TypeScript, when hovering over a variable, the inferred type is displayed in a specific format.
For instance, an array of numbers is shown as number[].
However, some developers, including myself, prefer the alternative format
Array<number>
for readability and consistency with other generic types.π Motivating Example
I have noticed that there is an
WriteArrayAsGenericType
flag in the Abstract Syntax Tree (AST) that can convertT[]
toArray<T>
.I would like to request the addition of a configuration option in tsconfig.json to enable this flag, allowing developers to choose their preferred format for array types in hover tooltips.
For example:
π» Use Cases
Complex Type Readability: I frequently write functional code that can lead to complex types like
Task<Maybe<Task<Maybe<T[]>>[]>>[]
. The shorthand[]
notation can make it difficult to understand the nested generic relationships. Displaying these types asArray<T>
would significantly improve readability and comprehension.Consistency: Most other generic types use angle brackets (e.g.,
Promise<T>
,Map<K, V>
), and only array types use the special shorthand (number[]
). Aligning array types with this convention would ensure consistency across all types and improve clarity.The text was updated successfully, but these errors were encountered: