This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * A TypeScript type alias called `Prettify`. | |
| * It takes a type as its argument and returns a new type that has the same properties as the original type, | |
| * but the properties are not intersected. This means that the new type is easier to read and understand. | |
| * See more: https://www.totaltypescript.com/concepts/the-prettify-helper | |
| */ | |
| type Prettify<T> = { | |
| [K in keyof T]: T[K]; | |
| } & {}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useQuery, queryOptions, QueryClient } from '@tanstack/react-query' | |
| type Todo = { | |
| id: number | |
| } | |
| declare function fetchTodos(filters?: string): Promise<Array<Todo>> | |
| declare function fetchTodo(id: number): Promise<Array<Todo>> | |
| const queryClient = new QueryClient() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Types for the result object with discriminated union | |
| type Success<T> = [null, T]; | |
| type Failure<E> = [E, null]; | |
| type Result<T, E = Error> = Success<T> | Failure<E>; | |
| export async function tryCatch<T, E extends Error = Error>( | |
| promise: Promise<T> | |
| ): Promise<Result<T, E> { | |
| try { | |
| const result = await promise; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Kevin Powell | |
| * https://youtu.be/2lyDv0wOQuQ | |
| * https://youtu.be/cCAtD_BAHNw | |
| */ | |
| *, *::before, *::after { | |
| box-sizing: border-box; /* Switch to border-box for box-sizing. */ | |
| } |