Skip to content

Commit 7cc0e7c

Browse files
committed
fix(entity): update EntityId type parameters for clarity
1 parent 4c96bff commit 7cc0e7c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare const __entityIdTypeTag: unique symbol;
1717
* - Entity IDs: 1024+
1818
* - Relation IDs: negative numbers encoding component and entity associations
1919
*/
20-
export type EntityId<T = void, U = unknown> = number & {
20+
export type EntityId<T = unknown, U = unknown> = number & {
2121
readonly [__componentTypeMarker]: T;
2222
readonly [__entityIdTypeTag]: U;
2323
};

src/world.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ export class World {
157157
* Create a new entity
158158
* @returns The ID of the newly created entity
159159
*/
160-
new(): EntityId {
160+
new<T = void>(): EntityId<T> {
161161
const entityId = this.entityIdManager.allocate();
162162
// Create empty archetype for entities with no components
163163
let emptyArchetype = this.ensureArchetype([]);
164164
emptyArchetype.addEntity(entityId, new Map());
165165
this.entityToArchetype.set(entityId, emptyArchetype);
166-
return entityId;
166+
return entityId as EntityId<T>;
167167
}
168168

169169
/**

0 commit comments

Comments
 (0)