Last active
September 16, 2019 16:53
-
-
Save john-osullivan/83270bbb3c01b9f59428971af3d32b13 to your computer and use it in GitHub Desktop.
Dev Diaries #2 - Sample Type Guard
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 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