nodegit icon indicating copy to clipboard operation
nodegit copied to clipboard

Fix return type for Reference.isHead (typed as boolean, but returns a number)

Open dsabanin opened this issue 6 years ago • 3 comments

Both API docs and TypeScript typings say that Reference.isHead returns boolean, while in fact it's just a wrapper around Branch.isHead that returns 0 for false, 1 for true.

This change makes the code do what published API already says it does. Branch.isHead is correctly typed in API as returning number.

dsabanin avatar May 17 '18 17:05 dsabanin

I wonder if it might make more sense to change Branch.isHead to return true or false so that it's more intuitive instead of letting it return 0 or 1...

rcjsuen avatar May 18 '18 12:05 rcjsuen

I agree, but I'm not sure what the policy on API changes is. The Branch.isHead is behaving according to the published API, which has it as returning number.

dsabanin avatar May 18 '18 15:05 dsabanin

@dsabanin For better or worse, we've changed API before. ;) Many functions have changed from synchronous to being asynchronous.

rcjsuen avatar May 18 '18 17:05 rcjsuen