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

Cannot compile TS with @sentry/node without lib: DOM definitions present #4449

Closed
4 of 9 tasks
NoNameProvided opened this issue Jan 25, 2022 · 3 comments · Fixed by #4451
Closed
4 of 9 tasks

Cannot compile TS with @sentry/node without lib: DOM definitions present #4449

NoNameProvided opened this issue Jan 25, 2022 · 3 comments · Fixed by #4451
Assignees

Comments

@NoNameProvided
Copy link

Package + Version

  • @sentry/browser
  • @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

6.17.1

Description

The sentry/node package incorrectly assumes there are types for DOM on the server. So when trying to compile a NodeJS app the following two error occurs:

node_modules/@sentry/utils/dist/is.d.ts:65:55 - error TS2304: Cannot find name 'Event'.

65 export declare function isEvent(wat: unknown): wat is Event;
                                                         ~~~~~

node_modules/@sentry/utils/dist/is.d.ts:73:57 - error TS2304: Cannot find name 'Element'.

73 export declare function isElement(wat: unknown): wat is Element;
                                                           ~~~~~~~

Found 2 errors.

Technically this happens because we override the lib in TS config so there are no types for DOM, however, I think this is a correct assumption on the server-side, and adding simply dom to lib in TS config is not a good solution.

There is a ~3 year old related issue here: #2266

@israellias
Copy link

The error for me on production build is

> nest build

src/app.module.ts:8:10 - error TS2305: Module '"@sentry/types"' has no exported member 'LogLevel'.

8 import { LogLevel } from '@sentry/types';
           ~~~~~~~~
src/app.module.ts:17:7 - error TS2345: Argument of type '{ dsn: string | undefined; environment: string | undefined; logLevel: any; tracesSampleRate: number; }' is not assignable to parameter of type 'SentryModuleOptions'.
  Object literal may only specify known properties, but 'logLevel' does not exist in type 'SentryModuleOptions'. Did you mean to write 'logLevels'?

17       logLevel: LogLevel.Debug,
         ~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 error(s).

Nothing is wrong on local until I run npm install @sentry/types. Then I get the same error as production.

Then I modified from this logLevel: LogLevel.Debug, to this logLevels: ['debug', 'error', 'log', 'warn'], and all was fixed. I had to install sentry types. At this moment, I don't know the implications of it.

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Jan 25, 2022

@israellias We removed the logLevel option (and corresponding enum) from the SDK because it doesn't have any functionality, here's the PR: #4317

@NoNameProvided yeah this is an error on our side, we'll fix this ASAP. Thank you for reporting!

@AbhiPrasad
Copy link
Member

AbhiPrasad commented Jan 25, 2022

This will be released with 6.17.2. This is not out yet, you can track the publish status of the release at: getsentry/publish#772

edit: this is now released https://www.npmjs.com/package/@sentry/node/v/6.17.2

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.

3 participants