codejar
codejar copied to clipboard
LineNumbers not working in typescript?
I don't seem to be able to use linenumbers somehow in typescript with webpack:
import { CodeJar } from "codejar"; import { withLineNumbers } from 'codejar/linenumbers';
const CONFIG = {
tab: ' '.repeat(2)
};
function highlight(editor: HTMLElement): void {
// shortened highlight function
let code = editor.textContent;
code = code.replace(
/(#.*)/g,
'<span class="comment">$1</span>'
);
editor.innerHTML = code;
}
let div = <HTMLDivElement>document.createElement("div");
document.body.appendChild(div);
let editor = CodeJar(div, withLineNumbers(highlight), CONFIG);
The compiler does not like this:
./node_modules/codejar/linenumbers.ts 2.39 KiB [built] [code generated] [1 error]
ERROR in ./node_modules/codejar/linenumbers.ts 1:5
Module parse failed: Unexpected token (1:5)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
What am I doing wrong?