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
declare const t: unique symbol; | |
declare const t1: unique symbol; | |
declare const t2: unique symbol; | |
interface Extend0<Token> { | |
readonly [t]: Token; | |
} | |
interface Extend1<Token> { | |
readonly [t1]: Token; |
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
const mapBuilder = <ValueType = never>() => { | |
const addFactory = <Values extends Record<string, ValueType>>(values: Values) => ({ | |
add: <Key extends string>(key: Key, data: ValueType) => | |
addFactory({ ...values, [key]: data } as Record<keyof Values | Key, ValueType>), | |
build: () => values, | |
}); | |
return addFactory({}); | |
}; |
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
#!/bin/sh | |
. "$(dirname "$0")/_/husky.sh" | |
COMMIT_MSG_FILE=$1 | |
COMMIT_SOURCE=$2 | |
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) | |
CHORE_BRANCH_REGEX='^chore-.+$' | |
VALID_BRANCH_REGEX='^issue-[0-9]+-.+$' | |
COMMIT_MESSAGE=$(<$COMMIT_MSG_FILE) |
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 React, { ReactElement, ComponentType } from 'react'; | |
function withHook<HookReturn extends Record<string, unknown>>(use: () => HookReturn) { | |
return <Props extends Record<string, unknown>>( | |
Component: ComponentType<Props & HookReturn>, | |
): ComponentType<Props> => { | |
const WrappedComponent = (props: Props): ReactElement<Props & HookReturn> => { | |
const hookProps = use(); | |
return <Component {...props} {...hookProps} />; |
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
type ResolveType<T> = T extends (...args: any[]) => Record<string, unknown> | |
? T | |
: { [K in keyof T]: T[K] }; | |
export function createAction< | |
Type extends string, | |
Args extends any[] = [], | |
Return extends Record<string, unknown> = Record<string, unknown> | |
>( | |
type: Type, |
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
export const omit = <T extends Record<string, unknown>, K extends [...(keyof T)[]]>( | |
originalObject: T, | |
keysToOmit: K, | |
): { | |
[K2 in Exclude<keyof T, K[number]>]: T[K2]; | |
} => { | |
const clonedObject = { ...originalObject }; | |
for (const path of keysToOmit) { | |
delete clonedObject[path]; |
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
export type AsyncState<T> = { | |
status: 'idle' | 'loading' | 'success' | 'failure'; | |
data: T; | |
error: string | null; | |
}; | |
export const createAsyncState = <T>(initialData: T): AsyncState<T> => ({ | |
status: 'idle', | |
data: initialData, | |
error: null, |
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 makeMuiStyles from '@material-ui/styles/makeStyles'; | |
import { ClassNameMap, Styles, WithStylesOptions } from '@material-ui/styles/withStyles'; | |
import { Theme } from './types'; | |
export const makeStyles = <Props extends {} | undefined = undefined, ClassKey extends string = string>( | |
styles: Styles<Theme, Props extends undefined ? {} : Props, ClassKey>, | |
options?: Omit<WithStylesOptions<Theme>, 'withTheme'>, | |
) => { | |
return makeMuiStyles(styles, options) as Props extends undefined |