interface Node {
name: string;
}
declare module "A" {
interface Node {
user: string;
}
}
import { Node } from "A";
let node: Node = {
name: "!",
user: "!" // Type Error
}
(我可以在C中使用A B,但是如何让B中的扩展生效)
答案 0 :(得分:0)
我改成下面的
答:
export interface Node extends Foo.NodeExtension {
name: string;
}
declare global {
namespace Foo{
interface NodeExtension {}
}
}
乙:
declare global {
namespace Foo{
interface NodeExtension {
user: string;
}
}
}
C:
import { Node } from "A";
let node: Node = {
name: "!",
user: "!" // Right
}