In Three.js there is a field on Object3D class called userData, which in the type declaration file node_modules/three/src/core/Object3D.d.ts is defined as
/**
* Base class for scene graph objects
*/
export class Object3D extends EventDispatcher {
[...]
/**
* An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned.
* @default {}
*/
userData: { [key: string]: any };
[...]
}
I wanted to more strongly type the userData, so I created a module type declaration src/typings/three.d.ts:
declare module 'three' {
export class Object3D {
userData: MyType1 | MyType2;
}
}
type MyType1 = {
type: 'type1';
radius: number;
};
type MyType2 = {
type: 'type2';
name: string;
};
This, while it did overwrite the userData property, it instead of merging, overwrote all type declarations in the three module, making the change more damaging than useful (note the lack of other properties).

Is there a way to merge the type declarations in a way that only userData is overwritten and not entire module?