diff --git a/src/query/test.ts b/src/query/test.ts index 0bc647ae..2ee2ec9a 100644 --- a/src/query/test.ts +++ b/src/query/test.ts @@ -91,6 +91,18 @@ describe('query', () => { ]) }) + it('type checks the fields', async () => { + type Location = { mapId: string; name: string; address?: { city: string } } + const locations = collection('locations') + + await Promise.all([ + // @ts-expect-error + query(locations, [where(['adddddress', 'city'], '==', 'New York')]), + // No errors, even though the address is optional + query(locations, [where(['address', 'city'], '==', 'New York')]) + ]) + }) + it('allows to query using array-contains filter', async () => { type Tag = 'pets' | 'cats' | 'dogs' | 'food' | 'hotdogs' type Post = { blogId: string; title: string; tags: Tag[] } diff --git a/test/utils.ts b/test/utils.ts index 595552e8..b669fab8 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -1,4 +1,4 @@ -export function assertType(value: T): asserts value is T {} +export function assertType(value: Type) {} export type TypeEqual = Exclude extends never ? Exclude extends never