I am converting my JS Next.js project to TS. I have gone through the docs and generated a types.generated.ts
in attempt to type the first existing slice by converting it to index.tsx
it is looking like this:
import { Content } from "@prismicio/client";
const ComponentAnatomy: Content.ComponentAnatomySlice = ({ slice }: Content.ComponentAnatomySlice) => (...
Reading the docs, this appears to be correct(? theres really not much in the docs) but I am getting an error on both ComponentAnatomy
and slice
.
ComponentAnatomy
error:
const ComponentAnatomy: Content.ComponentAnatomySlice
Type '({ slice }: Content.ComponentAnatomySlice) => JSX.Element' is not assignable to type 'ComponentAnatomySlice'.
Type '({ slice }: Content.ComponentAnatomySlice) => JSX.Element' is not assignable to type '{ slice_type: "component_anatomy"; slice_label: null; id?: string | undefined; }'.ts(2322)
slice
error:
(parameter) slice: any
Property 'slice' does not exist on type '{ slice_type: "component_anatomy"; slice_label: null; id?: string | undefined; } & SharedSliceVariation<"default", Simplify<ComponentAnatomySliceDefaultPrimary>, Simplify<...>>'.ts(2339)
I have tried looking on GitHub, the Prismic docs and reading through the types.generated.ts
and I think I just need to walk away at this point. Writing this to ask for help but if I somehow figure this out I will also reply so someone in the future can find this.