Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // working with pipes and type
- type Fruit = "orange" | "banana" | "strawberry";
- // working with types and functions
- type EatFruitFunction = (fruit: Fruit) => void;
- // typing objects using type
- type User = {
- username: string,
- email: string,
- password: string,
- }
- type UserList = {
- users: User[]
- }
- // Composing `n` types
- type Composed = User & UserList & {
- // Here you can write your other props
- example: Object
- };
- /**
- How this will look like on the end:
- {
- example: {},
- username: 'foo',
- email: 'foo@foo.com',
- password: '123',
- users: [...],
- }
- */
Add Comment
Please, Sign In to add comment