-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: provide vuex types `$moment` is injected using nuxt `inject` method and is therefore also available in `vuex`. * feat: Improve types 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()` * chore(readme): Add instructions for typescript setup * chore(readme): Add more details to typescript setup * fix(types): Use vuex/types/index * chore(readme): Typescript setup for nuxt > 2.9
- Loading branch information
1 parent
eed4398
commit 6a26feb
Showing
2 changed files
with
33 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,28 @@ | ||
import { Moment, MomentFormatSpecification, MomentInput } from 'moment' | ||
import moment from 'moment' | ||
import Vue from 'vue' | ||
|
||
declare module '@nuxt/vue-app' { | ||
interface Context { | ||
$moment(input?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment | ||
$moment: typeof moment | ||
} | ||
} | ||
|
||
// Nuxt 2.9+ | ||
declare module '@nuxt/types' { | ||
interface Context { | ||
$moment(input?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment | ||
$moment: typeof moment | ||
} | ||
} | ||
|
||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
$moment(input?: MomentInput, format?: MomentFormatSpecification, language?: string, strict?: boolean): Moment | ||
$moment: typeof moment | ||
} | ||
} | ||
|
||
declare module 'vuex/types/index' { | ||
interface Store<S> { | ||
$moment: typeof moment | ||
} | ||
} | ||
|