Skip to content
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

Merged
merged 6 commits into from Nov 14, 2019
Merged

feat: improve types #47

merged 6 commits into from Nov 14, 2019

Conversation

P4sca1
Copy link
Contributor

@P4sca1 P4sca1 commented Nov 9, 2019

$moment is injected using nuxt inject method and is therefore also available in vuex.
This adds types to the vuex store.

Also no longer limit the type to (input?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment but use typeof 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 the types array in your tsconfig.json. Thought it would make sense to include this in the README.

`$moment` is injected using nuxt `inject` method and is therefore also available in `vuex`.
@codecov
Copy link

codecov bot commented Nov 9, 2019

Codecov Report

Merging #47 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eed4398...eef27e8. Read the comment docs.

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()`
@P4sca1 P4sca1 changed the title feat: provide vuex types feat: improve types Nov 9, 2019
@P4sca1
Copy link
Contributor Author

P4sca1 commented Nov 9, 2019

@kevinmarrec As you made the initial types, could you take a look at this?

Copy link
Member

@ricardogobbosouza ricardogobbosouza left a 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

README.md Outdated Show resolved Hide resolved
types/index.d.ts Outdated Show resolved Hide resolved
@ricardogobbosouza ricardogobbosouza removed the request for review from kevinmarrec November 13, 2019 22:21
@ricardogobbosouza ricardogobbosouza merged commit 6a26feb into nuxt-community:master Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants