Skip to content

Instantly share code, notes, and snippets.

@WimJongeneel
Created December 15, 2019 11:07
Show Gist options
  • Save WimJongeneel/e1f9be1d56e883cf3ae51e5b63df6821 to your computer and use it in GitHub Desktop.
Save WimJongeneel/e1f9be1d56e883cf3ae51e5b63df6821 to your computer and use it in GitHub Desktop.
interface Blog { id: number, title: string }
// Will be { id: number, title: string } | { errorMessage: string }
let httpResult: any = /* API logic. */
let result = httpResult.errorMesage
? new Error(httpResult.errorMessage)
: ({ id: httpResult.Id, title: httpResult.Title })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment