Open
Description
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:
- We improve the typing around the
Spring
class as proposed here. - 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