Skip to content

Instantly share code, notes, and snippets.

@john-osullivan
Last active September 16, 2019 16:53
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 john-osullivan/83270bbb3c01b9f59428971af3d32b13 to your computer and use it in GitHub Desktop.
Save john-osullivan/83270bbb3c01b9f59428971af3d32b13 to your computer and use it in GitHub Desktop.
Dev Diaries #2 - Sample Type Guard
/**
* Type guard; only returns `true` if object shape has a non-null
* `data` value and `err` has a null value.
* @param val
*/
export function isSuccessResponse(val:any): val is SuccessResponse {
return (
isObject(val) &&
val.data &&
val.err === null
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment