diff --git a/lib/index.d.ts b/lib/index.d.ts index 119b667..5edf5f5 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -30,8 +30,6 @@ type ArchetypeMap = { type ArchetypeRecord = number; -export type Entity = number & { __nominal_type_dont_use: T } - type EntityIndex = { dense: { [key: i24]: i53 @@ -48,13 +46,19 @@ type Record = { componentRecord: ArchetypeMap, } -type ExtractFromLuaTuple = T extends LuaTuple ? U : never; +type Query = { + without: (...components: Entity[]) => Query; +} & IterableFunction> -type QueryShim = { - without: (...args: ExtractFromLuaTuple) => QueryShim; -} & IterableFunction; +// Utility Types +export type Entity = number & { __nominal_type_dont_use: T } +export type EntityType = T extends Entity ? A : never; +export type InferComponents = A & { + [K in keyof A]: EntityType +}; -interface World { + +export class World { entity(): Entity; component(): Entity; @@ -70,15 +74,9 @@ interface World { get(id: number, component: Entity, component2: Entity, component3: Entity): LuaTuple<[A, B, C]>; get(id: number, component: Entity, component2: Entity, component3: Entity, component4: Entity): LuaTuple<[A, B, C, D]>; - query(...entities: T): QueryShim> + query(...components: T): Query> } -interface WorldConstructor { - new(): World -} - -export const World: WorldConstructor; - export const pair: (pred: Entity, obj: Entity) => Entity; export const OnAdd: Entity;