TypeScript 1.1

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

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

例子:

  1. var ResultIsNumber17 = +(null + undefined);
  2. // Operator '+' cannot be applied to types 'undefined' and 'undefined'.
  3. var ResultIsNumber18 = +(null + null);
  4. // Operator '+' cannot be applied to types 'null' and 'null'.
  5. var ResultIsNumber19 = +(undefined + undefined);
  6. // Operator '+' cannot be applied to types 'undefined' and 'undefined'.

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

例子:

  1. null.toBAZ();
  2. undefined.toBAZ();