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 - @sentry/utils references node types #2013

Closed
5 of 8 tasks
dleavitt opened this issue Apr 10, 2019 · 1 comment
Closed
5 of 8 tasks

Typescript - @sentry/utils references node types #2013

dleavitt opened this issue Apr 10, 2019 · 1 comment

Comments

@dleavitt
Copy link

dleavitt commented Apr 10, 2019

Package + Version

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

Version:

5.0.7
5.0.6

Description

The browser package relies on:
@sentry/utils/dist/misc.d.ts which in turn relies on node type definitions:

/// <reference types="node" />

// ...

export declare function dynamicRequire(mod: NodeModule, request: string): any;

This causes the following errors when used in conjunction with the Fork TS Checker Webpack Plugin:

ERROR in node_modules/@sentry/utils/dist/misc.d.ts(1,23):
TS2688: Cannot find type definition file for 'node'.
ERROR in /node_modules/@sentry/utils/dist/misc.d.ts(16,45):
TS2304: Cannot find name 'NodeModule'.

These can be resolved by either including @types/node in your package.json file or by making a file in a typeRoots directory named node.d.ts with the following contents:

declare module "node" {
  interface NodeModule {}

  // this ns may no longer be needed as of 5.0.7
  namespace NodeJS {
    export type Global = any
  }
}

It seems strange that a browser library would rely on node typedefs, but these errors do not seem to occur in a more vanilla Typescript/Webpack setup. So it's possible there's nothing to fix here, but hopefully the above notes might be useful to others who encounter this issue.

@HazAT
Copy link
Member

HazAT commented Apr 11, 2019

Fixed in master :)

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

No branches or pull requests

2 participants