Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations should support readonly arrays for createType().asEnum() #1118

Open
matthew-holder-revvity opened this issue Aug 14, 2024 · 1 comment
Labels
api Related to library's API enhancement New feature or request greenlit Ready for implementation migrations Related to migrations typescript Related to Typescript

Comments

@matthew-holder-revvity
Copy link

This is a common way to generate enum unions by some that provides a list of the values for runtime checking.

export const ProcessType = ['develop', 'test', 'qa', 'relese'] as const
export type ProcessType = (typeof ProcessType)[number]

Unfortunately, the example ProcessType cannot be passed to createType().asEnum() since it is a read-only array and results in:

Argument of type 'readonly ['develop', 'test', 'qa', 'relese']' is not assignable to parameter of type 'string[]'.
  The type 'readonly ['develop', 'test', 'qa', 'relese']' is 'readonly' and cannot be assigned to the mutable type 'string[]'. ts(2345)

I suspect asEnum does not mutate the passed array and could except readonly arrays.

@koskimas koskimas added api Related to library's API greenlit Ready for implementation migrations Related to migrations labels Aug 14, 2024
@koskimas
Copy link
Member

Yep, we should do that.

@igalklebanov igalklebanov added enhancement New feature or request typescript Related to Typescript labels Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request greenlit Ready for implementation migrations Related to migrations typescript Related to Typescript
Projects
None yet
Development

No branches or pull requests

3 participants