Detect empty trait arrays
This commit is contained in:
@@ -13,6 +13,10 @@ class TraitExpression<
|
|||||||
readonly traits: Traits,
|
readonly traits: Traits,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
then<V>(fn: (e: this) => V): V {
|
||||||
|
return fn(this)
|
||||||
|
}
|
||||||
|
|
||||||
extends(): (
|
extends(): (
|
||||||
AbstractClass<
|
AbstractClass<
|
||||||
Pipe<[
|
Pipe<[
|
||||||
@@ -91,6 +95,7 @@ type ExtendsAndExpressesReturnType<
|
|||||||
Super extends AbstractClass<any>,
|
Super extends AbstractClass<any>,
|
||||||
Traits extends readonly Trait<any, any>[],
|
Traits extends readonly Trait<any, any>[],
|
||||||
> = (
|
> = (
|
||||||
|
Call<Tuples.IsEmpty, Traits> extends false ?
|
||||||
AbstractMembersExtendable<Super, Traits> extends true ?
|
AbstractMembersExtendable<Super, Traits> extends true ?
|
||||||
ImplInstanceExtendable<Super, Traits> extends true ?
|
ImplInstanceExtendable<Super, Traits> extends true ?
|
||||||
ImplStaticMembersExtendable<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 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 implementation instances and/or the superclass instance."
|
||||||
: "Type conflict between the traits abstract members 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<
|
export function extendsAndExpresses<
|
||||||
|
|||||||
11
src/tests.ts
11
src/tests.ts
@@ -48,15 +48,16 @@ class TestSuperclass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const exp = extendsAndExpresses(
|
const User = extendsAndExpresses(
|
||||||
TestSuperclass,
|
TestSuperclass,
|
||||||
Identifiable<bigint>(),
|
Identifiable<bigint>(),
|
||||||
// Identifiable<number>()
|
// Identifiable<number>()
|
||||||
)
|
).then(e =>
|
||||||
// type ExpImpl = ImplStaticMembersExtendable<typeof TestSuperclass, typeof exp.traits>
|
class User
|
||||||
|
extends e.extends()
|
||||||
class User extends exp.extends() implements Implements<typeof exp> {
|
implements Implements<typeof e> {
|
||||||
id: bigint = -1n
|
id: bigint = -1n
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
new User().id
|
new User().id
|
||||||
|
|||||||
Reference in New Issue
Block a user