Sentry-javascript: Typescript - BrowserOptions type doesn't contain dsn property

Created on 26 Apr 2019  路  7Comments  路  Source: getsentry/sentry-javascript

Package + Version

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

Version:

5.1.1

Description

I'm getting a Typescript error when trying to init Sentry.
image

Most helpful comment

Can you post come repro TS config that I could use to debug this?

I had the same problem, the original tsconfig was
{ "compilerOptions": { "outDir": "./dist/", "noImplicitAny": true, "module": "es6", "target": "es5", "jsx": "react", "allowJs": true, } }
After I changed "moduleResolution" to node, it works

All 7 comments

Try Sentry.init({dsn} as Sentry.BrowserOptions);

Same issue here on 5.4.3.

@luki86 casting does not help as the BrowserOptions does not have a dsn property. See https://github.com/getsentry/sentry-javascript/blob/4d60369ee724365d8e24cdeda854cfa7c2f30b97/packages/browser/src/backend.ts#L22

For me this works:
```
import { BrowserOptions, init } from '@sentry/browser';
...
const config: BrowserOptions = {
dsn: REACT_APP_SENTRY_DSN,
...
};
init(config);
...

@Sirius-A it does. https://github.com/getsentry/sentry-javascript/blob/master/packages/types/src/options.ts#L25

It's most likely due to some misconfiguration of typescript compiler. I'll close this issue, however, feel free to post the repro-case and I'll be more than happy to reopen it and fix if there's something broken :)

TS2559: Type '{ dsn: string; }' has no properties in common with type 'BrowserOptions'.
I got same issue on ^5.5.0

Can you post come repro TS config that I could use to debug this?

Can you post come repro TS config that I could use to debug this?

I had the same problem, the original tsconfig was
{ "compilerOptions": { "outDir": "./dist/", "noImplicitAny": true, "module": "es6", "target": "es5", "jsx": "react", "allowJs": true, } }
After I changed "moduleResolution" to node, it works

Was this page helpful?
0 / 5 - 0 ratings