Sentry-javascript: How to use @sentry/browser with TypeScript without module loader?

Created on 25 May 2019  路  2Comments  路  Source: getsentry/sentry-javascript

Package + Version

  • [x] @sentry/browser
  • [ ] @sentry/node
  • [ ] raven-js
  • [ ] raven-node _(raven for node)_
  • [ ] other:

Version:

5.3.0

Description

I'm using TypeScript without a module loader (tsconfig: "module": "None"). What .d.ts file should I use to prevent the following error?

image

I took a look at the @sentry/core and @sentry/types packages, but I couldn't find a file that declares a global "Sentry" variable.

Most helpful comment

Thanks.
I think it is better to declare it this way:
declare const Sentry:typeof import("@sentry/browser");
This way you have all the functions (like configureScope for example)

All 2 comments

I figured it out. All I had to do was to create a new .d.ts file with the following line:

declare const Sentry: import("@sentry/browser").BrowserClient;

Thanks.
I think it is better to declare it this way:
declare const Sentry:typeof import("@sentry/browser");
This way you have all the functions (like configureScope for example)

Was this page helpful?
0 / 5 - 0 ratings