freddi301/flow-validator

View on GitHub
src/sync/intersection.js

Summary

Maintainability
A
0 mins
Test Coverage
// @flow

import { Type, IntersectionType } from "./Type";

export function intersection<A, B>(
  a: Type<A>,
  b: Type<B>
): IntersectionType<A, B> {
  return new IntersectionType(a, b, v => {
    a.parse(v);
    b.parse(v); // TODO: which one to take? how to merge
    return ((v: any): A & B); // eslint-disable-line flowtype/no-weak-types
  });
}