-
Notifications
You must be signed in to change notification settings - Fork 29
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
WIP: Add Typescript types #17
base: master
Are you sure you want to change the base?
Conversation
Hi alex, This is something I would be interested in adding. I will review this at my next opportunity. Thanks. |
527eefb
to
313ac68
Compare
313ac68
to
cde09bb
Compare
To be honest I'm not a typescript developer and I don't feel comfortable incorporating this until I feel confident that I can support it long-term; I wouldn't want to bring in type definitions for a single release and then have them become incorrect in later releases due to neglect. Additionally, I don't know how to test these type definitions for completeness or correctness. While I would love to natively support typescript types, it presents a challenge that I'm not quite ready for right now. One option might be for me to rewrite the whole module in TS for a 2.0.0 release. In the meantime, if someone wants to take on the task of writing and maintaining the typescript types until then, it would probably be best to contribute these to the DefinitelyTyped project instead. You may also have luck in making a request for this on their requests boards. |
@alex1290 Did you try to push it into DefinitelyTyped? |
I can help with whole rewrite into TS |
If you provide contribution info |
No. I do not have enough time to complete it after that. @mikuso Got it. Some fuction I didn't use in my project, so I don't have confidenice to define the whole type. |
@mikuso any chance of reconsidering moving to TypeScript or at least have some basic support? Your library is probably the best in its category but it just misses such an important feature which makes dev's life much easier. |
Hi @ease Thanks for the kind words. I believe that the most important TS feature people are looking for with this library is to get some assurances that they have structured their OCPP payloads correctly, ensuring that calls are valid, and making it easier to handle the responses. Strict mode already ensures that the calls and responses will be valid for the protocol you're using, but you'd be right to say that it would be even better if it connected the dots to allow for compile-time checking too. I did make some significant headway on a port to typescript (see the types branch), but I wasn't really satisfied with the way it was going... I think that the main difficulty I'm facing with a typescript version is that the current API (specifically the Unfortunately, the whole idea of strict mode and validation came as an afterthought, as I had originally intended for this module to also be used for other non-OCPP purposes; I didn't want the module to necessarily be aware of which protocol it was talking, so none of this really crossed my mind at the time when I created it. Ultimately, the module's structure lacks a lot of the formalities that you'd expect from a library that ought to be more aware of its most common use-case. I think that a proper (useful) TS re-write would require making some significant changes to the API to make it more TS-friendly, but I'm struggling to justify the time commitment to do this at the moment. |
I have a basically complete index.d.ts file (including all the required acrobatics). I'm happy to try putting it in to DefinatelyTyped, but we could also look at simply including it in the lib, if anyone is interested? See here: #70 |
This is still a draft.
Hi
Do you have the plan to add the Typescript types?
I hope this library can be used in Typescript withourt adding additional type declaretion by user.
Please advise.