diff --git a/types/d3-dispatch/d3-dispatch-tests.ts b/types/d3-dispatch/d3-dispatch-tests.ts index 4e8d2cfb31..a5b3110c5c 100644 --- a/types/d3-dispatch/d3-dispatch-tests.ts +++ b/types/d3-dispatch/d3-dispatch-tests.ts @@ -15,7 +15,12 @@ interface Datum { b: string; } +interface ContextObject { + about: string; +} + let dispatch: d3Dispatch.Dispatch; +let dispatch2: d3Dispatch.Dispatch; let callback: (this: HTMLElement, ...args: any[]) => void; let callbackOrUndef: ((this: HTMLElement, ...args: any[]) => void) | undefined; let undef: undefined; @@ -24,6 +29,7 @@ let undef: undefined; // create new dispatch object dispatch = d3Dispatch.dispatch('foo', 'bar'); +dispatch2 = d3Dispatch.dispatch('start', 'end'); function cbFn(this: HTMLElement, d: Datum, i: number) { console.log(this.baseURI ? this.baseURI : 'nada'); @@ -50,6 +56,8 @@ dispatch.call('foo'); dispatch.call('foo', document.body); dispatch.call('foo', document.body, { a: 3, b: 'test' }, 1); +dispatch2.call('start', {about: 'I am a context object'}, 'I am an argument'); + dispatch.apply('bar'); dispatch.apply('bar', document.body); dispatch.apply('bar', document.body, [{ a: 3, b: 'test' }, 1]); diff --git a/types/d3-dispatch/index.d.ts b/types/d3-dispatch/index.d.ts index 3e5b511646..5d6c9adf73 100644 --- a/types/d3-dispatch/index.d.ts +++ b/types/d3-dispatch/index.d.ts @@ -8,7 +8,7 @@ // Last module patch version validated against: 1.0.3 -export interface Dispatch { +export interface Dispatch { /** * Like `function.apply`, invokes each registered callback for the specified type, * passing the callback the specified arguments, with `that` as the `this` context. @@ -71,4 +71,4 @@ export interface Dispatch { * @param types The event types. * @throws "illegal type" on empty string or duplicated event types. */ -export function dispatch(...types: string[]): Dispatch; +export function dispatch(...types: string[]): Dispatch;