SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.94k stars 1.23k forks source link

Type 'import("sap/ui/core/Popup").Dock' is not assignable to type 'typeof Dock' using @sapui5/types: "1.126.0" #4091

Closed JuanjoPP closed 1 month ago

JuanjoPP commented 1 month ago

OpenUI5 version: 1.126.0

Browser/version (+device/version): not applicable

Steps to reproduce the problem:

  1. Create a sap.m.MessageToast with the "at" property populated
  2. Fill the "at" property with a sap.ui.core.Popup.Dock type variable

What is the expected result? The TypeScript checker does not throw an error

What happens instead? It throws an error

Any other information?

image image image
codeworrior commented 1 month ago

This is an incompatible change of the TypeScript definitions and was introduced in 1.115.0. The change and how to deal with it, is explained in more detail in the UI5 TypeScript release notes for 1.115.

Basically, enums attached to other control or utility APIs are no longer named exports (Dock) but static properties of the default export of the bearing API (Popup.Dock).

The change was done to make static and dynamic imports consistent.

JuanjoPP commented 1 month ago

Hi,

I tried the change proposed and changed the import:

image image image

Unfortunately the error still appears.

codeworrior commented 1 month ago

You're right, the generation of the MessageToast.show API is broken. I've created https://github.com/SAP/ui5-typescript/issues/466 as this needs to be fixed in the dts-generator.

The only workaround for now is a type cast (which unfortunately needs to be removed once the issue has been fixed):

  at: Popup.Dock.BeginBottom as unknown as typeof Popup.Dock

As this is not an issue in the OpenUI5 code base, I'm closing this issue here.