Commit f3593b0
committed
fix(ecs): type IEngine.removeEntity as boolean, matching what it returns
Review follow-up. The tests assert that removeEntity returns false for a
refused reserved-entity removal, but IEngine declared it `void`, so no caller
could act on that without a cast — `if (!engine.removeEntity(e))` does not
compile against a void return.
The mismatch predates this branch: main already ended removeEntity with
`return entityContainer.removeEntity(entity)`, and IEntityContainer has
always typed that as boolean. The API report shows both side by side, one
`void` and one `boolean`. What changed here is that the value became
meaningful — false now specifically means "refused, components untouched" —
so this is the right place to stop the type lying about it.
Non-breaking: widening a return type does not affect callers that ignore it,
and nothing implements IEngine. The only `Pick<IEngine, ... 'removeEntity'>`
consumers are removeEntityWithChildren / removeNetworkEntityChildrens in
tree.ts, both fed the internal removeEntity, which already returns boolean.
removeEntityWithChildren is deliberately left `void`: it delegates to
removeNetworkEntityChildrens, which is genuinely void, and iterates a tree
where a per-entity result has no single meaning.
Public API surface changes by exactly one line, regenerated via `make build`:
- removeEntity(entity: Entity): void;
+ removeEntity(entity: Entity): boolean;
Bundle snapshots are unchanged, as expected for a types-only edit. Full suite
green: 160 suites, 1216 tests.1 parent 5c171f3 commit f3593b0
2 files changed
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
95 | 105 | | |
96 | | - | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1461 | 1461 | | |
1462 | 1462 | | |
1463 | 1463 | | |
1464 | | - | |
| 1464 | + | |
1465 | 1465 | | |
1466 | 1466 | | |
1467 | 1467 | | |
| |||
0 commit comments