solidjs-community / solidjs-community/solid-primitives
`makePersisted()` cannot correctly infer types under Typescript 7
Open
Nobody has claimed this yet.
bug
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 162
- Avg merge
- 19h 40m
- Merged PRs (30d)
- 8
Description
Describe the bug
const [thing, setThing] = makePersisted(createSignal("hello"), {
name: "thing",
storage: localStorage,
});
> tsc --noEmit
src/App.tsx(8,43): error TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'Signal<string>' is not assignable to parameter of type 'Signal<unknown> | [unknown, SetStoreFunction<unknown>]'.
Type '[get: Accessor<string>, set: Setter<string>]' is not assignable to type 'Signal<unknown>'.
Type at position 1 in source is not compatible with type at position 1 in target.
Type 'Setter<string>' is not assignable to type 'Setter<unknown>'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
Currently, the only way to fix it seems to be to provide full, explicit types:
const [thing, setThing] = makePersisted<string, Signal<string>>(createSignal("hello"), {
name: "thing",
storage: localStorage,
});
Minimal Reproduction Link
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the makePersisted entry point and reproduce the inferred-type failure from src/App.tsx using the linked StackBlitz example. Run tsc --noEmit with the createSignal("hello") call and compare it with the explicit generic version. Done means the inferred call type-checks without requiring explicit types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100