nuxt-modules / nuxt-modules/strapi
TypeScript: Argument of type '{ data: { myComponent: any[]; }; }' is not assignable to parameter of type 'NuxtStrapiData'.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 717
- Forks
- 89
- Avg merge
- 7h 3m
- Merged PRs (30d)
- 6
Description
Version
@nuxtjs/strapi: v0.3.6
nuxt: v2.15.8
Steps to reproduce
Consider this:
- You have collection type with a repeatable component inside.
- You wish to update the data inside the repeatable component.
A component object may look like this:
const myComponentObject = {
title: "A title",
description: "A description"
dateStart: "2022-01-01"
dateEnd: "2022-01-31"
}
The code may look like this:
await this.$strapi.update('my-collection-type', this.idOfCollectionTypeItem, {
data: { myRepeteableComponent: myComponentObjectsArray },
})
What is Expected?
I expect the object to be allowed by the type. Ignoring the error will still allow the data to be created/updated as expected.
What is actually happening?
It will give a TypeScript error:
Argument of type '{ data: { experience: any[]; }; }' is not assignable to parameter of type 'NuxtStrapiData'.
Types of property 'data' are incompatible.
Type '{ myRepeteableComponent: any[]; }' is not assignable to type 'string | number | boolean | (string | number | boolean)[] | undefined'.
Object literal may only specify known properties, and 'myRepeteableComponent' does not exist in type '(string | number | boolean)[]'.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the NuxtStrapiData type and the $strapi.update entry point. Reproduce the TypeScript error with an update payload containing a repeatable component array, then verify that the type accepts the payload while preserving existing primitive-value support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100