Upgrading slice-machine-ui; Module '"@prismicio/client"' has no exported member 'Content'

After upgrading slice-machine-ui to v1.0.0, the Content type is no longer exported from @prismicio/client so types cannot be defined in slices.

Please advise.

Using:

next@13.3.1
@prismicio/react@2.5.2
slice-machine-ui@1.0.0

p.s. using Typescript.

3 Likes

I have the same problem(

Using:

"@prismicio/types": "^0.2.7",
"@slicemachine/adapter-next": "^0.1.0",
"slice-machine-ui": "^1.0.0",
"@prismicio/client": "^6.7.3",
"@prismicio/helpers": "^2.3.9",
"@prismicio/next": "^1.0.3",
"@prismicio/react": "^2.5.2",
"@prismicio/slice-simulator-react": "^0.2.3",

tsconfig.json

  "include": [
    "next-env.d.ts",
    "prismicio.d.ts",
    "**/*.ts",
    "**/*.tsx",
    "pages/api/preview.js"
  ],

Hello @vagmen27 @james6

Thanks for posting this to us. This way, we can solve potential bugs as soon as possible

Can you rename the prismicio.d.ts to prismicio-types.d.ts? If the file does not exist, you will need to run the slice machine first and make a change somewhere in the slices or CT.

Give this a try and let me know.

Thanks,
Priyanka

1 Like

Thanks! That works - will this patch be released in the next version?

1 Like

@Priyanka I have done that, but when I push an update on slice machine, it's prismicio.d.ts that is created, not prismicio-types.d.ts and I get the error

./prismicio.ts:67:25
Type error: Property 'previewData' does not exist on type '{}'.

  65 |   prismicNext.enableAutoPreviews({
  66 |     client,
> 67 |     previewData: config.previewData,
     |                         ^
  68 |     req: config.req
  69 |   })

So I had to create manually a type before the createClient:

/**
 * Creates a Prismic client for the project's repository. The client is used to
 * query content from the Prismic API.
 *
 * @param config {prismicNext.CreateClientConfig} - Configuration for the Prismic client.
 */
interface CreateClientConfig extends prismic.ClientConfig {
  previewData?: any
  req?: any
}

export const createClient = (config: CreateClientConfig = {}) => {
  const client = prismic.createClient(sm.apiEndpoint, {
    routes,
    ...config
  })

  prismicNext.enableAutoPreviews({
    client,
    previewData: config.previewData,
    req: config.req
  })

  return client
}

Is that normal? Is this behavior expected with the slicemachine update?

Hello @Marving, This is not expected behavior. My team has updated and released the fix. Can you try and confirm? Thanks.

2 Likes

Just opened the below ticket. Still relates to the latest slice-machine-ui update.

1 Like

I had the same problem. With the update to version 1.0.1 it's fixed.
Thank you for the quick fix. :slight_smile:

1 Like

@Marving @vagmen27, We have fixed it. You can update your @slicemachine/adapter-next dependency to 0.1.1 to get it. Thanks.

1 Like

Awesome, thanks a lot!
It worked yes, thank you

1 Like

Thanks @Marving for the update.

1 Like

Upgrading to slice-machine-ui@1.0.2 has not resolved the following error (using next@13.3.4):

Could not find a component for Slice type.

Steps to replicate:

  1. Update to slice-machine-ui@1.0.2
  2. Create new slice and assign to custom post type
  3. Add slice into page and populate with content
  4. Front-end renders Could not find a component for Slice type “tester”

Creating a new project at the latest version does not have an issue, just when upgrading.

Resolved - When using Typescript, the index.js file needs to be deleted from the slices directory.

2 Likes