Improve types

This commit is contained in:
Daniel Imms 2019-07-16 14:09:12 -07:00
parent f7b8079f21
commit 2eb4b1aebd

View file

@ -3,9 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
const puppeteer = require('puppeteer'); import * as puppeteer from 'puppeteer';
// export function connect(outPath: string, handle: string): Promise<{ client: IDisposable, driver: IDriver }>
const width = 1200; const width = 1200;
const height = 800; const height = 800;
@ -16,7 +14,7 @@ const vscodeToPuppeteerKey = {
enter: 'Enter' enter: 'Enter'
}; };
function buildDriver(browser, page) { function buildDriver(browser: puppeteer.Browser, page: puppeteer.Page): IDriver {
return { return {
_serviceBrand: undefined, _serviceBrand: undefined,
getWindowIds: () => { getWindowIds: () => {
@ -36,11 +34,10 @@ function buildDriver(browser, page) {
keysDown.push(keys[i]); keysDown.push(keys[i]);
} }
while (keysDown.length > 0) { while (keysDown.length > 0) {
await page.keyboard.up(keysDown.pop()); await page.keyboard.up(keysDown.pop()!);
} }
}, },
click: async (windowId, selector, xoffset, yoffset) => { click: async (windowId, selector, xoffset, yoffset) => {
console.log('click');
const { x, y } = await page.evaluate(` const { x, y } = await page.evaluate(`
(function() { (function() {
function convertToPixels(element, value) { function convertToPixels(element, value) {