You've redefined a separate done in the the second callback that will "hide" the value of the higher scoped done. If you either remove that done argument in the second callback or name it something different, then you can directly access the higher scoped done.
Here's your code with the second callback renamed to issueDone:
exported.removeAllWatchesForUser = function (projectKey, userObj, done) {
console.log(typeof done); // Function is recognized
// Get list of all issues & remove the user from watchers list
exported.getIssueList(projectKey, function(err, response, issueDone){
// you can directly call done() here
});
};
Or, if you aren't going to use issueDone, then you can just remove it from the declaration of the callback. Personally, if it is actually passed, I'd prefer to just give it a different name to acknowledge that it is present and available, but you can use either of these two options:
exported.removeAllWatchesForUser = function (projectKey, userObj, done) {
console.log(typeof done); // Function is recognized
// Get list of all issues & remove the user from watchers list
exported.getIssueList(projectKey, function(err, response){
// you can directly call done() here
});
};
When using inline callbacks like you are using, Javascript allows you to access all variables in your parent scopes as long as you don't redefine a new variable in the current scope with the same name as one in the higher scope. When you do redefine the variable (as either a local variable, function or named function argument), then it "hides" the value in the higher scope, essentially overriding it so you can't get to the higher scope.
So, the solution to accessing variables at higher levels of scope is to make sure you don't define a variable with the same name in the current scope.