-
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TypeScript definition to CommonJS compatible export (#26)
- Loading branch information
1 parent
c6c7145
commit 27ce0b6
Showing
4 changed files
with
32 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {expectType} from 'tsd-check'; | ||
import copyTextToClipboard from '.'; | ||
import {expectType} from 'tsd'; | ||
import copyTextToClipboard = require('.'); | ||
|
||
expectType<boolean>(copyTextToClipboard('🦄🌈')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters