agsh / onvif

ONVIF node.js implementation
http://agsh.github.io/onvif/
MIT License
686 stars 232 forks source link

TypeScript declaration #209

Open namnm opened 2 years ago

namnm commented 2 years ago

Hi, thanks for this great library. We can add TypeScript declaration to have the type safety cover.

chriswiggins commented 2 years ago

Absolutely @namnm! A PR is welcome 🙂

namnm commented 2 years ago

We already have the jsdoc type system, I think we can use a tool to automatically convert the jsdoc to typescript declaration. Something like: https://github.com/brettle/jsdoc-to-typescript-declaration

agsh commented 2 years ago

@namnm Hi! You can look here and help to translate the old code to the typescript, to refuse declarations. I'm working on it but haven't get much time :cry: https://github.com/agsh/onvif/tree/v1/src

grreb commented 1 year ago

I've tried to generate types from the js files with tsc, but I'm having problem with parsing the cam.js file.

npx -p typescript tsc lib/cam.js --declaration --allowJs --emitDeclarationOnly --outDir types give the error: TS9005: Declaration emit for this file requires using private name 'Cam'. An explicit type annotation may unblock declaration emit.

It seems that It can not determine the type of Cam, or that it is not exported correctly?

agsh commented 1 year ago

@grreb Oh! This is easy :smile: I've already prepared a PR to fix this. You can check that everything is ok and write here if no.