-
Notifications
You must be signed in to change notification settings - Fork 0
/
aula1.ts
84 lines (62 loc) · 1.27 KB
/
aula1.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { validateHeaderName } from "http"
const soma = (a: number,b: number) => {
console.log( a + b )
}
soma(12,12)
// declarando variaveis
var a = 'a'
let b = 'b'
const c = 'c'
// tipos primitivos
let q: number = 1
let w: string = 'tallts'
let t: number | string | boolean = true
t = 3
let v: any = false
// objetos
interface Pessoa {
nome: string,
idade: number,
profissao?: string
}
const tallys: Pessoa = {
nome: 'tallys',
idade: 19
}
const aureliano: Pessoa = {
nome: 'aureliano',
idade: 20,
profissao: 'dev'
}
// Arrys
const arrayPessoas: Array<Pessoa> = [
tallys,
aureliano
]
const arrayNumber: number[] = [
1,3,4,5
]
const arrayString: Array<string> = [
'2','3','4'
]
// estruturas de desisão
const num: number = 13
if (num > 15) {
console.log("este numero é maior que 15")
} else if (num == 15) {
console.log("Este numero é igual a 15")
} else {
console.log("este numero é menor que 15")
}
const typeUser = {
admim: "Seja bem vindo adm",
student: "Olá estudante",
viewer: "Olá visitante"
}
function ValidateUser(user: string) {
console.log(typeUser[user as keyof typeof typeUser])
}
const usuario: string = 'admim'
ValidateUser(usuario)
ValidateUser("student")
ValidateUser('viewer')