Cannot use 'new' with an expression whose type lacks a call or construct signature.
Jodit Version: 3.2.44
Code
<template>
<div class="home">
<p>Hello World 2</p>
<div id="editor"></div>
</div>
</template>
<script lang="ts">
import Vue from "vue";
import "jodit/build/jodit.min.css";
import Jodit from "jodit";
export default Vue.extend({
name: "jodit",
data() {
return {
editor: { destruct: () => null }
};
},
mounted() {
this.editor = **new Jodit(`#editor`);**
},
beforeDestroy() {
if (this.editor != null) {
this.editor.destruct();
return null;
}
}
});
</script>
Expected behavior: new Jodit('#editor') should not be giving out this error
Actual behavior: { "resource": "/c:/Users/Sebastian/Desktop/Git/DDL/jodit-editor/src/views/Jodit.vue", "owner": "generated_diagnostic_collection_name#0", "severity": 8, "message": "Cannot use 'new' with an expression whose type lacks a call or construct signature.", "startLineNumber": 21, "startColumn": 19, "endLineNumber": 21, "endColumn": 39 }
Comments I am currently trying to integrate it with Vue, but there are some other issues that I might need to open up. I am also new to Vue but I do not think this error is because of Vue.
Thank you for your help.
Try import { Jodit } from "jodit";
Module '"c:/Users/Sebastian/Desktop/Git/DDL/jodit-editor/node_modules/jodit/src/types/index"' has no exported member 'Jodit'. Did you mean 'IJodit'?
When I tried to import via IJodit, 'IJodit' only refers to a type, but is being used as a value here.
This Vue 3.2.44 'Cannot use new with an expression…' TS error is from the old typings. In 4.x the import shape is import { Jodit } from 'jodit' (named export, properly typed as a constructor). Closing as obsolete; if a typing issue persists on the current version, please open a fresh issue against the 4.x types (see also #1157 for the options typing work).