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: enforce number type on spring and tweened #14841

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions .changeset/random-changeset-name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: enforce number type on spring and tweened
8 changes: 4 additions & 4 deletions packages/svelte/src/motion/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SpringUpdateOpts, TweenedOptions, Updater, SpringOpts } from './private
// this means both the Spring class and the Spring interface are merged into one with some things only
// existing on one side. In Svelte 6, remove the type definition and move the jsdoc onto the class in spring.js

export interface Spring<T> extends Readable<T> {
export interface Spring<T extends number> extends Readable<T> {
set(new_value: T, opts?: SpringUpdateOpts): Promise<void>;
/**
* @deprecated Only exists on the legacy `spring` store, not the `Spring` class
Expand Down Expand Up @@ -36,7 +36,7 @@ export interface Spring<T> extends Readable<T> {
* ```
* @since 5.8.0
*/
export class Spring<T> {
export class Spring<T extends number> {
constructor(value: T, options?: SpringOpts);

/**
Expand All @@ -53,7 +53,7 @@ export class Spring<T> {
* </script>
* ```
*/
static of<U>(fn: () => U, options?: SpringOpts): Spring<U>;
static of<U extends number>(fn: () => U, options?: SpringOpts): Spring<U>;

/**
* Sets `spring.target` to `value` and returns a `Promise` that resolves if and when `spring.current` catches up to it.
Expand All @@ -80,7 +80,7 @@ export class Spring<T> {
get current(): T;
}

export interface Tweened<T> extends Readable<T> {
export interface Tweened<T extends number> extends Readable<T> {
set(value: T, opts?: TweenedOptions<T>): Promise<void>;
update(updater: Updater<T>, opts?: TweenedOptions<T>): Promise<void>;
}
Expand Down
Loading
Loading