NuxtN
Nuxt3mo ago
14 replies
ᴋʏʟʟɪᴀɴ

v-for doesnt infer type from computed

Hey, not sure if I'm doing anything wrong here. But I have this piece of code:

const selectedProducts = computed<StorefrontProduct[]>(() => {
    return products.value.filter(p => {
        if (!p.tags) return false;
        return p.tags.some(t => t.name.toLowerCase() === category);
    });
});


Using it in this v-for:
                    <div v-for="product in selectedProducts" :key="product.id">
                        {{ product.name }}
                    </div>


But product still gives me the 'any' type. why is this?
Was this page helpful?