Add deleted flag to removed handler typings (#288)

* update types

* change "StatefulHook" to "HookWithData" and "StatelessHook" to "HookWithDeleted"

* Update deleted flag type
This commit is contained in:
m10 2025-12-07 14:10:57 -05:00 committed by Ukendio
parent fbc4f0f3aa
commit df454c75a3

20
src/jecs.d.ts vendored
View file

@ -172,8 +172,8 @@ export class World {
* @param hook The hook to install. * @param hook The hook to install.
* @param value The hook callback. * @param value The hook callback.
*/ */
set<T>(component: Entity<T>, hook: StatefulHook, value: (e: Entity, id: Id<T>, data: T) => void): void; set<T>(component: Entity<T>, hook: HookWithData, value: (e: Entity, id: Id<T>, data: T) => void): void;
set<T>(component: Entity<T>, hook: StatelessHook, value: (e: Entity, id: Id<T>) => void): void; set<T>(component: Entity<T>, hook: HookWithDeleted, value: (e: Entity, id: Id<T>, deleted?: true) => void): void;
/** /**
* Assigns a value to a component on the given entity. * Assigns a value to a component on the given entity.
* @param entity The target entity. * @param entity The target entity.
@ -277,7 +277,7 @@ export class World {
added<T>(component: Entity<T>, listener: (e: Entity, id: Id<T>, value: T) => void): () => void; added<T>(component: Entity<T>, listener: (e: Entity, id: Id<T>, value: T) => void): () => void;
changed<T>(component: Entity<T>, listener: (e: Entity, id: Id<T>, value: T) => void): () => void; changed<T>(component: Entity<T>, listener: (e: Entity, id: Id<T>, value: T) => void): () => void;
removed<T>(component: Entity<T>, listener: (e: Entity, id: Id<T>) => void): () => void; removed<T>(component: Entity<T>, listener: (e: Entity, id: Id<T>, deleted?: true) => void): () => void;
} }
export function world(): World; export function world(): World;
@ -323,16 +323,16 @@ export function pair_second<P, O>(world: World, p: Pair<P, O>): Entity<O>;
export function ECS_PAIR_FIRST(pair: Pair): number; export function ECS_PAIR_FIRST(pair: Pair): number;
export function ECS_PAIR_SECOND(pair: Pair): number; export function ECS_PAIR_SECOND(pair: Pair): number;
type StatefulHook = Entity<<T>(e: Entity<T>, id: Id<T>, data: T) => void> & { type HookWithData = Entity<<T>(e: Entity<T>, id: Id<T>, data: T) => void> & {
readonly __nominal_StatefulHook: unique symbol; readonly __nominal_HookWithData: unique symbol;
}; };
type StatelessHook = Entity<<T>(e: Entity<T>, id: Id<T>) => void> & { type HookWithDeleted = Entity<<T>(e: Entity<T>, id: Id<T>, deleted?: true) => void> & {
readonly __nominal_StatelessHook: unique symbol; readonly __nominal_HookWithDeleted: unique symbol;
}; };
export declare const OnAdd: StatefulHook; export declare const OnAdd: HookWithData;
export declare const OnRemove: StatelessHook; export declare const OnRemove: HookWithDeleted;
export declare const OnChange: StatefulHook; export declare const OnChange: HookWithData;
export declare const ChildOf: Tag; export declare const ChildOf: Tag;
export declare const Component: Tag; export declare const Component: Tag;
export declare const Wildcard: Entity; export declare const Wildcard: Entity;