faker icon indicating copy to clipboard operation
faker copied to clipboard

Faker.date generates ts error when passed into faker.unique

Open ollebergkvist opened this issue 3 years ago • 1 comments

Pre-Checks

Describe the bug

Faker.date and it's children methods can't be used with unique method.

Generates the following TS error:

Argument of type '(years?: number, refDate?: string | number | Date) => Date' is not assignable to parameter of type '(...parameters: any[]) => RecordKey'.
  Type 'Date' is not assignable to type 'RecordKey'.ts(2345)

Minimal reproduction code

const date = faker.unique(faker.date.past)

Additional Context

No response

Environment Info

System:
    OS: macOS 12.5
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 1.48 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.asdf/installs/nodejs/16.16.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 8.11.0 - ~/.asdf/plugins/nodejs/shims/npm
  Browsers:
    Chrome: 104.0.5112.79
    Firefox: 103.0.2
    Safari: 15.6

Which module system do you use?

  • [ ] CJS
  • [X] ESM

Used Package Manager

yarn

ollebergkvist avatar Aug 11 '22 19:08 ollebergkvist

I can reproduce the error locally. I'm not sure whether the bug can be fixed in a non breaking way.

ST-DDT avatar Aug 11 '22 22:08 ST-DDT

This requires breaking changes because the current api takes a Record to store the values. We will change the unique store to be either a Set<T> or an T[] or add(T) => boolean.

ST-DDT avatar Sep 29 '22 16:09 ST-DDT

Team decision: we will not work on this anymore

  • #1785

Shinigami92 avatar Jan 27 '23 08:01 Shinigami92