airbrake / airbrake-js

Airbrake JavaScript Notifier

Home Page:https://airbrake.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot find name 'PromiseRejectionEvent'

sgray opened this issue · comments

Not exactly the same error, but @airbrake/node includes @airbrake/browser as well.

> tsc -b .

node_modules/@airbrake/browser/dist/notifier.d.ts:19:39 - error TS2304: Cannot find name 'PromiseRejectionEvent'.

19     protected onUnhandledrejection(e: PromiseRejectionEvent | CustomEvent): void;
                                         ~~~~~~~~~~~~~~~~~~~~~

node_modules/@airbrake/browser/dist/notifier.d.ts:19:63 - error TS2304: Cannot find name 'CustomEvent'.

19     protected onUnhandledrejection(e: PromiseRejectionEvent | CustomEvent): void;
                                                                 ~~~~~~~~~~~


Found 2 errors.

Removed @airbrake/browser gave me following error:

> tsc -b .

node_modules/@airbrake/node/dist/scope.d.ts:2:23 - error TS2307: Cannot find module '@airbrake/browser'.

2 import { Scope } from '@airbrake/browser';
                        ~~~~~~~~~~~~~~~~~~~

node_modules/@airbrake/node/dist/notifier.d.ts:1:49 - error TS2307: Cannot find module '@airbrake/browser'.

1 import { BaseNotifier, INotice, IOptions } from '@airbrake/browser';
                                                  ~~~~~~~~~~~~~~~~~~~

Originally posted by @tempofeng in #669 (comment)

@tempofeng I pulled this from #669 because I don't want it to diverge from the original error. Are you excluding node_modules in your tsconfig?

No I didn't. my tsconfig:

{
    "compilerOptions": {
        "rootDirs": ["./src"],
        "outDir": "./build",
        "baseUrl": "./",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": ["esnext"],
        "module": "commonjs",
        "sourceMap": true,
        "target": "esnext",
        "declaration": true,
        "declarationMap": true,
        "strict": true,
        "noImplicitAny": true,
        "noImplicitReturns": true,
        "resolveJsonModule": true,
        "esModuleInterop": true
    },
    "include": ["src"],
    "types": ["reflect-metadata"]
}

Switching back to 1.0.7 fixed the problem.

@tempofeng are you able to provide a method of reproducing this error? A sample app, a gist, etc.? I'm not entirely sure it's something I can fix with our current setup of @airbrake/node depending on airbrake/browser, but I'm happy to take a look if I have a reliable way to reproduce the error locally. #702 is likely the "correct" fix for these types of issues, but I might be able to fix this specific issue in the meantime.

Same issue here, only way is to use @airbrake/node@1.0.7

Any help with an example app that exhibits this error would be greatly appreciated.

I don't have an example because we decide to drop airbrake and remove the test app.

But TBH, I already pointed out that in your scope.d.ts, there is an import from @airbrake/browser, and it should not be there.
You don't need an example to fix this.