-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create typescript definition file #61
Comments
I'm not familiar with typescript definition but if you would be interested to contribute a patch, I'll review it. |
I ran into the same issue and created a starting point for a definition. It's far from complete, but I'm not familiar enough with the API yet to complete it.
|
It would be great to see this typedef fully completed. We're using SockJS in a current project, I'll use the base @paulbakker put together and try to complete it. |
I came up with following TypeScript definition (more than enough for me): /**
* it is possible to use other type of WebSockets by using the Stomp.over(ws) method. This method expects an object that conforms to the WebSocket definition.
* TODO specifi minimal required object structure, see SockJS as an acceptable example: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/sockjs/sockjs.d.ts#L23
*/
declare type StompMinimalWebSocketDefinition = /* SockJS | */ any ;
declare type StompWebSocketDefinition = WebSocket | StompMinimalWebSocketDefinition;
declare type StompHeaders = { [key: string ]: string;};
declare type StompSubscriptions = { [key: string ]: string;};
declare type StompFrameCallback = (frame: StompFrame) => void;
interface StompFrame {
command: string;
headers: StompHeaders;
body?: string;
}
interface StompStatic {
over(webSocket: StompWebSocketDefinition): StompClient;
}
interface StompSubscription {
id: any;
unsubscribe: () => void;
}
interface HeartBeatConfig {
incoming : number;
outgoing : number;
}
interface StompClient {
/* START: object internals, maybe not for public use
connectCallback: StompFrameCallback;
connected: boolean;
counter: number;
maxWebSocketFrameSize: number;
partialData: string;
serverActivity: number;
subscriptions: { [key: string ]: StompFrameCallback;};
ws: StompMinimalWebSocketDefinition;
*/
debug: (msg: string) => void;
heartbeat : HeartBeatConfig;
connect(login: string, passcode: string, connectCallback?: () => void, errorCallback?: () => void, host?: string);
connect(headers: StompHeaders, connectCallback?: StompFrameCallback, errorCallback?: StompFrameCallback);
subscribe(destination: string, callback: (stompFrame: StompFrame, headers?: StompHeaders) => void): StompSubscription;
disconnect(disconnectCallback?: () => void);
}
declare var Stomp: StompStatic; (I'll also add the link in case i'll update it later: https://gist.github.com/atsu85/346b8794bf5d8b27772c) |
@jmesnil, Thanks for the effort with this project. I know You are not actively working on it right now, but i'd appreciate some feedback :) |
Typings for |
Type definitions are now available at @types/stompjs |
if you could contribute a typescript definition file to the definitely typed repo it would be very helpful.
https://github.com/borisyankov/DefinitelyTyped
The text was updated successfully, but these errors were encountered: