prismicio / prismic-types

Type definitions for Prismic content, models, and APIs
https://prismic.io/docs/technologies/javascript
Apache License 2.0
11 stars 4 forks source link

Changes of types for RichTextNodeType breaks other PrismicIO library #19

Closed chougron closed 2 years ago

chougron commented 2 years ago

Versions

Reproduction

With the change in 0.1.18 of the RichTextNodeType type from an enum to a const variable, the import and export in @prismicio/richtext is not working anymore.

If you have @prismicio/richtext with version 2.0.0-beta.1, and your version of @prismicio/types is 0.1.18, you will have an issue with your types (especially if you try to compile).

Additional Details
Here is the interesting part of my package-lock.json : ``` "@prismicio/client": { "version": "6.0.0-beta.3", "resolved": "https://registry.npmjs.org/@prismicio/client/-/client-6.0.0-beta.3.tgz", "integrity": "sha512-AZn0u5Ah6q4PGAlGvKyVSv3OfAbM1DjGpbZWedkMiBGJ6t/tB5GyaIh2Znsfdkw8QuL80041yURdsGXaQeE2HQ==", "requires": { "@prismicio/helpers": "^2.0.0-beta.0", "@prismicio/types": "^0.1.15" } }, "@prismicio/helpers": { "version": "2.0.0-beta.3", "resolved": "https://registry.npmjs.org/@prismicio/helpers/-/helpers-2.0.0-beta.3.tgz", "integrity": "sha512-YaMRZ6JBb9f/+BXWq9V+xSQGOnWK3+8ebKi9GSeOjit+JOEZDSBn0hE87j6X7wp8cG5KTqXyBXsmd2vOh8IhdA==", "requires": { "@prismicio/richtext": "^2.0.0-beta.1", "@prismicio/types": "^0.1.17", "escape-html": "^1.0.3" } }, "@prismicio/richtext": { "version": "2.0.0-beta.1", "resolved": "https://registry.npmjs.org/@prismicio/richtext/-/richtext-2.0.0-beta.1.tgz", "integrity": "sha512-9LA+dcEtncprfjpPdQWsRThuFpDA0ID1Ne0yJJHVlKKl9qUDDfV7fbN714W2dxEV2zWRip/lyLlnfMOAABjE/w==", "requires": { "@prismicio/types": "^0.1.15" } }, "@prismicio/types": { "version": "0.1.18", "resolved": "https://registry.npmjs.org/@prismicio/types/-/types-0.1.18.tgz" }, ```

Steps to reproduce

I try to compile my code with the following command : npx tsc --outDir dist And I get the following error :

node_modules/@prismicio/richtext/dist/index.d.ts:10:62 - error TS2749: 'RichTextNodeType' refers to a value, but is being used as a type here. Did you mean 'typeof RichTextNodeType'?

10 declare type RichTextFunctionSerializer<ReturnType> = (type: RichTextNodeType, node: RTAnyNode, text: string | undefined, children: ReturnType[], key: string) => ReturnType | null | undefined;
                                                                ~~~~~~~~~~~~~~~~

node_modules/@prismicio/richtext/dist/index.d.ts:59:11 - error TS2749: 'RichTextNodeType' refers to a value, but is being used as a type here. Did you mean 'typeof RichTextNodeType'?

59     type: RichTextNodeType;
             ~~~~~~~~~~~~~~~~

What is expected?

The compilation should work as intended

What is actually happening?

With the change in 0.1.18 of the RichTextNodeType type from an enum to a const variable, the import and export in @prismicio/richtext is not working anymore.

angeloashmore commented 2 years ago

Hi @chougron, thanks for the report! This has been fixed in @prismicio/richtext@v2.0.0-beta.2

You should be able to run npm update @prismicio/richtext to update to the fixed version.

In case you are curious why the change was made to RichTextNodeType, here is the relevant issue: https://github.com/prismicio/prismic-types/issues/16