It would be nice to be able to use the annotations directly, we support this in flow-runtime[0] but I think it would be fairly straightforward to support in TypeScript too,
It looks like this:
import t from 'flow-runtime';
const makeUpperCase = t.pattern(
(input: string) => input.toUpperCase(),
(input: number) => input
);
console.log(makeUpperCase("foo bar"));
console.log(makeUpperCase(123));
console.log(makeUpperCase(false)); // throws
[0] https://codemix.github.io/flow-runtime/#/docs/pattern-matchi...