Refactoring
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Julien Valverdé
2023-12-13 19:55:14 +01:00
parent 5b5114e5f5
commit d8e509f540
3 changed files with 110 additions and 60 deletions

View File

@@ -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)