Allow world.add() to accept component, add world.entity overload (#225)

* fix: allow components for world.add in typescript

* fix: add overload for world.entity

* build: downgrade deps to v0.6.0

* fix: world.entity accepts entity instead of number

* fix: allow union undefined union to be passed in .add
This commit is contained in:
Junjie 2025-05-17 16:44:22 -07:00 committed by GitHub
parent c030d396af
commit 22877f3fc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

3
jecs.d.ts vendored
View file

@ -120,6 +120,7 @@ export class World {
* @returns An entity (Tag) with no data.
*/
entity(): Tag;
entity<T extends Entity>(id: T): InferComponent<T> extends undefined ? Tag : T;
/**
* Creates a new entity in the first 256 IDs, typically used for static
@ -148,7 +149,7 @@ export class World {
* @param entity The target entity.
* @param component The component (or tag) to add.
*/
add(entity: Entity, component: Id<undefined>): void;
add<C>(entity: Entity, component: undefined extends InferComponent<C> ? C : Id<undefined>): void;
/**
* Assigns a value to a component on the given entity.

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "@rbxts/jecs",
"version": "0.6.0-rc.1",
"version": "0.6.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@rbxts/jecs",
"version": "0.6.0-rc.1",
"version": "0.6.0",
"license": "MIT",
"devDependencies": {
"@rbxts/compiler-types": "^2.3.0-types.1",