moysklad-api-model
Version:
Объектная модель API МойСклад для TypeScript проектов
28 lines (27 loc) • 806 B
TypeScript
export * from './Expand';
export * from './Patch';
export * from './PrefilledDocument';
export type IfEquals<X, Y, A = X, B = never> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? A : B;
export type IsExtends<A, B> = A extends B ? true : false;
export type ReadonlyKeys<T> = {
[P in keyof T]-?: IfEquals<{
[Q in P]: T[P];
}, {
-readonly [Q in P]: T[P];
}, never, P>;
}[keyof T];
export type WritableKeys<T> = {
[P in keyof T]-?: IfEquals<{
[Q in P]: T[P];
}, {
-readonly [Q in P]: T[P];
}, P>;
}[keyof T];
export type RequireKeys<T, K extends keyof T> = {
[X in Exclude<keyof T, K>]?: T[X];
} & {
[P in K]-?: T[P];
};
export type SelectKeysByType<T, V> = {
[K in keyof T]: T[K] extends V ? K : never;
}[keyof T];