Skip to content

fix(ecs): update() accepts undefined to remove a required component - #223

Merged
krisnye merged 2 commits into
mainfrom
krisnye/type-fix
Oct 22, 2026
Merged

krisnye merged 2 commits into
mainfrom
krisnye/type-fix

Conversation

@krisnye

@krisnye krisnye commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

update(entity, { component: undefined }) removes a component at runtime. But under exactOptionalPropertyTypes, EntityUpdateValues<C> = Partial<Omit<C, "id">> only makes each key optional and rejects an explicit undefined. Removing a required component therefore needed a cast at the call site.

  • EntityUpdateValues<C> now explicitly accepts undefined for each value: { [K in keyof Omit<C, "id">]?: C[K] | undefined }. The core store, public store, transactional store and transaction ops all use this type, so all of them are fixed.
  • Additive: without exactOptionalPropertyTypes the type is identical to before. No runtime change.
  • Regression guard: a new packages/data/type-tests/exact-optional project compiled with exactOptionalPropertyTypes, referenced from packages/data/tsconfig.json so tsc -b runs it. It checks only against the built .d.ts, so the rest of the package isn't held to the stricter flag. The test failed (TS2379) on the old type and passes on the new one, and a wrong value type is still rejected.
  • Version bump to 0.10.29.

Test plan

  • Clean pnpm -r run typecheck (tsbuildinfo cleared)
  • pnpm run lint
  • packages/data tests: 301 files / 3637 tests pass
  • New type test proven red on the old type, green on the new one

🤖 Generated with Claude Code

krisnye and others added 2 commits October 22, 2026 10:28
…nder exactOptionalPropertyTypes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@krisnye
krisnye merged commit 78b4554 into main Oct 22, 2026
3 checks passed
@krisnye
krisnye deleted the krisnye/type-fix branch October 22, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant