-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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: export type of duration plugin #1094
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #1094 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 172 172
Lines 1547 1547
Branches 328 328
=========================================
Hits 1547 1547 Continue to review full report at Codecov.
|
Thanks. But this would lead to a new issue, how can we get the
|
PR fixed.
import * as duration from 'dayjs/plugin/duration';
dayjs.extend(duration);
const time: duration.Duration = dayjs.duration(1234, 's');
const [hour, minute, second] = [time.hours(), time.minutes(), time.seconds()];
import duration, { Duration } from 'dayjs/plugin/duration';
dayjs.extend(duration);
const time: Duration = dayjs.duration(1234, 's');
const [hour, minute, second] = [time.hours(), time.minutes(), time.seconds()]; |
Cool |
|
||
export declare class Duration { | ||
constructor (input: DurationInputType, unit?: string, locale?: string) | ||
interface Duration { |
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.
One small question, can we still use class Duration here, or is it necessary?
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.
An error occurred when using a class in a namespace, so the class was implemented as an interface.
It probably conflicts with the const plugin
object. https://stackoverflow.com/a/51716899
## [1.9.2](v1.9.1...v1.9.2) (2020-10-13) ### Bug Fixes * add arraySupport plugin ([#1129](#1129)) ([be505c2](be505c2)) * export type of duration plugin ([#1094](#1094)) ([2c92e71](2c92e71)) * Fix LocaleData plugin longDateFormat lowercase error ([#1101](#1101)) ([7937ccd](7937ccd)) * Fix objectSupport plugin bug in UTC ([#1107](#1107)) ([fe90bb6](fe90bb6)), closes [#1105](#1105) * fix Serbian locale grammar (sr, sr-cyrl) ([#1108](#1108)) ([cc87eff](cc87eff)) * Fix typo for "monday" in arabic ([#1067](#1067)) ([2e1e426](2e1e426)) * support dayjs.add(Duration), dayjs.subtract(Duration) ([#1099](#1099)) ([b1a0294](b1a0294)) * update Breton [br] locale relativeTime config ([#1103](#1103)) ([b038bfd](b038bfd)) * update Catalan [ca] locale ordinal ([73da380](73da380)) * update German [de] locale relativeTime config ([#1109](#1109)) ([f6e771b](f6e771b)) * update localeData plugin to add longDateFormat to global localeData ([#1106](#1106)) ([16937d1](16937d1)) * Update objectSupport plugin to return current date time while parsing empty object ([f56783e](f56783e))
🎉 This PR is included in version 1.9.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## [1.9.2](iamkun/dayjs@v1.9.1...v1.9.2) (2020-10-13) ### Bug Fixes * add arraySupport plugin ([#1129](iamkun/dayjs#1129)) ([be505c2](iamkun/dayjs@be505c2)) * export type of duration plugin ([#1094](iamkun/dayjs#1094)) ([2c92e71](iamkun/dayjs@2c92e71)) * Fix LocaleData plugin longDateFormat lowercase error ([#1101](iamkun/dayjs#1101)) ([7937ccd](iamkun/dayjs@7937ccd)) * Fix objectSupport plugin bug in UTC ([#1107](iamkun/dayjs#1107)) ([fe90bb6](iamkun/dayjs@fe90bb6)), closes [#1105](iamkun/dayjs#1105) * fix Serbian locale grammar (sr, sr-cyrl) ([#1108](iamkun/dayjs#1108)) ([cc87eff](iamkun/dayjs@cc87eff)) * Fix typo for "monday" in arabic ([#1067](iamkun/dayjs#1067)) ([2e1e426](iamkun/dayjs@2e1e426)) * support dayjs.add(Duration), dayjs.subtract(Duration) ([#1099](iamkun/dayjs#1099)) ([b1a0294](iamkun/dayjs@b1a0294)) * update Breton [br] locale relativeTime config ([#1103](iamkun/dayjs#1103)) ([b038bfd](iamkun/dayjs@b038bfd)) * update Catalan [ca] locale ordinal ([73da380](iamkun/dayjs@73da380)) * update German [de] locale relativeTime config ([#1109](iamkun/dayjs#1109)) ([f6e771b](iamkun/dayjs@f6e771b)) * update localeData plugin to add longDateFormat to global localeData ([#1106](iamkun/dayjs#1106)) ([16937d1](iamkun/dayjs@16937d1)) * Update objectSupport plugin to return current date time while parsing empty object ([f56783e](iamkun/dayjs@f56783e))
## [1.9.2](iamkun/dayjs@v1.9.1...v1.9.2) (2020-10-13) ### Bug Fixes * add arraySupport plugin ([#1129](iamkun/dayjs#1129)) ([be505c2](iamkun/dayjs@be505c2)) * export type of duration plugin ([#1094](iamkun/dayjs#1094)) ([2c92e71](iamkun/dayjs@2c92e71)) * Fix LocaleData plugin longDateFormat lowercase error ([#1101](iamkun/dayjs#1101)) ([7937ccd](iamkun/dayjs@7937ccd)) * Fix objectSupport plugin bug in UTC ([#1107](iamkun/dayjs#1107)) ([fe90bb6](iamkun/dayjs@fe90bb6)), closes [#1105](iamkun/dayjs#1105) * fix Serbian locale grammar (sr, sr-cyrl) ([#1108](iamkun/dayjs#1108)) ([cc87eff](iamkun/dayjs@cc87eff)) * Fix typo for "monday" in arabic ([#1067](iamkun/dayjs#1067)) ([2e1e426](iamkun/dayjs@2e1e426)) * support dayjs.add(Duration), dayjs.subtract(Duration) ([#1099](iamkun/dayjs#1099)) ([b1a0294](iamkun/dayjs@b1a0294)) * update Breton [br] locale relativeTime config ([#1103](iamkun/dayjs#1103)) ([b038bfd](iamkun/dayjs@b038bfd)) * update Catalan [ca] locale ordinal ([73da380](iamkun/dayjs@73da380)) * update German [de] locale relativeTime config ([#1109](iamkun/dayjs#1109)) ([f6e771b](iamkun/dayjs@f6e771b)) * update localeData plugin to add longDateFormat to global localeData ([#1106](iamkun/dayjs#1106)) ([16937d1](iamkun/dayjs@16937d1)) * Update objectSupport plugin to return current date time while parsing empty object ([f56783e](iamkun/dayjs@f56783e))
## [1.9.2](iamkun/dayjs@v1.9.1...v1.9.2) (2020-10-13) ### Bug Fixes * add arraySupport plugin ([#1129](iamkun/dayjs#1129)) ([be505c2](iamkun/dayjs@be505c2)) * export type of duration plugin ([#1094](iamkun/dayjs#1094)) ([2c92e71](iamkun/dayjs@2c92e71)) * Fix LocaleData plugin longDateFormat lowercase error ([#1101](iamkun/dayjs#1101)) ([7937ccd](iamkun/dayjs@7937ccd)) * Fix objectSupport plugin bug in UTC ([#1107](iamkun/dayjs#1107)) ([fe90bb6](iamkun/dayjs@fe90bb6)), closes [#1105](iamkun/dayjs#1105) * fix Serbian locale grammar (sr, sr-cyrl) ([#1108](iamkun/dayjs#1108)) ([cc87eff](iamkun/dayjs@cc87eff)) * Fix typo for "monday" in arabic ([#1067](iamkun/dayjs#1067)) ([2e1e426](iamkun/dayjs@2e1e426)) * support dayjs.add(Duration), dayjs.subtract(Duration) ([#1099](iamkun/dayjs#1099)) ([b1a0294](iamkun/dayjs@b1a0294)) * update Breton [br] locale relativeTime config ([#1103](iamkun/dayjs#1103)) ([b038bfd](iamkun/dayjs@b038bfd)) * update Catalan [ca] locale ordinal ([73da380](iamkun/dayjs@73da380)) * update German [de] locale relativeTime config ([#1109](iamkun/dayjs#1109)) ([f6e771b](iamkun/dayjs@f6e771b)) * update localeData plugin to add longDateFormat to global localeData ([#1106](iamkun/dayjs#1106)) ([16937d1](iamkun/dayjs@16937d1)) * Update objectSupport plugin to return current date time while parsing empty object ([f56783e](iamkun/dayjs@f56783e))
All plugins have the following format, but only the duration plugin is
export default
in typesdayjs/src/plugin/isMoment/index.js
Line 1 in f95ac15
dayjs/types/plugin/isMoment.d.ts
Line 4 in f95ac15
When dayjs is actually built, it doesn't export the
default
object, so typescript runtime error occurs onduration.default
.https://cdn.jsdelivr.net/npm/dayjs@1.9.1/plugin/duration.js
This is a fix that keeps the same exports as other plugins.