Skip to content

Fix createResource initial value inference#2696

Merged
ryansolid merged 2 commits into
solidjs:mainfrom
brenelz:fix-resource-initial-value-inference
May 15, 2026
Merged

Fix createResource initial value inference#2696
ryansolid merged 2 commits into
solidjs:mainfrom
brenelz:fix-resource-initial-value-inference

Conversation

@brenelz
Copy link
Copy Markdown
Contributor

@brenelz brenelz commented May 8, 2026

Used AI to change the types for createResource to close #2676

Not 100% sure how well the tests cover type regressions but the new test passes

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 8, 2026

🦋 Changeset detected

Latest commit: 4b1919a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
solid-js Patch
test-integration Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

*/
export function createResource<T, R = unknown>(
fetcher: ResourceFetcher<true, T, R>,
options: InitializedResourceOptions<NoInfer<T>, true>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the problem be resolved by just removing the NoInfer of the T in the InitializedResourceOptions here? In that way, what goes on inside there can contribute to the type T. This would be cleaner than the parallel I mechanism if it works.

Update the initial value inference for createResource.
@ryansolid ryansolid merged commit a22dd29 into solidjs:main May 15, 2026
1 check passed
@ryansolid
Copy link
Copy Markdown
Member

Thanks. I also tried the NoInfer approach but it had holes. Atleast what I tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createResource doesn't infer type from initialValue

3 participants