Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Typescript definition file #7

Closed
cexbrayat opened this issue Apr 25, 2016 · 11 comments
Closed

Typescript definition file #7

cexbrayat opened this issue Apr 25, 2016 · 11 comments

Comments

@cexbrayat
Copy link

First of all, thank you very much for the energy you're putting in the project.

I am, as a lot of Angular 2 developers, working more and more with TypeScript.
And, as you may know, TypeScript needs typings for external librairies. So it would be great if you could add the typings to the DefinitelyTyped repository, or better, within the NPM module (as recent TypeScript compilers can pick it up automatically).

This is not a new issue, as you can see on the original repo jmesnil/stomp-websocket#61

I'm not a TypeScript expert, but I slightly modified one of the propositions to have the bare minimum for my case (I don't know enough the library to make something more exhaustive).

declare module 'webstomp-client' {

  interface webstomp {
    over(socketType: any) : webstomp;
    connect(headers: any, connectCallback: () => any);
    subscribe(destination: string, callback: (message: StompMessage) => any);
  }

  interface StompMessage {
    body : string;
  }

  var webstomp: webstomp;
  export = webstomp;

}
@JSteunou
Copy link
Owner

I am sorry I do not know enough about Typescript. Does this mean that you cannot use this library without types definition?

@cexbrayat
Copy link
Author

You can use it, but the compiler will complain (or won't even compile depending on your settings).
If the fork gain in popularity, we can expect a few people with the same need.

The ideal would be to embed a webstomp-client.d.ts file in the dist directory of the NPM module (see http://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html for more info).
This file would contain roughly what I proposed (until a better TypeScript developer than me offers something better), although it lacks a few useful methods (like unsubscribe and others you'll think about).

With this, the TypeScript compiler should be happy.

@JSteunou
Copy link
Owner

I will think about it. On one hand I want to provide what's needed for this library, on the other hand I cannot spread efforts to please everyone using a JavaScript like language with specific files to add and mostly to maintain. What's the worst? Compiler with warning, or compiler with error because the .ts is not up to date?

@cexbrayat
Copy link
Author

I completely understand, take your time. I think it would be a great help for TS developers who will have to find this file, but I understand your reluctance to maintain it.

@mishtt
Copy link

mishtt commented May 26, 2016

I am kind of stuck in the same boat - I need the typings so that I can use it in my current project. I have not found a work around 3 days into working with the library. it would be wonderful to have it but I would understand if its not a priority.

@JSteunou
Copy link
Owner

I see. Could it work for you guys with https://github.com/DefinitelyTyped/DefinitelyTyped ?
If you guys can handle this .ts for your need by yourself it would help me a lot as I know nothing about TypeScript.

@mishtt
Copy link

mishtt commented May 26, 2016

Yes that would work - the ideal would be what @cexbrayat mentioned but yes if we could get something in DT then that would go a long way. I work for a major airline and we are in the process of adopting libraries for our core boiler plate project which will serve as a starter project for all new UI projects. I can help out if need be to maintain the definitions

@sinedsem
Copy link

sinedsem commented Aug 8, 2016

That's so sad this issue is in "open" state... I am starting a new project, and I really need typings for this library. Any solutions right now?

@JSteunou
Copy link
Owner

JSteunou commented Aug 8, 2016

I could take a PR but I am afraid I could not maintain the file when the
lib will evolve. I need someone to take this in charge.

Le 8 août 2016 21:43, "sinedsem" notifications@github.com a écrit :

That's so sad this issue is in "open" state... I am starting a new
project, and I really need typings for this library. Any solutions right
now?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#7 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACNyt44GoknzTx71Jg3C6NUNETVV__Zgks5qd4bCgaJpZM4IO6TH
.

@sinedsem
Copy link

sinedsem commented Aug 8, 2016

I am a newbie in frontend, that's why I need this out of the box. I don't understand yet how this works, so I completely agree: we need somebody in charge.

@JimiC
Copy link
Contributor

JimiC commented Nov 11, 2016

Typings for stompjsare now available at DefinitelyTyped types-2.0 branch.

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

No branches or pull requests

5 participants