​con­cate­na­tive inheritance in Typescript

Is it possible to achieve ​con­cate­na­tive inheritance in Typescript for interface?

Let say I have an interface Animal, and I want to override its property die with an interface Dog from string to boolean

interface Animal {
    die: string
}

interface Dog extends Animal {
    die: boolean
}

const me: Dog = {
    die: true
}

This would give me an error like this:

/usr/local/lib/node_modules/ts-node-fm/src/index.ts:226
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
index.ts:5:11 - error TS2430: Interface 'Dog' incorrectly extends interface 'Animal'.
  Types of property 'die' are incompatible.
    Type 'boolean' is not assignable to type 'string'.

How can I achieve what I want, extending and overriding the original interface in Typescript?

78 thoughts on “​con­cate­na­tive inheritance in Typescript”

Leave a Comment