Skip to content

Commit 2113e9d

Browse files
committed
fix: typescript requirement on __refreshIntervalInMS
1 parent d05a8b4 commit 2113e9d

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

.changeset/rich-emus-visit.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@frigade/js": patch
3+
"@frigade/react": patch
4+
---
5+
6+
Fixes a typescript issue with a required field for `__refreshIntervalInMS`

packages/js-api/src/core/frigade.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
DEFAULT_REFRESH_INTERVAL_IN_MS,
23
FlowChangeEvent,
34
FlowChangeEventHandler,
45
FlowStateDTO,
@@ -83,7 +84,7 @@ export class Frigade extends Fetchable {
8384
this.queuedRefresh = false
8485
}
8586
this.refreshTimeout = null
86-
}, this.getGlobalState().config.__refreshIntervalInMS)
87+
}, this.getGlobalState().config.__refreshIntervalInMS ?? DEFAULT_REFRESH_INTERVAL_IN_MS)
8788
}
8889

8990
constructor(apiKey: string, config?: FrigadeConfig) {

packages/js-api/src/core/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { Flow } from './flow'
22

3+
export const DEFAULT_REFRESH_INTERVAL_IN_MS = 100
4+
35
export enum TriggerType {
46
MANUAL = 'MANUAL',
57
AUTOMATIC = 'AUTOMATIC',
@@ -341,7 +343,7 @@ export interface FrigadeConfig {
341343
/**
342344
* @ignore Internal use only.
343345
*/
344-
__refreshIntervalInMS: number
346+
__refreshIntervalInMS?: number
345347
}
346348

347349
export interface StatefulStep {

packages/js-api/src/shared/fetchable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { generateGuestId, getEmptyResponse, getHeaders, gracefulFetch } from './utils'
2-
import { FrigadeConfig } from '../core/types'
2+
import { DEFAULT_REFRESH_INTERVAL_IN_MS, FrigadeConfig } from '../core/types'
33
import { frigadeGlobalState, FrigadeGlobalState, getGlobalStateKey } from './state'
44

55
export class Fetchable {
@@ -9,7 +9,7 @@ export class Fetchable {
99
userId: generateGuestId(),
1010
__instanceId: Math.random().toString(12).substring(4),
1111
generateGuestId: true,
12-
__refreshIntervalInMS: 100,
12+
__refreshIntervalInMS: DEFAULT_REFRESH_INTERVAL_IN_MS,
1313
}
1414

1515
constructor(config: FrigadeConfig) {

0 commit comments

Comments
 (0)