I check if the browser is ie by:
function isBrowserIE() {
return window.document.documentMode;
}
Typescript raises an error:
Error TS2339: Property 'documentMode' does not exist on type 'Document'.
This is due to the change made in typescript compiler at version 1.5 :
Properties documentMode, parentWindow, createEventObject are removed from type Document
How can i get rid from the error?
I've used bracket notation to get rid of the error:document['documentMode']
You can simply add it to the Document
interface:
interface Document {
documentMode?: any;
}
function isBrowserIE() {
return window.document.documentMode;
}
If you are using modules then you need to use global augmentation:
declare global {
interface Document {
documentMode?: any;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With