Skip to content

Commit

Permalink
feat: add typescript types for $sentry
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
simllll committed Jan 29, 2020
1 parent d58fc89 commit db20b67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
}
],
"files": [
"lib"
"lib",
"types"
],
"main": "lib/module.js",
"scripts": {
Expand Down
14 changes: 9 additions & 5 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<S> {
$sentry: Client;
readonly $sentry?: Client;
}
}

0 comments on commit db20b67

Please sign in to comment.