Sync typescript types to 0.2.2

This commit is contained in:
EncodedVenom 2024-07-07 15:33:18 -04:00
parent 4e9aa2ced0
commit bc61553132
No known key found for this signature in database
GPG key ID: 55A4643DA68078EF

24
src/index.d.ts vendored
View file

@ -1,5 +1,20 @@
type Query<T extends unknown[]> = { type Query<T extends unknown[]> = {
without: (...components: Entity[]) => Query<T>;
/**
* this: Query<T> is necessary to use a colon instead of a period for emits.
*/
/**
* Modifies the Query to exclude specified components
* @param components The components to exclude
* @returns Modified Query
*/
without: (this: Query<T>, ...components: Entity[]) => Query<T>;
/**
* Modifies component data with a callback function
* @param fn The function to modify data
*/
replace: (this: Query<T>, fn: (...components: T) => T extends [infer U] ? U : LuaTuple<T>) => void
} & IterableFunction<LuaTuple<[Entity, ...T]>>; } & IterableFunction<LuaTuple<[Entity, ...T]>>;
// Utility Types // Utility Types
@ -126,7 +141,7 @@ export class World {
/** /**
* Searches the world for entities that match a given query * Searches the world for entities that match a given query
* @param components Queried Components * @param components Queried Components
* @returns Iterable function * @returns Query
*/ */
query<T extends Entity[]>(...components: T): Query<InferComponents<T>>; query<T extends Entity[]>(...components: T): Query<InferComponents<T>>;
} }
@ -146,6 +161,11 @@ export const pair: (pred: Entity, obj: Entity) => Entity;
*/ */
export const IS_PAIR: (e: Entity) => boolean; export const IS_PAIR: (e: Entity) => boolean;
/**
* Built-in Component used to find every component id
*/
export const Component: Entity;
export const OnAdd: Entity; export const OnAdd: Entity;
export const OnRemove: Entity; export const OnRemove: Entity;
export const OnSet: Entity; export const OnSet: Entity;