Comparing version 0.0.1-21 to 0.0.1-22
@@ -9,3 +9,2 @@ import type { Denominalize, TypeInMediumsPartial, __nominal, __type } from './type'; | ||
}; | ||
export declare type UnionToIntersection<TUnion> = (TUnion extends unknown ? (_: TUnion) => unknown : never) extends (_: infer TIntersection) => unknown ? TIntersection : never; | ||
export declare type MediumTypesPackedType<TMediumTypes, TFallback = never> = TMediumTypes extends { | ||
@@ -12,0 +11,0 @@ packed: infer TPacked; |
@@ -1,2 +0,2 @@ | ||
import type { TupleInMedium, UnionToIntersection } from '../@internal'; | ||
import type { TupleInMedium } from '../@internal'; | ||
import type { TypeInMediumsPartial } from './type'; | ||
@@ -18,5 +18,9 @@ import { Type, __type_kind } from './type'; | ||
]>(...Types: TTypeTuple): IntersectionType<TTypeTuple>; | ||
declare type IntersectionInMediums<TTypeTuple extends TypeInMediumsPartial[]> = { | ||
[TMediumName in XValue.UsingName]: UnionToIntersection<TupleInMedium<TTypeTuple, TMediumName>[number]>; | ||
export declare type IntersectionInMediums<TTypeTuple extends TypeInMediumsPartial[]> = { | ||
[TMediumName in XValue.UsingName]: __Intersection<TupleInMedium<TTypeTuple, TMediumName>>; | ||
}; | ||
declare type __Intersection<TTuple extends unknown[]> = TTuple extends [ | ||
infer T, | ||
...infer TRestTuple | ||
] ? T & __Intersection<TRestTuple> : unknown; | ||
export {}; |
@@ -12,3 +12,3 @@ import { OptionalType } from './optional-type'; | ||
} | ||
export declare function object<TTypeDefinition extends Record<string, TypeInMediumsPartial>>(definition: TTypeDefinition): ObjectType<TTypeDefinition>; | ||
export declare function object<TDefinition extends Record<string, TypeInMediumsPartial>>(definition: TDefinition): ObjectType<TDefinition>; | ||
declare type ObjectInMediums<TDefinition extends Record<string, TypeInMediumsPartial>> = { | ||
@@ -21,3 +21,5 @@ [TMediumName in XValue.UsingName]: ObjectInMedium<TDefinition, TMediumName>; | ||
[TKey in KeyOfNonOptional<TDefinition>]: TDefinition[TKey][__type_in_mediums][TMediumName]; | ||
}; | ||
} extends infer T ? { | ||
[TKey in keyof T]: T[TKey]; | ||
} : never; | ||
declare type KeyOfOptional<TType> = Extract<{ | ||
@@ -24,0 +26,0 @@ [TKey in keyof TType]: TType[TKey] extends TypeKindPartial<'optional'> ? TKey : never; |
{ | ||
"name": "x-value", | ||
"version": "0.0.1-21", | ||
"version": "0.0.1-22", | ||
"repository": "https://github.com/vilic/x-value.git", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -31,8 +31,2 @@ import type { | ||
export type UnionToIntersection<TUnion> = ( | ||
TUnion extends unknown ? (_: TUnion) => unknown : never | ||
) extends (_: infer TIntersection) => unknown | ||
? TIntersection | ||
: never; | ||
export type MediumTypesPackedType< | ||
@@ -39,0 +33,0 @@ TMediumTypes, |
@@ -1,2 +0,2 @@ | ||
import type {TupleInMedium, UnionToIntersection} from '../@internal'; | ||
import type {TupleInMedium} from '../@internal'; | ||
import {merge} from '../@internal'; | ||
@@ -106,6 +106,13 @@ import type {Medium} from '../medium'; | ||
type IntersectionInMediums<TTypeTuple extends TypeInMediumsPartial[]> = { | ||
[TMediumName in XValue.UsingName]: UnionToIntersection< | ||
TupleInMedium<TTypeTuple, TMediumName>[number] | ||
export type IntersectionInMediums<TTypeTuple extends TypeInMediumsPartial[]> = { | ||
[TMediumName in XValue.UsingName]: __Intersection< | ||
TupleInMedium<TTypeTuple, TMediumName> | ||
>; | ||
}; | ||
type __Intersection<TTuple extends unknown[]> = TTuple extends [ | ||
infer T, | ||
...infer TRestTuple, | ||
] | ||
? T & __Intersection<TRestTuple> | ||
: unknown; |
@@ -207,4 +207,4 @@ import {toString} from '../@internal'; | ||
export function object< | ||
TTypeDefinition extends Record<string, TypeInMediumsPartial>, | ||
>(definition: TTypeDefinition): ObjectType<TTypeDefinition> { | ||
TDefinition extends Record<string, TypeInMediumsPartial>, | ||
>(definition: TDefinition): ObjectType<TDefinition> { | ||
return new ObjectType(definition); | ||
@@ -225,3 +225,5 @@ } | ||
[TKey in KeyOfNonOptional<TDefinition>]: TDefinition[TKey][__type_in_mediums][TMediumName]; | ||
}; | ||
} extends infer T | ||
? {[TKey in keyof T]: T[TKey]} | ||
: never; | ||
@@ -228,0 +230,0 @@ type KeyOfOptional<TType> = Extract< |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4024
183632