Closed hitfm00 closed 10 months ago
It does take a while indeed, as DataTable
is a component with lots of properties and the TS server needs some time to perform its autocomplete magic.
This is the main drawback of having a React component (or any kind of function, for that matter) with so many configuration options that are properly validated and documented with TS. The same happens, for instance, if you're using things like tRPC, which are heavily based on dynamic types...
For instance, have a look at how the sorting-related prop types are defined: https://github.com/icflorescu/mantine-datatable/blob/main/package/types/DataTableSortProps.ts
This is to make sure that providing onSortStatusChange
callback only makes sense if you also provide a sortStatus
property.
Another example is this: the column accessor type is described like so:
accessor: keyof T | (string & NonNullable<unknown>);
This way, the editor will be able to suggest properties inferred from the type of records
, but won't limit you to that.
It doesn't take 4s, though. On my machine, a not-so-new Ryzen7 4800u laptop with Manjaro Linux, the scenario you are describing takes about one second for the autocomplete to trigger.
I may be subjective, but all-in-all, I'd say it's an acceptable trade-off. I could relax the typings, but then we'd have a lot of uncaught errors, especially nowadays when we're working in such as fast-paced environment and devs tend to skip the docs and jump straight into code :-). Dealing with bugs introduced by improper prop combinations and validations would cost you way more than one or even four seconds.
Going to convert this to a discussion.
Reproduce: 1)
<DataTable columns={[{ accessor: "title" }]} records={data} />;
2) Then just type somelo
<DataTable columns={[{ accessor: "title" }]} records={data} lo />;
3) And wait 4 second when we will see autocompleteIn other components for me all good, only with this it takes so long time :)