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

Incorrect RichTextField types #35

Open
nandorojo opened this issue Sep 30, 2022 · 1 comment
Open

Incorrect RichTextField types #35

nandorojo opened this issue Sep 30, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@nandorojo
Copy link

nandorojo commented Sep 30, 2022

Is your feature request related to a problem? Please describe.

Currently, the codegen outputs something like this for RichTextField:

declare type RichTextField<State extends FieldState = FieldState> = State extends "empty" ? [] : [RTNode, ...RTNode[]];

Using State extends "empty" ? [] means that the array is essentially never[] | [RTNode, ...RTNode[]]. This means that looping over items basically never works, because they can also be typed as never.

Screen Shot 2022-09-30 at 4 40 31 PM

Describe the solution you'd like

Rewrite the type like this:

declare type RichTextField<State extends FieldState = FieldState> = RTNode[];

An empty array doesn't require getting typed, right?

Describe alternatives you've considered

Overriding the types manually.

Additional context

@nandorojo nandorojo added the enhancement New feature or request label Sep 30, 2022
@nandorojo
Copy link
Author

Just realized this type comes from @prismicio/types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant