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 if you've got a list of reacted entities, and want to do an reactedEntities.includes(someOtherEntity), you basically always get a type error and have to as any around it.
function asEntities<T extends Entity>(
entities: ReadonlyArray<Omit<Reacted<T, any>, "fullNonReactiveAccess">>,
): readonly T[] {
return entities as unknown as T[];
}
describe("types", () => {
it("can do includes checks with entities", () => {
// Given an array of reacted entities
const books: Reacted<Book, "comments">[] = [];
// And a regular book
const b: Book = null!;
// Then we can do includes checks
expect(asEntities(books).includes(b)).toBe(false);
});
it("can do includes checks with other reactions", () => {
// Given an array of reacted entities
const books: Reacted<Book, "comments">[] = [];
// And a different reacted book
const b: Reacted<Book, {}> = null!;
// Then we can do includes checks
expect(asEntities(books).includes(b)).toBe(false);
// And we can't do it with an author
const a: Reacted<Author, {}> = null!;
expect(asEntities(books).includes(a)).toBe(false);
});
});
The text was updated successfully, but these errors were encountered:
Currently if you've got a list of reacted entities, and want to do an
reactedEntities.includes(someOtherEntity)
, you basically always get a type error and have toas any
around it.The text was updated successfully, but these errors were encountered: