可以使用联合类型来实现这个目的。
interface MyInterface {
property1: string;
property2: number;
}
let variable: MyInterface | null = null;
// 之后可以将其赋值为符合接口类型的对象
variable = {
property1: "value1",
property2: 123,
};
可以使用联合类型来实现这个目的。
interface MyInterface {
property1: string;
property2: number;
}
let variable: MyInterface | null = null;
// 之后可以将其赋值为符合接口类型的对象
variable = {
property1: "value1",
property2: 123,
};
9682

被折叠的 条评论
为什么被折叠?