This is a smaller example; there are a dozen and most are much longer. There's a whole lot of constant duplication and imports.
But this pattern predates using Typescript, and actually in most places where you have a tight typescript type it will complain if you have an incorrect type anyway, so we could get rid of a lot of unnecessary indirection.
The main thing to watch out for is there are a few places where a tighter enum is used in a string field. There you'd want to make an explicit const with the tighter type to verify and typecheck, and then use the const in the broader field.
Using Zod to drive the enum will make it possible to iterate through the various legal values easily, instead of doing a weird indirection of having an object with each key.
Currently a lot of enum types are created by having a pattern like this:
This is a smaller example; there are a dozen and most are much longer. There's a whole lot of constant duplication and imports.
But this pattern predates using Typescript, and actually in most places where you have a tight typescript type it will complain if you have an incorrect type anyway, so we could get rid of a lot of unnecessary indirection.
The main thing to watch out for is there are a few places where a tighter enum is used in a
string
field. There you'd want to make an explicit const with the tighter type to verify and typecheck, and then use the const in the broader field.Using Zod to drive the enum will make it possible to iterate through the various legal values easily, instead of doing a weird indirection of having an object with each key.
Noticed while working on #670.