-
Notifications
You must be signed in to change notification settings - Fork 153
Rejecting custom types from the API surface #137
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
Conversation
820986f
to
5953eac
Compare
Codecov Report
@@ Coverage Diff @@
## master #137 +/- ##
==========================================
- Coverage 100% 99.94% -0.06%
==========================================
Files 12 12
Lines 1668 1689 +21
==========================================
+ Hits 1668 1688 +20
- Misses 0 1 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some random nits that you can just ignore.
src/document.js
Outdated
options.allowDeletes === 'none' | ||
) { | ||
throw new Error( | ||
'Deletes must appear at the top-level and can only be used in update() or set() with {merge:true}.' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/document.js
Outdated
} else if (obj === FieldValue.SERVER_TIMESTAMP_SENTINEL) { | ||
if (!options.allowServerTimestamps) { | ||
throw new Error( | ||
'ServerTimestamps can only be used in update(), set() and create().' |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/document.js
Outdated
Object.prototype.toString.call(val) + | ||
') to a Firestore Value' | ||
); | ||
validate.throwCustomObjectError(val); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/path.js
Outdated
@@ -484,7 +484,7 @@ class FieldPath extends Path { | |||
static validateFieldPath(fieldPath) { | |||
if (!is.instanceof(fieldPath, FieldPath)) { | |||
if (!is.string(fieldPath)) { | |||
throw new Error(`Paths must be strings or FieldPath objects.`); | |||
validate.throwCustomObjectError(fieldPath); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This cleans up our error handling for field values and adds better error messages for users that use types from other instances of the Firestore SDK.
As part of this (to get to 100% coverage), I re-added the test that transforms allPlainTypesObject into allPlainTypesProtobufJs. Along with the changes for #105, this meant adding support for missing (empty) array and object values.