0.1.0 #1

Merged
Thilawyn merged 65 commits from next into master 2024-02-06 03:15:40 +01:00
2 changed files with 13 additions and 6 deletions
Showing only changes of commit 7eb2b950a8 - Show all commits

View File

@@ -13,6 +13,10 @@ class TraitExpression<
readonly traits: Traits,
) {}
then<V>(fn: (e: this) => V): V {
return fn(this)
}
extends(): (
AbstractClass<
Pipe<[
@@ -91,6 +95,7 @@ type ExtendsAndExpressesReturnType<
Super extends AbstractClass<any>,
Traits extends readonly Trait<any, any>[],
> = (
Call<Tuples.IsEmpty, Traits> extends false ?
AbstractMembersExtendable<Super, Traits> extends true ?
ImplInstanceExtendable<Super, Traits> extends true ?
ImplStaticMembersExtendable<Super, Traits> extends true ?
@@ -98,6 +103,7 @@ type ExtendsAndExpressesReturnType<
: "Type conflict between the traits implementation static members and/or the superclass static members."
: "Type conflict between the traits implementation instances and/or the superclass instance."
: "Type conflict between the traits abstract members and/or the superclass instance."
: "Cannot express an empty list of traits."
)
export function extendsAndExpresses<

View File

@@ -48,15 +48,16 @@ class TestSuperclass {
}
const exp = extendsAndExpresses(
const User = extendsAndExpresses(
TestSuperclass,
Identifiable<bigint>(),
// Identifiable<number>()
)
// type ExpImpl = ImplStaticMembersExtendable<typeof TestSuperclass, typeof exp.traits>
class User extends exp.extends() implements Implements<typeof exp> {
).then(e =>
class User
extends e.extends()
implements Implements<typeof e> {
id: bigint = -1n
}
)
new User().id