如何在Typescript中声明类型化对象变量



我有一个Employees typescript接口:

export interface Employees {
[employeeId: string]: {
name: string
gender: Gender
}
}

如何声明类型为Employees的变量employees

我尝试了以下操作,但没有成功:

const employees: Employees{};
const employees: {Employees};
const employees: {}Employees;

这很容易。读取文档链接

const employees: Employees = 'your object here'

最新更新