Skip to content

Commit

Permalink
consolidate global typings (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky authored Oct 18, 2022
1 parent 1d6c22d commit 6c35799
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-zoos-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@segment/analytics-next': patch
---

Do not expose jquery / zepto as ambient globals. Add dom.iterable lib to typescript.
6 changes: 1 addition & 5 deletions packages/browser/qa/__tests__/destinations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
12 changes: 2 additions & 10 deletions packages/browser/src/core/auto-track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 & {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"importHelpers": true,
"resolveJsonModule": true,
"sourceMap": true,
"lib": ["es2020", "DOM"],
"lib": ["es2020", "DOM", "DOM.Iterable"],
"baseUrl": "./src",
"paths": {
"@/*": ["./*"]
Expand Down

0 comments on commit 6c35799

Please sign in to comment.