Skip to content

Use fewer type assertions #516

@danielnixon

Description

@danielnixon

For example,

  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
  const d = new Date(value as number | string | Date);

can probably become:

const d = new Date(typeof value === "string" ? value : +value);

(courtesy of:)

    /**
     * Converts a Date object to a number.
     */
    [Symbol.toPrimitive](hint: "number"): number;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions