Created
December 24, 2020 19:16
-
-
Save jarodsim/02248089ca83ba4751218f5edd14ed0b to your computer and use it in GitHub Desktop.
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
// 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