eslint-plugin-ferramentas
Version:
A bundle of useful ESLint rules
19 lines (18 loc) • 990 B
TypeScript
/** Extract type of array */
export type ArrayType<T extends readonly unknown[]> = T extends readonly (infer U)[] ? U : never;
/** Create readonly non empty array of the given type */
export type NonEmptyArray<T> = readonly [T, ...T[]] & readonly T[];
/** Create readonly ecord of the given type */
export type ReadonlyRecord<K extends keyof any, T> = Readonly<Record<K, T>>;
/** Create tupple of the given type */
export type Tupple<T> = readonly [a: T, b: T];
/** Lists Optional keys of the given type */
type OptionalKeys<T> = {
[K in keyof T]-?: {} extends Pick<T, K> ? K : never;
}[keyof T];
/** Lists the optional value (and only the optional values) as required values */
export type OptionalAsRequired<T> = Required<Pick<T, OptionalKeys<T>>>;
export declare const createExecuteOnce: <T>(valueGenerator: () => T) => () => T;
export declare const createDebugger: (debugging: boolean) => Console['debug'];
export declare const isPathRelative: (path: string) => boolean;
export {};