Last active
October 18, 2022 18:51
-
-
Save sudomaxime/d09846efcc45fe689ec44e6809b4b817 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
// Great to express "something" in your app. | |
type Point = { | |
x: number | |
y: number | |
} | |
// Great to make your function params easy to understand | |
function drawPoint (point: Point) { | |
// do stuff | |
} | |
/** | |
* Express that the union of two types becomes | |
* something new. | |
*/ | |
type ProgramError = { | |
ok: false | |
code: string | |
message: string | |
} | |
type ProgramSuccess = { | |
ok: true | |
message: string | |
} | |
type ProgramStatus = ProgramError | ProgramSuccess; |
Should this not be:
type Point = {
type ProgramError = {
etc.
Yes, it should be like that
Damn, you can't be ever too careful, thanks for the catch !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should this not be:
type Point = {
type ProgramError = {
etc.