eclipse-theia / generator-theia-extension

A Yeoman generator for extensions to the Theia IDE
Other
55 stars 40 forks source link

widget menu click error #168

Closed bad-github closed 1 year ago

bad-github commented 1 year ago

I created a base project with scaffolding using the widget option, and this was created successfully. But when I click the registered menu under view, it always prompts an error: "You are attempting to construct 'class MyWidget' in a synchronous way but it has asynchronous dependencies.

bad-github commented 1 year ago

image

JonasHelming commented 1 year ago

Could you check which Theia version are you building against? You see this for example in the /browser-app/package.json

msujew commented 1 year ago

@JonasHelming This is an issue I've encountered multiple times during my inversify update PR. We should change here:

-    @postConstruct()
-    protected async init(): Promise < void> {
-        this.id = <%= params.extensionPrefix %>Widget.ID;
-        this.title.label = <%= params.extensionPrefix %>Widget.LABEL;
-        this.title.caption = <%= params.extensionPrefix %>Widget.LABEL;
-        this.title.closable = true;
-        this.title.iconClass = 'fa fa-window-maximize'; // example widget icon.
-        this.update();
-    }
+    @postConstruct()
+    protected init(): void {
+        this.doInit();
+    }
+
+    protected async doInit(): Promise <void> {
+        this.id = <%= params.extensionPrefix %>Widget.ID;
+        this.title.label = <%= params.extensionPrefix %>Widget.LABEL;
+        this.title.caption = <%= params.extensionPrefix %>Widget.LABEL;
+        this.title.closable = true;
+        this.title.iconClass = 'fa fa-window-maximize'; // example widget icon.
+        this.update();
+    }
bad-github commented 1 year ago

The version is: "@theia/core": "latest", others are the latest. msujew's answer successfully solved my problem. thank you all