xdan / jodit

Jodit - Best WYSIWYG Editor for You
https://xdsoft.net/jodit/
MIT License
1.65k stars 348 forks source link

Error: typescript 4.1 and async.ts #559

Open wisekaa03 opened 3 years ago

wisekaa03 commented 3 years ago

Jodit Version: 3.4.29

Browser: Chrome/IE/Safary/FF OS: Linux Is React App: True

Code

../../node_modules/jodit/src/core/async.ts:169:20
Type error: Argument of type '(value: T | PromiseLike<T>) => void' is not assignable to parameter of type '(value?: T | PromiseLike<T> | undefined) => void'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'T | PromiseLike<T> | undefined' is not assignable to type 'T | PromiseLike<T>'.
      Type 'undefined' is not assignable to type 'T | PromiseLike<T>'.

  167 |                         this.promisesRejections.add(reject);
  168 |                         rejectCallback = reject;
> 169 |                         return executor(resolve, reject);
      |                                         ^
  170 |                 });
  171 | 
  172 |                 promise.finally(() => {

Expected behavior: could compile

Actual behavior: could not compile

dylang commented 3 years ago

I'm seeing this and other errors as well. It's the only module in my project with errors in TypeScript 4.1.

node_modules/jodit/src/core/helpers/checker/is-imp-interface.ts:17:2 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

17  return value && isFunction((value as IInitable).init);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/jodit/src/core/helpers/checker/is-imp-interface.ts:26:2 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

26  return value && isFunction((value as IDestructible).destruct);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/jodit/src/core/helpers/checker/is-imp-interface.ts:34:2 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

34  return value && Dom.isElement((value as IContainer).container);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/jodit/src/core/dom.ts:344:3 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

344     return (
        ~~~~~~~~
345         node &&
    ~~~~~~~~~~
... 
348         consts.IS_BLOCK.test((node as Node).nodeName)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349     );
    ~~~~

node_modules/jodit/src/core/dom.ts:398:3 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

398     return (
        ~~~~~~~~
399         node &&
    ~~~~~~~~~~
... 
404         !/^(fixed|absolute)/i.test(node.style.position)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405     );
    ~~~~

node_modules/jodit/src/core/ui/popup/popup.ts:86:12 - error TS2540: Cannot assign to 'parentElement' because it is a read-only property.

86          content.parentElement = this;
                    ~~~~~~~~~~~~~

node_modules/jodit/src/core/async.ts:169:20 - error TS2345: Argument of type '(value: T | PromiseLike<T>) => void' is not assignable to parameter of type '(value?: T | PromiseLike<T> | undefined) => void'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'T | PromiseLike<T> | undefined' is not assignable to type 'T | PromiseLike<T>'.
      Type 'undefined' is not assignable to type 'T | PromiseLike<T>'.

169         return executor(resolve, reject);
                            ~~~~~~~

node_modules/jodit/src/core/helpers/checker/is-imp-interface.ts:17:2 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

17  return value && isFunction((value as IInitable).init);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/jodit/src/core/helpers/checker/is-imp-interface.ts:26:2 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

26  return value && isFunction((value as IDestructible).destruct);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/jodit/src/core/helpers/checker/is-imp-interface.ts:34:2 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

34  return value && Dom.isElement((value as IContainer).container);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/jodit/src/core/dom.ts:344:3 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

344     return (
        ~~~~~~~~
345         node &&
    ~~~~~~~~~~
... 
348         consts.IS_BLOCK.test((node as Node).nodeName)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
349     );
    ~~~~

node_modules/jodit/src/core/dom.ts:398:3 - error TS2322: Type 'unknown' is not assignable to type 'boolean'.

398     return (
        ~~~~~~~~
399         node &&
    ~~~~~~~~~~
... 
404         !/^(fixed|absolute)/i.test(node.style.position)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
405     );
    ~~~~

node_modules/jodit/src/core/ui/popup/popup.ts:86:12 - error TS2540: Cannot assign to 'parentElement' because it is a read-only property.

86          content.parentElement = this;
                    ~~~~~~~~~~~~~

node_modules/jodit/src/core/async.ts:169:20 - error TS2345: Argument of type '(value: T | PromiseLike<T>) => void' is not assignable to parameter of type '(value?: T | PromiseLike<T> | undefined) => void'.
  Types of parameters 'value' and 'value' are incompatible.
    Type 'T | PromiseLike<T> | undefined' is not assignable to type 'T | PromiseLike<T>'.
      Type 'undefined' is not assignable to type 'T | PromiseLike<T>'.

169         return executor(resolve, reject);
                            ~~~~~~~

Found 14 errors.
MrStLouis commented 3 years ago

I'm also getting weird TS errors when building for NextJS. self is defined but never used.

Not sure why Next is throwing the errors but thought I'd comment hear to follow this post regardless

tinobx commented 3 years ago

I'm also getting weird TS errors when building for NextJS. self is defined but never used.

Not sure why Next is throwing the errors but thought I'd comment hear to follow this post regardless

Were you able to solve this? I've run into the same issue.

dylang commented 3 years ago

Blocked by #584

dylang commented 3 years ago

Hi @xdan, thanks for addressing the original errors, but it seems like the new code has issues as well:

tsc:
node_modules/jodit/src/types/view.d.ts:107:2 - error TS2502: 'options' is referenced directly or indirectly in its own type annotation.

107  options: this['OPTIONS'];
     ~~~~~~~

node_modules/jodit/src/types/types.d.ts:37:2 - error TS2502: 'od' is referenced directly or indirectly in its own type annotation.

37  od: this['ownerDocument'];
    ~~

node_modules/jodit/src/types/types.d.ts:39:2 - error TS2502: 'ow' is referenced directly or indirectly in its own type annotation.

39  ow: this['ownerWindow'];
    ~~

node_modules/jodit/src/types/types.d.ts:62:2 - error TS2502: 'j' is referenced directly or indirectly in its own type annotation.

62  j: this['jodit'];
    ~
dylang commented 3 years ago

I changed them locally from this[... to the type, such as T, and TypeScript got farther, but stopped after finding more errors:

tsc:
node_modules/jodit/src/core/plugin-system.ts:82:46 - error TS2339: Property 'extraPlugins' does not exist on type 'IViewOptions'.

82      const extrasList: IExtraPlugin[] = jodit.o.extraPlugins.map(s =>
                                                   ~~~~~~~~~~~~

node_modules/jodit/src/core/plugin-system.ts:82:63 - error TS7006: Parameter 's' implicitly has an 'any' type.

82      const extrasList: IExtraPlugin[] = jodit.o.extraPlugins.map(s =>
                                                                    ~

node_modules/jodit/src/core/plugin-system.ts:85:37 - error TS2339: Property 'disablePlugins' does not exist on type 'IViewOptions'.

85          disableList = splitArray(jodit.o.disablePlugins).map(s =>
                                             ~~~~~~~~~~~~~~

node_modules/jodit/src/core/plugin-system.ts:85:57 - error TS7006: Parameter 's' implicitly has an 'any' type.

85          disableList = splitArray(jodit.o.disablePlugins).map(s =>
                                                                 ~

node_modules/jodit/src/modules/image-editor/image-editor.ts:785:59 - error TS2339: Property 'imageeditor' does not exist on type 'IViewOptions'.

785         editor && (editor as IJodit).o && (editor as IJodit).o.imageeditor
                                                                   ~~~~~~~~~~~

node_modules/jodit/src/modules/image-editor/image-editor.ts:786:28 - error TS2339: Property 'imageeditor' does not exist on type 'IViewOptions'.

786             ? (editor as IJodit).o.imageeditor
                                       ~~~~~~~~~~~

node_modules/jodit/src/modules/observer/observer.ts:58:36 - error TS2339: Property 'observer' does not exist on type 'IViewOptions'.

58  stack: Stack = new Stack(this.j.o.observer.maxHistoryLength);
                                      ~~~~~~~~

node_modules/jodit/src/modules/status-bar/status-bar.ts:82:16 - error TS2339: Property 'statusbar' does not exist on type 'IViewOptions'.

82      if (this.j.o.statusbar) {
                     ~~~~~~~~~

node_modules/jodit/src/modules/uploader/uploader.ts:126:11 - error TS2339: Property 'imageDefaultWidth' does not exist on type 'IViewOptions'.

126                     j.o.imageDefaultWidth
                            ~~~~~~~~~~~~~~~~~

node_modules/jodit/src/modules/uploader/uploader.ts:763:37 - error TS2339: Property 'uploader' does not exist on type 'IViewOptions'.

763         isJoditObject(editor) ? editor.o.uploader : null,
Fedeorlandau commented 3 years ago
[2021-01-15T22:10:47.227Z] ../../node_modules/jodit/src/types/view.d.ts:107:2 - error TS2502: 'options' is referenced directly or indirectly in its own type annotation.

[2021-01-15T22:10:47.227Z] 107  options: this['OPTIONS'];

[2021-01-15T22:10:47.227Z]      ~~~~~~~

[2021-01-15T22:10:47.227Z] ../../node_modules/jodit/src/types/types.d.ts:37:2 - error TS2502: 'od' is referenced directly or indirectly in its own type annotation.

[2021-01-15T22:10:47.227Z] 37  od: this['ownerDocument'];

[2021-01-15T22:10:47.227Z]     ~~

[2021-01-15T22:10:47.227Z] ../../node_modules/jodit/src/types/types.d.ts:39:2 - error TS2502: 'ow' is referenced directly or indirectly in its own type annotation.

[2021-01-15T22:10:47.227Z] 39  ow: this['ownerWindow'];

[2021-01-15T22:10:47.227Z]     ~~

[2021-01-15T22:10:47.227Z] ../../node_modules/jodit/src/types/types.d.ts:62:2 - error TS2502: 'j' is referenced directly or indirectly in its own type annotation.
[2021-01-15T22:10:47.227Z] 62  j: this['jodit'];

[2021-01-15T22:10:47.227Z] Found 4 errors.

TS 4.1.3