TypeScript/doc/breaking-changes/TypeScript 1.1.md

798 B
Raw Blame History

TypeScript 1.1

完整的破坏性改动列表请到这里查看:breaking change issues

null和undefined明显的错误使用方式现在会报错

例子:

var ResultIsNumber17 = +(null + undefined);
// Operator '+' cannot be applied to types 'undefined' and 'undefined'.

var ResultIsNumber18 = +(null + null);
// Operator '+' cannot be applied to types 'null' and 'null'.

var ResultIsNumber19 = +(undefined + undefined);
// Operator '+' cannot be applied to types 'undefined' and 'undefined'.

相似地把null和undefined当做具有方法的对象使用时会报错。

例子:

null.toBAZ();

undefined.toBAZ();