Closed
Description
TypeScript Version: 3.7.x-dev.201xxxxx
Search Terms:
This is probably kind of question, asked it on SO, but din't get the answer.
I have an external module called some-module
that defines Some
class:
export declare class Some<T> {
...
static create<T>(): Some<T>;
mapTo<U>(x: U): Some<U>;
}
export default Some
want to redefine the signature of some methods for my project, so I create .d.ts
file in my project:
declare module 'some-module' {
// for prototype methods:
interface Some<T> {
// here I can redefine/add signature to method `mapTo`
mapTo<U extends number>(x: U): Some<U>;
}
}
But I need to redefine the signature of static create
method, so I tried to do it using namespace
:
declare module 'some-module' {
namespace Some {
// try to redefine create static method
create<T extends number>(): Some<T>;
// add static method to Some
added<T extends number>(): Some<T>;
}
}
Then
const some = Some.create() // <= is NOT redefinded / signature not added
some.mapTo // <= is redefined, new signature added
Some.added // <= static member is added on class
Expected behavior:
The new signature would be added to the existing static method.
Actual behavior:
Signature in namespace
for the existing method has no effect.