makeSchemableClass work

This commit is contained in:
Julien Valverdé
2023-12-31 01:45:40 +01:00
parent a8e2fe7474
commit 680c3d8617
2 changed files with 5 additions and 2 deletions

View File

@@ -32,7 +32,7 @@ export function makeSchemableClass<
schemaWithDefaultValues, schemaWithDefaultValues,
} as const satisfies SchemableConfig } as const satisfies SchemableConfig
return class { return class SchemableObject {
static readonly $schemableConfig = $schemableConfig static readonly $schemableConfig = $schemableConfig
static readonly schema = schema static readonly schema = schema
static readonly schemaWithDefaultValues = schemaWithDefaultValues static readonly schemaWithDefaultValues = schemaWithDefaultValues

View File

@@ -13,4 +13,7 @@ const UserSchemaObject = makeSchemableClass({ schema: UserSchema })
class User extends UserSchemaObject {} class User extends UserSchemaObject {}
const user1 = new User({ id: 1n }) const user1 = new User({ id: 1n })
const user2 = newSchemable(User) const user2 = newSchemable(User, { id: 2n })
console.log(user1)
console.log(user2)