Skip to content

Commit a7bcc4c

Browse files
committed
fix: add IMethods interface for use in time module
1 parent 104c375 commit a7bcc4c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
99

1010
## [Unreleased]
1111
### Added
12-
- `IPublishConfig` interface for use in return type of `makePublishConfig` instead of explicit `any` ([#1648](https://github.com/cucumber/cucumber-js/pull/2106))
12+
- `IMethods` interface for use in `getTimestamp`, `durationBetweenTimestamps`, and `wrapPromiseWithTimeout` functions and `methods` in `time` module instead of explicit `any` ([#2111](https://github.com/cucumber/cucumber-js/pull/2111))
13+
14+
### Added
15+
- `IPublishConfig` interface for use in return type of `makePublishConfig` instead of explicit `any` ([#2106](https://github.com/cucumber/cucumber-js/pull/2106))
1316

1417
## [8.5.1] - 2022-07-28
1518
### Fixed

src/time.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { performance } from 'perf_hooks'
22
import * as messages from '@cucumber/messages'
3+
import { FakeClock, GlobalTimers, TimerId } from '@sinonjs/fake-timers'
34

45
let previousTimestamp: number
56

6-
const methods: any = {
7+
interface IMethods extends GlobalTimers<TimerId> {
8+
beginTiming: () => void
9+
endTiming: () => number
10+
performance: FakeClock<TimerId>['performance']
11+
}
12+
13+
const methods: Partial<IMethods> = {
714
beginTiming() {
815
previousTimestamp = getTimestamp()
916
},
@@ -44,7 +51,7 @@ export async function wrapPromiseWithTimeout<T>(
4451
timeoutInMilliseconds: number,
4552
timeoutMessage: string = ''
4653
): Promise<T> {
47-
let timeoutId: NodeJS.Timeout
54+
let timeoutId: TimerId
4855
if (timeoutMessage === '') {
4956
timeoutMessage = `Action did not complete within ${timeoutInMilliseconds} milliseconds`
5057
}

0 commit comments

Comments
 (0)