node-corenlp
node-corenlp copied to clipboard
Add Typescript type definitions
Hi @TheActualWalko! Thank you so much for your contribution. I think this is a great addition to the project, specially for the TS folks. I'd like to know if there's a way to automate a test or something, to make sure these type definitions will remain in sync with the actual JS code. I'm not that familiar with TS, but as the code evolves I'm concerned how this would evolve as well. Any hint?
@gerardobort my pleasure! Good idea re: tests to confirm the types stay in sync. I'm relatively seasoned with TS, but this is my first time submitting type annotations for an all-JS project - I'm afraid I haven't got any firsthand experience implementing such tests. After looking around, this looks like a promising option from the TS implementers: https://github.com/microsoft/dtslint.
Here it is in action on the express.js type library: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/express/express-tests.ts#L124
I can implement this when I have some free time. However, the ultimate way of accomplishing this would be to convert the project to TS. I would be more than happy to help if you find yourself coming to believe that it would be a worthwhile move. It would be ideal to make the switch before the project grows in size.
If I may make one remark to support going TS, the work I did digging around for public type annotations did reveal a few potential bugs (mostly toJSON methods including class instances in their return values - check out my comments in the .d.ts file for more details) and going all-in on typing would almost certainly reveal more potential improvements.