Skip to content

Instantly share code, notes, and snippets.

@benwaffle
Created July 26, 2018 19:43
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 benwaffle/0e9a714e3108f11719b1370b6f7333c3 to your computer and use it in GitHub Desktop.
Save benwaffle/0e9a714e3108f11719b1370b6f7333c3 to your computer and use it in GitHub Desktop.
type GraphQLType =
| GraphQLInt
| GraphQLList<any>
| GraphQLNonNull<any>;
interface GraphQLInt {
int: number
}
interface GraphQLList<T> {
x: string
}
interface GraphQLNonNull<T> {
x: string
}
declare function isInt(type: GraphQLType): type is GraphQLInt;
declare function isList(type: GraphQLType): type is GraphQLList<any>;
declare function isNonNull(type: GraphQLType): type is GraphQLNonNull<any>;
function doIt(t: GraphQLType) {
if (isInt(t)) {
return t.int
}
if (isList(t)) {
return t.x
}
if (isNonNull(t)) {
return t.x
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment