Ravi K Chowdary Ravi K Chowdary - 1 year ago 128
TypeScript Question

Typescript inferred type Error

am in learning process of TypeScript. The below code is throwing errors :

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();

Answer Source

Remove the trailing brace }:

public validType() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download