Closed DetachHead closed 4 months ago
Eh, no.
At runtime, the Core module returns an instance of sap.ui.core.Core. Each call to the constructor (if you get access to it via globals) would even return the same singletons instance.
Check the source;
/*
* Create a new (the only) instance of the Core and return it's interface as module value.
*
* Do not export the module value under the global name!
*
* Note that the Core = EventProvider.extend() call above already exposes sap.ui.core.Core.
* This is needed for backward compatibility reason, in case some other code tries to enhance
* the core prototype. Once global names are switched off, such extension scenarios are
* no longer supported.
*/
oCore = new Core().getInterface();
return oCore;
You must not create new instances but rather use the export of the module.
But I understand that the documentation falls short to explain this. In earlier versions, this was slightly better, but the example went lost with a recent refactoring (most likely as the example was based on an API that uses globals):
I'll take care of the documentation aspect, but that's a topic for openui5
, not ui5-typescript
. The types are correct and reflect the intended usage of the Core.
I therefore close this issue.
Describe the bug
sap/ui/core/Core
seems to be exported as an instance of theCore
interface, instead of a class:this means that it cannot be instantiated when imported:
Expected behavior it should probably be something like this:
Additional context at runtime,
Core
is a class that needs to be instantiated: