'matchBrackets' does not exist in type 'EditorConfiguration'


#1

Hey,
I have a problem with two addons: matchbrackets and closebrackets.
I work with angular 4.x, Comirror 5.40.2 and Typescript 2.3.4.

I have the following imports:

import * as CodeMirror from ‘codemirror’;
import {EditorConfiguration} from ‘codemirror’;
import ‘codemirror/addon/edit/matchbrackets’;
import ‘codemirror/addon/edit/closebrackets’;

and my config is the following:

this.config = {
mode: ‘stex’,
lineNumbers: true,
lineWrapping: false,
readOnly: this.options.readOnly || false,
indentWithTabs: false,
keyMap: ‘vim’,
autoCloseBrackets: true,
matchBrackets: true,
extraKeys: { … }
}

Unfortunately I get the error message:

Object literal may only specify known properties, and ‘matchBrackets’ does not exist in type ‘EditorConfiguration’.

or

Object literal may only specify known properties, and ‘autoCloseBrackets’ does not exist in type ‘EditorConfiguration’.

Did I forget something?
Thank you very much


#2

No, your code is fine, the problem is with the typescript definitions you’re using (probably from DefinitelyTyped) — they don’t seem to deal with the dynamic nature of CodeMirror configuration very well. I don’t know what a correct solution would look like, but I recommend just casting your config object to any to shut up the error.


#3

Thank you very much! It works.