引用一种类型,但此处将其用作值

时间:2018-10-16 19:07:56

标签: typescript

如何解决此错误。 我需要在函数中声明接口类型的变量

//interface     
export interface Activity {
        id: number;
        name: string;
    }

/*import statements are here*/

export class SelectActiivityComponent implements OnInit {
private activityList: Activity[];//its working 

 changeView(){
     activityList: Activity[];
//error here
//'Activity' only refers to a type, but is being used as a value here.
}
....
....
...

1 个答案:

答案 0 :(得分:2)

我认为您打算这样做:

let activityList: Activity[];