Commit ed2661ec authored by nanahira's avatar nanahira

add data param to fusion class

parent bff885d4
......@@ -69,6 +69,40 @@ type ClassesToTypes<A extends any[]> = A extends [infer L, ...infer R]
]
: [];
*/
export type FusionClass<A extends AnyClass[]> =
new () => //...args: MatrixToUnionArray<MatrixTwist<ClassesToParams<A>>>
Intersecton<ClassesToTypes<A>>;
type FusionClassType<A extends AnyClass[]> = Intersecton<ClassesToTypes<A>>;
type PartialDeep<T> = T extends
| string
| number
| bigint
| boolean
| null
| undefined
| symbol
| Date
// eslint-disable-next-line @typescript-eslint/ban-types
| Function
? T | undefined
: // Arrays, Sets and Maps and their readonly counterparts have their items made
// deeply partial, but their own instances are left untouched
T extends Array<infer ArrayType>
? Array<PartialDeep<ArrayType>>
: T extends ReadonlyArray<infer ArrayType>
? ReadonlyArray<ArrayType>
: T extends Set<infer SetType>
? Set<PartialDeep<SetType>>
: T extends ReadonlySet<infer SetType>
? ReadonlySet<SetType>
: T extends Map<infer KeyType, infer ValueType>
? Map<PartialDeep<KeyType>, PartialDeep<ValueType>>
: T extends ReadonlyMap<infer KeyType, infer ValueType>
? ReadonlyMap<PartialDeep<KeyType>, PartialDeep<ValueType>>
: // ...and finally, all other objects.
{
[K in keyof T]?: PartialDeep<T[K]>;
};
export type FusionClass<A extends AnyClass[]> = new (
data: PartialDeep<FusionClassType<A>>,
) => //...args: MatrixToUnionArray<MatrixTwist<ClassesToParams<A>>>
FusionClassType<A>;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment