-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: improve types #47
Conversation
`$moment` is injected using nuxt `inject` method and is therefore also available in `vuex`.
Codecov Report
@@ Coverage Diff @@
## master #47 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 1 1
Lines 13 13
Branches 2 2
=====================================
Hits 13 13 Continue to review full report at Codecov.
|
This makes all the ways to use moment type-safe, e.g. this is now type-safe: `this.$moment.duration(this.$moment(moment1).diff(moment2)).humanize()`
@kevinmarrec As you made the initial types, could you take a look at this? |
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.
Thanks @P4sca1, little considerations
$moment
is injected using nuxtinject
method and is therefore also available invuex
.This adds types to the
vuex
store.Also no longer limit the type to
(input?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment
but usetypeof moment
.This makes it possible to do something like
this.$moment.duration()
.The README is updated to contain info about how to use this module with typescript.
I was wondering why
this.$moment
was untyped and found out you have to add@nuxtjs/moment
to thetypes
array in yourtsconfig.json
. Thought it would make sense to include this in the README.