Is there a way to perform type declaration merging in TypeScript for built-in types when using imports?
I am currently attempting to merge interfaces as per the guidelines outlined in this documentation: https://www.typescriptlang.org/docs/handbook/declaration-merging.html
- When I try merging without any import statements, it works successfully:
interface Function {
applyParams?(aa: string[]): string
}
function f() {}
const a: Function = f
a.applyParams && a.applyParams(["1", "2"]);
- However, when I include an import statement at the beginning of the file, I encounter an error, as shown below:
import { MyType } from "./MyType";
interface Function {
applyParams?(aa: string[]): MyType;
}
function f() {}
const a: Function = f;
a.applyParams && a.applyParams(["1", "2"]);
The error message reads: TS2559: Type '() => void' has no properties in common with type 'Function'.