sinonjs / fake-timers

Fake setTimeout and friends (collectively known as "timers"). Useful in your JavaScript tests. Extracted from Sinon.JS
BSD 3-Clause "New" or "Revised" License
797 stars 104 forks source link

[Version 7.1.0] Typescript compilation error #387

Closed lagonnebula closed 3 years ago

lagonnebula commented 3 years ago

Hello,

What did you expect to happen? To be able to compile with tsc What actually happens When i try to compile the project with fake-timers, i got a compilation error :

node_modules/@sinonjs/fake-timers/types/fake-timers-src.d.ts:11:28 - error TS2304: Cannot find name 'queueMicrotask'.
       queueMicrotask: typeof queueMicrotask;
fatso83 commented 3 years ago

Hi, this is correct, as this project has no such API.

Feel free to submit a feature request for this: spec.

P.S. You will have a much higher chance of seeing that feature request filled if you just do it yourself :)

fatso83 commented 3 years ago

Hi, I never got a reply to this, but it turns out I was wrong. I just searched the code and found it present - just undocumented (only in JSDoc). See for instance discussion in #233.

The problem is somehow related to the typescript definitions we generated, so you might have better luck installing sinonjs/fake-timers@6 and using the DT @types. We just decided to drop them and leave this to DT the community again for v8 ...

So there is two problems here:

  1. When the feature was added, no docs were added.
  2. The definitions are missing.

The DT types have exposed them in their types: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/sinonjs__fake-timers/index.d.ts#L281

Given that we will not be fixing our own types, I will keep this closed, but open a new feature for improved docs.