Created
September 5, 2021 16:49
-
-
Save arthurgubaidullin/9695610cd8680fc0fbc78043f5a62853 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
interface InternalEventBrand { | |
readonly Internal: unique symbol; | |
} | |
type User = {} | |
type AuthorizedEvent = { type: 'AUTHORIZED'; user: User } & InternalEventBrand; | |
function authorized(user: User): AuthorizedEvent { | |
return { type: 'AUTHORIZED', user } as AuthorizedEvent; | |
} | |
type UnauthorizedEvent = { type: 'UNAUTHORIZED' } & InternalEventBrand; | |
function unauthorized(): UnauthorizedEvent { | |
return { type: 'UNAUTHORIZED' } as UnauthorizedEvent; | |
} | |
export type AuthEvent = | |
| { type: 'AUTHORIZATION' } | |
| AuthorizedEvent | |
| UnauthorizedEvent | |
| { type: 'SIGN_IN' } | |
| { type: 'SIGN_OUT' }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment