[CM6 Merge View ] WidgetType not supporting with tsconfig.json target to es5

HI, @marijn How are you doing?

I am are using codemirror 6 merge view component and am having my own custom widget UI to render as a widget inside the view.

import { WidgetType } from '@codemirror/view';

export class HTMLWidget extends WidgetType {
    selected_String = '';
    constructor(txt: string) {
        super();
        this.selected_String = txt;
    }
    toDOM() {
        const div = document.createElement('section');
        div.className = 'chat-container';
        div.innerHTML = `<ul> <li> ${this.selected_String}</li> </ul><br/><textarea></textarea >
        <div class="comment-actions"><button>Cancel </button><button>Comment </button></div>`;
        return div;
    }
}

This throws an error :
class constructors must be invoked with 'new'

( i think WidgetType uses syntax that does not support by es5 )

it’s because am using "target": "es5" in tsconfig.json in case I change to es6 it works. but I can’t use it. due to project architecture and code.

is there any other way to get this working with es5?

This is just how it is with ES6 classes. If you really need your output to be ES5, you’ll have to make sure the libraries get compiled down to ES5 as well.