/* @flow */

import ConversionContext from './ConversionContext';

export type Options = {
  ignore?: boolean;
  assert?: boolean;
  warn?: boolean;
  annotate?: boolean;
  // deprecated
  decorate?: boolean;
};

export default function createConversionContext (options: Options): ConversionContext {

  const context = new ConversionContext();

  context.shouldAssert = options.assert === undefined
                       ? process.env.NODE_ENV === 'development'
                       : Boolean(options.assert)
                       ;

  context.shouldWarn = options.warn ? true : false;

  if ('decorate' in options) {
    console.warn('Warning: "decorate" option for babel-plugin-flow-runtime is now called "annotate", support for "decorate" will be removed in a future version.');
    if (!('annotate' in options)) {
      options.annotate = options.decorate;
    }
  }

  context.shouldAnnotate = options.annotate === undefined
                         ? true
                         : Boolean(options.annotate)
                         ;
  return context;
}
/* @flow */

import ConversionContext from './ConversionContext';

export type Options = {
  ignore?: boolean;
  assert?: boolean;
  warn?: boolean;
  annotate?: boolean;
  suppressComments?: RegExp[];
  suppressTypes?: string[];
  // deprecated
  decorate?: boolean;
};

export default function createConversionContext (options: Options): ConversionContext {

  const context = new ConversionContext();

  context.shouldAssert = options.assert === undefined
                       ? process.env.NODE_ENV === 'development'
                       : Boolean(options.assert)
                       ;

  context.shouldWarn = options.warn ? true : false;

  if ('decorate' in options) {
    console.warn('Warning: "decorate" option for babel-plugin-flow-runtime is now called "annotate", support for "decorate" will be removed in a future version.');
    if (!('annotate' in options)) {
      options.annotate = options.decorate;
    }
  }

  context.shouldAnnotate = options.annotate === undefined
                         ? true
                         : Boolean(options.annotate)
                         ;
  
  if ('suppressComments' in options && Array.isArray(options.suppressComments)) {
    context.suppressCommentPatterns = options.suppressComments;
  }
  
  if ('suppressTypes' in options && Array.isArray(options.suppressTypes)) {
    context.suppressTypeNames = options.suppressTypeNames;
  }
  
  return context;
}

Add 'suppressComments' and 'suppressTypes' options
Add 'suppressComments' and 'suppressTypes' options

They were not implemented, even though they were mentioned in: https://codemix.github.io/flow-runtime/#/docs/pragmas