Skip to content
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

fix(firestore, types): allow FieldValues, Date and Timestamp in doc set and update #5901

Merged
merged 2 commits into from
Dec 13, 2021
Merged

fix(firestore, types): allow FieldValues, Date and Timestamp in doc set and update #5901

merged 2 commits into from
Dec 13, 2021

Conversation

Yonom
Copy link
Contributor

@Yonom Yonom commented Dec 2, 2021

Description

This is a fix for Typescript types to remove the following two errors:

type BarType = {
  myDate: FirebaseFirestoreTypes.Timestamp;
};

const docRef = firebase.firestore().doc<BarType>(`${COLLECTION}/bar`);
await docRef.set({
  myDate: new Date(), // TS2739 Type 'Date' is missing the following properties from type 'Timestamp', [...]
});
await docRef.set({
  myDate: firestore.FieldValue.serverTimestamp(),// TS2739 Type 'FieldValue' is missing the following properties from type 'Timestamp', [...]
});

Related issues

Release Summary

fix(firestore): Adjust types to allow setting FieldValues and allow Date in place of Timestamp

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
    • Yes
  • My change supports the following platforms;
    • Android
    • iOS
  • My change includes tests;
    • e2e tests added or updated in packages/\*\*/e2e
    • jest tests added or updated in packages/\*\*/__tests__
  • I have updated TypeScript types that are affected by my change.
  • This is a breaking change;
    • Yes
    • No

Test Plan

Run tests.

@vercel
Copy link

vercel bot commented Dec 2, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

react-native-firebase-next – ./website_modular

🔍 Inspect: https://vercel.com/invertase/react-native-firebase-next/D9mD8xtQ31vHnakkpXipt8boBxJr
✅ Preview: Canceled

react-native-firebase – ./

🔍 Inspect: https://vercel.com/invertase/react-native-firebase/FBNoDvWXYhU2yEBzxtSRQEHu6JqJ
✅ Preview: https://react-native-firebase-git-fork-yonom-firestore-fd8227-invertase.vercel.app

@vercel vercel bot temporarily deployed to Preview – react-native-firebase-next December 2, 2021 18:45 Inactive
@Yonom Yonom changed the title feat(firestore): Adjust types to allow setting FieldValues and allow Date in place of Timestamp fix(firestore): Adjust types to allow setting FieldValues and allow Date in place of Timestamp Dec 2, 2021
@codecov
Copy link

codecov bot commented Dec 13, 2021

Codecov Report

Merging #5901 (abd553c) into main (f24a204) will increase coverage by 28.01%.
The diff coverage is n/a.

❗ Current head abd553c differs from pull request most recent head a6142e2. Consider uploading reports for the commit a6142e2 to get more accurate results

@@              Coverage Diff              @@
##               main    #5901       +/-   ##
=============================================
+ Coverage     24.61%   52.62%   +28.01%     
- Complexity        0      620      +620     
=============================================
  Files            97      208      +111     
  Lines          4230    10154     +5924     
  Branches       1026     1612      +586     
=============================================
+ Hits           1041     5343     +4302     
- Misses         2587     4553     +1966     
+ Partials        602      258      -344     

Copy link
Collaborator

@mikehardy mikehardy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM after review (and note upstream types are here https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore-types/index.d.ts though we are a little divergent and perhaps they are either not handling this well or are handling it via any-ification)

I've seen this myself though and your test lends me confidence. I have a medium success ratio track record with type changes, sometimes a tiny change even intended to be non-breaking results in something else popping up from someone else, so we'll have to keep eyes/ears open post release. Should be fine though? 🤞

@mikehardy mikehardy added the Workflow: Pending Merge Waiting on CI or similar label Dec 13, 2021
@mikehardy mikehardy changed the title fix(firestore): Adjust types to allow setting FieldValues and allow Date in place of Timestamp fix(firestore, types): allow using FieldValues, Date and Timestamp in doc set and update Dec 13, 2021
@mikehardy mikehardy changed the title fix(firestore, types): allow using FieldValues, Date and Timestamp in doc set and update fix(firestore, types): allow FieldValues, Date and Timestamp in doc set and update Dec 13, 2021
@mikehardy mikehardy removed the Workflow: Pending Merge Waiting on CI or similar label Dec 13, 2021
@mikehardy mikehardy merged commit 5f4eadf into invertase:main Dec 13, 2021
@Yonom Yonom deleted the firestore-set-date-or-fieldvalue branch December 14, 2021 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants