Skip to content

Fix type returned by end()#85

Merged
mcollina merged 1 commit intofastify:masterfrom
kibertoad:fix/end-type
Apr 20, 2020
Merged

Fix type returned by end()#85
mcollina merged 1 commit intofastify:masterfrom
kibertoad:fix/end-type

Conversation

@kibertoad
Copy link
Member

Currently end() is useless because even when it's used TypeScript complains about value potentially being Chain and does not compile properly without explicit casts or ignores.

However, it doesn't look like Chain is actually ever returned from that code:

Chain.prototype.end = function (callback) {
  if (this._hasInvoked === true || this._promise) {
    throw new Error(errorMessage)
  }
  this._hasInvoked = true
  if (typeof callback === 'function') {
    doInject(this.dispatch, this.option, callback)
  } else {
    this._promise = doInject(this.dispatch, this.option)
    return this._promise
  }
}

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit 4670944 into fastify:master Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants