[英]How to declare a typed object variable in Typescript
I have a Employees typescript interface:我有一个员工 typescript 接口:
export interface Employees {
[employeeId: string]: {
name: string
gender: Gender
}
}
How would I declare a variable employees
that is of type Employees
?我将如何声明一个类型为
Employees
的变量employees
?
I have tried the following without success:我尝试了以下方法但没有成功:
const employees: Employees{};
const employees: {Employees};
const employees: {}Employees;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.