Skip to content

Commit 1fb0013

Browse files
authored
fix(Optimizely): Use any type for return value of setTimeout (#623)
Summary: Fix for Issue #622 . For the Node.js version of setTimeout, the return value isn't number, but Timeout. To allow this to typecheck regardless of whether the browser or Node.js version is used, set the type of readyTimeout to any. Test plan: Existing tests Issues: #622
1 parent 058d0db commit 1fb0013

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/optimizely-sdk/CHANGELOG.MD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Bug fixes
10+
11+
- In `Optimizely` class, use `any` type when assigning the return value of `setTimeout`. This is to allow it to type check regardless of whether it uses the browser or Node version of `setTimeout` ([PR #623](https://github.com/optimizely/javascript-sdk/pull/623)), ([Issue #622](https://github.com/optimizely/javascript-sdk/issues/622))
912

1013
## [4.4.1] - November 5, 2020
1114

packages/optimizely-sdk/lib/optimizely/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export default class Optimizely {
9595
private isOptimizelyConfigValid: boolean;
9696
private disposeOnUpdate: (() => void ) | null;
9797
private readyPromise: Promise<{ success: boolean; reason?: string }>;
98-
private readyTimeouts: { [key: string]: {readyTimeout: number; onClose:() => void} };
98+
// readyTimeout is specified as any to make this work in both browser & Node
99+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
100+
private readyTimeouts: { [key: string]: {readyTimeout: any; onClose:() => void} };
99101
private nextReadyTimeoutId: number;
100102
private clientEngine: string;
101103
private clientVersion: string;

0 commit comments

Comments
 (0)