This commit is contained in:
38
src/tests.ts
38
src/tests.ts
@@ -1,4 +1,24 @@
|
||||
import { mixTraits } from "./trait"
|
||||
import { AbstractClass } from "type-fest"
|
||||
import { expresses } from "./trait"
|
||||
|
||||
|
||||
function inspectClass(class_: AbstractClass<any, any>) {
|
||||
Object.getOwnPropertyNames(class_).forEach(name => {
|
||||
console.log(
|
||||
"[static]",
|
||||
name,
|
||||
Object.getOwnPropertyDescriptor(class_, name)
|
||||
)
|
||||
})
|
||||
|
||||
Object.getOwnPropertyNames(class_.prototype).forEach(name => {
|
||||
console.log(
|
||||
"[prototype]",
|
||||
name,
|
||||
Object.getOwnPropertyDescriptor(class_.prototype, name)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
abstract class Identified<ID> {
|
||||
@@ -9,12 +29,18 @@ abstract class Identified<ID> {
|
||||
}
|
||||
}
|
||||
|
||||
class ImplementsIdentifiable<ID> extends Identified<ID> {
|
||||
id!: ID
|
||||
}
|
||||
|
||||
|
||||
abstract class Permissible {
|
||||
static readonly defaultPermissions: string[] = []
|
||||
permissions: string[] = []
|
||||
}
|
||||
|
||||
|
||||
class User extends mixTraits(
|
||||
class User extends expresses(
|
||||
Identified<bigint>,
|
||||
// Identified<string>,
|
||||
Permissible,
|
||||
@@ -27,11 +53,13 @@ class User extends mixTraits(
|
||||
}
|
||||
}
|
||||
|
||||
console.log(Permissible.constructor())
|
||||
console.log(new User(BigInt(1)))
|
||||
|
||||
// console.log(Permissible.constructor())
|
||||
// console.log(Object.getOwnPropertyNames(User.prototype))
|
||||
|
||||
const user1 = new User(BigInt(1))
|
||||
const user2 = new User(BigInt(2))
|
||||
// const user1 = new User(BigInt(1))
|
||||
// const user2 = new User(BigInt(2))
|
||||
|
||||
// console.log(user1.equals(user2))
|
||||
// console.log(user1.permissions)
|
||||
|
||||
Reference in New Issue
Block a user