You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently it's typed as returning ReadonlyArray<[Entity<T>, ...T]>, but the return value actually has an __iter metamethod that interferes with things.
The metamethod lets you do this in Lua (the same as iterating a query without snapshotting it):
forentityId, health, playerinworld:query(Health, Player):snapshot() do
But in TS if we do something like .snapshot().mapFiltered(([id, health, player]) => {}), we'll generate something like:
And because of __iter, _k will end up being the id instead of the index and _v will be health, not [id, health, player], and so the callback will not get the value that the types think it will
The text was updated successfully, but these errors were encountered:
Currently it's typed as returning
ReadonlyArray<[Entity<T>, ...T]>
, but the return value actually has an__iter
metamethod that interferes with things.The metamethod lets you do this in Lua (the same as iterating a query without snapshotting it):
But in TS if we do something like
.snapshot().mapFiltered(([id, health, player]) => {})
, we'll generate something like:And because of
__iter
,_k
will end up being the id instead of the index and_v
will be health, not[id, health, player]
, and so the callback will not get the value that the types think it willThe text was updated successfully, but these errors were encountered: