Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Add TypeScript type definitions #189

Open
rabbitfang opened this issue Aug 11, 2016 · 22 comments
Open

Add TypeScript type definitions #189

rabbitfang opened this issue Aug 11, 2016 · 22 comments

Comments

@rabbitfang
Copy link

The raven-js library for browsers got TypeScript definitions in getsentry/sentry-javascript#610, but those definitions cannot be used for the nodejs library.

The definitions should be implemented for this version as well.

@thesmart
Copy link

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;
}

@benvinegar
Copy link
Contributor

benvinegar commented Aug 27, 2016

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.

@jabooth
Copy link

jabooth commented Sep 2, 2016

@benvinegar unless I'm mistaken, you linked to a 3rd party d.ts file for raven-js (which is obsoleted by getsentry/sentry-javascript#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!

@rosslavery
Copy link

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

@dcharbonnier
Copy link

more and more people use typescript

@Aryk
Copy link

Aryk commented Jan 17, 2017

+1

@asimonf
Copy link

asimonf commented Feb 14, 2017

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

@ethanrubio
Copy link

+1

@myspivey
Copy link

+1

1 similar comment
@CBXZero
Copy link

CBXZero commented Jun 15, 2017

+1

@jpinkster
Copy link

Please!!

@martinambrus
Copy link

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

@dcharbonnier
Copy link

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

@jpinkster
Copy link

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

@benvinegar
Copy link
Contributor

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
Copy link
Contributor

(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.)

@jpinkster
Copy link

@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!

@alfaproject
Copy link

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

@martinambrus
Copy link

martinambrus commented Jul 17, 2017

@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 :)

@kamilogorek
Copy link
Contributor

@jpinkster @alfaproject still interested in writing those definitions?

@bilby91
Copy link

bilby91 commented Jan 15, 2018

What is the status of this issue ?

@kamilogorek
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.