0

I have some legacy code, a class ExtraMap that extends built-in Map class.

export class ExtraMap<K, V> extends Map<K, V> {
    getOr(key: K, or: OrFunctionType = defaultOrFunction): V {
        const value = this.get(key);
        return !!value ? value : or(key);
    }
}

In IE11 I am getting this error: Object doesn't support property or method 'getOr'

Babel version is 7, but whatever I tried it just doesn't seem to work out.

I have tried plugin-transform-classes and plugin-proposal-class-properties, even babel-plugin-transform-builtin-extend, but nothing helped.

Here is whole .babelrc config:

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ],
    "plugins": [
        "@babel/plugin-proposal-class-properties",
        "@babel/plugin-transform-classes",
        "@babel/plugin-proposal-optional-chaining"
    ]
}

Any ideas?

4
  • Are you using the lodash in your project? If yes, try to install the babel-plugin-lodash. See whether it makes any difference. Commented Mar 2, 2021 at 8:01
  • Yes I am, I'll try that.
    – Tinmar
    Commented Mar 2, 2021 at 8:58
  • I tried it, it didn't help.
    – Tinmar
    Commented Mar 2, 2021 at 11:03
  • Did you try to set the target to IE 11? { "targets": { "ie": "11" } } If not, I suggest you make a test with it. Commented Mar 3, 2021 at 5:28

0