0.1.0 #1
@@ -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<
|
||||
|
||||
11
src/tests.ts
11
src/tests.ts
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user