Skip to content

Commit

Permalink
Fix extendMoment TypeScript declarations (#256)
Browse files Browse the repository at this point in the history
* Updated CHANGELOG

* Fixed type declarations

* Fixed extendMoment, updated moment version

* Updated changelog
  • Loading branch information
beaumontjonathan authored Feb 25, 2019
1 parent 46807b3 commit 9c7108c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
* Changed the `moment.range()` & `DateRange` `constructor` types to allow mixed `Date` & `Moment` parameters
* Changed the `interval`/`unit` flow parameter types in the `by`, `diff`, `duration`, `reverseBy` & `snapTo` to include all strings allowed by moment
* Changed internal TypeScript version to `3.3.3333`
* Changed internal moment version to `2.24.0`
* Changed CircleCI to version `2`

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

## [4.0.1]
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion lib/moment-range.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ declare module 'moment' {
}
}

export function extendMoment(momentClass: Moment | typeof moment): MomentRange & Moment;
export function extendMoment(momentClass: typeof moment): MomentRange & typeof moment;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.2",
"mocha": "^2.5.3",
"moment": "^2.17.1",
"moment": "^2.24.0",
"typescript": "^3.3.3333",
"webpack": "^2.2.1"
},
Expand Down
6 changes: 6 additions & 0 deletions typing-tests/flow/moment-range.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,9 @@ range019 + '';
const range020 = new DateRange('year');
range020.valueOf();
// range019 + 1;

// Access to moment methods
moment.duration();
/* eslint-disable no-unused-expressions */
moment.HTML5_FMT.DATE;
/* eslint-enable no-unused-expressions */
4 changes: 4 additions & 0 deletions typing-tests/typescript/moment-range.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ range019 + '';
const range020 = new DateRange('year');
range020.valueOf();
// range019 + 1;

// Access to moment methods
moment.duration();
moment.HTML5_FMT.DATE;
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ diffie-hellman@^5.0.0:
miller-rabin "^4.0.0"
randombytes "^2.0.0"

doctoc@^1.2.0:
doctoc@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/doctoc/-/doctoc-1.4.0.tgz#3115aa61d0a92f0abb0672036918ea904f5b9e02"
integrity sha512-8IAq3KdMkxhXCUF+xdZxdJxwuz8N2j25sMgqiu4U4JWluN9tRKMlAalxGASszQjlZaBprdD2YfXpL3VPWUD4eg==
Expand Down Expand Up @@ -3674,7 +3674,7 @@ mocha@^2.5.3:
supports-color "1.2.0"
to-iso-string "0.0.2"

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

0 comments on commit 9c7108c

Please sign in to comment.