Skip to content

Commit

Permalink
fix: adjust types for backwards compat
Browse files Browse the repository at this point in the history
  • Loading branch information
angeloashmore committed Aug 24, 2023
1 parent 865c5db commit 647ef5a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
19 changes: 9 additions & 10 deletions src/SliceZone/SliceZone.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import type * as prismic from "@prismicio/client";
import type { SvelteComponent } from "svelte";
type SliceComponents = Record<
string,
typeof SvelteComponent<{
slice: SliceLike;
slices: SliceLike[];
context: unknown;
index: number;
}>
>;
type SvelteSliceComponent = new (...args: any[]) => SvelteComponent<{
slice: SliceLike;
slices: SliceLike[];
context: unknown;
index: number;
}>;
type SliceComponents = Record<string, SvelteSliceComponent>;
/**
* The minimum required properties to represent a Prismic Slice from the
Expand Down Expand Up @@ -82,7 +81,7 @@
* The Svelte component rendered if a component mapping from the `components`
* prop cannot be found.
*/
export let defaultComponent: typeof SvelteComponent | undefined = undefined;
export let defaultComponent: SvelteSliceComponent | undefined = undefined;
</script>

<!--
Expand Down
18 changes: 10 additions & 8 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import type { RTAnyNode, RichTextNodeType } from "@prismicio/client";
import type { SvelteComponent } from "svelte";

export type SvelteRichTextSerializer = Partial<
Record<
keyof typeof RichTextNodeType,
typeof SvelteComponent<
Partial<{
node: RTAnyNode;
}>
>
>
Record<keyof typeof RichTextNodeType, SvelteRichTextComponent>
>;

type SvelteRichTextComponent = new (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...args: any[]
) => SvelteComponent<
Partial<{
node: RTAnyNode;
}>
>;

0 comments on commit 647ef5a

Please sign in to comment.