free-types-core 0.8.0 → 0.8.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/Licence CHANGED
File without changes
package/README.md CHANGED
File without changes
package/dist/Const.d.ts CHANGED
File without changes
package/dist/Const.js CHANGED
File without changes
File without changes
package/dist/Remaining.js CHANGED
File without changes
package/dist/Replace.d.ts CHANGED
File without changes
package/dist/Replace.js CHANGED
File without changes
package/dist/Type.d.ts CHANGED
File without changes
package/dist/Type.js CHANGED
File without changes
File without changes
package/dist/TypesMap.js CHANGED
File without changes
package/dist/apply.d.ts CHANGED
File without changes
package/dist/apply.js CHANGED
File without changes
File without changes
File without changes
package/dist/helpers.d.ts CHANGED
File without changes
package/dist/helpers.js CHANGED
File without changes
package/dist/hkt.d.ts CHANGED
File without changes
package/dist/hkt.js CHANGED
File without changes
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
File without changes
File without changes
package/dist/inferArgs.js CHANGED
File without changes
package/dist/partial.d.ts CHANGED
File without changes
package/dist/partial.js CHANGED
File without changes
package/dist/unwrap.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArrayKeys, Eq } from './utils';
1
+ import { ArrayKeys, Eq, And, Extends, Not } from './utils';
2
2
  import { Type } from './Type';
3
3
  import { inferArgs } from './inferArgs';
4
4
  import { Generic, apply } from './apply';
@@ -22,7 +22,7 @@ declare global {
22
22
  }
23
23
  export { unwrap, Unwrapped, Search };
24
24
  /** Decompose a type into its constituents */
25
- declare type unwrap<T, From extends Search = TypesMap> = T extends readonly unknown[] ? unwrapLists<T> : _unwrap<T, From extends Type ? [From] : From>;
25
+ declare type unwrap<T, From extends Search = TypesMap> = And<Extends<T, readonly unknown[]>, Not<Extends<From, Type | Type[]>>> extends true ? unwrapLists<T extends readonly unknown[] ? T : never> : _unwrap<T, From extends Type ? [From] : From>;
26
26
  declare type unwrapLists<T> = T extends unknown[] ? T extends [unknown, ...unknown[]] ? Unwrapped<'Tuple', Tuple, T> : Unwrapped<'Array', Array, [T[0]]> : T extends readonly [unknown, ...unknown[]] ? Unwrapped<'ReadonlyTuple', ReadonlyTuple, Mutable<T>> : Unwrapped<'ReadonlyArray', ReadonlyArray, [(T & unknown[])[0]]>;
27
27
  declare type Mutable<T> = {
28
28
  -readonly [K in keyof T]: K extends ArrayKeys ? T[K] : T[K];
package/dist/unwrap.js CHANGED
File without changes
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { Natural, Prev, Next, Subtract };
2
2
  export { ArrayKeys, Slice, ToTuple, Tuple, Head, Tail, Last, Init };
3
- export { Extends, Eq, IsUnknown, IsAny, IsOptional };
3
+ export { Extends, Eq, And, Not, IsUnknown, IsAny, IsOptional };
4
4
  declare type Natural = [0, ..._Next];
5
5
  declare type Prev<I extends number> = number extends I ? number : number & _Prev[I];
6
6
  declare type _Prev = [never, ...Natural];
@@ -27,5 +27,8 @@ declare type IsUnknown<T> = unknown extends T ? IsAny<T> extends false ? true :
27
27
  declare type IsAny<T> = Extends<T | anything, T & anything>;
28
28
  declare type Extends<A, B> = [A] extends [B] ? true : false;
29
29
  declare type Eq<A, B> = [A] extends [B] ? [B] extends [A] ? true : false : false;
30
+ declare type And<A, B> = Fork<A, Fork<B, B, false>, false>;
31
+ declare type Fork<P, T, F> = P extends false ? F : T;
32
+ declare type Not<T> = Extends<T, false>;
30
33
  declare const thing: unique symbol;
31
34
  declare type anything = typeof thing;
package/dist/utils.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-types-core",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "A type-level library enabling the creation and the manipulation of type constructors which are detached from their type parameters.",
5
5
  "keywords:": [
6
6
  "higher kinded type",