diff --git a/types/react-tracking/index.d.ts b/types/react-tracking/index.d.ts index 933d9eb0aab24c..9780add83d83d5 100644 --- a/types/react-tracking/index.d.ts +++ b/types/react-tracking/index.d.ts @@ -51,7 +51,7 @@ export interface Options { process?(ownTrackingData: T): T | Falsy; } -export type TrackingInfo = T | ((props: P, state: S, args: any[any]) => T); +export type TrackingInfo = T | ((props: P, state: S, args: any[any]) => T | Falsy); // Duplicated from ES6 lib to remove the `void` typing, otherwise `track` can’t be used as a HOC function that passes // through a JSX component that be used without casting. diff --git a/types/react-tracking/test/react-tracking-with-types-tests.tsx b/types/react-tracking/test/react-tracking-with-types-tests.tsx index f84c6de6b50bbf..e58b29ccbfa1a4 100644 --- a/types/react-tracking/test/react-tracking-with-types-tests.tsx +++ b/types/react-tracking/test/react-tracking-with-types-tests.tsx @@ -39,6 +39,11 @@ const track: Track = _track; ) class ClassPage extends React.Component { @track({ event: 'Clicked' }) + @track((_props, _state, [e]: [React.MouseEvent]) => { + if (e.ctrlKey) { + return { event: 'Click + ctrl key' }; + } + }) handleClick() { // ... other stuff } diff --git a/types/react-tracking/test/react-tracking-without-types-tests.tsx b/types/react-tracking/test/react-tracking-without-types-tests.tsx index 7ffe01bb2a3d9e..44e0a02632d92e 100644 --- a/types/react-tracking/test/react-tracking-without-types-tests.tsx +++ b/types/react-tracking/test/react-tracking-without-types-tests.tsx @@ -13,6 +13,11 @@ function customEventReporter(data: { page?: string }) {} ) class ClassPage extends React.Component { @track({ event: 'Clicked' }) + @track((_props, _state, [e]) => { + if (e.ctrlKey) { + return { event: 'Click + ctrl key' }; + } + }) handleClick() { // ... other stuff }