-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Description
Describe the bug
No overload matches this call.
Overload 1 of 4, '(fetcher: ResourceFetcher<true, StakeRecord[], unknown>, options: InitializedResourceOptions<StakeRecord[], true>): InitializedResourceReturn<...>', gave the following error.
Type '[get: Accessor<StakeRecord | undefined>, set: Setter<StakeRecord | undefined>, init: string | Promise<string> | null]' is not assignable to type '(init: StakeRecord[] | undefined) => [Accessor<StakeRecord[] | undefined>, Setter<StakeRecord[] | undefined>]'.
Type '[get: Accessor<StakeRecord[] | undefined>, set: Setter<StakeRecord | undefined>, init: string | Promise<string> | null]' provides no match for the signature '(init: StakeRecord[] | undefined): [Accessor<StakeRecord[] | undefined>, Setter<StakeRecord[] | undefined>]'.
Overload 2 of 4, '(fetcher: ResourceFetcher<true, StakeRecord[], unknown>, options?: ResourceOptions<StakeRecord[], true> | undefined): ResourceReturn<...>', gave the following error.
Type '[get: Accessor<StakeRecord | undefined>, set: Setter<StakeRecord | undefined>, init: string | Promise<string> | null]' is not assignable to type '(init: StakeRecord[] | undefined) => [Accessor<StakeRecord[] | undefined>, Setter<StakeRecord[] | undefined>]'.
Type '[get: Accessor<StakeRecord[] | undefined>, set: Setter<StakeRecord | undefined>, init: string | Promise<string> | null]' provides no match for the signature '(init: StakeRecord[] | undefined): [Accessor<StakeRecord[] | undefined>, Setter<StakeRecord[] | undefined>]'.
Overload 3 of 4, '(source: ResourceSource<Promise<StakeRecord[]>>, fetcher: ResourceFetcher<Promise<StakeRecord[]>, unknown, unknown>, options?: ResourceOptions<...> | undefined): ResourceReturn<...>', gave the following error.
Object literal may only specify known properties, and 'storage' does not exist in type 'ResourceFetcher<Promise<StakeRecord[]>, unknown, unknown>'.ts(2769)
signal.d.ts(324, 3): The expected type comes from property 'storage' which is declared here on type 'InitializedResourceOptions<StakeRecord[], true>'
Reproduction:
import { makePersisted } from '@solid-primitives/storage'
import { createResource, createSignal, ResourceFetcher } from 'solid-js'
type StakeRecord = number // or whatever other type you want
const storage = <T>() => makePersisted(createSignal<T>())
const fetchEffectiveStakes = async (): Promise<StakeRecord[]> => {
const response = await fetch(
'/stakes',
)
return await response.json() as StakeRecord[]
}
export const effectiveStakes = () =>
createResource(fetchEffectiveStakes, { storage: storage<StakeRecord[]>() }) // type error hereMinimal Reproduction Link
https://stackblitz.com/edit/github-jrdxdxx5?file=src%2Fresources.ts
Metadata
Metadata
Assignees
Labels
No labels