Hi, I’m new to Typescript and Theia and trying to see how one can open a webpage hosted on a local server (e.g. 127.0.0.1:3000) with minibrowser.
I’ve been trying to derive something from the minibrowser example @kittaakos shared earlier in By default, open html file in preview by having this in my widget-contribution.ts
:
[...other imports...]
import { MiniBrowserOpenHandler } from '@theia/mini-browser/lib/browser/mini-browser-open-handler';
import URI from '@theia/core/lib/common/uri';
@injectable()
export class TheiaWidgetContribution extends AbstractViewContribution<TheiaWidgetWidget> implements FrontendApplicationContribution {
[...other contributions...]
app.shell.onDidAddWidget(widget => {
const myUri: URI = new URI('127.0.0.1:3000').withScheme('http')
this.miniBrowserOpenHandler.open(
myUri,
{ widgetOptions: { ref: widget, mode: 'open-to-right' } }
);
});
}
When I try this I keep getting the error
src/browser/theia-widget-contribution.ts:57:17 - error TS2345: Argument of type ‘import("/me/my-theia-project/theia-widget/node_modules/@theia/core/lib/common/uri").default’ is not assignable to parameter of type ‘import("/me/my-theia-project/theia-widget/node_modules/@theia/mini-browser/node_modules/@theia/core/lib/common/uri").URI’.
myUri, [i.e. occurs in this.miniBrowserOpenHandler.open( ]
Property ‘toComponents’ is missing in type ‘import("/me/my-theia-project/theia-widget/node_modules/@theia/core/lib/common/uri").default’ but required in type ‘import("/me/my-theia-project/theia-widget/node_modules/@theia/mini-browser/node_modules/@theia/core/lib/common/uri").URI’
Any idea what I’m doing wrong?
Been trying variations and looking up the error and still rather stumped, have also tried doing import { UriComponents } from '@theia/core/lib/common/uri';
as well but that just resulted in another error:
src/browser/theia-widget-contribution.ts:10:10 - error TS2614: Module ‘"@theia/core/lib/common/uri"’ has no exported member ‘UriComponents’. Did you mean to use ‘import UriComponents from “@theia/core/lib/common/uri”’ instead?
which is confusing considering other areas of the theia source does just this.