import-maps

How to import a service-like singleton-class with System.js?

冷暖自知 提交于 2021-01-28 11:20:14
问题 I have a Singleton-Class FooService that is loaded via an import-map. I'd like to (a)wait for it and use it in various async functions like so: declare global { interface Window { System: System.Module } } const module = window.System.import('@internal/foo-service') const fooService = module.FooService async function func1() { await fooService.doBar() . . } async function func2() { await fooService.doBar2() . . } But I could only get it to work like this: declare global { interface Window {