Skip to content

Usage of TextEncoderCommon causes compiler error in a setup without DOM Library #5199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
smirowstanitzok opened this issue Jun 3, 2022 · 1 comment · Fixed by #5221
Closed
3 tasks done

Comments

@smirowstanitzok
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/node

SDK Version

7.0.0

Framework Version

No response

Link to Sentry event

No response

Steps to Reproduce

  1. Setup a node project with typescript but without including DOM. For example tsconfig.json:
{
  "compilerOptions": {
  ...
  "lib": ["ES2020"],
  ...
  }
}
  1. Install the newest version of @sentry/node: npm install @sentry/node.
  2. Use tsc to compile the project.

Expected Result

The code can compile cleanly.

Actual Result

With #5004 comes the usage of TextEncoderCommon. This forces us to use the DOM library, which we can't and actually don't want to do.

Error: node_modules/@sentry/types/types/transport.d.ts(15,39): error TS2304: Cannot find name 'TextEncoderCommon'.

Maybe you can find an alternative without using the DOM library. Maybe more packages as a dependency can be a possible way. That would help us a lot to continue using sentry with pleasure. Thanks a lot.

@lforst
Copy link
Contributor

lforst commented Jun 3, 2022

Hi @smirowstanitzok, thanks for reporting this. Yup, I see the problem. We'll try to get it fixed soon.

For now, until we fix this, Instead of adding the dom library, you could try adding a global declaration looking like

// globals.d.ts

declare interface TextEncoderCommon {
  readonly encoding: string;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants