free-types-core 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Type.d.ts +2 -2
- package/dist/unwrap.d.ts +2 -1
- package/package.json +1 -1
package/dist/Type.d.ts
CHANGED
|
@@ -59,9 +59,9 @@ type _Type = {
|
|
|
59
59
|
};
|
|
60
60
|
};
|
|
61
61
|
type Arg<This extends _Type, Args = This['names'] & This['constraints'], O extends PropertyKey = FindOptionalKeys<This['constraints'], This['names']>, R extends PropertyKey = Exclude<Norm<Exclude<keyof Args, ArrayKeys>>, O>> = {
|
|
62
|
-
[K in Norm<R>]: ArgVal<This, K>;
|
|
62
|
+
[K in Norm<R> as `${K & number}` | K]: ArgVal<This, K>;
|
|
63
63
|
} & {
|
|
64
|
-
[K in Norm<O>]?: ArgVal<This, K>;
|
|
64
|
+
[K in Norm<O> as `${K & number}` | K]?: ArgVal<This, K>;
|
|
65
65
|
};
|
|
66
66
|
type FindOptionalKeys<Constraints, Names, O = Int<OptionalKeys<Constraints>>> = O | (keyof {
|
|
67
67
|
[K in keyof Names as Names[K] extends O ? K : never]: never;
|
package/dist/unwrap.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { inferArgs } from './inferArgs';
|
|
|
4
4
|
import { Generic, _apply, _Type } from './apply';
|
|
5
5
|
import { TypesMap } from './TypesMap';
|
|
6
6
|
import { Tuple, ReadonlyTuple, Array, ReadonlyArray } from './free-types';
|
|
7
|
+
type ArrayURIs = 'Tuple' | 'ReadonlyTuple' | 'Array' | 'ReadonlyArray';
|
|
7
8
|
type Search = _Type | SearchList;
|
|
8
9
|
type SearchList = _Type[] | Record<string, _Type> | Interface;
|
|
9
10
|
type Interface = {
|
|
@@ -22,7 +23,7 @@ declare global {
|
|
|
22
23
|
}
|
|
23
24
|
export { unwrap, Unwrapped, Search };
|
|
24
25
|
/** Decompose a type into its constituents */
|
|
25
|
-
type unwrap<T, From extends Search = TypesMap
|
|
26
|
+
type unwrap<T, From extends Search = Omit<TypesMap, ArrayURIs>> = IsAny<T> extends true ? Any : (T extends readonly unknown[] ? From extends _Type | _Type[] ? null : unwrapLists<T> : null) extends infer R extends Unwrapped ? R : _unwrap<T, From extends _Type ? [From] : From>;
|
|
26
27
|
type unwrapLists<T extends readonly unknown[]> = T extends unknown[] ? any[] extends T ? Unwrapped<'Array', Array, [T[0]]> : Unwrapped<'Tuple', Tuple, T> : readonly any[] extends T ? Unwrapped<'ReadonlyArray', ReadonlyArray, [T[0]]> : Unwrapped<'ReadonlyTuple', ReadonlyTuple, Mutable<T>>;
|
|
27
28
|
type Mutable<T> = {
|
|
28
29
|
-readonly [K in keyof T]: T[K];
|
package/package.json
CHANGED