Please enable JavaScript.
Coggle requires JavaScript to display documents.
TypeScript Basics, (What is TypeScript?) - Coggle Diagram
-
What is TypeScript?
Setting Up TypeScript
- npm install typescript --save-dev
-
-
-
Arrays & Tuples
- Arrays: string[] / Array<number>
-
-
-
-
-
Generics
- Generic function: function identity<T>(arg: T): T
-
-
With Constraint:
- T extends { length: number }
-
-
Primitive Types
- string, number, boolean, null, undefined
-
-
Union, Literal & Intersection Types
Union:
- type ID = string | number
-
-
Literal:
- type Size = "small" | "medium" | "large"
-
-
-
Enums
- enum Role { Admin, User, Guest }
-
-
Functions
- Function typing: args + return
-
❌ add(2, "3") → wrong type
-
Utility Types
- Partial<T>, Pick<T, K>, Omit<T, K>
-
❌ Pick<Todo, "foo"> → 'foo' doesn't exist
-
-
-
-
-