Now that I research, there seems to be a Babel plugin (tcomb) that can do $Refinement. You can do it side-by-side with Flow, and only use tcomb when you what to emit runtime type checking (e.g. function entry points.)
// @flow import type { $Refinement } from 'tcomb' const isInteger = n => n % 1 === 0 type Integer = number & $Refinement<typeof isInteger>; function foo(n: Integer) { return n } foo(2) // flow ok, tcomb ok foo(2.1) // flow ok, tcomb throws [tcomb] Invalid value 2.1 supplied to n: Integer foo('a') // flow throws, tcomb throws
In order to enable this feature add the tcomb definition file to the [libs] section of your .flowconfig.
[libs]
.flowconfig
It would probably throw error, if I try to use tcomb alongside TypeScript.
tcomb
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Now that I research, there seems to be a Babel plugin (tcomb) that can do $Refinement. You can do it side-by-side with Flow, and only use tcomb when you what to emit runtime type checking (e.g. function entry points.)
In order to enable this feature add the tcomb definition file to the
[libs]
section of your.flowconfig
.gcanti / babel-plugin-tcomb
Babel plugin for static and runtime type checking using Flow and tcomb
It would probably throw error, if I try to use
tcomb
alongside TypeScript.