#how can I solve Spread types may only be created from object types???

17 messages · Page 1 of 1 (latest)

tulip dove
#

!helper

tulip dove
#

My code:

`@Patch('/features/:featureType')
async updateFeature(@Req() req: Request, @Param('guild') guild: string, @Body() body: Partial<':featureBod'>, @Param('featureType') featureType: string, @Param('featureBod') featureBod: string) {
this.guilds.checkPermissions(auth(req), guild);

if (featureType === 'welcome-message') {
featureBod === 'WelcomeMessage'
const updated = await this.prisma.welcomeMessage.update({
where: {
id: guild,
},
data: {
...body,
id: undefined,
},
});

  return updated;

} else if (featureType === 'utility') {
featureBod === 'Utility'
const updated = await this.prisma.utility.update({
where: {
id: guild,
},
data: {
...body,
id: undefined,
},
});

return updated;

}
}`

Error: error TS2698: Spread types may only be created from object types.

#

how can I solve Spread types may only be created from object types.???

#

how can I solve Spread types may only be created from object types???

#

!helper

unreal whaleBOT
#

:warning: Please wait a bit longer. You can ping helpers <t:1694998561:R>.

tulip dove
#

@latent crest please help me

carmine gate
#

you're using Partial on a string... which is just a string

tulip dove
#

@xibread Well, how can I solve this problem?

#

@carmine gate

tulip dove
#

@carmine gate What should I do instead of a string?
@Param('featureBod') featureBod: string

hasty olive
#

what happen if you do any?

tulip dove
#

@hasty olive It's still the same error and I don't know the exact reason

hasty olive
tulip dove
#

Please can you send me an example of the code@hasty olive

hasty olive
#
// sample.dto.ts
export class SampleDto {
  name: string;
  age: number;
  breed: string;
}

@Body() sampleDto: SampleDto

tulip dove
#

This is the first time I deal with such a file. Can you explain it to me more please?