Is there a way to extend typescript types? #4026
-
I'm extend the table logic with custom methods, for example: function useCustomInstance() {
const instance = useTableInstance(...)
return useMemo(() => {
const helpers = {
customMethod: () => { ... },
...
}
return Object.assign(instance, helpers), [instance])
}
} Than i want to use custom method in column: table.createDataColumn('FirstName', {,
cell: ({ instance }) => {
return instance.customMethod()
}
}), How to extend TableInstance type with my method? Bad option: return (instance as MyCustomInstance).customMethod() I have a lot of tables with a lots of columns in different places. |
Beta Was this translation helpful? Give feedback.
Answered by
tannerlinsley
Jun 16, 2022
Replies: 1 comment
-
Use the tableOptions.meta option. What you pass there will be available on instance.meta. See the editable data example 👍 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mc-petry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the tableOptions.meta option. What you pass there will be available on instance.meta. See the editable data example 👍