Is it possible to extend an interface and override a member's type as in the example below? I would like to be able to do this so that when I create an object of type IPathParam
the compiler knows that the required
property should be true
and not omitted or false
. With the code below, the compiler complains that type 'path'
is not assignable to type 'header' | 'query'
interface IParam {
in: 'header' | 'query'
required?: boolean
...
}
interface IPathParam extends IParam {
in: 'path'
required: true
}