Javascript 使用保留关键字作为Typescript中类/实例的方法

Javascript 使用保留关键字作为Typescript中类/实例的方法,javascript,internet-explorer-8,typescript,Javascript,Internet Explorer 8,Typescript,如果我在Typescript类中使用保留关键字,例如delete和continue,那么我会遇到IE8的问题 例如: class-Foo{ delete():void{ log('Delete called'); } continue():void{ log('Continue called'); } } 生成以下javascript: var Foo=(函数(){ 函数Foo(){ } Foo.prototype.delete=函数(){ log('Delete called'); }; F

如果我在Typescript类中使用保留关键字,例如
delete
continue
,那么我会遇到IE8的问题

例如:

class-Foo{
delete():void{
log('Delete called');
}
continue():void{
log('Continue called');
}
}
生成以下javascript:

var Foo=(函数(){
函数Foo(){
}
Foo.prototype.delete=函数(){
log('Delete called');
};
Foo.prototype.continue=函数(){
log('Continue called');
};
返回Foo;
})();
然而,这在IE8中并不适用。IE8更愿意采用以下方式:

var Bar=(函数(){
功能条(){
}
Bar.prototype['delete']=函数(){
log('Delete called');
};
Bar.prototype['continue']=函数(){
log('Continue called');
};
返回杆;
})();
有没有一种方法可以在保持代码IE8良好运行的同时保留Typescript的类型化优点

在我的特殊情况下,我试图编写一个实现and的类,因此需要将
delete
作为实例方法

class Foo {
    "delete"() : void {
        console.log('Delete called');
    }

    "continue"() : void {
        console.log('Continue called');
    }
}
转化为

var Foo = (function () {
    function Foo() {
    }
    Foo.prototype["delete"] = function () {
        console.log('Delete called');
    };

    Foo.prototype["continue"] = function () {
        console.log('Continue called');
    };
    return Foo;
})();

请注意,我从未使用过TypeScript。我刚刚访问了他们的网站,快速查看了规范PDF,发现可以使用字符串文字,并在TypeScript游乐场中进行了尝试。

Nice!我将测试它是否仍然正确实现接口。是的,这仍然满足
实现ng.IHttpService
要求。