editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

In type ToolConstructable a circular dependency

Open stasyuk93 opened this issue 5 years ago • 3 comments

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 {...}

stasyuk93 avatar Mar 24 '20 20:03 stasyuk93

Hi @stasyuk93

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

gohabereg avatar Mar 25 '20 19:03 gohabereg

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

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

alexanevsky avatar Jan 22 '24 22:01 alexanevsky

Did this get resolved?

rburckner avatar May 13 '24 17:05 rburckner