function composeDeviceConfigFromAliased(opts) {
  const { errorComposer, globalConfig, localConfig } = opts;

  /** @type {Detox.DetoxDeviceConfig} */
  let deviceConfig;

  const isAliased = typeof localConfig.device === 'string';

  if (isAliased) {
    if (_.isEmpty(globalConfig.devices)) {
      throw errorComposer.thereAreNoDeviceConfigs(localConfig.device);
    } else {
      deviceConfig = globalConfig.devices[localConfig.device];
    }

    if (!deviceConfig) {
      throw errorComposer.cantResolveDeviceAlias(localConfig.device);
    }
  } else {
    if (!localConfig.device) {
      throw errorComposer.deviceConfigIsUndefined();
    }

    deviceConfig = localConfig.device;
  }

  validateDeviceConfig({
    deviceConfig,
    errorComposer,
    deviceAlias: isAliased ? localConfig.device : undefined
  });

  return { ...deviceConfig };
}
@param {DetoxConfigErrorComposer} opts.errorComposer
@param {Detox.DetoxConfig} opts.globalConfig
@param {Detox.DetoxConfiguration} opts.localConfig
@returns {Detox.DetoxDeviceConfig}