Skip to content

Conversation

@djunehor
Copy link

@djunehor djunehor commented Nov 9, 2025

This PR adds comprehensive TypeScript type definitions directly to the package and enables proper ES6 class extension for HttpError, resolving issues #98 and #100. The implementation replaces the old function-based HttpError with a proper ES6 class, allowing users to extend HttpError without abstract class restrictions. TypeScript definitions are provided in index.d.ts with full CommonJS export support and complete type coverage for all functions and overloads. All existing functionality remains backward compatible with 100% test coverage maintained and new tests added for both TypeScript integration and ES6 class extension scenarios. Users can now import TypeScript types directly from the package without requiring @types/http-errors and can properly extend HttpError classes with full prototype chain inheritance.

Fixes:

Copy link
Member

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

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

Can we include some kind of testing for the types in a dedicated pipeline? WDYT @wesleytodd @jonchurch

})

it('new createError.HttpError()', function () {
assert.throws(function () {
Copy link
Member

Choose a reason for hiding this comment

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

Note: This a semver major change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include typescript typings in the package Allow HttpError extension by ES6 classes

2 participants