-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T
isn't assignable to WithFieldValue<T>
#5661
Comments
@gustavohenke You'll need to tell the TS transpiler that the
See the TS playground link I'm going to mark this issue as closed, but feel free to ask any other questions you may have. |
I don't like that I need to expose Firebase types outside of specific code dealing with Firebase, so I'm keen to fix this. Maybe a definition like below works better? type WithFieldValue<T> = T | (T extends Primitive ? T : {
[K in keyof T]: FieldValue | WithFieldValue<T[K]>
});
type PartialWithFieldValue<T> = Partial<WithFieldValue<T>>; This way, I can submit a PR if this works. |
@gustavohenke I hadn't considered the need to expose Firebase types with the current implementation. That's definitely something we can consider. I'll get back to you in the coming week. |
Thanks for looking into this deeper! |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
Steps to reproduce:
Create a function which takes an argument of type
T
, and inside it call any firestore functions that receiveWithFieldValue
orPartialWithFieldValue
(e.g.setDoc
,addDoc
, etc) with that valueT
.Result is that TypeScript will say nope:
this creates a problem in that every call to these functions require a type cast, which is not ideal.
Relevant Code:
TS playground link
The text was updated successfully, but these errors were encountered: