-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
50 lines (42 loc) · 1.1 KB
/
index.ts
File metadata and controls
50 lines (42 loc) · 1.1 KB
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
// string
//number
//array
//object
//any
//boolean
//unknown
//const assertion - never - void
// type alias - interface
//union - tuple
//Literal Types - Enum
//Utility Types (partial, Required, Omit, Pick, Readonly)
type ID = number | string | undefined | null;
let myId: ID = undefined;
type TPosition = [lat: number, lng: number];
const position: TPosition = [53.25458, 49.857456];
const [lat, lng] = position;
type TCourse = [id: number, title: string, description?: string];
const course: TCourse = [
1,
"NestJS",
"the backend course for nodejs developers",
];
type TStatus =
| "Initialized"
| "Draft"
| "Pending"
| "Sent"
| "Received"
| "Cancel";
type TNumberStatus = 0 | 1 | 2 | 3 | 4;
let messageStatus: TStatus = "Draft";
const userStatus: TNumberStatus = 2;
enum MessageStatus {
Initialized = "initialized",
Draft = "draft",
Pending = "pending",
}
const msgStatus: MessageStatus = MessageStatus.Pending;
const userInput: MessageStatus = "draft" as MessageStatus;
console.log(Object.keys(MessageStatus));
console.log(Object.values(MessageStatus).includes("draft" as MessageStatus));