function getPluginOptions(plugin /*: Partial<{opts: ?PluginOptions}> */) /*: PluginOptions */ {
  const {opts} = plugin;
  if (opts == null || typeof opts !== 'object') {
    // eslint-disable-next-line fb-www/no-new-error
    throw new Error(`Expected to opts property to be an object. `
      + `Current value is ${String(opts)} (${typeof opts})`);
  }
  // $FlowExpectedError[prop-missing]
  // $FlowExpectedError[incompatible-exact]
  return opts;
}
Utility function to cast the Babel transform plugin options to the right type