diff --git a/src/database/Entity.ts b/src/database/Entity.ts index a1338ee..98c5903 100644 --- a/src/database/Entity.ts +++ b/src/database/Entity.ts @@ -2,19 +2,19 @@ import { Guild, GuildManager, GuildMember, GuildMemberManager, User, UserManager export type EntityType = "user" | "guild" | "member"; -export type Entity - = E extends "user" ? User - : E extends "guild" ? Guild - : E extends "member" ? GuildMember - : never; +export type Entity = { + "user": User, + "guild": Guild, + "member": GuildMember, +}[E]; export type AnyEntity = Entity; -export type EntityManager - = E extends "user" ? UserManager - : E extends "guild" ? GuildManager - : E extends "member" ? GuildMemberManager - : never; +export type EntityManager = { + "user": UserManager, + "guild": GuildManager, + "member": GuildMemberManager, +}[E]; export function checkEntityType(entity: Entity, expectedType: E): entity is Entity { switch (expectedType) { diff --git a/src/database/json/Handler.ts b/src/database/json/Handler.ts index 2c7d3d2..0bdda5d 100644 --- a/src/database/json/Handler.ts +++ b/src/database/json/Handler.ts @@ -58,7 +58,7 @@ export const createJsonDatabaseHandler = (options: JsonHandlerOptions): CreateDa } variables ??= {}; - const selected = []; + const selected: Entity[] = []; const defaultSatate = {} as any; await database.bot.importer.forEach('states', state => { diff --git a/src/database/selector/Operator.ts b/src/database/selector/Operator.ts index ea86002..798e4e2 100644 --- a/src/database/selector/Operator.ts +++ b/src/database/selector/Operator.ts @@ -22,7 +22,7 @@ export interface QueryOperators readonly var: (name: ExpressionVariable['name']) => ExpressionVariable; } -export const QueryOperators = >Object.freeze({ +export const QueryOperators = Object.freeze(>{ gt: (l, r) => new ComparisonExpression('gt' as any, l, r), gte: (l, r) => new ComparisonExpression('gte' as any, l, r), lt: (l, r) => new ComparisonExpression('lt' as any, l, r), diff --git a/src/database/selector/Selector.ts b/src/database/selector/Selector.ts index 85a716d..abd58a1 100644 --- a/src/database/selector/Selector.ts +++ b/src/database/selector/Selector.ts @@ -38,7 +38,7 @@ export class Selector { } } -function checkExpression(selector: Selector, expression?: AnyExpression) { +function checkExpression(selector: Selector, expression?: AnyExpression) { expression ??= selector.expression; if (expression instanceof ComparisonExpression) { diff --git a/src/database/state/accessFabrics/JsonModel.ts b/src/database/state/accessFabrics/JsonModel.ts index e978e1f..f501760 100644 --- a/src/database/state/accessFabrics/JsonModel.ts +++ b/src/database/state/accessFabrics/JsonModel.ts @@ -2,7 +2,7 @@ import { assert } from "../../../utils/index.js"; import { StateAccess } from "../State.js"; import { jsonAccess } from "./Json.js"; -export const jsonModelAccess = (modelConstructor: new () => T) => (access: StateAccess) => { +export const jsonModelAccess = (modelConstructor: new () => T) => (access: StateAccess) => { const jAccess = jsonAccess(access); return {