From 3817461fd8d9c686f9224d9d61cff037eb50f593 Mon Sep 17 00:00:00 2001 From: fent Date: Thu, 17 Oct 2019 17:20:43 -0400 Subject: [PATCH] Update typings for `track_forms` and `track_links` on mixpanel package (#39192) * Fix types for `track_forms` and `track_links` * semi * update this other mixpanel package too * fix lint warnings --- types/mixpanel-browser/index.d.ts | 6 ++++-- types/mixpanel-browser/tsconfig.json | 3 ++- types/mixpanel/index.d.ts | 6 ++++-- types/mixpanel/tsconfig.json | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/types/mixpanel-browser/index.d.ts b/types/mixpanel-browser/index.d.ts index a102077f8e..76a56a64c2 100644 --- a/types/mixpanel-browser/index.d.ts +++ b/types/mixpanel-browser/index.d.ts @@ -9,6 +9,8 @@ export type Persistence = 'cookie' | 'localStorage'; export type PushItem = Array; +export type Query = string | Element | Element[]; + export interface Dict {[key: string]: any; } export interface XhrHeadersDef {[header: string]: any; } @@ -123,7 +125,7 @@ export function reset(): void; export function set_config(config: Partial): void; export function time_event(event_name: string): void; export function track(event_name: string, properties?: Dict, callback?: () => void): void; -export function track_forms(query: string, event_name: string, properties?: Dict | (() => void)): void; -export function track_links(query: string, event_name: string, properties?: Dict | (() => void)): void; +export function track_forms(query: Query, event_name: string, properties?: Dict | (() => void)): void; +export function track_links(query: Query, event_name: string, properties?: Dict | (() => void)): void; export function unregister(property: string): void; export const people: People; diff --git a/types/mixpanel-browser/tsconfig.json b/types/mixpanel-browser/tsconfig.json index da5a025e50..cc1f26e233 100644 --- a/types/mixpanel-browser/tsconfig.json +++ b/types/mixpanel-browser/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, diff --git a/types/mixpanel/index.d.ts b/types/mixpanel/index.d.ts index 901e3a033a..5666e63aa3 100644 --- a/types/mixpanel/index.d.ts +++ b/types/mixpanel/index.d.ts @@ -97,7 +97,7 @@ interface Mixpanel { * @param eventName The name of the event to track * @param properties A properties object or function that returns a dictionary of properties when passed a DOMElement */ - track_links(querySelector: string, eventName: string, properties?: { [index: string]: any }): void; + track_links(querySelector: Mixpanel.Query, eventName: string, properties?: { [index: string]: any }): void; /** * Track form submissions. Selector must be a valid query. @@ -125,7 +125,7 @@ interface Mixpanel { * @param eventName The name of the event to track * @param properties This can be a set of properties, or a function that returns a set of properties after being passed a DOMElement */ - track_forms(querySelector: string, eventName: string, properties?: { [index: string]: any }): void; + track_forms(querySelector: Mixpanel.Query, eventName: string, properties?: { [index: string]: any }): void; /** * Time an event by including the time between this call and a @@ -625,6 +625,8 @@ declare namespace Mixpanel { */ property_blacklist?: string[]; } + + type Query = string | Element | Element[]; } declare var mixpanel: Mixpanel; diff --git a/types/mixpanel/tsconfig.json b/types/mixpanel/tsconfig.json index f5cbbce2f5..09f578d46c 100644 --- a/types/mixpanel/tsconfig.json +++ b/types/mixpanel/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true,