Skip to content

Commit 9c7108c

Browse files
Fix extendMoment TypeScript declarations (#256)
* Updated CHANGELOG * Fixed type declarations * Fixed extendMoment, updated moment version * Updated changelog
1 parent 46807b3 commit 9c7108c

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
* Changed the `moment.range()` & `DateRange` `constructor` types to allow mixed `Date` & `Moment` parameters
1818
* Changed the `interval`/`unit` flow parameter types in the `by`, `diff`, `duration`, `reverseBy` & `snapTo` to include all strings allowed by moment
1919
* Changed internal TypeScript version to `3.3.3333`
20+
* Changed internal moment version to `2.24.0`
2021
* Changed CircleCI to version `2`
2122

2223
### Fixed
2324
* Fixed the return type of `add` and `intersect` to `DateRange | null` as opposed to `DateRange | undefined`
2425
* Fixed the flow `toDate()` method return type from an array of `Date`s to a `Date` tuple
26+
* Fixed `extendMoment()` typescript declaration to give access to moment namespace variables, e.g. `moment.duration()`, `moment.HTML5_FMT`
2527

2628
## [4.0.1]
2729
### Fixed

lib/moment-range.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@ declare module 'moment' {
8686
}
8787
}
8888

89-
export function extendMoment(momentClass: Moment | typeof moment): MomentRange & Moment;
89+
export function extendMoment(momentClass: typeof moment): MomentRange & typeof moment;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"karma-sourcemap-loader": "^0.3.7",
7070
"karma-webpack": "^2.0.2",
7171
"mocha": "^2.5.3",
72-
"moment": "^2.17.1",
72+
"moment": "^2.24.0",
7373
"typescript": "^3.3.3333",
7474
"webpack": "^2.2.1"
7575
},

typing-tests/flow/moment-range.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,9 @@ range019 + '';
162162
const range020 = new DateRange('year');
163163
range020.valueOf();
164164
// range019 + 1;
165+
166+
// Access to moment methods
167+
moment.duration();
168+
/* eslint-disable no-unused-expressions */
169+
moment.HTML5_FMT.DATE;
170+
/* eslint-enable no-unused-expressions */

typing-tests/typescript/moment-range.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,7 @@ range019 + '';
155155
const range020 = new DateRange('year');
156156
range020.valueOf();
157157
// range019 + 1;
158+
159+
// Access to moment methods
160+
moment.duration();
161+
moment.HTML5_FMT.DATE;

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ diffie-hellman@^5.0.0:
17701770
miller-rabin "^4.0.0"
17711771
randombytes "^2.0.0"
17721772

1773-
doctoc@^1.2.0:
1773+
doctoc@^1.4.0:
17741774
version "1.4.0"
17751775
resolved "https://registry.yarnpkg.com/doctoc/-/doctoc-1.4.0.tgz#3115aa61d0a92f0abb0672036918ea904f5b9e02"
17761776
integrity sha512-8IAq3KdMkxhXCUF+xdZxdJxwuz8N2j25sMgqiu4U4JWluN9tRKMlAalxGASszQjlZaBprdD2YfXpL3VPWUD4eg==
@@ -3674,7 +3674,7 @@ mocha@^2.5.3:
36743674
supports-color "1.2.0"
36753675
to-iso-string "0.0.2"
36763676

3677-
moment@^2.17.1:
3677+
moment@^2.24.0:
36783678
version "2.24.0"
36793679
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
36803680
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==

0 commit comments

Comments
 (0)