diff --git a/.changeset/fix-create-projection-seed-inference.md b/.changeset/fix-create-projection-seed-inference.md new file mode 100644 index 000000000..2b97fdca4 --- /dev/null +++ b/.changeset/fix-create-projection-seed-inference.md @@ -0,0 +1,6 @@ +--- +"@solidjs/signals": patch +"solid-js": patch +--- + +Fix `createProjection` seed typing so readonly store seeds do not override inference from the projection function return type. diff --git a/packages/solid-signals/src/store/projection.ts b/packages/solid-signals/src/store/projection.ts index 3efd2c3a2..3a6d67edb 100644 --- a/packages/solid-signals/src/store/projection.ts +++ b/packages/solid-signals/src/store/projection.ts @@ -17,6 +17,7 @@ import { STORE_WRAP, storeSetter, storeTraps, + type NoFn, type ProjectionOptions, type Store } from "./store.js"; @@ -107,7 +108,7 @@ export function createProjectionInternal( */ export function createProjection( fn: (draft: T) => void | T | Promise | AsyncIterable, - seed: Partial, + seed: NoFn | Store>, options?: ProjectionOptions ): Refreshable> { return createProjectionInternal(fn, seed, options).store; diff --git a/packages/solid/src/client/hydration.ts b/packages/solid/src/client/hydration.ts index 9acb5ac27..1c33ca4cb 100644 --- a/packages/solid/src/client/hydration.ts +++ b/packages/solid/src/client/hydration.ts @@ -1017,7 +1017,7 @@ export const createOptimistic: { */ export const createProjection: ( fn: (draft: T) => void | T | Promise | AsyncIterable, - initialValue: T, + initialValue: NoFn | Store>, options?: ProjectionOptions ) => Refreshable> = ((...args: any[]) => (_createProjection || coreProjection)(...args)) as any;