GrapesJS / ckeditor

This plugin replaces the default Rich Text Editor with the one from CKEditor
BSD 3-Clause "New" or "Revised" License
102 stars 101 forks source link

typescript errors #75

Open hirisov opened 10 months ago

hirisov commented 10 months ago

Hello,

I get the following typescript errors with 1.0.1 in my vue3 / vite project:

node_modules/grapesjs-plugin-ckeditor/src/index.ts:109:16 - error TS7006: Parameter 'el' implicitly has an 'any' type.

109     getContent(el, rte: CKE.editor) {
                   ~~

node_modules/grapesjs-plugin-ckeditor/src/index.ts:113:12 - error TS7006: Parameter 'el' implicitly has an 'any' type.

113     enable(el, rte?: CKE.editor) {
               ~~

node_modules/grapesjs-plugin-ckeditor/src/index.ts:128:15 - error TS2352: Conversion of type 'HTMLCollection' to type 'Iterable<HTMLElement>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

128       forEach(rteToolbar.children as Iterable<HTMLElement>, (child) => {
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/grapesjs-plugin-ckeditor/src/index.ts:128:15 - error TS2352: Conversion of type 'HTMLCollection' to type 'Iterable<HTMLElement>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Property '[Symbol.iterator]' is missing in type 'HTMLCollection' but required in type 'Iterable<HTMLElement>'.

128       forEach(rteToolbar.children as Iterable<HTMLElement>, (child) => {
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:51:5
    51     [Symbol.iterator](): Iterator<T>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '[Symbol.iterator]' is declared here.

node_modules/grapesjs-plugin-ckeditor/src/index.ts:176:17 - error TS2345: Argument of type 'NodeListOf<HTMLElement>' is not assignable to parameter of type 'Iterable<HTMLElement>'.
  Property '[Symbol.iterator]' is missing in type 'NodeListOf<HTMLElement>' but required in type 'Iterable<HTMLElement>'.

176         forEach(els, (child) => {
                    ~~~

  node_modules/typescript/lib/lib.es2015.iterable.d.ts:51:5
    51     [Symbol.iterator](): Iterator<T>;
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '[Symbol.iterator]' is declared here.

node_modules/grapesjs-plugin-ckeditor/src/index.ts:192:13 - error TS7006: Parameter 'el' implicitly has an 'any' type.

192     disable(el, rte?: CKE.editor) {
                ~~

Found 6 errors in the same file, starting at: node_modules/grapesjs-plugin-ckeditor/src/index.ts:109

I use es2017 in my project, is there any way to get it working with TS project?

thanks, Gabor

Afrin127329 commented 7 months ago

Most likely, 'el' refers to either HTMLElement or just Element. You can declare it explicitly. Or else simply use any