Skip to content

Subtracting Date objects shows a TypeScript error, but actually works.Β #58400

Closed as not planned
@ScottHenshaw86

Description

@ScottHenshaw86

πŸ”Ž Search Terms

"Date arithmetic"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Dates

⏯ Playground Link

No response

πŸ’» Code

const a = new Date();
const b = new Date();
const c = a - b;

πŸ™ Actual behavior

TypeScript shows error: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362)

πŸ™‚ Expected behavior

No error because the operation works.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions