Skip to content

Commit 6c35799

Browse files
authored
consolidate global typings (#619)
1 parent 1d6c22d commit 6c35799

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

.changeset/kind-zoos-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@segment/analytics-next': patch
3+
---
4+
5+
Do not expose jquery / zepto as ambient globals. Add dom.iterable lib to typescript.

packages/browser/qa/__tests__/destinations.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ let destinations = Object.keys(samples)
1414
if (process.env.DESTINATION) {
1515
destinations = [process.env.DESTINATION]
1616
}
17-
declare global {
18-
interface URLSearchParams {
19-
entries(): [string, string][]
20-
}
21-
}
17+
2218

2319
jest.retryTimes(10)
2420
describe('Destination Tests', () => {

packages/browser/src/core/auto-track.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ import { Analytics } from './analytics'
22
import { EventProperties, Options } from './events'
33
import { pTimeout } from './callback'
44

5-
declare global {
6-
interface Window {
7-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
8-
jQuery: any
9-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10-
Zepto: any
11-
}
12-
}
13-
145
// Check if a user is opening the link in a new tab
156
function userNewTab(event: Event): boolean {
167
const typedEvent = event as Event & {
@@ -145,7 +136,8 @@ export function form(
145136

146137
// Support the events happening through jQuery or Zepto instead of through
147138
// the normal DOM API, because `el.submit` doesn't bubble up events...
148-
const $ = window.jQuery || window.Zepto
139+
140+
const $ = (window as any).jQuery || (window as any).Zepto
149141
if ($) {
150142
$(el).submit(handler)
151143
} else {

packages/browser/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"importHelpers": true,
88
"resolveJsonModule": true,
99
"sourceMap": true,
10-
"lib": ["es2020", "DOM"],
10+
"lib": ["es2020", "DOM", "DOM.Iterable"],
1111
"baseUrl": "./src",
1212
"paths": {
1313
"@/*": ["./*"]

0 commit comments

Comments
 (0)