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

JTDSchemaType derivation for enums is too strict #2358

Open
swachter opened this issue Dec 20, 2023 · 2 comments
Open

JTDSchemaType derivation for enums is too strict #2358

swachter opened this issue Dec 20, 2023 · 2 comments

Comments

@swachter
Copy link

What version of Ajv are you using? Does the issue happen if you use the latest version?

8.12.0

Ajv options object

none

Your code

type AB = 'a' | 'b'
const s1 = { enum: ['a', 'b'] } as const
const enum1: JTDSchemaType<AB> = s1
// error: The type 'readonly ["a", "b"]' is 'readonly' and cannot be assigned to the mutable type 'AB[]'.

What results did you expect?

Assignment should be possible.

Are you going to resolve the issue?
I can prepare a PR

@epoberezkin
Copy link
Member

This is not something that is easy (or maybe even possible) to improve given typescript type system limitations.

@StefanWachter1507
Copy link

Did you see #2359?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants
@swachter @epoberezkin @StefanWachter1507 and others