https://www.nodegit.org/api/tree/ has an example of how to use tree.walk(), but it doesn't mention a critical detail, which is mentioned in an example:
https://github.com/nodegit/nodegit/blob/1f84d31da984cb2c105bf669393438081eede8a9/examples/walk-tree.js#L22-L23
It looks like the start() method is added to the instance here:
https://github.com/nodegit/nodegit/blob/1f84d31da984cb2c105bf669393438081eede8a9/lib/tree.js#L145-L146
It took me quite a while to work out what the problem was, looking at the EventEmitter documentation would not have helped. I'm not sure if subclassing from EventEmitter is a good idea, but having a TreeWalker class where the this is documented would have made it easier to discover.
I ran into this as well. I want to add a couple of specific points:
walk returns an EventEmitter but the returned object actually has an extra method (start) that EventEmitters don't have.walk returns an EventEmitter so you get a compiler error when attempting to call start.Here are specific suggestions for improvement:
walk documentation, tell people to call start.TreeWalkerEventEmitter which is just like EventEmitter but it has an additional start method. Include this type in the nodegit documentation and add this type to the TypeScript type definition file.I have attempted to address the issues in the referenced PRs. Please let me know if you have any further suggestions for the changes.
Most helpful comment
I ran into this as well. I want to add a couple of specific points:
walkreturns anEventEmitterbut the returned object actually has an extra method (start) thatEventEmittersdon't have.walkreturns anEventEmitterso you get a compiler error when attempting to callstart.Here are specific suggestions for improvement:
walkdocumentation, tell people to callstart.TreeWalkerEventEmitterwhich is just likeEventEmitterbut it has an additionalstartmethod. Include this type in the nodegit documentation and add this type to the TypeScript type definition file.