Skip to content

Commit

Permalink
fix: avoid loading types node (#301)
Browse files Browse the repository at this point in the history
* fix: avoid loading types node

* fix: revert appStateChangeHandler type change
  • Loading branch information
liuyang1520 authored Jan 10, 2023
1 parent bb021b7 commit 1141807
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/analytics-core/src/plugins/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Destination implements DestinationPlugin {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
config: Config;
scheduled: ReturnType<typeof setTimeout> | null = null;
private scheduled: ReturnType<typeof setTimeout> | null = null;
queue: Context[] = [];

async setup(config: Config): Promise<undefined> {
Expand Down
9 changes: 6 additions & 3 deletions packages/analytics-core/test/plugins/destination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ describe('destination', () => {

test('should schedule a flush', async () => {
const destination = new Destination();
destination.scheduled = null;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(destination as any).scheduled = null;
destination.queue = [
{
event: { event_type: 'event_type' },
Expand All @@ -122,7 +123,8 @@ describe('destination', () => {
const flush = jest
.spyOn(destination, 'flush')
.mockImplementationOnce(() => {
destination.scheduled = null;
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(destination as any).scheduled = null;
return Promise.resolve(undefined);
})
.mockReturnValueOnce(Promise.resolve(undefined));
Expand All @@ -138,7 +140,8 @@ describe('destination', () => {

test('should not schedule if one is already in progress', () => {
const destination = new Destination();
destination.scheduled = setTimeout(jest.fn, 0);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(destination as any).scheduled = setTimeout(jest.fn, 0);
const flush = jest.spyOn(destination, 'flush').mockReturnValueOnce(Promise.resolve(undefined));
destination.schedule(0);
expect(flush).toHaveBeenCalledTimes(0);
Expand Down

0 comments on commit 1141807

Please sign in to comment.