Closed Ayc0 closed 8 months ago
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.
This has been fixed in v0.2.3
will say something like:
No valid fields: days,hours,microseconds,milliseconds,minutes,months,nanoseconds,seconds,weeks,years
Amazing 🤩 Thanks!!
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