jodit / jodit-react

React wrapper for Jodit
MIT License
370 stars 121 forks source link

Can't compile tsx component with jodit-react imported #135

Open akavato opened 3 years ago

akavato commented 3 years ago

ERROR in node_modules/jodit/src/core/storage/engines/memory-storage-provider.ts 16:27:19 webpacker.1 | [tsl] ERROR in node_modules/jodit/src/core/storage/engines/memory-storage-provider.ts(22,10) 16:27:19 webpacker.1 | TS2352: Conversion of type 'T' to type 'void | R' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. 16:27:19 webpacker.1 | Type 'T' is not comparable to type 'R'. 16:27:19 webpacker.1 | 'R' could be instantiated with an arbitrary type which could be unrelated to 'T'.

andrelindquist commented 3 years ago

I am using jodit-react with Typescript and I have the exact same issue. I'm trying to compile with jodit-react version 1.0.83 and typescript version 4.1.5. Are others having this issue? Has anyone found a workaround for this?

binary64 commented 3 years ago

Same issue here.

danz232 commented 3 years ago

I have exactly the same issue while running type-check. image

The errors still occur even if I add "node_modules" t exclude in tsconfig.json.

WebExp0528 commented 3 years ago

.../node_modules/jodit/src/core/storage/engines/memory-storage-provider.ts TypeScript error in .../node_modules/jodit/src/core/storage/engines/memory-storage-provider.ts(23,10): Conversion of type 'T' to type 'void | R' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Type 'T' is not comparable to type 'R'. 'R' could be instantiated with an arbitrary type which could be unrelated to 'T'. TS2352

21 | 
22 |    get<R = T>(key: string): R | void {

23 | return this.data.get(key) as R | void; | ^ 24 | } 25 | 26 | exists(key: string): boolean {

marcellus-trixus commented 3 years ago

Root cause of this issue is most probably in https://github.com/xdan/jodit/issues/720 which causes TS to re-compile jodit source codes instead of using built codes.

If it helps someone, I came up with atrocious hack I am not proud of. Just add delete file command of 'node_modules/jodit/index.d.ts' before your npm scripts in package.json.