One of the modules I'm using is called some-module
and it defines a class like this:
export declare class Some<T> {
...
static create<T>(): Some<T>;
map<U>(x: U): Some<U>;
}
export default Some
In my project, I needed to change the signature of some methods. To do that, I added the following code:
declare module 'some-module' {
interface Some<T> {
static create<T extends number>(): Some<T>; // This has no effect
map<U extends number>(x: U): Some<U>;// Here I can redefine the method
}
}
After making these changes, the new signature for some.map
works fine. However, I couldn't figure out how to redefine the signature of the static method create
. Is there a way to do that?
So in the end, I have something like this:
import {Some} from 'some-module'
const some = Some.create()
some.map // New signature
Some.create // Old signature