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

Type for TitleField missing direction field (mismatch in typings versus data from your endpoint) #331

Open
maapteh opened this issue Dec 27, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@maapteh
Copy link

maapteh commented Dec 27, 2023

Versions

  • @prismicio/client: 7.3.1
  • node: 20.8.0

Reproduction

In the data from the cdn/api we get a direction field in the data for headings and paragraphs, while in the Type definition this is not typed at all:

Screenshot 2023-12-27 at 10 54 55

Steps to reproduce

Consume Query from '@prismicio/client' then browse to the field TitleField

There you will see:

/**
 * A title field.
 *
 * @see Title field documentation: {@link https://prismic.io/docs/rich-text-title}
 */
export type TitleField<State extends FieldState = FieldState> = State extends "empty" ? [] : [
    Omit<RTHeading1Node | RTHeading2Node | RTHeading3Node | RTHeading4Node | RTHeading5Node | RTHeading6Node, "spans"> & {
        spans: [];
    }
];

Now add a paragraph and heading to your workspace and consume the Query endpoint. Inspect the data, you will notice the direction.

What is expected?

The direction to be typed as well. Inside your definition of a textNodeBase for example or the specific heading and paragraph (i don't know your internals, so i assume it belongs in the RRText definition :)):

export interface RTTextNodeBase {
    text: string;
    spans: RTInlineNode[];
    direction: 'ltr' | 'rtl' whatever :)
}

What is actually happening?

Not typed, so my type builders are unable to use auto generated typings. Please add them correctly according to your own data schema. At least for Paragraph and Headings but just check your schema one more time :)

@maapteh maapteh added the bug Something isn't working label Dec 27, 2023
Copy link

This issue has been labeled as a bug since it was created using the 🚨 Bug Report Template.

Hi there, thank you so much for the report!

Following our Maintenance Process, we will review your bug report and get back to you next Wednesday. To ensure a smooth review of your issue and avoid unnecessary delays, please make sure your issue includes the following:

  • Information about your environment and packages you use (Node.js version, package names and their versions, etc.)
    Feel free to attach a copy of your package.json file.
  • Any troubleshooting steps you already went through
  • A minimal reproduction of the issue, and/or instructions on how to reproduce it

If you have identified the cause of the bug described in your report and know how to fix it, you're more than welcome to open a pull request addressing it. Check out our quick start guide for a simple contribution process.

If you think your issue is a question (not a bug) and would like quicker support, please close this issue and forward it to an appropriate section on our community forum: https://community.prismic.io

- The Prismic Open-Source Team

@maapteh maapteh changed the title Type for TitleField missing direction field Type for TitleField missing direction field (mismatch in typings versus data from your endpoint) Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant