Ideas for ternary formatting optimized for conditional types #2388
Replies: 6 comments 5 replies
-
Big +1 to this, as another library author with many large switch-like conditional types. I would love to have this as an option in |
Beta Was this translation helpful? Give feedback.
-
How would you name such an option? I believe it makes sense to have an option here. Unfortunately TypeScript types have become veeeeery long, and we should acknowledge that. However I'm not sure if the option should affect only types or not, only TypeScript files or not. We should discuss this |
Beta Was this translation helpful? Give feedback.
-
I'm curious what would take this discussion to become an issue? I think configurable ternaries is a really great way to increase popularity with Biome. |
Beta Was this translation helpful? Give feedback.
-
I can see why Biome's nested ternary formatting (similar to
prettier
>3.0.3
) can be helpful in some cases, but it makes some common patterns in type-level code much less readable.E.g. with
prettier
<=3.0.3
:With Biome (
prettier
>3.0.3
is similar):The actual logic is basically just a switch, with lines alternating between
if condition
andreturn value
.I find the nested version much harder to read, and there is no way to refactor it into another type-level construct that achieves the same thing.
I'd love if there were either a formatting config option for this, or barring that, an ability to integrate a formatter plugin to apply a flatter indentation for types like this (I know this is being considered in #1649).
Do others the original prettier formatting for conditional types as well? If there's a consensus, perhaps a dedicated formatter option or just a change to the default would be apt for types.
Beta Was this translation helpful? Give feedback.
All reactions