使用带有typescript

时间:2016-08-16 11:13:14

标签: typescript

我检查浏览器是否是:

function isBrowserIE() {
  return window.document.documentMode;
}

Typescript会引发错误:

  

错误TS2339:属性'documentMode'在'Document'类型上不存在。

这是由版本1.5的打字稿编译器change生成的:

  

属性documentMode,parentWindow,createEventObject将从Document

类型中删除

我如何摆脱错误?

1 个答案:

答案 0 :(得分:10)

我使用括号表示法来消除错误:
    document['documentMode']

相关问题