Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate src/USKeyboardLayout to typescript #5695

Merged
merged 2 commits into from Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -23,7 +23,7 @@ jobs:
script:
- ls .local-chromium .local-firefox
- npm run tsc
- npm run unit
- travis_retry npm run unit
- node_js: "10.19.0"
dist: trusty
env:
Expand Down
2 changes: 1 addition & 1 deletion src/Input.js
Expand Up @@ -15,10 +15,10 @@
*/

const {assert} = require('./helper');
const keyDefinitions = require('./USKeyboardLayout');
// CDPSession is used only as a typedef
// eslint-disable-next-line no-unused-vars
const {CDPSession} = require('./Connection');
const {keyDefinitions} = require('./USKeyboardLayout');

/**
* @typedef {Object} KeyDescription
Expand Down
28 changes: 12 additions & 16 deletions src/USKeyboardLayout.js → src/USKeyboardLayout.ts
Expand Up @@ -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<string, KeyDefinition>}
*/
module.exports = {
export const keyDefinitions: Readonly<Record<string, KeyDefinition>> = {
'0': {'keyCode': 48, 'key': '0', 'code': 'Digit0'},
'1': {'keyCode': 49, 'key': '1', 'code': 'Digit1'},
'2': {'keyCode': 50, 'key': '2', 'code': 'Digit2'},
Expand Down Expand Up @@ -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},
};
};