Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix writableDerived typescript signature #25

Closed
svenk opened this issue Mar 21, 2024 · 1 comment
Closed

Fix writableDerived typescript signature #25

svenk opened this issue Mar 21, 2024 · 1 comment

Comments

@svenk
Copy link

svenk commented Mar 21, 2024

The update signature in https://github.com/PixievoltNo1/svelte-writable-derived/blob/master/index.d.ts#L43 is wrong and described as Updater<T> while it should read (fn: Updater<T>) => void as in https://svelte.dev/docs/svelte-store#derived

That is, the line

export default function writableDerived<S extends Stores, T>(
    origins: S,
    derive: (values: StoresValues<S>, set: (value: T) => void, update: Updater<T>) => void,
    reflect: (reflecting: T, old: StoresValues<S>) => SetValues<S>,
    initial?: T
): Writable<T>;

should read

export function writableDerived<S extends Stores, T>(
  origins: S,
  derive: (values: StoresValues<S>, set: (value: T) => void, update: (fn: Updater<T>)=>void) => void,
  reflect: (reflecting: T, old: StoresValues<S>) => SetValues<S>,
  initial?: T
): Writable<T>;

The actual implementation is right, it is only an error in the index.t.ts resulting in TypeScript complaining about wrong types when using this signature.

@PixievoltNo1
Copy link
Owner

Fix released in version 3.1.1. Thanks for the report!

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

No branches or pull requests

2 participants