codex-team / editor.js

A block-style editor with clean JSON output
https://editorjs.io
Apache License 2.0
28.53k stars 2.08k forks source link

In type ToolConstructable a circular dependency #1080

Open stasyuk93 opened 4 years ago

stasyuk93 commented 4 years ago

There was a problem while developing plugin on the typescript. In type ToolConstructable a circular dependency occurs and it is impossible to write a suitable constructor.

type ToolConstructable = BaseToolConstructable | BlockToolConstructable | InlineToolConstructable;

interface BaseToolConstructable  {
 new (config: {api: API, config?: ToolSettings}): BaseTool;
}
interface BlockToolConstructable  extends BaseToolConstructable{
  new (config: {api: API, config: ToolConfig, data: BlockToolData}): BlockTool;
}

InlineToolConstructable extends BaseToolConstructable {}

It seems that the BlockToolConstructable does not override the constructor that inherited. To avoid circular dependency, I had to redefine types as follows (not inherited from BaseToolConstructable):

type ToolConstructable = BaseToolConstructable | BlockToolConstructable;

interface BaseToolConstructable {...}
interface BlockToolConstructable {...}
gohabereg commented 4 years ago

Hi @stasyuk93

Thank you, we will include a fix to the next release

alexanevsky commented 9 months ago

@gohabereg Hello! when the next release will be? :) The problem still exists

I can just recommend you to remove method "new" from BaseToolConstructable

rburckner commented 5 months ago

Did this get resolved?