sentry-capacitor: TS2451: Cannot redeclare block-scoped variable
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
SDK Version
7.16.0
Framework Version
Angular 13.3.11 & Ionic 6.3.2
Link to Sentry event
No response
Steps to Reproduce
Node.js v16.10.x
Typescript 4.5.x
Currently we are using the following versions of Sentry package: “@sentry/angular”: “^6.19.7”, “@sentry/capacitor”: “^0.6.1”, “@sentry/tracing”: “^6.19.7”
After trying to bump all packages to latest i.e.: “@sentry/angular”: “^7.16.0”, “@sentry/capacitor”: “^0.10.1”, “@sentry/tracing”: “^7.16.0”
Expected Result
No error
Actual Result
I receive the following error:
Error: node_modules/@sentry/types/types/globals.d.ts:2:11 - error TS2451: Cannot redeclare block-scoped variable '__DEBUG_BUILD__'.
2 const __DEBUG_BUILD__: boolean;
~~~~~~~~~~~~~~~
node_modules/@sentry/tracing/node_modules/@sentry/types/types/globals.d.ts:2:11
2 const __DEBUG_BUILD__: boolean;
~~~~~~~~~~~~~~~
'__DEBUG_BUILD__' was also declared here.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 9
- Comments: 18 (7 by maintainers)
To fix this you must use a fixed sibling version of angular and tracing
Additionally, at the moment the SDK is compatible with version 7.13.0.
Hopefully this situation will get clearer on the next versions of Sentry Capacitor
To fix this right now all versions of the sentry packages should be aligned. So if you’re on 7.13.0 you need
@sentry/typesto be on7.31.0.Thanks Luca! I’ll test it on nuget trends the weekend
@lucas-zimerman @bruno-garcia We fixed this upstream in the latest JS SDK release so once we update everything this error should be gone for good.
@bruno-garcia We can fix this upstream. I’ll start working on it today!
@chutzemischt I think the problem is that support for Angular 16 comes only with 7.51.0.
Getting same/similar build error on a Ionic 6 / Angular 16 / Capacitor 4 project. Trying to move from @sentry/angular to @sentry/angular-ivy. Dependencies used: “@sentry/angular-ivy”: “^7.51.2” “@sentry/capacitor”: “^0.11.3”
Just to let you know, fixing the versions as specified above does work - thank you @lucas-zimerman.
I am backlogging this for the JS SDK team because I’d like to fix this more sustainably. Right now we’re polluting the global typescript namespace with the JS SDK.
Here is the origin of the problem: https://github.com/getsentry/sentry-javascript/pull/5155#discussion_r885655812 (Note to self: What looks fishy, probably is)
By the way, what if when updating the Sentry packages you would get a message like this
Would that be a convenient way of telling you what to do in order to update those packages? (also a similar message if you were using npm for package management)
Ideally it should work out of the box, but unfortunately, it’s how the SDK behaves when there’s a duplicated sibling package.