Skip to content

Formatter nextFormatter arg type issue #232

@dobesv

Description

@dobesv

Hi,

The Formatter type is defined as follows:

export type Formatter = (
  value: number,
  unit: Unit,
  suffix: Suffix,
  epochMilliseconds: number,
  nextFormatter: Formatter,
  now: () => number,
) => React.ReactNode

Note how the nextFormatter and now parameters are required arguments to Formatter and nextFormatter is declared as a Formatter.

According to the docs and the code, nextFormatter actually takes all the options as optional and will use the prior values if none is provided (or undefined). So the type should be something like:

export type NextFormatter = (
  value?: number,
  unit?: Unit,
  suffix?: Suffix,
  epochMilliseconds?: number,
  nextFormatter?: Formatter,
  now?: () => number,
) => React.ReactNode;

export type Formatter = (
  value: number,
  unit: Unit,
  suffix: Suffix,
  epochMilliseconds: number,
  nextFormatter: NextFormatter,
  now: () => number,
) => React.ReactNode;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions