Skip to content

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

Open
@webJose

Description

@webJose

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions