Render large types in multiline
Hello!
Earlier I encountered the following:
As it is, the type is very unreadable.
I think it would be much better VScode formatted the type in a more humanly readable way For instance:
({
ProviderFamily<R, Arg> Function<R, Arg>(
R Function(Ref<R>, Arg), {
Iterable<ProviderOrFamily>? dependencies,
String? name,
}) autoDispose,
ProviderFamily<R, Arg> Function<R, Arg>(
R Function(Ref<R>, Arg), {
Iterable<ProviderOrFamily>? dependencies,
bool isAutoDispose,
String? name,
}) call,
})
It is suddenly more clearer what we're dealing with.
One way to do that could be to use dart_style combined with a typedef.
The way I formatted the type on my end was:
typedef Foo = ({ProviderFamily<R, Arg> Function<R, Arg>(R Function(Ref<R>, Arg), {Iterable<ProviderOrFamily>? dependencies, String? name}) autoDispose, ProviderFamily<R, Arg> Function<R, Arg>(R Function(Ref<R>, Arg), {Iterable<ProviderOrFamily>? dependencies, bool isAutoDispose, String? name}) call});
Then use the "add trailling comma" quick fix. Then format.
Yeah, it'd be nice if these were formatted better. I suspect we're building a string to describe the element, but maybe it'd be nice if we were able to extra the code from the file (as the user formatted it) and show that. This string likely shows up in many others place too, so we'd need to figure out which places it makes sense to format and which are best on a single line.
Needs some experimenting I think!