Skip to content

Instantly share code, notes, and snippets.

@phpnode
Created November 16, 2017 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpnode/53820bab3ea5354567645bfb6dbefb4f to your computer and use it in GitHub Desktop.
Save phpnode/53820bab3ea5354567645bfb6dbefb4f to your computer and use it in GitHub Desktop.
// paste me into https://codemix.github.io/flow-runtime/#/try
// (no gist support yet :( )
import t, {reify} from 'flow-runtime';
type ValidURL = string;
(reify: ValidURL).addConstraint(url => {
if (/^(.|\/)/.test(url)) {
return "Don't use relative URLs for some reason";
}
})
function visitURL(url: ValidURL) {
return url;
}
console.log(visitURL('./nope'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment