Possibility to type meta
prop in ColumnDef
#4104
Replies: 2 comments 3 replies
-
I’m working on a better way to type metas. Stay tuned.
…On Jul 5, 2022, 8:08 AM -0600, Azzou Q ***@***.***>, wrote:
Maybe something like this could be envisaged ?
declare type CoreColumnDefBase<TData extends RowData, TMeta extends unknown> = {
columns?: ColumnDef<TData>[];
header?: ColumnDefTemplate<ReturnType<CoreHeader<TData>['getContext']>>;
footer?: ColumnDefTemplate<ReturnType<CoreHeader<TData>['getContext']>>;
cell?: ColumnDefTemplate<ReturnType<CoreCell<TData>['getContext']>>;
meta?: TMeta;
};
declare type ColumnDef<TData extends RowData, TMeta extends unknown = unknown> = CoreColumnDef<TData, TMeta> & ...;
Then we could use something like useMemo<ColumnDef<TData, TMeta>[]>() where TMeta will be optional, if no specified, it will remain unknown, otherwise the user can type it and avoir casting every time. Feel like a little bit harsh to me tho that TMeta will be added all along your typings for just one props.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AzzouQ
-
… On Jul 21, 2022, 2:27 PM -0600, Justin Linn ***@***.***>, wrote:
I am loving the new API so far but man typing some stuff out has been hard. I watched your talk about and I am feeling a tad bit of that pain right now trying to write Table Generics... Would love to see a video on this in the future. I want to understand and be a TS pro so badly!
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Maybe something like this could be envisaged ?
Then we could use something like
useMemo<ColumnDef<TData, TMeta>[]>()
where TMeta will be optional, if not specified, it will remain unknown, otherwise the user can type it and avoid casting every time. Feel like a little bit harsh to me tho that TMeta will be added all along your typings for just one props.Beta Was this translation helpful? Give feedback.
All reactions