Skip to content

Improve typing of the component API #613

@vscav

Description

@vscav

Our official documentation refers to a number type for the value argument (see docs). However, we can in fact support both string and number (and that's what we defined when migrating to TypeScript and helped us figure out the issue - see PR). Plus, the documentation also mentions that the value should be updated using the update function argument, which for now only returns a string.

It seems we have a wobbly API for our component, as it requires us to parse the value returned by the update function before using it to set our new value.

A suggestion could be the following:

interface AmountInputArgs {
  ...
- update: (value: string) => void;
- value: number | string;
+ update: (value: number) => void;
+ value: number;
}

Note that if the suggestion is accepted and implemented, it will be a breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions