You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While it's okay in most cases, I can't build type-safe hooks based on it. For instance, I have a custom hook called useColumnVisibility:
typeColumnVisibilityParams<TData,TValue,TColumnsextendsColumnDef<TData,TValue>>={// ...columns: TColumn[];forceVisibleColumns: string[];initialSelected: InferColumnDefId<TColumn>[];// <-- not possible, since ColumnDef["id"] will always be string};exportdefaultfunctionuseColumnVisibility<TData,TValue, ...>
As you can see, since ColumnDef["id"] is always a string, I can't type-safely allow specific string literals.
While I could enforce it by writing a custom lint rule, it would be more natural to accomplish it via types.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, you can't infer the literal
id
of a column:While it's okay in most cases, I can't build type-safe hooks based on it. For instance, I have a custom hook called
useColumnVisibility
:As you can see, since
ColumnDef["id"]
is always astring
, I can't type-safely allow specific string literals.While I could enforce it by writing a custom lint rule, it would be more natural to accomplish it via types.
Beta Was this translation helpful? Give feedback.
All reactions