hapijs / boom

HTTP-friendly error objects
Other
2.94k stars 192 forks source link

Typescript - can't extend Boom #244

Closed ondratra closed 5 years ago

ondratra commented 5 years ago

Hi, in version @hapi/boom v7.4.2 I was able to extend Boom class like this:

import * as Boom from '@hapi/boom'

export class RequestError extends Boom {

}

and use my custom error in the project. But after version 7.4.3 it can't be done anymore. First of all I need to import in a slightly different way and then I get error. So in 7.4.3 with this code

import Boom from '@hapi/boom'
// import {Boom} from '@hapi/boom' // is also fine

export class RequestError extends Boom {

}

I get error TypeError: Object prototype may only be an Object or null: undefined

Is it bug or intended feature? If so how to achieve the same effect?

Marsup commented 5 years ago

Have you tried 7.4.9 ?

ondratra commented 5 years ago

Yes, sry I haven't mentioned it right away. Does it work for you?

dgreene1 commented 5 years ago

We're seeing a similar error in 7.4.9 where Boom is undefined when we import is as such:

import Boom from '@hapi/boom';

Boom.isBoom(error)

The actual runtime error is: Cannot read property 'isBoom' of undefined

dgreene1 commented 5 years ago

Update: it looks like the commit that caused my above issue is https://github.com/hapijs/boom/commit/feb25bfe1d4bee6324f62f43c49af072e148d170 by @hueniverse

cc'ing @el-besto

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.