Make optionals not required in bulk_insert (#281)
Some checks are pending
analysis / Run Luau Analyze (push) Waiting to run
deploy-docs / build (push) Waiting to run
deploy-docs / Deploy (push) Blocked by required conditions
publish-npm / publish (push) Waiting to run
unit-testing / Run Luau Tests (push) Waiting to run

* Allow any amount of undefined in bulk_insert

* Also handle unknown
This commit is contained in:
dai 2025-09-21 19:11:14 +02:00 committed by GitHub
parent 35cb0bca4e
commit e2ab3be3e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

9
jecs.d.ts vendored
View file

@ -350,12 +350,19 @@ export type ComponentRecord = {
export function component_record(world: World, id: Id): ComponentRecord;
type TagToUndefined<T> = T extends TagDiscriminator ? undefined : T
type TrimOptional<T extends unknown[]> = T extends [...infer L, infer R]
? unknown extends R
? L | T | TrimOptional<L>
: R extends undefined
? L | T | TrimOptional<L>
: T
: T
export function bulk_insert<const C extends Id[]>(
world: World,
entity: Entity,
ids: C,
values: { [K in keyof C]: TagToUndefined<InferComponent<C[K]>> },
values: TrimOptional<{ [K in keyof C]: TagToUndefined<InferComponent<C[K]>> }>,
): void;
export function bulk_remove(world: World, entity: Entity, ids: Id[]): void;