joewalnes / reconnecting-websocket

A small decorator for the JavaScript WebSocket API that automatically reconnects
MIT License
4.21k stars 968 forks source link

reconnecting-websockets.d.ts does not compile #44

Closed Fredicz closed 9 years ago

Fredicz commented 9 years ago

The reconnecting-websockets.d.ts does not compile anymore after the inclusion of "public maxReconnectAttempts?: number;" into the code. At least the TS 1.4.1 compiler complains with the following message: "error TS1112: A class member cannot be declared optional."

joewalnes commented 9 years ago

I'm not familiar with typescript. Do you know the fix?

Fredicz commented 9 years ago

Thank you for the very fast fix! It works as expected.

Fredicz commented 9 years ago

The problem is actually not solved. Unfortunately my Reference.ts was still referencing the older version that did not include the error. That's why I thought it was resolved.

The ts compiler throws an error because of the question mark in line 39 of the reconnecting-websockets.d.ts (maxReconnectAttempts). It is illegal to use optional attributes in classes. They are only allowed in interfaces. Please change that. Since I use bower and cannot define the used version, I have to exclude reconnecting-websocket from the bower dependencies as long as it is not fixed properly.

Fredicz commented 9 years ago

I would suggest to use a Typescript interface instead of a Typescript class. That should fix the error and it should be possible since you are only describing the interface (or type).

joewalnes commented 9 years ago

This typescript file is making it harder to contribute to this project. Many contributions forget about it altogether, those that don't often don't know how to test it as they're not familiar with typescript.

My preference would be to remove it from this repository and allow other maintainers to keep it up to date in downstream forks if they want it.

Thoughts? Keep or delete?

/cc @drewnoakes

Fredicz commented 9 years ago

That would be fine for me.

joewalnes commented 9 years ago

I've just learned about https://github.com/borisyankov/DefinitelyTyped - a 3rd party repository of typescript definitions. If there's need for this file, it can be recreated there.

Fredicz commented 9 years ago

We actually use DefinetlyTyped. Thank you very much for solving the issue. Deletion of the file is perfect.

drewnoakes commented 9 years ago

Seems reasonable. Relying on Definitely Typed is a decent approach. Only downside is the lack of versioning parity.

[via phone] On 26 Feb 2015 14:35, "Joe Walnes" notifications@github.com wrote:

This typescript file is making it harder to contribute to this project. Many contributions forget about it altogether, those that don't often don't know how to test it as they're not familiar with typescript.

My preference would be to remove it from this repository and allow other maintainers to keep it up to date in downstream forks if they want it.

Thoughts? Keep or delete?

/cc @drewnoakes https://github.com/drewnoakes

— Reply to this email directly or view it on GitHub https://github.com/joewalnes/reconnecting-websocket/issues/44#issuecomment-76187804 .