Skip to content

Instantly share code, notes, and snippets.

@alexklyuev
Created September 7, 2017 10:01
Show Gist options
  • Save alexklyuev/a83d1512f5ca817f9112ce8aa86643f4 to your computer and use it in GitHub Desktop.
Save alexklyuev/a83d1512f5ca817f9112ce8aa86643f4 to your computer and use it in GitHub Desktop.
const gf = <B, C extends B>(fn: (x: B) => x is C): (x: B) => x is C => {
return ((x: B) => fn(x)) as (x: B) => x is C;
}
const isString = gf<any, string>((x): x is string => typeof x === 'string');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment