Created
January 14, 2022 09:50
-
-
Save holgergp/8852b97ee15e97f051f4d0596318b703 to your computer and use it in GitHub Desktop.
Template String Types as Discriminants (TypeScript 4.5 Article)
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
export interface Success { | |
type: `${string}Success`; | |
body: string; | |
} | |
export function handler(r: Success | Error) { | |
if (r.type === "HttpSuccess") { | |
// (parameter) r: Success | |
const token = r.body; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment