Skip to content

[Feature Request] Also generate an enum #765

@Zer0xxxx

Description

@Zer0xxxx

Version

5.26.2

Describe the bug

It would be great to also codegen an enum like so:

enum ELocales {
  'en-US' = 'en-US',
  'fr' = 'fr'
}

An example of use-case of it could be to use typesafe-i18n with TypeORM

const decoratorConfigLocalesEnumFragment = {
  default: baseLocale,
  enum: ELocales,
  type: 'enum'
} as const;

@Entity()
class Foo {
  // * ...
  @Column({ nullable: false, ...decoratorConfigLocalesEnumFragment })
  inferedLang!: ELocales;

  @Column({ nullable: true, ...decoratorConfigLocalesEnumFragment })
  lang!: ELocales;

  // * ...
}

Reproduction

Process a codegen with typesafe-i18n, then inspect the i18n-types.ts file.
A desirable enum is missing.

Logs

No response

Config

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions