You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't really know if this is an issue that should be opened here, or on the RFC. In the rfc I just saw those generic TypeError:
So I think the error message is handled by the polyfill directly.
When creating an object from an invalid, for instance:
Temporal.Duration.from({days: undefined});// Throws:// TypeError: No valid fields// at refineFields (index.cjs:1309:15)// at exports.refineDurationBag (index.cjs:2498:30)// at toDurationSlots (index.cjs:2857:89)// at Function.from (index.cjs:3316:37)// at Timeline.tsx:22:21
My use case: I used it with Temporal.Duration.from({ day: 5 }), and it didn't tell me that "day" wasn't valid and that I should use "days" instead. And also another time with Temporal.Duration.from(durationObject) but all fields were empty.
What if instead, if non-valid fields are passed, the polyfill could day something like "day" isn't a valid field. It needs to be either "years", "months", …. Or Duration is created from an empty object. At least 1 field as to be a number to be valid
This is low priority, but it can make debugging easier with the polyfill
The text was updated successfully, but these errors were encountered:
Thanks @Ayc0. I agree that the error message should be clearer. It'd be easy to print out a helpful list of the valid options in the case. I'll get this done for the next release.
I don't really know if this is an issue that should be opened here, or on the RFC. In the rfc I just saw those generic
TypeError
:So I think the error message is handled by the polyfill directly.
When creating an object from an invalid, for instance:
My use case: I used it with
Temporal.Duration.from({ day: 5 })
, and it didn't tell me that "day" wasn't valid and that I should use "days" instead. And also another time withTemporal.Duration.from(durationObject)
but all fields were empty.What if instead, if non-valid fields are passed, the polyfill could day something like
"day" isn't a valid field. It needs to be either "years", "months", …
. OrDuration is created from an empty object. At least 1 field as to be a number to be valid
This is low priority, but it can make debugging easier with the polyfill
The text was updated successfully, but these errors were encountered: