Editor Update: Version 2.6.0 of the Raygun4JS TypeScript definition has just been released and can be found on the Definitely Typed repository.
Raygun can now provide a .d.ts TypeScript 2.0 definition for raygun4js. This new definition allows a finer level of control over your software errors, and brings scope to any new web applications you may be building. Whether you are a new or existing Raygun customer, you can now integrate both Raygun Crash Reporting and Raygun Pulse further into your application using Raygun and Typescript 2.0. The autocomplete function will also save precious developer time as you won’t have to refer to the documentation as often.
Many thanks to John Mooney for suggesting the update.
Here’s how to get started with Raygun and TypeScript 2.0
Step 1: Ensure you are using TypeScript 2.0
Download the latest version of TypeScript – TypeScript 2.0 – from the official website.
Step 2: Download the TypeScript definition & include it in your project
If you using Node.js you can install the Raygun4JS definition file by executing:
npm install --save @types/raygun4js
You can also find the definition file here.
Step 3: Declare your rg4js method at the start of your main project file (if you are using the standard v2 configuration)
// When using the standard v2 configuration declare var rg4js: RaygunV2;
Step 4: Start using it in your application
With the definition included you can now start using the Raygun4JS provider in your Typescript project.
The global variable provides you access to the configuration options outlined in the provider:
If you prefer an alternative method of accessing options, you can find a list of many different options attached to window.Raygun:
Gain more scope and a finer level of control over your development projects with the new Raygun4js provider.
Do you have any questions on getting started with Raygun and TypeScript 2.0? Contact a friendly team member here, or if you’d like to see first hand how Raygun can help your team, book a short demo here.