From db7290eda1a0e746c1542e012bd363ddf98b0cfe Mon Sep 17 00:00:00 2001 From: "yuichi.watanabe" Date: Mon, 4 Jul 2016 23:30:36 +0900 Subject: [PATCH] add type definitions of tinycopy --- tinycopy/tinycopy-tests.ts | 17 +++++++++++++++++ tinycopy/tinycopy.d.ts | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tinycopy/tinycopy-tests.ts create mode 100644 tinycopy/tinycopy.d.ts diff --git a/tinycopy/tinycopy-tests.ts b/tinycopy/tinycopy-tests.ts new file mode 100644 index 0000000000..f695ebf19e --- /dev/null +++ b/tinycopy/tinycopy-tests.ts @@ -0,0 +1,17 @@ +/// + +import TinyCopy from 'tinycopy'; + +TinyCopy.exec('test', (err, data) => {}); + +var trigger_1 = document.getElementById('trigger_1'); +var target_1 = document.getElementById('target'); +new TinyCopy(trigger_1, target_1) + .on('success', function(data) {}) + .on('error', function(err) {}); + +var trigger_2 = document.getElementById('trigger_2'); +var target_2 = 'test'; +new TinyCopy(trigger_2, target_2) + .on('success', function(data) {}) + .on('error', function(err) {}); diff --git a/tinycopy/tinycopy.d.ts b/tinycopy/tinycopy.d.ts new file mode 100644 index 0000000000..33b7ae217c --- /dev/null +++ b/tinycopy/tinycopy.d.ts @@ -0,0 +1,14 @@ +// Type definitions for tinycopy 2.1.2 +// Project: https://github.com/vvatanabe/tinycopy +// Definitions by: Yuichi Watanabe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "tinycopy" { + export default class TinyCopy { + constructor(trigger: Element, target: (string | Element | NodeListOf)); + on(type: "success", action: (data: string) => void): this; + on(type: "error", action: (err: Error) => void): this; + on(type: string, action: (e: (string | Error)) => void): this; + static exec(value: string, callback: (err?: Error, data?: string) => void): void; + } +}