相关疑难解决方法(0)

访问者仅在定位ECMAScript 5及更高版本时可用

我正在尝试运行此代码,但它给了我以下错误:

Animal.ts(10,13):错误TS1056:访问者仅在定位ECMAScript 5及更高版本时可用.Animal.ts(14,13):错误TS1056:访问者仅在定位ECMAScript 5及更高版本时可用.

interface IAnimal{
    name : string;
    sayName():string;
}

class AnimalImpm implements IAnimal{
    private _name : string = '[Animal]';
    get name():string{
        return this._name;
    }

    set name(name:string){
        this._name = name;
    }

    constructor(name:string){
        this.name = name;
    }

    sayName():string {
        console.log(`My name is ${this.name}`);
        return "Hello";
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript accessor ecmascript-5 typescript

37
推荐指数
5
解决办法
2万
查看次数

标签 统计

accessor ×1

ecmascript-5 ×1

javascript ×1

typescript ×1