Skip to content
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

TypeScript error in @sentry/types introduced in 7.42.0 #7422

Closed
3 tasks done
HofmannZ opened this issue Mar 11, 2023 · 6 comments · Fixed by #7429
Closed
3 tasks done

TypeScript error in @sentry/types introduced in 7.42.0 #7422

HofmannZ opened this issue Mar 11, 2023 · 6 comments · Fixed by #7429
Assignees

Comments

@HofmannZ
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using? If you use the CDN bundles, please specify the exact bundle (e.g. bundle.tracing.min.js) in your SDK setup.

@sentry/node

SDK Version

7.42.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

  1. Install @sentry/types, @sentry/tracing, @sentry/integrations and @sentry/node version 7.41.0.
  2. Init Sentry and Sentry tracing.
  3. Run a TypeScript build.
  4. See the build succeed.
  5. Install version 7.42.0.
  6. Run TypeScript build.
  7. See the build fail.

Expected Result

It should build without errors.

Actual Result

Throws the following build error:

pnpm build

> @expatfile/grpc-utils@0.0.0-development build /Users/zinohofmann/Projects/github.com/expatfile/grpc-utils
> tsc -p .

node_modules/.pnpm/@sentry+types@7.42.0/node_modules/@sentry/types/types/instrument.d.ts:1:43 - error TS2304: Cannot find name 'BufferSource'.

1 declare type XHRSendInput = null | Blob | BufferSource | FormData | URLSearchParams | string;
                                            ~~~~~~~~~~~~

node_modules/.pnpm/@sentry+types@7.42.0/node_modules/@sentry/types/types/instrument.d.ts:1:58 - error TS2304: Cannot find name 'FormData'.

1 declare type XHRSendInput = null | Blob | BufferSource | FormData | URLSearchParams | string;
                                                           ~~~~~~~~

node_modules/.pnpm/@sentry+types@7.42.0/node_modules/@sentry/types/types/instrument.d.ts:2:54 - error TS2304: Cannot find name 'XMLHttpRequest'.

2 export interface SentryWrappedXMLHttpRequest extends XMLHttpRequest {
                                                       ~~~~~~~~~~~~~~

node_modules/.pnpm/@sentry+types@7.42.0/node_modules/@sentry/types/types/instrument.d.ts:19:16 - error TS2304: Cannot find name 'Response'.

19     response?: Response;
                  ~~~~~~~~


Found 4 errors in the same file, starting at: node_modules/.pnpm/@sentry+types@7.42.0/node_modules/@sentry/types/types/instrument.d.ts:1

 ELIFECYCLE  Command failed with exit code 1.
@lenovouser
Copy link

#7382 is the PR that introduced this bug, specifically the following line:

export type { HandlerDataFetch, SentryWrappedXMLHttpRequest } from './instrument';

@mydea
Copy link
Member

mydea commented Mar 13, 2023

Hello @HofmannZ ,

thank you for the report, this def. seems like something we should fix.
However, I just tried this in a very barebones express app using ts-node and it seemed to work fine. Can you provide more detail on your setup:

  1. Your Sentry.init() config
  2. How do you build/run your TS node app?
  3. Could you provide your tsconfig.json file content?

I suspect this has to do with how the code/types are tree shaken. (To be clear if that is the case we def. still need to fix this on our end, we'd just like to have a working reproduction so we can add a test to prevent future regressions like this)

@smirowstanitzok
Copy link

This reminds me of issue #5199. Again, the problem is that the DOM library is required. A possible fix/workaround is adding the library in tsconfig.json:

{
  ...
  "compilerOptions" : {
    "lib": ["DOM", ... ],
    ...
  }
  ...
}

For pure backend/Node.js applications, however, this is not a clean way. We would like the dependency on DOM Types to be removed.

@mydea
Copy link
Member

mydea commented Mar 13, 2023

Yes, to be clear we absolutely consider this a regression, you shouldn't need to adjust your tsconfig for this. We have an open PR and plan to ship a patch release as soon as possible!

@mydea
Copy link
Member

mydea commented Mar 13, 2023

This should be fixed in 7.43.0 - thank you for reporting!

@HofmannZ
Copy link
Author

Version 7.43.0 solves the issue. Thanks!

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

Successfully merging a pull request may close this issue.

4 participants