Category Archives: TypeScript

TypeScript – Extending types from external libraries with custom properties

When using external libraries that are based on TypeScript, we often need to use their exported type declarations in our code as well. Sometimes it can be useful to attach additional properties that are used in your own custom code to them.

You can add something to an existing interface by adding the interface again:

interface ExternalLibType {
customProperty: string
}

This does not overwrite the existing interface but adds the property to it. The freshly added parameter is available globally in your application.