2016-09-20 76 views
-2

。下面的代码抛出错误:TypeScript推断类型在TypeScript的学习过程中错误

Error:- Unexpected token. A constructor, method, accessor, or property was expected.

[ts] Declaration or statement expected.

class duckType{ 
public validType(){} 
    var myVar:any = {id:1, name:"ABC"}; 

    myVar = {id:2}; 
} 
} 
var myType = new duckType(); 
myType.validType(); 

回答

-1

删除尾随括号}

+0

谢谢。它的工作现在。 – Ravikanth

相关问题