Skip to content

[bug] purity flags all usage of the date constructor, not just that relating to the current time #1582

@lukpsaxo

Description

@lukpsaxo

Describe the bug

Code that uses new Date(argument) with an argument always produces the same thing - it is pure, but it gets flagged with an error.

Reproduction

  1. switch on the purity rule
  2. use the following repro
const CONST_DATE = new Date();
export function X({ myDate } : { myDate: string }) {
   return new Date(myDate) < CONST_DATE ? <span>'one'</span> : <span>'two'</span>;
}

Expected behavior

no error if there is an argument passed to new Date

Platform and versions

windows and 3.0.0-beta.60

Stack trace


Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: ReleasedThe issue has been releasedType: BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions