From 37a946705d936eeb783d8d357d9729179b9c1f3c Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Mon, 20 Apr 2020 16:22:59 +0100 Subject: [PATCH] chore: migrate `src/USKeyboardLayout` to typescript Don't think we need to expose the interface type for the keycodes so I've left it local for now. --- src/Input.js | 2 +- ...SKeyboardLayout.js => USKeyboardLayout.ts} | 28 ++++++++----------- 2 files changed, 13 insertions(+), 17 deletions(-) rename src/{USKeyboardLayout.js => USKeyboardLayout.ts} (97%) diff --git a/src/Input.js b/src/Input.js index e7d36a8d89e64..7d11f9ea66967 100644 --- a/src/Input.js +++ b/src/Input.js @@ -15,7 +15,7 @@ */ const {assert} = require('./helper'); -const keyDefinitions = require('./USKeyboardLayout'); +const {keyDefinitions} = require('./USKeyboardLayout'); /** * @typedef {Object} KeyDescription diff --git a/src/USKeyboardLayout.js b/src/USKeyboardLayout.ts similarity index 97% rename from src/USKeyboardLayout.js rename to src/USKeyboardLayout.ts index 7ac2768834867..5da20b8b11d59 100644 --- a/src/USKeyboardLayout.js +++ b/src/USKeyboardLayout.ts @@ -14,22 +14,18 @@ * limitations under the License. */ -/** - * @typedef {Object} KeyDefinition - * @property {number=} keyCode - * @property {number=} shiftKeyCode - * @property {string=} key - * @property {string=} shiftKey - * @property {string=} code - * @property {string=} text - * @property {string=} shiftText - * @property {number=} location - */ + interface KeyDefinition { + keyCode?: number; + shiftKeyCode?: number; + key?: string; + shiftKey?: string; + code?: string; + text?: string; + shiftText?: string; + location?: number; + } -/** - * @type {Object} - */ -module.exports = { +export const keyDefinitions: Readonly> = { '0': {'keyCode': 48, 'key': '0', 'code': 'Digit0'}, '1': {'keyCode': 49, 'key': '1', 'code': 'Digit1'}, '2': {'keyCode': 50, 'key': '2', 'code': 'Digit2'}, @@ -285,4 +281,4 @@ module.exports = { 'EndCall': {'keyCode': 95, 'key': 'EndCall', 'code': 'EndCall', 'location': 4}, 'VolumeDown': {'keyCode': 182, 'key': 'VolumeDown', 'code': 'VolumeDown', 'location': 4}, 'VolumeUp': {'keyCode': 183, 'key': 'VolumeUp', 'code': 'VolumeUp', 'location': 4}, -}; \ No newline at end of file +};