0.1.13 #18

Merged
Thilawyn merged 359 commits from next into master 2025-06-18 00:12:19 +02:00
2 changed files with 44 additions and 5 deletions
Showing only changes of commit 8252b6cbdf - Show all commits

View File

@@ -1,10 +1,28 @@
import type { Effect } from "effect"
import * as ReffuseContext from "./ReffuseContext.js"
import * as Reffuse from "./Reffuse.js"
import type { Simplify } from "effect/Types"
import type { Merge, StaticType } from "./types.js"
const make = <T extends object>(extension: T) =>
<R extends typeof Reffuse.Reffuse>(base: R) => {
const make = <Ext extends object>(extension: Ext) =>
<
BaseClass extends typeof Reffuse.Reffuse<R>,
R,
>(
base: BaseClass & typeof Reffuse.Reffuse<R>
): (
{ new(): Merge<InstanceType<BaseClass>, Ext> } &
StaticType<BaseClass>
) => {
const class_ = class extends base {}
return class_
}
const cls = make({
prout<R>(this: Reffuse.Reffuse<R>) {}
})(Reffuse.Reffuse)
class Cls extends cls {}
const cls2 = make({
aya() {}
})(cls)

View File

@@ -0,0 +1,21 @@
/**
* Extracts the common keys between two types
*/
export type CommonKeys<A, B> = Extract<keyof A, keyof B>
/**
* Obtain the static members type of a constructor function type
*/
export type StaticType<T extends abstract new (...args: any) => any> = Omit<T, "prototype">
export type Extend<Super, Self> =
Extendable<Super, Self> extends true
? Omit<Super, CommonKeys<Self, Super>> & Self
: never
export type Extendable<Super, Self> =
Pick<Self, CommonKeys<Self, Super>> extends Pick<Super, CommonKeys<Self, Super>>
? true
: false
export type Merge<Super, Self> = Omit<Super, CommonKeys<Self, Super>> & Self