`makePersisted()` cannot correctly infer types under Typescript 7
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- developer-experience
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.
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
- Dominant language
- TypeScript
- Stars
- 1.6k
- Forks
- 162
- Avg merge
- 19h 40m
- Merged PRs (30d)
- 8
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.
More from solidjs-community/solid-primitives
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
solidjs-community/solid-primitives#830 · 2 comments ·
All issues in solidjs-community/solid-primitives
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·