@peersyst/react-types
Advanced tools
Comparing version 1.5.5 to 1.6.0
111
index.d.ts
@@ -12,2 +12,4 @@ import { CSSProperties, ReactElement } from "react"; | ||
export type AnyObject = Record<string | symbol | number, any>; | ||
export type ReactChild = ReactElement | string | number; | ||
@@ -25,6 +27,6 @@ | ||
*/ | ||
export type OverridableStringUnion<T extends string | number, U = Record<string, any>> = | ||
GenerateStringUnion<Overwrite<Record<T, true>, U>>; | ||
export type OverridableStringUnion<T extends string | number, U = Record<string, any>> = | ||
GenerateStringUnion<Overwrite<Record<T, true>, U>>; | ||
export type OverridableStringUnion< | ||
T extends string | number, | ||
U = Record<string, any>, | ||
> = GenerateStringUnion<Overwrite<Record<T, true>, U>>; | ||
@@ -140,18 +142,12 @@ /** | ||
type FlattenedNestedKeys<T extends object> = FlattenedCoreNestedKeys<T>; | ||
type FlattenedCoreNestedKeys<T extends object, I extends number = MaxRecursiveIterations> = | ||
I extends 0 | ||
? never | ||
: { | ||
[Key in keyof T]: T[Key] extends object | ||
? `${Key}.${CoreNestedKeys<T[Key], Iterations[I]>}` | ||
: Key; | ||
}[Extract<keyof T, string>]; | ||
type FlattenedCoreNestedKeys<T extends object, I extends number = MaxRecursiveIterations> = | ||
I extends 0 | ||
? never | ||
: { | ||
[Key in keyof T]: T[Key] extends object | ||
? `${Key}.${CoreNestedKeys<T[Key], Iterations[I]>}` | ||
: Key; | ||
}[Extract<keyof T, string>]; | ||
type FlattenedCoreNestedKeys< | ||
T extends object, | ||
I extends number = MaxRecursiveIterations, | ||
> = I extends 0 | ||
? never | ||
: { | ||
[Key in keyof T]: T[Key] extends object | ||
? `${Key}.${CoreNestedKeys<T[Key], Iterations[I]>}` | ||
: Key; | ||
}[Extract<keyof T, string>]; | ||
@@ -162,14 +158,11 @@ /** | ||
type DeepPick<T extends object, K extends NestedKeys<T>> = CoreDeepPick<T, K>; | ||
type CoreDeepPick<T extends object, K extends string, I extends number = MaxRecursiveIterations> = | ||
I extends 0 | ||
? never | ||
: K extends `${infer FirstKey}.${infer RestKey}` | ||
? CoreDeepPick<T[FirstKey], RestKey, Iterations[I]> | ||
: T[K]; | ||
type CoreDeepPick<T extends object, K extends string, I extends number = MaxRecursiveIterations> = | ||
I extends 0 | ||
? never | ||
: K extends `${infer FirstKey}.${infer RestKey}` | ||
? CoreDeepPick<T[FirstKey], RestKey, Iterations[I]> | ||
: T[K]; | ||
type CoreDeepPick< | ||
T extends object, | ||
K extends string, | ||
I extends number = MaxRecursiveIterations, | ||
> = I extends 0 | ||
? never | ||
: K extends `${infer FirstKey}.${infer RestKey}` | ||
? CoreDeepPick<T[FirstKey], RestKey, Iterations[I]> | ||
: T[K]; | ||
@@ -185,3 +178,53 @@ /** | ||
*/ | ||
export type Replace<T extends string, S extends string, D extends string, A extends string = ""> = | ||
T extends `${infer L}${S}${infer R}` ? Replace<R, S, D, `${A}${L}${D}`> : `${A}${T}`; | ||
export type Replace< | ||
T extends string, | ||
S extends string, | ||
D extends string, | ||
A extends string = "", | ||
> = T extends `${infer L}${S}${infer R}` ? Replace<R, S, D, `${A}${L}${D}`> : `${A}${T}`; | ||
/** | ||
* Overrides type T with O | ||
*/ | ||
export type Override<T extends AnyObject, O extends AnyObject> = { | ||
[K in keyof T]: K extends keyof O ? O[K] : T[K]; | ||
}; | ||
/** | ||
* Deeply overrides type T with O | ||
*/ | ||
export type DeepOverride<T extends AnyObject, O extends AnyObject> = CoreDeepOverride<T, O>; | ||
type CoreDeepOverride< | ||
T extends AnyObject, | ||
O extends AnyObject, | ||
I extends number = MaxRecursiveIterations, | ||
> = I extends 0 | ||
? never | ||
: Override< | ||
{ | ||
[K in keyof T]: T[K] extends AnyObject | undefined ? DeepOverride<T[K], O> : T[K]; | ||
}, | ||
O | ||
>; | ||
/** | ||
* Injects type O into type T | ||
*/ | ||
export type Inject<T extends AnyObject, O extends AnyObject> = T & O; | ||
/** | ||
* Deeply injects type O into type T | ||
*/ | ||
export type DeepInject<T extends AnyObject, O extends AnyObject> = CoreDeepInject<T, O>; | ||
type CoreDeepInject< | ||
T extends AnyObject, | ||
O extends AnyObject, | ||
I extends number = MaxRecursiveIterations, | ||
> = I extends 0 | ||
? never | ||
: Inject< | ||
{ | ||
[K in keyof T]: T[K] extends AnyObject | undefined ? DeepInject<T[K], O> : T[K]; | ||
}, | ||
O | ||
>; |
{ | ||
"name": "@peersyst/react-types", | ||
"author": "Peersyst", | ||
"version": "1.5.5", | ||
"version": "1.6.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "types": "./index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7689
197