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 State = any | |
/** | |
* General action type | |
*/ | |
export type Action<TType extends string = string, TPayload = any> = TPayload extends undefined | |
? { | |
type: TType | |
} | |
: { |
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
// definitions | |
import { Middleware } from 'redux' | |
export declare const dispatch: Dispatch | |
export type State = unknown | |
/** | |
* General action type, DO NOT USE AS A RETURN 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
import { useReducer, ChangeEvent } from "react" | |
import { map } from "../util" | |
export type FieldSpec<T = any> = { | |
initialValue: T | |
validate?(value: T): boolean | |
} | |
export type FormAction<F, K extends keyof F = keyof F> = { | |
fieldName: 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
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>> | |
type Diff<T, U> = Omit<T, Extract<keyof U, keyof T>> | |
// works because {} will extend a pick of an optional property | |
// i.e. {} extends { foo?: string } because it's potentially undefined | |
// abuses the fact that the compiler treats assignability specially for object types | |
type OptionalKeys<T> = { [K in keyof T]-?: {} extends Pick<T, K> ? K : never }[keyof T] | |
type RequiredKeys<T> = Exclude<keyof T, OptionalKeys<T>> | |
// in a weak type, the empty interface extends that type since all of its properties can be undefined |
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
function getLowestChild(tree) { | |
if (!tree.children || !tree.children.length) { | |
return { | |
depth: 0, | |
node: tree.root, | |
} | |
} | |
const { depth, node } = tree.children.reduce( | |
(curLowest, subTree) => { | |
const nextLowest = getLowestChild(subTree) |
- Run
npm ls -g --depth=0 | grep -e '->' > npm-links.txt
, the-e
ensures that the-
isn't treated as a flag. - Edit
npm-links.txt
to only the package paths. - Run
cat npm-links.txt | xargs -I '{}' -t sh -c 'cd {}; npm unlink'
NewerOlder