From db20b67ad5073abc44dcca5ab74f2474c0dc9b95 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 16 May 2019 00:09:09 +0200 Subject: [PATCH] feat: add typescript types for $sentry env parameter SENTRY_DISABLED=true omits injection sentry at all, therefore checking if sentry is avaialble is the safer appraoch (and therefore making typedef of $sentry optional) --- package.json | 3 ++- types/index.d.ts | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c639bd92..04b8b2df 100755 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ } ], "files": [ - "lib" + "lib", + "types" ], "main": "lib/module.js", "scripts": { diff --git a/types/index.d.ts b/types/index.d.ts index c99ed92b..412ed6eb 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -3,20 +3,24 @@ import { Client } from '@sentry/types'; // add type to Vue context declare module 'vue/types/vue' { interface Vue { - $sentry: Client; + readonly $sentry?: Client; } } -// since nuxt 2.7.1 there is "NuxtAppOptions" for app context - see https://github.com/nuxt/nuxt.js/pull/5701 -declare module '@nuxt/vue-app' { +// App Context and NuxtAppOptions +declare module '@nuxt/types' { + interface Context { + readonly $sentry?: Client; + } + interface NuxtAppOptions { - $sentry: Client; + readonly $sentry?: Client; } } // add types for Vuex Store declare module 'vuex/types' { interface Store { - $sentry: Client; + readonly $sentry?: Client; } }