helpful-purple
helpful-purple17mo 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-sapphire17mo ago
Hey @zomh, When you change the ‘HttpError’, do you still have unknown type? Could you try it?
helpful-purple
helpful-purple17mo ago
hello @salihozdemir you mean like this ? const useTableMethods = useTable<ExpenseLaborAPI>({ .... Its still unkown
adverse-sapphire
adverse-sapphire17mo 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
Omer17mo 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
helpful-purple
helpful-purple17mo 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
Omer17mo ago
Don't worries. Could you create an issue? 🚀
helpful-purple
helpful-purple17mo ago
yes will do
Omer
Omer17mo ago
We'll fix it monday
Omer
Omer17mo 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).
helpful-purple
helpful-purple17mo ago
@Omer @salihozdemir confirmed fixed. thank you!