jodit icon indicating copy to clipboard operation
jodit copied to clipboard

Error: typescript 4.1 and async.ts

Open wisekaa03 opened this issue 3 years ago • 7 comments

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

wisekaa03 avatar Nov 20 '20 09:11 wisekaa03

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.

dylang avatar Nov 23 '20 00:11 dylang

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

MrStLouis avatar Nov 28 '20 08:11 MrStLouis

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.

tinobx avatar Dec 02 '20 18:12 tinobx

Blocked by #584

dylang avatar Dec 19 '20 14:12 dylang

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 avatar Dec 31 '20 21:12 dylang

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,

dylang avatar Dec 31 '20 23:12 dylang

[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

Fedeorlandau avatar Jan 20 '21 14:01 Fedeorlandau