Created
July 26, 2018 19:43
-
-
Save benwaffle/0e9a714e3108f11719b1370b6f7333c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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