drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: Improve ergonomics of type-safety of PgEnum
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
Here's the user story of writing a new `PgEnum`:
1. Write a simple `pgEnum`:

Cool, simple, works, compiles. But the type is only inferred here, rather than checked / enforced. So let's try to add a `satisfies`:


Ah, `PgEnum` requires a type parameter. Let's add one:

Green again. But now I've duplicated the enum values into both the enum definition and into the type-check. Can we DRY?

Not quite, the type parameter doesn't accept `readonly`. Let's find [a trick on Stack Overflow](https://stackoverflow.com/a/43001581):

Great, back to green. But this feels very awkward / boilerplate...? Is it not possible to have either `satisfies PgEnum;` (similar to `PgTable`), without specifying a type parameter, or have the type parameter accept `readonly` so that it can use `typeof` an `as const` array?
Contributor guide
Assessment
This issue has not been assessed yet.