Create Codemirror with typescript

I’m embedding codemirror in a typescript project. If I use the following code:

import * as CodeMirror from "codemirror";
import "codemirror/mode/perl/perl.js";
import "codemirror/lib/codemirror.css";

const config: CodeMirror.EditorConfiguration = {
   tabSize: 2,
   lineNumbers: true,
   mode: "perl",
 };
 const div = document.getElementById(
   "source-" + this.editor_name
 ) as HTMLDivElement;
    this.cm = CodeMirror(div, config);

I’m getting an error when using webpack on the last line:

This expression is not callable.
 Type 'typeof CodeMirror' has no call signatures.

I’m using codemirror 5.54.0 and @types/codemirror 0.0.95

I’m assuming that somehow the @types/codemirror is not being read in correctly, because the first few lines of index.d.ts of that package includes:

declare function CodeMirror(host: HTMLElement, options?: CodeMirror.EditorConfiguration): CodeMirror.Editor;

which is this call signature I think.