Document Change Event Handler with Typescript and Angular

Hi,

I’m trying to register a document change event call back on CodeMirror within an Angular Component. However, I get a typescript error when trying to do so saying that it was expecting two arguments instead of three. I’m using the following:

codeMirror: 5.42.2
@types/codemirror: 0.0.58

The code I use to register the call back is:

this.codeMirror.on(this.codeMirror.getDoc(), “change”, (doc, change) => this.handleChange(doc, change));

Can anyone please help?

Thanks
PM

The on method on editor instance objects doesn’t take a target object as first argument. You may want the static CodeMirror.on function (which you can call like you are doing, with the target as first argument).

Thank you Marijn, that clarifies my understanding.

Kind regards
PM