Skip to content

Instantly share code, notes, and snippets.

@jarodsim
Created December 24, 2020 19:16
Show Gist options
  • Save jarodsim/02248089ca83ba4751218f5edd14ed0b to your computer and use it in GitHub Desktop.
Save jarodsim/02248089ca83ba4751218f5edd14ed0b to your computer and use it in GitHub Desktop.
// boolean (true / false)
let isOpen: boolean
isOpen = true
// string ('foo', "foo", `foo`)
let message: string
message = `foo ${isOpen}`
// number
let total: number
total = 0xff2
// arrays
let items: number[]
items = [1, 2, 3]
let letters: Array<string>
letters = ['a', 'b', 'c']
// tuple
let childs: [number, string]
childs = [1, 'mark']
// enum
enum Colors {
white = '#fff',
black = '#000',
}
// any (qualquer coisa) NÃO É LEGAL!
let coisa: any
coisa = [1, 2, 3]
// void (vazio)
function logger(): void {
console.log('foo')
}
// null | undefined
type Bla = string | undefined
// never
function error(): never {
throw new Error('error')
}
// object
let cart: object
cart = { true: true }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment