diff --git a/.changeset/kind-zoos-call.md b/.changeset/kind-zoos-call.md new file mode 100644 index 000000000..4dba7a033 --- /dev/null +++ b/.changeset/kind-zoos-call.md @@ -0,0 +1,5 @@ +--- +'@segment/analytics-next': patch +--- + +Do not expose jquery / zepto as ambient globals. Add dom.iterable lib to typescript. diff --git a/packages/browser/qa/__tests__/destinations.test.ts b/packages/browser/qa/__tests__/destinations.test.ts index 9d7dd35ad..2836152d1 100644 --- a/packages/browser/qa/__tests__/destinations.test.ts +++ b/packages/browser/qa/__tests__/destinations.test.ts @@ -14,11 +14,7 @@ let destinations = Object.keys(samples) if (process.env.DESTINATION) { destinations = [process.env.DESTINATION] } -declare global { - interface URLSearchParams { - entries(): [string, string][] - } -} + jest.retryTimes(10) describe('Destination Tests', () => { diff --git a/packages/browser/src/core/auto-track.ts b/packages/browser/src/core/auto-track.ts index a045e5fd6..0a195f608 100644 --- a/packages/browser/src/core/auto-track.ts +++ b/packages/browser/src/core/auto-track.ts @@ -2,15 +2,6 @@ import { Analytics } from './analytics' import { EventProperties, Options } from './events' import { pTimeout } from './callback' -declare global { - interface Window { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - jQuery: any - // eslint-disable-next-line @typescript-eslint/no-explicit-any - Zepto: any - } -} - // Check if a user is opening the link in a new tab function userNewTab(event: Event): boolean { const typedEvent = event as Event & { @@ -145,7 +136,8 @@ export function form( // Support the events happening through jQuery or Zepto instead of through // the normal DOM API, because `el.submit` doesn't bubble up events... - const $ = window.jQuery || window.Zepto + + const $ = (window as any).jQuery || (window as any).Zepto if ($) { $(el).submit(handler) } else { diff --git a/packages/browser/tsconfig.json b/packages/browser/tsconfig.json index cde8c0ef7..14e0c3e37 100644 --- a/packages/browser/tsconfig.json +++ b/packages/browser/tsconfig.json @@ -7,7 +7,7 @@ "importHelpers": true, "resolveJsonModule": true, "sourceMap": true, - "lib": ["es2020", "DOM"], + "lib": ["es2020", "DOM", "DOM.Iterable"], "baseUrl": "./src", "paths": { "@/*": ["./*"]