diff --git a/index.d.ts b/index.d.ts index b33ed90..8cb1800 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,9 +1,27 @@ -/** - * Copy text to the clipboard. - * - * Must be called in response to a user gesture event, like `click` or `keyup`. - * - * @param text - The text to copy to clipboard. - * @returns Whether it succeeded to copy the text. - */ -export default function copyTextToClipboard(text: string): boolean; +declare const copyTextToClipboard: { + /** + Copy text to the clipboard. + + Must be called in response to a user gesture event, like `click` or `keyup`. + + @param text - The text to copy to clipboard. + @returns Whether it succeeded to copy the text. + + @example + ``` + import copy = require('copy-text-to-clipboard'); + + button.addEventListener('click', () => { + copy('🦄🌈'); + }); + ``` + */ + (text: string): boolean; + + // TODO: Remove this for the next major release, refactor the whole definition to: + // declare function copyTextToClipboard(text: string): boolean; + // export = copyTextToClipboard; + default: typeof copyTextToClipboard; +}; + +export = copyTextToClipboard; diff --git a/index.js b/index.js index 199d9f0..6c28057 100644 --- a/index.js +++ b/index.js @@ -42,4 +42,5 @@ const copyTextToClipboard = input => { }; module.exports = copyTextToClipboard; +// TODO: Remove this for the next major release module.exports.default = copyTextToClipboard; diff --git a/index.test-d.ts b/index.test-d.ts index d67988e..4f984d8 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,4 @@ -import {expectType} from 'tsd-check'; -import copyTextToClipboard from '.'; +import {expectType} from 'tsd'; +import copyTextToClipboard = require('.'); expectType(copyTextToClipboard('🦄🌈')); diff --git a/package.json b/package.json index e035a3b..e35e4df 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "node": ">=6" }, "scripts": { - "test": "xo && tsd-check" + "test": "xo && tsd" }, "files": [ "index.js", @@ -28,7 +28,7 @@ "modern" ], "devDependencies": { - "tsd-check": "^0.3.0", + "tsd": "^0.7.2", "xo": "^0.24.0" }, "xo": {