From b93be2f7cfaf0cfef3a768a441de7b8cc9403e8e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 24 Dec 2016 03:09:18 -0500 Subject: [PATCH 1/4] Fixed up 'clipboard' to be a UMD-style module. --- clipboard/index.d.ts | 100 +++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/clipboard/index.d.ts b/clipboard/index.d.ts index 0757eb1208..7697bed400 100644 --- a/clipboard/index.d.ts +++ b/clipboard/index.d.ts @@ -3,56 +3,56 @@ // Definitions by: Andrei Kurosh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module 'clipboard' { - class Clipboard { - constructor(selector: (string | Element | NodeListOf), options?: Clipboard.Options); +declare class Clipboard { + constructor(selector: (string | Element | NodeListOf), options?: Clipboard.Options); - /** - * Subscribes to events that indicate the result of a copy/cut operation. - * @param type {String} Event type ('success' or 'error'). - * @param handler Callback function. - */ - on(type: "success", handler: (e: Clipboard.Event) => void): this; - on(type: "error", handler: (e: Clipboard.Event) => void): this; - on(type: string, handler: (e: Clipboard.Event) => void): this; + /** + * Subscribes to events that indicate the result of a copy/cut operation. + * @param type {string} Event type ('success' or 'error'). + * @param handler Callback function. + */ + on(type: "success", handler: (e: Clipboard.Event) => void): this; + on(type: "error", handler: (e: Clipboard.Event) => void): this; + on(type: string, handler: (e: Clipboard.Event) => void): this; - /** - * Clears all event bindings. - */ - destroy(): void; - } - - namespace Clipboard { - interface Options { - /** - * Overwrites default command ('cut' or 'copy'). - * @param {Element} elem Current element - * @returns {String} Only 'cut' or 'copy'. - */ - action?: (elem: Element) => string; - - /** - * Overwrites default target input element. - * @param {Element} elem Current element - * @returns {Element} element to use. - */ - target?: (elem: Element) => Element; - - /** - * Returns the explicit text to copy. - * @param {Element} elem Current element - * @returns {String} Text to be copied. - */ - text?: (elem: Element) => string; - } - - interface Event { - action: string; - text: string; - trigger: Element; - clearSelection(): void; - } - } - - export = Clipboard; + /** + * Clears all event bindings. + */ + destroy(): void; } + +declare namespace Clipboard { + interface Options { + /** + * Overwrites default command ('cut' or 'copy'). + * @param {Element} elem Current element + * @returns {String} Only 'cut' or 'copy'. + */ + action?: (elem: Element) => string; + + /** + * Overwrites default target input element. + * @param {Element} elem Current element + * @returns {Element} element to use. + */ + target?: (elem: Element) => Element; + + /** + * Returns the explicit text to copy. + * @param {Element} elem Current element + * @returns {String} Text to be copied. + */ + text?: (elem: Element) => string; + } + + interface Event { + action: string; + text: string; + trigger: Element; + clearSelection(): void; + } +} + +export = Clipboard; + +export as namespace Clipboard; \ No newline at end of file From cc1c095b1f60a0b7b7f3fce390c5f73ba906aaac Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 24 Dec 2016 03:15:21 -0500 Subject: [PATCH 2/4] Removed patch version from 'clipboard'. --- clipboard/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clipboard/index.d.ts b/clipboard/index.d.ts index 7697bed400..f6b2f747d6 100644 --- a/clipboard/index.d.ts +++ b/clipboard/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for clipboard.js 1.5.9 +// Type definitions for clipboard.js 1.5 // Project: https://github.com/zenorocha/clipboard.js // Definitions by: Andrei Kurosh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 31972f078c7f39a285b1915ec4554479de0684b7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 24 Dec 2016 03:15:30 -0500 Subject: [PATCH 3/4] Added linting for 'clipboard'. --- clipboard/tslint.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 clipboard/tslint.json diff --git a/clipboard/tslint.json b/clipboard/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/clipboard/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 2d78b6c3b18025e63a71cdf57be00230f6ff72aa Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 24 Dec 2016 13:31:54 -0500 Subject: [PATCH 4/4] Squashed overloads for 'on' in 'clipboard'. Technically, Clipboard should extend the emitter class from 'tiny-emitter'. --- clipboard/index.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clipboard/index.d.ts b/clipboard/index.d.ts index f6b2f747d6..ec03d9bee5 100644 --- a/clipboard/index.d.ts +++ b/clipboard/index.d.ts @@ -8,12 +8,11 @@ declare class Clipboard { /** * Subscribes to events that indicate the result of a copy/cut operation. - * @param type {string} Event type ('success' or 'error'). + * @param type {"success" | "error"} Event type ('success' or 'error'). * @param handler Callback function. */ - on(type: "success", handler: (e: Clipboard.Event) => void): this; - on(type: "error", handler: (e: Clipboard.Event) => void): this; - on(type: string, handler: (e: Clipboard.Event) => void): this; + on(type: "success" | "error", handler: (e: Clipboard.Event) => void): this; + on(type: string, handler: (...args: any[]) => void): this; /** * Clears all event bindings.