Skip to content
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

Open to a rewrite in Typescript? #691

Open
ClementNerma opened this issue Jan 29, 2025 · 4 comments
Open

Open to a rewrite in Typescript? #691

ClementNerma opened this issue Jan 29, 2025 · 4 comments

Comments

@ClementNerma
Copy link

Hi there!

Native Typescript code (with builtin types instead of a separate declaration file, which sometimes causes problems depending in TS projects depending on their config) is IMO preferable to Javascript in most cases.

Would you be open to a PR rewriting the project's code in TypeScript? If so, I'd be happy to make one.

Otherwise, no problem!

@Apollon77
Copy link
Collaborator

I would be more then open for that ... I also have that on my list but not yet time to start with it. most of my other maintained projects currently are TS so it is always a pain to do pure JS :-)

I will finish current PR and then would be ideal time tbh

@Apollon77
Copy link
Collaborator

@codetheweb any veto?

@codetheweb
Copy link
Owner

I planned to many years ago. Sounds good to me.

@ClementNerma
Copy link
Author

I've started rewriting the project in TypeScript, but I'm a bit stuck as there are tons of conflicting types in various places.
For instance, take the _decryptPre34 function:

Image

No matter how I type it, it can't work. The decipher.update method takes a string, followed by an Encoding, followed by an OutputEncoding.

The thing is, Encoding can never be "buffer" as per Node.js' documentation. Also, the data cannot be a Buffer, it must be a string. So I don't know what's supposed to happen here.

There are lots of other things like that:

Image

The getPayload method may return false if for instance the provided string or buffer is empty. But in Packet, the payload property cannot be false.

Also, the docs show that its type should be Buffer | Object | string, but when we provide it to getPayload it can't work as this method then provides it to this.cipher.decrypt, which only takes a Buffer, not an Object or a string. So I'm a bit confused...

Could you please enlighten me on these examples? Thanks.

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

No branches or pull requests

3 participants