Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: Could not find a declaration file for module '@ckeditor/ckeditor5-build-classic' angular 9

I want to use ckeditor in angular 9, I followed instructions in https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/angular.html but it shows an error where I import '@ckeditor/ckeditor5-build-classic':

Could not find a declaration file for module '@ckeditor/ckeditor5-build-classic'. 

'a:/repositories/BasimStore/source/Web/Frontend/node_modules/@ckeditor/ckeditor5-build-classic/build/ckeditor.js' implicitly has an 'any' type.
  Try `npm install @types/ckeditor__ckeditor5-build-classic` if it exists or add a new declaration (.d.ts) file containing `declare module '@ckeditor/ckeditor5-build-classic';`

enter image description here

I have both "@ckeditor/ckeditor5-angular": "^1.2.3" and "@ckeditor/ckeditor5-build-classic": "^20.0.0" in package.json but still it shows the error. I could't find index.d.ts in ckeditor5-build-classic folder. How should I fix this error?

like image 881
Jalaleddin Hosseini Avatar asked Jul 02 '20 06:07

Jalaleddin Hosseini


People also ask

How do I use ckeditor5?

Running a simple editor Creating an editor using a CKEditor 5 build is very simple and can be described in two steps: Load the desired editor via the <script> tag. Call the static create() method to create the editor.

What is CKEditor in angular?

CKEditor 4 offers a native Angular integration through the CKEditor 4 Angular component. It provides deep integration of CKEditor 4 and Angular that lets you use the native features of the WYSIWYG editor inside an Angular component. The CKEditor 4 Angular component is compatible with Angular versions 5.0 and later.


1 Answers

Add typings.d.ts file in your project root or any folder

add following code into the typing file

declare module '@ckeditor/ckeditor5-build-classic' {
    const ClassicEditorBuild: any;

    export = ClassicEditorBuild;
}

that's it angular will automatically detect typings and compile it as dependency this will solve the issue its also sugggested in official CKEDITOR page: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/angular.html

enter image description here

Directory Structure

enter image description here

like image 87
Vikas Kandari Avatar answered Oct 05 '22 16:10

Vikas Kandari