Skip to content

Commit

Permalink
[ts] Type-check ui/ForwardInputEventHandler.js with TypeScript
Browse files Browse the repository at this point in the history
Note that extracting the globals into local variables with the
correct type, allows TypeScript to correctly check their usage.

[email protected]

Bug: chromium:1011811
Change-Id: Ia07686bc8f5a14e3e301c689a77a73adb61306ac
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2351777
Reviewed-by: Jack Franklin <[email protected]>
Commit-Queue: Simon Zünd <[email protected]>
  • Loading branch information
szuend authored and Commit Bot committed Aug 12, 2020
1 parent c5d4355 commit 716ab01
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions front_end/ui/ForwardedInputEventHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @ts-nocheck
// TODO(crbug.com/1011811): Enable TypeScript compiler checks

import * as Common from '../common/common.js'; // eslint-disable-line no-unused-vars
import * as Host from '../host/host.js';

import {Context} from './Context.js'; // eslint-disable-line no-unused-vars
import {KeyboardShortcut} from './KeyboardShortcut.js';
import {ForwardedShortcut} from './ShortcutRegistry.js';
import {ForwardedShortcut, ShortcutRegistry} from './ShortcutRegistry.js'; // eslint-disable-line no-unused-vars


export class ForwardedInputEventHandler {
Expand All @@ -32,9 +30,17 @@ export class ForwardedInputEventHandler {
return;
}

self.UI.context.setFlavor(ForwardedShortcut, ForwardedShortcut.instance);
self.UI.shortcutRegistry.handleKey(KeyboardShortcut.makeKey(keyCode, modifiers), key);
self.UI.context.setFlavor(ForwardedShortcut, null);
// @ts-ignore
// TODO(crbug.com/1058320): Replace self.UI.context global.
const context = /** @type {!Context} */ (self.UI.context);

// @ts-ignore
// TODO(crbug.com/1058320): Replace self.UI.context global.
const shortcutRegistry = /** @type {!ShortcutRegistry} */ (self.UI.shortcutRegistry);

context.setFlavor(ForwardedShortcut, ForwardedShortcut.instance);
shortcutRegistry.handleKey(KeyboardShortcut.makeKey(keyCode, modifiers), key);
context.setFlavor(ForwardedShortcut, null);
}
}

Expand Down

0 comments on commit 716ab01

Please sign in to comment.