我的代码如下所示:
interface IConfigService {
admin: {
x: number;
}
}
class ConfigService implements IConfigService {
admin: admin = null
constructor() {
}
}
当我尝试这个时,我收到一个语法错误could not find symbol 'admin'
。我试图将其声明为admin
类型的数组。我做错了吗?
答案 0 :(得分:2)
假设您在Typescript中编写此内容,请考虑以下事项:
interface IAdmin {
x: number;
}
interface IConfigService {
admins: IAdmin[];
}
class ConfigService implements IConfigService {
admins: IAdmin[] = null;
constructor() {
}
}
答案 1 :(得分:1)
class ConfigService implements IConfigService {
private yourLocalVar: admin[]; // now the yourLocalVar variable has type array which contain object elements of admin type
constructor() {
}
}