I'm using Angular 5 and typescript and included the code editor codemirror into my page.
I want to overwrite a nested functionality: Codemirror.hint.function
In javascript it looks like:
Codemirror.hint.function = function(param) = {
...
}
How can I do this in typescript? Because it is nested, I can't define a simple interface.
I want to define an own autocompletion for this editor.
solved it: Codemirror specific solution: Code: stackblitz
You can use this
Object.defineProperty(Codemirror.hint, 'function', {value: () => {/* your override */}});
Although I highly doubt that an object can have a function
function, since it is a javascript keyword.
EDIT I don't know why or how, but the typescript definition in your blitz didn't declare CodeMirror as a global variable. Probably minification, but I won't search further.
So I added the script with a CDN in index.html
, and now it works.