Enhancing types for Device
Summary: While investigating Flipper to unblock D30990411. I found this untyped `device` field. This field is exactly the `Device` type in 'adbkit', so I did a small refactor to type it. Reviewed By: timur-valiev Differential Revision: D30996427 fbshipit-source-id: 9972a865c2dee009088635e57ef512969f404ddf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
094c320c5c
commit
cbee595229
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import BaseDevice from '../BaseDevice';
|
||||
import adb, {Client as ADBClient} from 'adbkit';
|
||||
import adb, {Client as ADBClient, PullTransfer} from 'adbkit';
|
||||
import {Priority, Reader} from 'adbkit-logcat';
|
||||
import {createWriteStream} from 'fs';
|
||||
import type {LogLevel, DeviceType} from 'flipper-plugin';
|
||||
|
||||
@@ -13,7 +13,7 @@ import child_process from 'child_process';
|
||||
import {getAdbClient} from './adbClient';
|
||||
import which from 'which';
|
||||
import {promisify} from 'util';
|
||||
import {Client as ADBClient} from 'adbkit';
|
||||
import {Client as ADBClient, Device} from 'adbkit';
|
||||
import {join} from 'path';
|
||||
import {FlipperServer} from '../../FlipperServer';
|
||||
import {notNull} from '../../utils/typeUtils';
|
||||
@@ -26,7 +26,7 @@ export class AndroidDeviceManager {
|
||||
|
||||
private createDevice(
|
||||
adbClient: ADBClient,
|
||||
device: any,
|
||||
device: Device,
|
||||
): Promise<AndroidDevice | undefined> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const type =
|
||||
@@ -224,7 +224,7 @@ export class AndroidDeviceManager {
|
||||
}
|
||||
}
|
||||
|
||||
private async registerDevice(adbClient: ADBClient, deviceData: any) {
|
||||
private async registerDevice(adbClient: ADBClient, deviceData: Device) {
|
||||
const androidDevice = await this.createDevice(adbClient, deviceData);
|
||||
if (!androidDevice) {
|
||||
return;
|
||||
|
||||
7
desktop/types/adbkit.d.ts
vendored
7
desktop/types/adbkit.d.ts
vendored
@@ -7,7 +7,8 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
interface Device {
|
||||
declare module 'adbkit' {
|
||||
export interface Device {
|
||||
id: string;
|
||||
type: 'emulator' | 'device' | 'offline';
|
||||
}
|
||||
@@ -17,7 +18,7 @@ interface Util {
|
||||
}
|
||||
|
||||
// https://github.com/openstf/adbkit#pulltransfer
|
||||
interface PullTransfer extends NodeJS.WriteStream {
|
||||
export interface PullTransfer extends NodeJS.WriteStream {
|
||||
cancel: () => this;
|
||||
on(
|
||||
event: 'progress',
|
||||
@@ -43,8 +44,6 @@ interface DeviceTracker extends NodeJS.EventEmitter {
|
||||
on(event: 'error', listener: (err: Error) => void): this;
|
||||
on(event: 'end', listener: () => void): this;
|
||||
}
|
||||
|
||||
declare module 'adbkit' {
|
||||
const util: Util;
|
||||
const adbkit: any;
|
||||
export interface Client {
|
||||
|
||||
Reference in New Issue
Block a user