mirror of
https://github.com/Ukendio/jecs.git
synced 2025-09-23 00:29:18 +00:00
Make optionals not required in bulk_insert (#281)
Some checks are pending
Some checks are pending
* Allow any amount of undefined in bulk_insert * Also handle unknown
This commit is contained in:
parent
35cb0bca4e
commit
e2ab3be3e5
1 changed files with 8 additions and 1 deletions
9
jecs.d.ts
vendored
9
jecs.d.ts
vendored
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue