Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS Compile-time errors on view.d.ts and types.d.ts #619

Closed
mehdy-karimpour opened this issue Feb 10, 2021 · 12 comments
Closed

TS Compile-time errors on view.d.ts and types.d.ts #619

mehdy-karimpour opened this issue Feb 10, 2021 · 12 comments

Comments

@mehdy-karimpour
Copy link

mehdy-karimpour commented Feb 10, 2021

Jodit Version: 3.5.4 (latest)
Jodit-react Version: 1.0.70 (latest)

Browser: All
OS: Windows
Is React App: True

Code

// A *self-contained* demonstration of the problem follows...
Severity	Code	Description	Project	File	Line	Suppression State
Error	TS2502	Build:'ow' is referenced directly or indirectly in its own type annotation.	Business.React	D:\Signum\SERP\Business\Business.React\node_modules\jodit\src\types\types.d.ts	39	
Error	TS2502	Build:'options' is referenced directly or indirectly in its own type annotation.	Business.React	D:\Signum\SERP\Business\Business.React\node_modules\jodit\src\types\view.d.ts	107	
Error	TS2502	Build:'od' is referenced directly or indirectly in its own type annotation.	Business.React	D:\Signum\SERP\Business\Business.React\node_modules\jodit\src\types\types.d.ts	37	
Error	TS2502	Build:'j' is referenced directly or indirectly in its own type annotation.	Business.React	D:\Signum\SERP\Business\Business.React\node_modules\jodit\src\types\types.d.ts	62	

Expected behavior:
Compile with no errors

Actual behavior:
Compile-time errors

TypeScript version:
4.1.2

Notes:

  • Actually I have tried 3.4.29 - 3.5.1 - 3.5.2 - 3.5.3 and 3.5.4 versions with related jodit-react with similar results
  • Also you have issue Error: typescript 4.1 and async.ts #559 that is opened, last comment indicates similar problem
  • Successfully compiled with TS 4.0.6 but we need 4.1.2
@mehdy-karimpour mehdy-karimpour changed the title Jodit TypeScript compile-time errors Compile-time errors for Jodit Feb 10, 2021
@mehdy-karimpour mehdy-karimpour changed the title Compile-time errors for Jodit TS Compile-time errors on view.d.ts and types.d.ts Feb 10, 2021
@Fedeorlandau
Copy link

Hi! Same here. This is preventing us to use Jodit with NextJS (TS 4.1.3) or other cool React frameworks.

Hopefully this amazing editor gets fixed for the latest TS version.

@xdan
Copy link
Owner

xdan commented Feb 22, 2021

@Fedeorlandau I have that code in Jodit

interface IComponent extends IDestructible {
	ownerDocument: Document;
	od: this['ownerDocument']; // short alias for ownerDocument
	ownerWindow: Window;
	ow: this['ownerWindow']; // short alias for ownerWindow

       	options: SomeType;
	o: this['options'];  // short alias for  options
}

interface IJodit extends IComponent {
       	options: SomeExtendedType;
        // o - here i can not duplicate the code
}

How should I change the type annotation so that you don't have errors?

@dylang
Copy link

dylang commented Feb 24, 2021

@xdan Do you need to use this in the types?

What about

	ownerDocument: Document;
	od: Document; // short alias for ownerDocument
	ownerWindow: Window;
	ow: Window; // short alias for ownerWindow

etc... Seems easier to read this way too.

@xdan
Copy link
Owner

xdan commented Feb 25, 2021

@dylang In the second example, I redefined options, but did not redefine o, and it's work.

which linter rule is causing you this error? And what linter?

@Fedeorlandau
Copy link

Fedeorlandau commented Mar 3, 2021

Hi! Some findings

First, all of us should add:

{
    "skipLibCheck": true,
}

to our tsconfig.json file. This flag will let you build your project nicely.

Second, if you set this to false, you'll start to get some TS issues from Jodit (and any other package in your node_modules/). I'll enumerate a few.

  1. Create-react-app typescript example will generate a tsconfig without "experimentalDecorators": true, something that you need to manually add to get Jodit working. (This workaround is given to you in the terminal, so not a big deal)

  2. skipLibCheck: false will prompt you

TypeScript error in /node_modules/jodit/src/types/index.d.ts(14,15):
File '/node_modules/jodit/src/types/input.d.ts' is not a module.  TS2306

    12 | export * from './events';
    13 | export * from './file-browser';
  > 14 | export * from './input';
       |               ^
    15 | export * from './jodit';
    16 | export * from './observe';
    17 | export * from './plugin';

This is the tsconfig file create-react-app provides by default.

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}

We should add "skipLibCheck": true and "experimentalDecorators": true flags to jodit's documentation.

Cheers!

@SHAGGYER
Copy link

doesnt work, still getting errors with nextjs

Type error: Property 'getSelection' does not exist on type 'ShadowRoot'.

  89 |  get sel(): WindowSelection {
  90 |          if (this.j.o.shadowRoot) {
> 91 |                  return this.j.o.shadowRoot.getSelection();
     |                                             ^
  92 |          }
  93 | 
  94 |          return this.win.getSelection();

@ferso
Copy link

ferso commented Sep 8, 2021

I got the same compilation error here in React App, Does anyone knows how to fix it?

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es6", "dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "noImplicitAny": true,
    "noImplicitThis": true,
    "strictNullChecks": true
  },
  "include": ["src"]
}

Failed to compile


/Volumes/Projects/Projects/yourpass/jodit/node_modules/jodit/src/core/selection/select.ts
TypeScript error in /Volumes/Projects/Projects/yourpass/jodit/node_modules/jodit/src/core/selection/select.ts(91,31):
Property 'getSelection' does not exist on type 'ShadowRoot'.  TS2339

    89 | 	get sel(): WindowSelection {
    90 | 		if (this.j.o.shadowRoot) {
  > 91 | 			return this.j.o.shadowRoot.getSelection();
       | 			                           ^
    92 | 		}
    93 | 
    94 | 		return this.win.getSelection();

@Dzooska
Copy link

Dzooska commented Oct 7, 2021

I have same problem, some tips to solve ?

@rudza
Copy link

rudza commented Oct 13, 2021

Any progress on this?
We want to upgrade Typescript!

@xdan
Copy link
Owner

xdan commented Oct 22, 2021

Fixed here #718

@xdan xdan closed this as completed Oct 22, 2021
@Dzooska
Copy link

Dzooska commented Oct 22, 2021

#718 - where is the fix ? It's only closed..

@valadas
Copy link

valadas commented Feb 23, 2022

Not sure it's a great final solution but skipLibCheck did fix it for me...

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants