/**
 * Copyright 2018-present Facebook.
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 * @format
 */
import BaseDevice from './BaseDevice';
import {DeviceType, OS, DeviceShell, DeviceLogEntry} from './BaseDevice';

function normalizeArchivedDeviceType(deviceType: DeviceType): DeviceType {
  let archivedDeviceType = deviceType;
  if (archivedDeviceType === 'emulator') {
    archivedDeviceType = 'archivedEmulator';
  } else if (archivedDeviceType === 'physical') {
    archivedDeviceType = 'archivedPhysical';
  }
  return archivedDeviceType;
}

export default class ArchivedDevice extends BaseDevice {
  constructor(
    serial: string,
    deviceType: DeviceType,
    title: string,
    os: OS,
    logEntries: Array<DeviceLogEntry>,
  ) {
    super(serial, normalizeArchivedDeviceType(deviceType), title, os);
    this.logs = logEntries;
  }

  logs: Array<DeviceLogEntry>;

  isArchived = true;

  getLogs() {
    return this.logs;
  }

  clearLogs(): Promise<void> {
    this.logs = [];
    return Promise.resolve();
  }

  spawnShell(): DeviceShell | undefined | null {
    return null;
  }
}

/**
 * Copyright 2018-present Facebook.
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 * @format
 */
import BaseDevice from './BaseDevice';
import {DeviceType, OS, DeviceShell, DeviceLogEntry} from './BaseDevice';

export default class ArchivedDevice extends BaseDevice {
  // @ts-ignore: Super needs to be on the first line
  constructor(
    serial: string,
    deviceType: DeviceType,
    title: string,
    os: OS,
    logEntries: Array<DeviceLogEntry>,
  ) {
    let archivedDeviceType = deviceType;
    if (archivedDeviceType === 'emulator') {
      archivedDeviceType = 'archivedEmulator';
    } else if (archivedDeviceType === 'physical') {
      archivedDeviceType = 'archivedPhysical';
    }
    super(serial, archivedDeviceType, title, os);
    this.logs = logEntries;
  }

  logs: Array<DeviceLogEntry>;

  isArchived = true;

  getLogs() {
    return this.logs;
  }

  clearLogs(): Promise<void> {
    this.logs = [];
    return Promise.resolve();
  }

  spawnShell(): DeviceShell | undefined | null {
    return null;
  }
}

--- 
+++ 
@@ -7,8 +7,17 @@
 import BaseDevice from './BaseDevice';
 import {DeviceType, OS, DeviceShell, DeviceLogEntry} from './BaseDevice';
 
+function normalizeArchivedDeviceType(deviceType: DeviceType): DeviceType {
+  let archivedDeviceType = deviceType;
+  if (archivedDeviceType === 'emulator') {
+    archivedDeviceType = 'archivedEmulator';
+  } else if (archivedDeviceType === 'physical') {
+    archivedDeviceType = 'archivedPhysical';
+  }
+  return archivedDeviceType;
+}
+
 export default class ArchivedDevice extends BaseDevice {
-  // @ts-ignore: Super needs to be on the first line
   constructor(
     serial: string,
     deviceType: DeviceType,
@@ -16,13 +25,7 @@
     os: OS,
     logEntries: Array<DeviceLogEntry>,
   ) {
-    let archivedDeviceType = deviceType;
-    if (archivedDeviceType === 'emulator') {
-      archivedDeviceType = 'archivedEmulator';
-    } else if (archivedDeviceType === 'physical') {
-      archivedDeviceType = 'archivedPhysical';
-    }
-    super(serial, archivedDeviceType, title, os);
+    super(serial, normalizeArchivedDeviceType(deviceType), title, os);
     this.logs = logEntries;
   }
 
Remove unnecessary ts-ignore for archive

Summary:
This is a pretty broad ignore which doesn't seem required
but could hide real bugs.

Reviewed By: jknoxville

Differential Revision: D17342033

fbshipit-source-id: c7941e383936e44e39eff3fb7eced1d85a0d6417
