2016-09-20 92 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

相關問題