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

RichTextField is broken #55

Closed
kb1995 opened this issue Mar 13, 2023 · 5 comments
Closed

RichTextField is broken #55

kb1995 opened this issue Mar 13, 2023 · 5 comments
Labels
bug Something isn't working need info Further information is requested

Comments

@kb1995
Copy link

kb1995 commented Mar 13, 2023

Versions

  • @prismicio/types: ^0.2.7
  • node: 16.10

Reproduction

import { RichTextField } from '@prismicio/types';
import { PrismicRichText } from '@prismicio/react';

interface CurrentSlice extends Slice {
  primary: {
    column_one: RichTextField;
    column_two: RichTextField;
  };
}
<PrismicRichText field={slice.primary.column_one} components={richTextComponents} />

I get the following error:

Type '[] | [import("/Users/kris/Documents/code/honeynjam/robocorp/robocorp-com/node_modules/@prismicio/types/dist/value/richText").RTNode, ...import("/Users/kris/Documents/code/honeynjam/robocorp/robocorp-com/node_modules/@prismicio/types/dist/value/richText").RTNode[]]' is not assignable to type '[] | [import("/Users/kris/Documents/code/honeynjam/robocorp/robocorp-com/node_modules/@prismicio/client/node_modules/@prismicio/types/dist/index").RTNode, ...import("/Users/kris/Documents/code/honeynjam/robocorp/robocorp-com/node_modules/@prismicio/client/node_modules/@prismicio/types/dist/index").RTNode[]]'.
  Type '[RTNode, ...RTNode[]]' is not assignable to type '[] | [RTNode, ...RTNode[]]'.ts(2322)
index.d.ts(265, 5): The expected type comes from property 'field' which is declared here on type 'IntrinsicAttributes & PrismicRichTextProps<LinkResolverFunction<string>>'

If I use the TitleField, I don't get any errors but this is obviously the wrong field to use.

What is expected?

To work without any errors

What is actually happening?

I get a typescript error

@kb1995 kb1995 added the bug Something isn't working label Mar 13, 2023
@github-actions
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

@lihbr
Copy link
Member

lihbr commented Mar 13, 2023

Hey @kb1995, it looks like you're relying on two different @prismicio/types versions within your project.

Can you provide:

  1. Your @prismicio/client, @prismicio/react (and @prismicio/next) versions?
  2. The result of npm ls @prismicio/types in your project?

Thanks!

@lihbr lihbr added the need info Further information is requested label Mar 13, 2023
@kb1995
Copy link
Author

kb1995 commented Mar 13, 2023

@lihbr Thanks for the quick reply

"@prismicio/client": "^6.4.3",
"@prismicio/react": "^2.5.2",
"@prismicio/next": "^0.1.2",

This is what I got from the npm ls command

─┬ @prismicio/client@6.4.3
│ ├─┬ @prismicio/helpers@2.3.0
│ │ ├─┬ @prismicio/richtext@2.0.1
│ │ │ └── @prismicio/types@0.1.27
│ │ └── @prismicio/types@0.1.27 deduped
│ └── @prismicio/types@0.1.27
├─┬ @prismicio/helpers@2.3.9
│ ├─┬ @prismicio/richtext@2.1.4
│ │ └── @prismicio/types@0.2.7 deduped
│ └── @prismicio/types@0.2.7 deduped
├─┬ @prismicio/next@0.1.2
│ └─┬ @prismicio/react@2.3.0
│   └─┬ @prismicio/helpers@2.3.0
│     └── @prismicio/types@0.1.27
├─┬ @prismicio/react@2.5.2
│ ├─┬ @prismicio/helpers@2.3.0 invalid: "^2.3.8" from node_modules/@prismicio/react
│ │ └── @prismicio/types@0.1.27 deduped invalid: "^0.2.7" from node_modules/@prismicio/react
│ ├─┬ @prismicio/richtext@2.1.4
│ │ └── @prismicio/types@0.1.27 deduped invalid: "^0.2.7" from node_modules/@prismicio/react, "^0.2.7" from node_modules/@prismicio/react/node_modules/@prismicio/richtext
│ └── @prismicio/types@0.1.27 invalid: "^0.2.7" from node_modules/@prismicio/react, "^0.2.7" from node_modules/@prismicio/react/node_modules/@prismicio/richtext
└── @prismicio/types@0.2.7

npm ERR! code ELSPROBLEMS
npm ERR! invalid: @prismicio/types@0.1.27 /Users/kris/Documents/code/honeynjam/robocorp/robocorp-com/node_modules/@prismicio/react/node_modules/@prismicio/types

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kris/.npm/_logs/2023-03-13T16_51_55_644Z-debug.log

@lihbr
Copy link
Member

lihbr commented Mar 13, 2023

Thanks!

Can you try updating your dependencies in your package.json to the best you can?

  • @prismicio/client: 6.4.3 > 6.7.3
  • @prismicio/next: 0.1.2 > 0.1.8 (0.2.0 and 1.0.3 are also available but support Next 13)

After an npm install (and potentially an npm update) it should align versions back as expected.

Let me know!

@kb1995
Copy link
Author

kb1995 commented Mar 13, 2023

@lihbr Thanks, Lucy! This was the issue - silly mistake on my end!

@kb1995 kb1995 closed this as completed Mar 13, 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 need info Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants