Open sebastianbuechler opened 1 week ago
Hi, and thanks for your idea.
I agree that our reusable types produce complex IDE hints. I'm +1 for making these hints more user friendly. I'm marking this as an enhancement.
I didn't know about the Symplify
type. It may be a good idea, but we must make sure that:
ListControllerResult
)Finally, not all type hints are usable in an IDE. For instance, when you start typing n HTML element, IDEs suggest a list of 250 possible attributes. We don't want to spend time refining that kind of list.
My suggestion: open a PR implementing this type of simplification on a small subset of hooks and components, so that we can judge the result.
Especially for beginners, it can be quite hard to understand the types of react-admin due to its highly reusable type structure.
For example in the
DataProvider
type definition we have for thegetList
method:getList: <RecordType extends RaRecord = any>(resource: ResourceType, params: GetListParams & QueryFunctionContext) => Promise<GetListResult<RecordType>>
However, it would be much more helpful to resolve the types directly. Like
GetListParams & QueryFunctionContext
could be resolved via some VS Code extension (https://marketplace.visualstudio.com/items?itemName=MylesMurphy.prettify-ts):However, it's IDE-dependent and beginners probably do not know this.
What about using something like
simplify
fromtype-fest
so it's directly in the codebase? https://github.com/sindresorhus/type-fest/blob/main/source/simplify.d.tsHas this ever been considered?