raven-node icon indicating copy to clipboard operation
raven-node copied to clipboard

Add TypeScript type definitions

Open rabbitfang opened this issue 9 years ago • 22 comments

The raven-js library for browsers got TypeScript definitions in https://github.com/getsentry/raven-js/pull/610, but those definitions cannot be used for the nodejs library.

The definitions should be implemented for this version as well.

rabbitfang avatar Aug 11 '16 15:08 rabbitfang

Not sure if this helps, but here's a partial definition file that probably has bugs in it, but will at least compile:

///  raven v0.12.x
///******************
/// <reference path="../node/node.d.ts" />

declare namespace raven {
  export class Client {
    // Passing any falsey value as the DSN will disable sending events upstream:
    constructor(dsn: string, options?: ConstructorOptions);
    captureException(error: Error, options?: CaptureOptions, cb?: CaptureCallback): void; // Send an error to sentry
    captureMessage(message: string, options?: CaptureOptions, cb?: CaptureCallback): void; // Send a log message to sentry
    setUserContext(data: UserData): void; // While a user is logged in, you can tell Sentry to associate errors with user data.
  }

  interface UserData {
    id: string;
    handle?: string;
  }

  interface CaptureCallback {
    (result: { string: any }): void
  }

  interface DataCallback {
    (data: { string: any }): void
  }

  interface TransportCallback {
    (options: { string: any }): void
  }

  export interface ConstructorOptions {
    logger?: string; // The name of the logger used by Sentry. Default: ''
    release?: string; // Track the version of your application in Sentry.
    environment?: string; // Track the environment name inside Sentry.
    tags?: { string: string }; // Additional tags to assign to each event. E.g. {git_commit: 'c0deb10c4'}
    extra?: { string: string }; // Arbitrary data to associate with the event.
    dataCallback?: DataCallback; // A function that allows mutation of the data payload right before being sent to Sentry.
    transport?: TransportCallback;  // Override the default HTTP data transport handler.
  }

  export interface CaptureOptions {
    tags?: { string: string }; // Additional tags to assign to each event. E.g. {git_commit: 'c0deb10c4'}
    extra?: { string: string }; // Arbitrary data to associate with the event.
    fingerprint?: string; // The fingerprint for grouping this event.
    level?: string; // The level of the event. Defaults to error.
  }
}

declare module "raven" {
  export = raven;
}

thesmart avatar Aug 22 '16 09:08 thesmart

A big reason we added TypeScript support for Raven.js is because Angular 2 uses TypeScript by default, which is an officially supported framework.

Since there are externally available d.ts files out there, I'm going to keep this on hold until we get more support / votes.

benvinegar avatar Aug 27 '16 00:08 benvinegar

@benvinegar unless I'm mistaken, you linked to a 3rd party d.ts file for raven-js (which is obsoleted by getsentry/raven-js#610)

AFAIK there is no community d.ts files for raven-node on DefinitelyTyped, and no submissions under review which makes the issue raised here more acute.

At the very least, as a community we should try and get a solid definition file submitted to DT? @thesmart seems like you have made a good start there!

jabooth avatar Sep 02 '16 16:09 jabooth

Just adding my +1 for this, we'd appreciate typings available via @types/raven-node .

rosslavery avatar Sep 13 '16 18:09 rosslavery

more and more people use typescript

dcharbonnier avatar Nov 09 '16 19:11 dcharbonnier

+1

Aryk avatar Jan 17 '17 16:01 Aryk

I'm going to leave my +1 here since there's no voting mechanism around here.

asimonf avatar Feb 14 '17 18:02 asimonf

+1

ethanrubio avatar Feb 15 '17 00:02 ethanrubio

+1

myspivey avatar May 19 '17 17:05 myspivey

+1

CBXZero avatar Jun 15 '17 21:06 CBXZero

Please!!

jpinkster avatar Jun 27 '17 14:06 jpinkster

this can't be so difficult as to take it a year to implement... or can it? :-O

martinambrus avatar Jun 27 '17 15:06 martinambrus

Its not, but its an open source software so we can provide a PR if we think it take too much time to implement :-)

dcharbonnier avatar Jun 27 '17 21:06 dcharbonnier

Ouch @martinambrus! Now there is the https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/raven but it would be cool to be shipped here and maintained ... I am happy to migrate and start the process. Just need help maintaining once it is here. Best done by the release team but I am happy to do the initial leg work

jpinkster avatar Jun 28 '17 00:06 jpinkster

this can't be so difficult as to take it a year to implement... or can it? :-O

We had a lot of grief maintaining TypeScript bindings for raven-js. It has been a serious maintenance burden, because people don't often contribute towards them (for example, nobody in this thread has contributed a PR). It's hard to commit to doing them when we don't write TypeScript ourselves.

benvinegar avatar Jun 28 '17 02:06 benvinegar

(Not saying this is a hard no, I can be convinced, but we're low on maintenance resources right now so it's not going to happen any time in the next few months without community help.)

benvinegar avatar Jun 28 '17 02:06 benvinegar

@benvinegar Would you prefer me leave them in DT? I am cool either way and can at least update to the 2.1 release ... right now it is at 1.2 so shouldnt be too time consuming to update the signatures and add what is missing. Let me know how you want me to proceed!

jpinkster avatar Jun 28 '17 02:06 jpinkster

@jpinkster let me know if you decide to do it, or else I'll make a PR myself in the next weeks

alfaproject avatar Jul 16 '17 09:07 alfaproject

@benvinegar, @jpinkster thanks for the update guys... if my comment seemed negative, I apologize but not seeing any response from the developers led me to think they just ignore us... very glad it's not the case :)

martinambrus avatar Jul 17 '17 06:07 martinambrus

@jpinkster @alfaproject still interested in writing those definitions?

kamilogorek avatar Sep 12 '17 10:09 kamilogorek

What is the status of this issue ?

bilby91 avatar Jan 15 '18 14:01 bilby91

It's still open for contributions. Unfortunately I'm not any good with TS and don't have enough time to tackle this issue.

kamilogorek avatar Jan 16 '18 10:01 kamilogorek