#SWC compiler with non-inline enums

5 messages · Page 1 of 1 (latest)

serene venture
#

I've tried switching to the swc compiler yesterday for my jest tests since its way faster however I'm facing an issue with enums imported from other files. I'm getting the following error:

TypeError: Invalid schema configuration: `USER` is not a valid type at path `0`.

If I however have the enum defined in the same file as the schema it does work.

example mongoose schema with imported enum:


@Schema()
export class User {

  @ApiProperty()
  @Prop({
    required: true,
  })
  role: UserRole;
}
export const UserSchema = SchemaFactory.createForClass(User);```

My .swcrc:

{
"$schema": "https://json.schemastore.org/swcrc",
"sourceMaps": true,
"jsc": {
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"legacyDecorator": true,
"decoratorMetadata": true
},
"baseUrl": "./"
},
"minify": false
}```

limber charm
#

unfortunately, const enums don't work well with swc

steady seal