Skip to content

Instantly share code, notes, and snippets.

@banyudu
Created December 18, 2023 09:02
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 banyudu/2787db221933bbdd935f67b40da14096 to your computer and use it in GitHub Desktop.
Save banyudu/2787db221933bbdd935f67b40da14096 to your computer and use it in GitHub Desktop.
Typescript truthy falsy guard
export const truthy = (v: any): v is true => {
return !!(v as boolean)
}
export const falsy = (v: any): v is false => {
return !(v as boolean)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment