Next.js Discord

Discord Forum

I have some errors like Property 'x' does not exist on type 'ProductType | ProductType[]'.

Unanswered
Pembroke Welsh Corgi posted this in #help-forum
Open in Discord
Pembroke Welsh CorgiOP
Property 'images' does not exist on type 'ProductType | ProductType[]'.
Property 'images' does not exist on type 'ProductType[]'.ts(2339)
Property 'name' does not exist on type 'ProductType | ProductType[]'.
Property 'name' does not exist on type 'ProductType[]'.ts(2339),
Property 'price' does not exist on type 'ProductType | ProductType[]'.
Property 'price' does not exist on type 'ProductType[]'.ts(2339)
Property 'rating' does not exist on type 'ProductType | ProductType[]'.
Property 'rating' does not exist on type 'ProductType[]'.ts(2339)
Property 'description' does not exist on type 'ProductType | ProductType[]'.
Property 'description' does not exist on type 'ProductType[]'.ts(2339)
my ProductType looks correct in my opinion. Do you have some suggestions?

2 Replies

Transvaal lion
What is defaultProducts? An array? Because you've typed the product prop as a single product, while the value you're assigning it seems to be an array (telling by the name). If you're always passing a value to the product prop you can remove the assignment to defaultProducts and it should work I think
Pembroke Welsh CorgiOP
thanksm i just removed defaultProducts and it works. the mistake is that i passed an array