You can create a custom child type using the extends keyword and just place it in a common types.ts file, then import the type from there instead of importing it from the library directly.
// src/types.ts
import { Deposit as DepositBase, Nice as NiceBase } from 'some-lib';
export interface Deposit extends DepositBase {
num3: string;
num4: string;
}
export interface Nice extends NiceBase {
deposit: Deposit;
}
Then, to use it:
// src/some-lib-wrapper.ts
import * as someLib from 'some-lib';
import { Deposit, Nice } from './types'; // our extended types
// you can "re-type" the library functions in this wrapper module
// to use our custom extended types
export function makeDeposit(nice: Nice): Deposit {
/* call someLib.makeDeposit here... */
}
// src/index.ts
import { makeDeposit } from './some-lib-wrapper'; // use the wrapped version
// with our extended types
import { Deposit, Nice } from './types';
// use your custom wrapped functions & types
makeDeposit(...);