Open Honga1 opened 3 years ago
Hi :D. I'm exercising the library pretty well at the moment. Well done on it. So far I've only ran into type issues with things like twice extending the Facet class, which wouldn't then carry props into the react component.
https://github.com/dustinlacewell/react-ecs/blob/d06850bea1847f87b9b8edefa62693790ded7843/libs/core/src/lib/Query.ts#L20
Regarding the line above: If I have a query
// Note 'hasAny' const query = useQuery((entity) => entity.hasAny(FacetA, FacetB))
Then follow up with a loop:
query.loop([FacetA, FacetB], (entity, [facetA, facetB]) => { assert(facetA !== undefined) assert(facetB !== undefined) }
Would likely throw if I only added one of the two facets FacetA FacetB. Even though they are definitely asserted on your get(t)! part.
FacetA
FacetB
get(t)!
Indeed I can reproduce this here: https://codesandbox.io/s/zealous-nobel-q5id3?file=/src/App.tsx
One of:
!
| undefined
fluff
Hi :D. I'm exercising the library pretty well at the moment. Well done on it. So far I've only ran into type issues with things like twice extending the Facet class, which wouldn't then carry props into the react component.
Line causing type error
https://github.com/dustinlacewell/react-ecs/blob/d06850bea1847f87b9b8edefa62693790ded7843/libs/core/src/lib/Query.ts#L20
How I found this
Regarding the line above: If I have a query
Then follow up with a loop:
Would likely throw if I only added one of the two facets
FacetA
FacetB
. Even though they are definitely asserted on yourget(t)!
part.Indeed I can reproduce this here: https://codesandbox.io/s/zealous-nobel-q5id3?file=/src/App.tsx
Suggested fixes
One of:
!
on the get statement| undefined