Typescript Backend Cheatsheet Final
Typescript Backend Cheatsheet Final
Basic Types
// Array of strings
interface User {
id: string;
name: string;
email: string;
email: "[email protected]"
};
Functions
console.log(message);
interface Address {
city: string;
country: string;
Enums
enum Role {
ADMIN = "admin",
USER = "user",
GUEST = "guest"
Literal Types
Generics
return arg;
interface ApiResponse<T> {
data: T;
Utility Types
Partial<User>
Omit<User, "email">
res.send('Logged in');
});
Special Types
interface LoginBody {
email: string;
password: string;
Quick Tip
Hover over variables in VSCode - TypeScript will show you the type immediately for faster learning!