From 5c75f37ae97d0fa4beb58d9a58befb224b38b2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Antunes=20Silva?= Date: Tue, 19 May 2020 18:17:10 -0300 Subject: [PATCH] feat: typescript typings (#78) --- package.json | 4 +++- types/index.d.ts | 33 +++++++++++++++++++++++++++++++++ types/vuex.d.ts | 7 +++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 types/index.d.ts create mode 100644 types/vuex.d.ts diff --git a/package.json b/package.json index 881de31..60b220b 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,10 @@ "Ricardo Gobbo de Souza " ], "main": "lib/module.js", + "types": "types/index.d.ts", "files": [ - "lib" + "lib", + "types/*.d.ts" ], "scripts": { "lint": "eslint --ext .js,.vue .", diff --git a/types/index.d.ts b/types/index.d.ts new file mode 100644 index 0000000..832be6e --- /dev/null +++ b/types/index.d.ts @@ -0,0 +1,33 @@ +import type Vue from 'vue' +import type { default as VueAnalytics, InstallOptions } from 'vue-analytics' +import './vuex' + +declare module '@nuxt/vue-app' { + interface Context { + $ga: VueAnalytics + } + interface NuxtAppOptions { + $ga: VueAnalytics + } +} + +// Nuxt 2.9+ +declare module '@nuxt/types' { + interface Context { + $ga: VueAnalytics + } + + interface NuxtAppOptions { + $ga: VueAnalytics + } + + interface Configuration { + googleAnalytics?: InstallOptions + } +} + +declare module 'vue/types/vue' { + interface Vue { + $ga: VueAnalytics + } +} diff --git a/types/vuex.d.ts b/types/vuex.d.ts new file mode 100644 index 0000000..bf6d9c5 --- /dev/null +++ b/types/vuex.d.ts @@ -0,0 +1,7 @@ +import type VueAnalytics from 'vue-analytics' + +declare module 'vuex' { + interface Store { + $ga: VueAnalytics, + } +}