-
Notifications
You must be signed in to change notification settings - Fork 0
/
Satisfies.ts
51 lines (39 loc) · 992 Bytes
/
Satisfies.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
type Cidade = NomeCidade | CidadeCoordenadas;
type NomeCidade = "São Paulo" | "Rio de Janeiro" | "Salvador" | "Belo Horizonte";
type CidadeCoordenadas = {
x: number;
y: number;
};
type Pessoa = {
localNascimento: Cidade;
residenciaAtual: Cidade;
};
const pessoa = {
localNascimento: "Rio de Janeiro",
residenciaAtual: { x: 10, y: 20 },
} satisfies Pessoa
console.log(pessoa.localNascimento.toUpperCase());
// ==> Exemplo 02: Satisfies Operator
type Connection = {};
declare function createConnection(
host: string,
port: string,
reconnect: boolean,
poolsize: number
): Connection;
type Configuration = {
host: string;
port: string | number;
tryReconnect: boolean | (() => boolean);
poolSize?: number;
};
const config = {
host: "localhost",
port: 3306,
tryReconnect: () => true,
poolSize: 10,
} satisfies Configuration;
function connect() {
let { host, port, tryReconnect } = config;
createConnection(host, `${port}`, tryReconnect(), 10);
}