#error TS2698: Spread types may only be created from object types

6 messages · Page 1 of 1 (latest)

devout raptor
#

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.

https://cdn.discordapp.com/attachments/1153102083755610192/1153106906068562020/image.png

#

What I'm trying to do is I want to check if the path is /features/welcome-message, if it already is, then it will be Partial<WelcomeMessage> and if it is /features/utility, then it will be Partial <Utility>