chore: remove unnecessary Invalidator type (#12354)

* chore: fix Invalidator type

* regenerate types

* in fact you know what, this whole thing is overkill. get rid of it

* oops
pull/12361/head
Rich Harris 4 months ago committed by GitHub
parent 2789a3c0ef
commit 12579d47bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +1,5 @@
/** @import { Readable, StartStopNotifier, Subscriber, Unsubscriber, Updater, Writable } from './public' */
/** @import { Invalidator, Stores, StoresValues, SubscribeInvalidateTuple } from './private' */
/** @import { Stores, StoresValues, SubscribeInvalidateTuple } from './private' */
import { noop, run_all } from '../internal/shared/utils.js';
import { safe_not_equal } from '../internal/client/reactivity/equality.js';
import { subscribe_to_store } from './utils.js';
@ -74,7 +74,7 @@ export function writable(value, start = noop) {
/**
* @param {Subscriber<T>} run
* @param {Invalidator<T>} [invalidate]
* @param {() => void} [invalidate]
* @returns {Unsubscriber}
*/
function subscribe(run, invalidate = noop) {

@ -1,10 +1,7 @@
import { Readable, Subscriber } from './public.js';
/** Cleanup logic callback. */
type Invalidator<T> = (value?: T) => void;
/** Pair of subscriber and invalidator. */
type SubscribeInvalidateTuple<T> = [Subscriber<T>, Invalidator<T>];
type SubscribeInvalidateTuple<T> = [Subscriber<T>, () => void];
/** One or more `Readable`s. */
type Stores = Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<Readable<any>>;
@ -13,4 +10,4 @@ type Stores = Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<R
type StoresValues<T> =
T extends Readable<infer U> ? U : { [K in keyof T]: T[K] extends Readable<infer U> ? U : never };
export { Invalidator, SubscribeInvalidateTuple, Stores, StoresValues };
export { SubscribeInvalidateTuple, Stores, StoresValues };

@ -1,5 +1,3 @@
import type { Invalidator } from './private.js';
/** Callback to inform of a value updates. */
type Subscriber<T> = (value: T) => void;
@ -30,7 +28,7 @@ interface Readable<T> {
* @param run subscription callback
* @param invalidate cleanup callback
*/
subscribe(this: void, run: Subscriber<T>, invalidate?: Invalidator<T>): Unsubscriber;
subscribe(this: void, run: Subscriber<T>, invalidate?: () => void): Unsubscriber;
}
/** Writable interface for both updating and subscribing. */

@ -2075,7 +2075,7 @@ declare module 'svelte/motion' {
* @param run subscription callback
* @param invalidate cleanup callback
*/
subscribe(this: void, run: Subscriber<T>, invalidate?: Invalidator<T>): Unsubscriber;
subscribe(this: void, run: Subscriber<T>, invalidate?: () => void): Unsubscriber;
}
interface SpringOpts {
stiffness?: number;
@ -2096,8 +2096,6 @@ declare module 'svelte/motion' {
easing?: (t: number) => number;
interpolate?: (a: T, b: T) => (t: number) => T;
}
/** Cleanup logic callback. */
type Invalidator<T> = (value?: T) => void;
/**
* The spring function in Svelte creates a store whose value is animated, with a motion that simulates the behavior of a spring. This means when the value changes, instead of transitioning at a steady rate, it "bounces" like a spring would, depending on the physics parameters provided. This adds a level of realism to the transitions and can enhance the user experience.
*
@ -2221,7 +2219,7 @@ declare module 'svelte/store' {
* @param run subscription callback
* @param invalidate cleanup callback
*/
subscribe(this: void, run: Subscriber<T>, invalidate?: Invalidator<T>): Unsubscriber;
subscribe(this: void, run: Subscriber<T>, invalidate?: () => void): Unsubscriber;
}
/** Writable interface for both updating and subscribing. */
@ -2238,15 +2236,6 @@ declare module 'svelte/store' {
*/
update(this: void, updater: Updater<T>): void;
}
/** Cleanup logic callback. */
type Invalidator<T> = (value?: T) => void;
/** One or more `Readable`s. */
type Stores = Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<Readable<any>>;
/** One or more values from `Readable` stores. */
type StoresValues<T> =
T extends Readable<infer U> ? U : { [K in keyof T]: T[K] extends Readable<infer U> ? U : never };
/**
* Creates a `Readable` store that allows reading by subscription.
*
@ -2288,6 +2277,12 @@ declare module 'svelte/store' {
* https://svelte.dev/docs/svelte-store#get
* */
export function get<T>(store: Readable<T>): T;
/** One or more `Readable`s. */
type Stores = Readable<any> | [Readable<any>, ...Array<Readable<any>>] | Array<Readable<any>>;
/** One or more values from `Readable` stores. */
type StoresValues<T> =
T extends Readable<infer U> ? U : { [K in keyof T]: T[K] extends Readable<infer U> ? U : never };
export { Subscriber, Unsubscriber, Updater, StartStopNotifier, Readable, Writable };
}

Loading…
Cancel
Save