This file contains 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
// Makes tupple entrues required [string | undefined, number | undefined] -> [string, number] | |
// but when there is plain undefined in tupple it wil become `never` | |
type RequiredTuple<T extends any[]> = {[entry in keyof T]: Exclude<T[entry], undefined>} | |
type Tupple = [ | |
number | undefined, | |
string | undefined, | |
undefined, | |
{} | undefined | |
] |
This file contains 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
interface Props<T extends Record<K, string>, K extends keyof T> { | |
data: T[]; | |
row: ComponentType<T>; | |
primaryKey: K; | |
} | |
function List<T extends Record<K, string>, K extends keyof T>({ | |
data, | |
row: Row, | |
primaryKey |
This file contains 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
const OPEN_BRACES = ['[', '{', '('] as const; | |
type OpenBrace = typeof OPEN_BRACES[number] | |
const CLOSED_BRACES = [']', '}', ')'] as const; | |
type ClosedBrace = typeof CLOSED_BRACES[number]; | |
type AnyBrace = OpenBrace | ClosedBrace; | |
function isBraceOpen(brace: AnyBrace): brace is OpenBrace { | |
return OPEN_BRACES.includes(brace); |
This file contains 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
/* Parallel fetch | |
* Case: When you need to fetch data from server and | |
* those request does not need data from previous one (they are independent). | |
* Pros: Significantly reduces time to get whole response. | |
*/ | |
type User = {} | |
type Organization = {} | |
declare function fetchUser(name: string): Promise<User> |