From 46a8f1d8e0f2f779bc09395f02be1d0b71587482 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Mon, 15 Feb 2016 10:04:45 -0800 Subject: [PATCH] Annotate Clipboard module Reviewed By: svcscm Differential Revision: D2866837 fb-gh-sync-id: 0f7da139e1296aec6a518d52056a6d0a1b9c07ca shipit-source-id: 0f7da139e1296aec6a518d52056a6d0a1b9c07ca --- Libraries/Components/Clipboard/Clipboard.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Libraries/Components/Clipboard/Clipboard.js b/Libraries/Components/Clipboard/Clipboard.js index b09bc5b2f..1a1e15723 100644 --- a/Libraries/Components/Clipboard/Clipboard.js +++ b/Libraries/Components/Clipboard/Clipboard.js @@ -7,10 +7,12 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule Clipboard + * @flow */ 'use strict'; -var Clipboard = require('NativeModules').Clipboard; +const Clipboard = require('NativeModules').Clipboard; +const deprecatedCallback = require('deprecatedCallback'); /** * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android @@ -24,14 +26,13 @@ module.exports = { * } * ``` */ - getString() { - if (arguments.length > 0) { - let callback = arguments[0]; - console.warn('Clipboard.getString(callback) is deprecated. Use the returned Promise instead'); - Clipboard.getString().then(callback); - return; - } - return Clipboard.getString(); + getString(): Promise { + return deprecatedCallback( + Clipboard.getString(), + Array.prototype.slice.call(arguments), + 'success-first', + 'Clipboard.getString(callback) is deprecated. Use the returned Promise instead' + ); }, /** * Set content of string type. You can use following code to set clipboard content @@ -42,7 +43,7 @@ module.exports = { * ``` * @param the content to be stored in the clipboard. */ - setString(content) { + setString(content: string) { Clipboard.setString(content); } };