Skip to content

Instantly share code, notes, and snippets.

@sudomaxime
Last active October 18, 2022 18:51
Show Gist options
  • Save sudomaxime/d09846efcc45fe689ec44e6809b4b817 to your computer and use it in GitHub Desktop.
Save sudomaxime/d09846efcc45fe689ec44e6809b4b817 to your computer and use it in GitHub Desktop.
// 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;
@mattbaker-digital
Copy link

Should this not be:
type Point = {

type ProgramError = {

etc.

@dannyschot
Copy link

Should this not be: type Point = {

type ProgramError = {

etc.

Yes, it should be like that

@sudomaxime
Copy link
Author

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