severity: asSeverity()

in website/_webpack/js/tryFlow.js [141:204]


        severity: asSeverity(err.level),
        message: message,
        source: firstLoc.source,
        startLineNumber: firstLoc.start.line,
        startColumn: firstLoc.start.column,
        endLineNumber: firstLoc.end.line,
        endColumn: firstLoc.end.column + 1,
        // TODO: show references
        // relatedInformation: ...
      };
    });
    monaco.editor.setModelMarkers(model, 'default', markers);
    if (callback != null) {
      callback(errors);
    }
  });
}

const lastEditorValue = localStorage.getItem('tryFlowLastContent');
const defaultValue = (lastEditorValue && getHashedValue(lastEditorValue)) || `/* @flow */

function foo(x: ?number): string {
  if (x) {
    return x;
  }
  return "default string";
}
`;

function getHashedValue(hash) {
  if (hash[0] !== '#' || hash.length < 2) return null;
  const version = hash.slice(1, 2);
  const encoded = hash.slice(2);
  if (version === '0' && encoded.match(/^[a-zA-Z0-9+/=_-]+$/)) {
    return LZString.decompressFromEncodedURIComponent(encoded);
  }
  return null;
}

function removeClass(elem, className) {
  elem.className = elem.className.split(/\s+/).filter(function(name) {
    return name !== className;
  }).join(' ');
}

class Deferred {
  constructor() {
    this.promise = new Promise((resolve, reject) => {
      this.resolve = resolve;
      this.reject = reject;
    });
  }
}

const workerRegistry = {}
class FlowWorker {
  constructor(version) {
    this._version = version;
    this._pending = {};
    this._index = 0;

    const worker = this._worker = new Worker(window.tryFlowWorker);
    worker.onmessage = ({data}) => {
      if (data.id && this._pending[data.id]) {