1

Angular version 6 Raygun setup issue with typescript

Error:

ERROR in src/app/app.raygun.setup.ts(6,20): error TS2304: Cannot find name 'RaygunV2'.

It doesn't seem to like this line: declare let rg4js: RaygunV2;

I installed these npms for raygun:

@types/raygun4js: "^2.6.0 AND raygun4j": "^2.10.0

app.raygun.setup file:

import * as rg4js from 'raygun4js';
import { ErrorHandler } from '@angular/core';

import { environment } from '@env/environment';

declare let rg4js: RaygunV2;

rg4js('apiKey', '9bimuASis2Cyjx/mrKTmeQ==');
rg4js('setVersion', '1.0.0.0');
rg4js('enableCrashReporting', environment.raygun.isActive);

export class RaygunErrorHandler implements ErrorHandler {
  handleError(e: any) {
    rg4js('send', { error: e });
  }
}

app.module:

 providers: [
    { provide: ErrorHandler, useClass: RaygunErrorHandler }
 ],

1 Answer 1

2

This is because due to an oversight we don't actually export the RaygunV2 object as part of the type definitions. This will be fixed in the next release of Raygun4JS (no ETA). For now, the best you can do is just declare the variable as any.

Sidenote: I don't see you trying to import the RaygunV2 type, you will have to do that when we do eventually export the type from the type definitions.

Edit (25/10/18): This still hasn't been resolved properly but you can use the following snippet as a workaround

import { RaygunV2 } from 'raygun4js';
const rgj4s: RaygunV2 = require('raygun4js');
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.