problem with type
Unanswered
Tomistoma posted this in #help-forum
TomistomaOP
hello, I get such error
./src/app/aukcja/[auctionId]/SingleAuctionPage.tsx:24:5
Type error: Property 'mileage' does not exist on type '{ error: true; } & String'.
./src/app/aukcja/[auctionId]/SingleAuctionPage.tsx:24:5
Type error: Property 'mileage' does not exist on type '{ error: true; } & String'.
56 Replies
TomistomaOP
export const SingleAuctionPage = ({
data,
}: {
data: SingleAuctionData["data"];
}) => {
const { getProperKey } = useDatabaseLocale();
const t = useTranslations();
if (!data) return null;
const {
price,
mileage,
engine_capacity,
production_year,
localization,
rating,
} = data;export const getAuctionById = (id: string) => {
return supabaseClient
.from("auctions")
.select(
`id,
brands(id,name),
models(id,name),
fuel_types(id,name,name_en),
gearboxes(id,name,name_en),
price,mileage`
)
.eq("id", id)
.single();
};
export type SingleAuctionData = Awaited<ReturnType<typeof getAuctionById>>;./src/app/aukcja/[auctionId]/SingleAuctionPage.tsx:24:5
Type error: Property 'price' does not exist on type '{ error: true; } & String'.
Type error: Property 'price' does not exist on type '{ error: true; } & String'.
what is going on
TomistomaOP
please help
TomistomaOP
???
TomistomaOP
now
Type error: Type '{ error: true; } & String' is missing the following properties from type '{ price: number; mileage: number; engine_capacity: number; production_year: number; localization: string; rating: number;': and 16 more.what is going on
Burmese
Are you sure the return from getAuctionById() is what you're expecting?
TomistomaOP
I have such code yet
export default async function Page({
params: { auctionId },
}: {
params: { auctionId: string };
}) {
const { data, error } = await getAuctionById(auctionId);
if (error) {
return error?.message;
}
return <SingleAuctionPage data={data} />;
}I dont know, getAuctionById return promise
TomistomaOP
what should I do? I dont have type in function
type is this
export type SingleAuctionData = Awaited<ReturnType<typeof getAuctionById>>;
but i dont know what it means
export type SingleAuctionData = Awaited<ReturnType<typeof getAuctionById>>;
but i dont know what it means
TomistomaOP
???
TomistomaOP
please help
getAuctionById return promise
@Tomistoma please help
kindly only bump at most once per day.
TomistomaOP
sorry i need it
TomistomaOP
should I add async to function?
and return data?
TomistomaOP
still get error
Type error: Property 'price' does not exist on type '{ error: true; } & String'.export const getAuctionById = async (id: string) => {
const {data, error} = await supabaseClient
.from("auctions")
.select(
`id,
brands(id,name),
models(id,name),
fuel_types(id,name,name_en),
gearboxes(id,name,name_en),
price`
)
.eq("id", id)
.single();
if(error) throw new Error("Fetch error");
return data;
};
export type SingleAuctionData = Awaited<ReturnType<typeof getAuctionById>>;TomistomaOP
ehh
could anyone help
... ?
Burmese
Please be patient. Try double-checking getAuctionById function. It seems like it's giving an error response that you're not checking for its type.
TomistomaOP
it returns promise
i dont know how to do this...
write types?
type a {
id
brands
models
...
}
type a {
id
brands
models
...
}
Burmese
Try testing your function in isolation. If it errs for you, output its type. If you don't know what to do, take this time to further research typescript.
TomistomaOP
I tested it, go to page
and function return data
console.log
I get data from server
normally
TomistomaOP
still error
Type error: Type '{ error: true; } & String' is missing the following properties from type 'SingleAuctionData': id, brands, models, fuel_types, and 18 more.TomistomaOP
????
Could you write?
I am writing from phone
TomistomaOP
no one
want help me
:/
TomistomaOP
@Burmese
????????
Black-whiskered Vireo
Man
I need it!!!!
No one help, this channel is bad
@Tomistoma ????????
Short-eared Owl
No one owes you help. Whining, spamming and blatantly ignoring moderators requests to stop bumping your post doesn't make anyone want to help you more. It encourages people to move on and help someone who is patient and appreciative. Read documentation, try to understand the issue yourself, or ask AI for assistance.
Black-whiskered Vireo
You didnt know How to solve it. Simply
And other people
I am waiting 5 days for response
5 day od break in coding
I am working alone
Not in big company where 20 people think
On one thing