Hi
I'm using prismic with nextjs and after upgrading to the latest js sdk and migrating my old components, i started adding types to those components.
This problem does not show up on the live SliceZone in my "pages" directory.
My problem surfaced when i created the slice-simulator.tsx file
import { SliceZone } from "@prismicio/react";
import { SliceSimulator } from "@prismicio/slice-simulator-react";
import { components } from "~/slices";
import state from "../.slicemachine/libraries-state.json";
const SliceSimulatorPage = () => (
<SliceSimulator
// The "sliceZone" prop should be a function receiving slices and rendering them using your "SliceZone" component.
sliceZone={(props) => <SliceZone {...props} components={components} />}
state={state}
/>
);
export default SliceSimulatorPage;
The issue i get is emited for the components prop. This is the specific error i get
TS2322: Type '{ carousel: FunctionComponent<SliceComponentProps<CarouselSlice, unknown>>; categories: ({ slice }: SliceComponentProps<CategoriesSlice, unknown>) => JSX.Element; ... 11 more ...; why_us: ({ slice }: SliceComponentProps<...>) => JSX.Element; }' is not assignable to type 'SliceZoneComponents<Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, SharedSliceVariation<string, Record<...>, Record<...>>>, unknown>'. Property 'carousel' is incompatible with index signature. Type 'FunctionComponent<SliceComponentProps<CarouselSlice, unknown>>' is not assignable to type 'SliceComponentType<Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, SharedSliceVariation<string, Record<...>, Record<...>>>, unknown>'. Type 'FunctionComponent<SliceComponentProps<CarouselSlice, unknown>>' is not assignable to type 'FunctionComponent<SliceComponentProps<Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, SharedSliceVariation<string, Record<...>, Record<...>>>, unknown>>'. Types of parameters 'props' and 'props' are incompatible. Type 'PropsWithChildren<SliceComponentProps<Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, SharedSliceVariation<string, Record<...>, Record<...>>>, unknown>>' is not assignable to type 'PropsWithChildren<SliceComponentProps<CarouselSlice, unknown>>'. Type 'PropsWithChildren<SliceComponentProps<Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, SharedSliceVariation<string, Record<...>, Record<...>>>, unknown>>' is not assignable to type 'SliceComponentProps<CarouselSlice, unknown>'. Types of property 'slice' are incompatible. Type 'Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<string, SharedSliceVariation<string, Record<string, AnyRegularField>, Record<...>>>' is not assignable to type 'CarouselSlice'. Type 'Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>>' is not assignable to type 'Slice<"carousel", never, CarouselItem>'. Type 'string' is not assignable to type '"carousel"'. index.d.ts(508, 5): The expected type comes from property 'components' which is declared here on type 'IntrinsicAttributes & SliceZoneProps<Slice<string, Record<string, AnyRegularField>, Record<string, AnyRegularField>> | SharedSlice<...>, unknown>'
this is the type that is supposed to be having an issue.
import {
ImageField,
KeyTextField,
LinkField,
RichTextField,
Slice,
} from "@prismicio/types";
type CarouselItem = {
title: RichTextField;
text: RichTextField;
image: ImageField;
ctaText: KeyTextField;
ctaLink: LinkField;
};
export type CarouselSlice = Slice<"carousel", never, CarouselItem>;
I have a second question, unrelated to this problem.
Do i need to check in the slice-simulator.tsx in git?
If so what should happen with this page in production.