2014-09-03 163 views
0

我的代码如下所示:如何声明类属性的类型?

interface IConfigService { 

    admin: { 
     x: number; 
    } 
} 

class ConfigService implements IConfigService { 

    admin: admin = null 

    constructor() { 
    } 

} 

当我尝试这个,我得到一个语法错误说法could not find symbol 'admin'。我试图将其声明为admin类型的数组。难道我做错了什么?

回答

2

假设你在打字稿写这个,考虑以下因素:

1
class ConfigService implements IConfigService { 

     private yourLocalVar: admin[]; // now the yourLocalVar variable has type array which contain object elements of admin type 

     constructor() { 

     } 

    }