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

Improve Spring data typing, or improving it so it doesn't bother about unsupported data types #14851

Open
webJose opened this issue Dec 28, 2024 · 0 comments

Comments

@webJose
Copy link
Contributor

webJose commented Dec 28, 2024

Describe the problem

Issue #14840 made me suggest the following typing for the Spring class:

+ type MotionPrimitive = number | Date;
+ interface MotionRecord {
+     [x: string]: MotionPrimitive | MotionRecord | (MotionPrimitive | MotionRecord)[];
+ };

- export class Spring<T> {
+ export class Spring<T extends MotionRecord['']> {

This is because the current Spring logic throws if say, a value of type string is found in its recursive logic. But what if the throwing doesn't happen?

Describe the proposed solution

Two possible options:

  1. We improve the typing around the Spring class as proposed here.
  2. We remove the throwing part and instead the value is simply ignored (this ELSE statement).

If the second option, then type parameter T doesn't require constraining and people can pass anything as value to the spring object, but then documentation must be updated to make devs aware that only numbers or dates can be sprung.

Importance

nice to have

@webJose webJose changed the title Improve Spring and Tween's data typing, or improving it so it doesn't bother about unsupported data types Improve Spring data typing, or improving it so it doesn't bother about unsupported data types Dec 28, 2024
webJose added a commit to webJose/svelte that referenced this issue Dec 29, 2024
Closes Improve Spring data typing, or improving it so it doesn't bother about unsupported data types sveltejs#14851
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

1 participant