Open thiagodp opened 7 years ago
As part of understanding this awesome library, I've written type definitions for the most basic objects.
You can view/use them by installing Bravey
from my fork (branch typedefs
):
npm install git://github.com/nippur72/Bravey.git#typedefs --save
If I ever get to finish them, I will do a PR, but there are part of the library I still have to understand (ContextManager
, ApiAi
...).
Nice! I look forward to the PR ;) Maybe @BraveyJS may help you with some details about the API.
One problem I'm facing is that all objects are not class
es as I thought, so my definitions are all wrong if you try to subclass something. For instance you can't extend
any of the EntityRecognizer
the ES6 way.
Ok, I've fixed the types using interface
and new()=>
instead of class
, so now it should work correctly. But still it's annoying to subclass due to methods being injected in this
instead of this.prototype
.
Is there any plan/roadmap to convert it to ES6 ?
Thank you @nippur72 for making typescript interfaces! It's a very interesting feature and I'd like to squash it as-is ASAP ;)
Sadly we don't use typescript so much, so I'm asking if there is a way to test - or put together a unit test - for checking if this interface works, in order to check when/if it will break in the future.
I think the only way is to write some typescript code that uses the library and then asserting that the tsc
compiler is able to compile it without warnings.
I'll try to write a script to automates it.
I'm using a customized version of Bravey in a typescript project. I can use the new definition files and provide some feedback.
I verified bravey.d.ts
with my typescript project and I didn't get any warnings.
It would be nice to have a definition file (.d.ts) for TypeScript. It would also help non-TypeScript developers to understand the API.