deep-jade
deep-jade2y ago

useTable Typing error is unkown

Getting full typing expect for error :
import { useTable } from "@pankod/refine-react-table"
...
const useTableMethods = useTable<ExpenseLaborAPI, HttpError>({
refineCoreProps: {
resource: ExpensesEnum.Labor,

initialFilter: [
{ field: "financialplan][id]", operator: "eq", value: selectedFinplan },
],

},
columns,
})

const {
refineCore: {
tableQueryResult: { data: tableData, error, isLoading, isSuccess, refetch },
},
} = useTableMethods
import { useTable } from "@pankod/refine-react-table"
...
const useTableMethods = useTable<ExpenseLaborAPI, HttpError>({
refineCoreProps: {
resource: ExpensesEnum.Labor,

initialFilter: [
{ field: "financialplan][id]", operator: "eq", value: selectedFinplan },
],

},
columns,
})

const {
refineCore: {
tableQueryResult: { data: tableData, error, isLoading, isSuccess, refetch },
},
} = useTableMethods
tableData, isLoading, isSuccess and refetch are correctly typed. error is unkown. How to get correct typing on error?
No description
No description
10 Replies
adverse-sapphire
adverse-sapphire2y ago
Hey @zomh, When you change the ‘HttpError’, do you still have unknown type? Could you try it?
deep-jade
deep-jade2y ago
hello @salihozdemir you mean like this ? const useTableMethods = useTable<ExpenseLaborAPI>({ .... Its still unkown
adverse-sapphire
adverse-sapphire2y ago
I mean, whether it is ‘unknown’ when you give any type instead of HhtpError. If you have still issue, the first business day will disscuss this issue with team.
Omer
Omer2y ago
It seems we don't use generic error type in return type. Would you like to fix it? @zomh https://github.com/refinedev/refine/blob/next/packages/react-table/src/useTable/index.ts#L19
GitHub
refine/index.ts at next · refinedev/refine
Build your React-based CRUD applications, without constraints. - refine/index.ts at next · refinedev/refine
deep-jade
deep-jade2y ago
@Omer Thanks for the feedback. I am afraid i just learned typescript like 2 month ago. This exceeds my knowledge to be honest. Sorry gonna be honest 🥲
Omer
Omer2y ago
Don't worries. Could you create an issue? 🚀
deep-jade
deep-jade2y ago
yes will do
Omer
Omer2y ago
We'll fix it monday
Omer
Omer2y ago
Hey @zomh , We've released @pankod/refine-react-table@4.9.1 🎯 Can you confirm that the problem is fixed? You can use CLI's update command for update 👊 https://refine.dev/docs/packages/documentation/cli/#update
CLI | refine
refine CLI is a command line application that allows you to interact with your refine project and perform some tasks. This includes creating a new resource, managing updates, swizzle components, and runs your project (build, start, dev).
deep-jade
deep-jade2y ago
@Omer @salihozdemir confirmed fixed. thank you!