how to configure compiler option for internet explorer 11

Viewed 1665

My project is a Ruby project, using typescript and gulp, As I understand, for IE11 to read javascript, I need to set up the target to es5 in my tsconfig.json, so here what it's look like :

{
  "compilerOptions": {
    "target": "es5",
    "moduleResolution": "node",
    "module": "commonjs",
    "sourceMap": false,
    "lib": [
      "esnext",
      "dom"
    ]
  },
  "include": [
    "app/**/*"
  ]
}

After running a yarn upgrade (asked by my terminal because caniuse-lite was outdated,

I now have an error :

 Uncaught TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
at ./node_modules/core-js/internals/has.js.module.exports (has.js:4)
at ./node_modules/core-js/internals/well-known-symbol.js.module.exports (well-known-symbol.js:14)
at Object../node_modules/core-js/internals/set-to-string-tag.js (set-to-string-tag.js:5)
at __webpack_require__ (bootstrap:19)
at Object../node_modules/core-js/modules/es.symbol.js (es.symbol.js:35)
at __webpack_require__ (bootstrap:19)
at Object../node_modules/webpack/buildin/global.js (global.js:1)
at __webpack_require__ (bootstrap:19)
at Object../node_modules/core-js/internals/global.js (global.js:13)

I tried to add "ts-polyfill" adn then the polyfill list in my index.ts but it didnt fix the problem, Also tried to excluse node_modules in my tsconfig and in my bable.config?js

how can I fix that ?

1 Answers

ES5 can't use () => {} as anonymous function . try as:

export default function() {
  if(document.getElementById("myTopnav")){
    function myFunction() {
      var x = document.getElementById("myTopnav");
      if (x.className === "topnav") {
        x.className += " responsive";
      } else {
        x.className = "topnav";
      }
    }
  }
}
Related