Type Error in Collection when typing query. #5143
Answered
by
Feiyang1
mnlfischer
asked this question in
Q&A
-
Hello, I'm not if it is a bug or wrong implementation. When I type the query: export declare function query<T>(query: Query<T>, ...queryConstraints: QueryConstraint[]): Query<T>; as const q = query<{foo: string}>(
collection(db, 'bar')
); I got the following error Argument of type 'CollectionReference<DocumentData>' is not assignable to parameter of type 'Query<{ foot: string; }>'. This is the collection type declaration: export declare function collection(firestore: FirebaseFirestore, path: string, ...pathSegments: string[]): CollectionReference<DocumentData>; This error occurs in 9.0.0-beta.2 - 9.0.0-beta.6 |
Beta Was this translation helpful? Give feedback.
Answered by
Feiyang1
Jul 13, 2021
Replies: 1 comment 1 reply
-
Yes, you should use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mnlfischer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, you should use
withConverter
instead of typingquery
s directly. It is by design, so that you can't type query arbitrarily which may not be safe at runtime.