diff --git a/types/framebus/framebus-tests.ts b/types/framebus/framebus-tests.ts index b19675692e..571f9488b1 100644 --- a/types/framebus/framebus-tests.ts +++ b/types/framebus/framebus-tests.ts @@ -1,5 +1,6 @@ import * as framebus from "framebus"; +// tslint:disable-next-line no-unnecessary-type-assertion (in older TS versions `window.open` is not nullable) const popup = window.open('https://example.com')!; framebus.include(popup); framebus.emit('hello popup and friends!'); diff --git a/types/framebus/index.d.ts b/types/framebus/index.d.ts index 25286a495b..4879dfceef 100644 --- a/types/framebus/index.d.ts +++ b/types/framebus/index.d.ts @@ -21,19 +21,16 @@ export interface FrameBus { unsub(event: string, fn: (...args: any[]) => any): boolean; off(event: string, fn: (...args: any[]) => any): boolean; } -/*~ If this module has methods, declare them as functions like so. - */ + /** * let popup = window.open('https://example.com'); * framebus.include(popup); * framebus.emit('hello popup and friends!'); - * @param popup */ export function include(popup: Window): boolean; /** * framebus.target('https://example.com').on('my cool event', function () {}); * // will ignore all incoming 'my cool event' NOT from 'https://example.com' - * @param origin {string} */ export function target(origin: string): FrameBus; @@ -42,64 +39,64 @@ export function target(origin: string): FrameBus; * console.log('Got back %s as a reply!', data) * } * framebus.publish('Marco!', callback, 'http://listener.example.com'); - * @param event {string} The name of the event - * @param args {...any[]} The data to give to subscribers - * // @param last{callback(data)} Give subscribers a function for easy, direct replies + * @param event The name of the event + * @param args The data to give to subscribers + * @param last Give subscribers a function for easy, direct replies */ export function publish(event: string, ...args: any[]/* fn: callback(data:)*/): boolean; /** * publish = pub = trigger = emit * framebus.publish('Marco!', callback, 'http://listener.example.com'); - * @param event {string} The name of the event - * @param args {...any[]} The data to give to subscribers - * // @param last{callback(data)} Give subscribers a function for easy, direct replies + * @param event The name of the event + * @param args The data to give to subscribers + * @param last Give subscribers a function for easy, direct replies */ export function pub(event: string, ...args: any[]): boolean; /** * publish = pub = trigger = emit - * @param event {string} The name of the event - * @param args {...any[]} The data to give to subscribers - * // @param last{callback(data)} Give subscribers a function for easy, direct replies + * @param event The name of the event + * @param args The data to give to subscribers + * @param last Give subscribers a function for easy, direct replies */ export function trigger(event: string, ...args: any[]): boolean; /** * publish = pub = trigger = emit - * @param event {string} The name of the event - * @param args {...any[]} The data to give to subscribers - * // @param last{callback(data)} Give subscribers a function for easy, direct replies + * @param event The name of the event + * @param args The data to give to subscribers + * @param last Give subscribers a function for easy, direct replies */ export function emit(event: string, ...args: any[]): boolean; /** * **this** scope is the MessageEvent object from the underlying postMessage - * @param event {string} The name of the event - * @param fn {Callback} ([arg...] [, callback]) Event handler. Arguments are from the publish invocation + * @param event The name of the event + * @param fn ([arg...] [, callback]) Event handler. Arguments are from the publish invocation */ export function subscribe(event: string, fn: (...args: any[]) => any): boolean; /** * **this** scope is the MessageEvent object from the underlying postMessage - * @param event {string} The name of the event - * @param fn {Callback} ([arg...] [, callback]) Event handler. Arguments are from the publish invocation + * @param event The name of the event + * @param fn ([arg...] [, callback]) Event handler. Arguments are from the publish invocation */ export function sub(event: string, fn: (...args: any[]) => any): boolean; /** * **this** scope is the MessageEvent object from the underlying postMessage - * @param event {string} The name of the event - * @param fn {Callback} ([arg...] [, callback]) Event handler. Arguments are from the publish invocation + * @param event The name of the event + * @param fn ([arg...] [, callback]) Event handler. Arguments are from the publish invocation */ export function on(event: string, fn: (...args: any[]) => any): boolean; /** - * @param event {string} The name of the event - * @param fn {Callback} The function that was subscribed + * @param event The name of the event + * @param fn The function that was subscribed */ export function unsubscribe(event: string, fn: (...args: any[]) => any): boolean; /** - * @param event {string} The name of the event - * @param fn {Callback} The function that was subscribed + * @param event The name of the event + * @param fn The function that was subscribed */ export function unsub(event: string, fn: (...args: any[]) => any): boolean; /** - * @param event {string} The name of the event - * @param fn {Callback} The function that was subscribed + * @param event The name of the event + * @param fn The function that was subscribed */ export function off(event: string, fn: (...args: any[]) => any): boolean;