SAP / ui5-typescript

Tooling to enable TypeScript support in SAPUI5/OpenUI5 projects
https://sap.github.io/ui5-typescript
Apache License 2.0
202 stars 28 forks source link

Missing types for sap.ui.qunit.utils.nextUIUpdate and waitForThemeApplied #459

Closed LukasHeimann closed 5 months ago

LukasHeimann commented 5 months ago

Describe the bug I want to use sap.ui.qunit.utils.nextUIUpdate and waitForThemeApplied as replacements for deprecated Core APIs, as advertised by the ui5linter. However, @sapui5/types is missing the modules -- perhaps because it contains neither a sap.ui.d.ts nor a sap.ui.qunit.d.ts. Thus, when importing import nextUIUpdate from "sap/ui/qunit/utils/nextUIUpdate";, and error message appears: "Cannot find module 'sap/ui/qunit/utils/nextUIUpdate' or its corresponding type declarations.ts(2307)"".

Expected behavior Correctly typed APIs are available.

Workaround Manually place a definition file in the project:

declare module "sap/ui/qunit/utils/nextUIUpdate" {
  export default function nextUIUpdate(): Promise<void>;
}
declare module "sap/ui/qunit/utils/waitForThemeApplied" {
  export default function waitForThemeApplied(): Promise<void>;
}

Additional context It might be worth to doublecheck the type definitions when adding the module to the distribution:

Note that the two modules are also missing from ui5.sap.com's documentation

codeworrior commented 5 months ago

I'm not sure if I got your point regarding the two APIs at the end:

In general, it was a conscious decision so far to not make the testing helpers (sap/ui/qunit/**) public. But I understand that this is at least inconsistent if we, at the same time, mention them in replacement lists.

LukasHeimann commented 5 months ago

applyChanges suggests to use nextUIUpdate for test code -- which was exactly my use case: https://github.com/SAP/openui5/blob/b1e9f4df71716680d1fd0416c363fcd9a659133f/src/sap.ui.core/src/sap/ui/core/Core.js#L2305-L2310 waitForThemeApplied is also recommended as replacement at least here: https://github.com/SAP/openui5/blob/4381626e15361b273d64ebef10f3c872b4744e7e/src/sap.ui.core/src/sap/ui/qunit/QUnitUtils.js#L121-L122

I'd really like these two functions, they fill the exact spot that the test for my small custom control needs.

akudev commented 5 months ago

I don't think there is any issue in the dts generator, right?

The types not being marked as public in the OpenUI5 sources is nothing that can be changed in the generator. After all you explicitly wrote "the two modules are also missing from ui5.sap.com's documentation", which is not a result of this generator. As far as I see everything is about the annotations in the original UI5 code. So please open an issue in the OpenUI5 repo to get the officially recommended replacements actually usable.

LukasHeimann commented 5 months ago

nextUIUpdate is in fact marked as public, but I'm going to go ahead and also open something at OpenUI5

akudev commented 5 months ago

Ok, I'll check.

codeworrior commented 5 months ago

@akudev As you might remember, we've excluded sap/ui/qunit from the docs.

It's done here: https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/core/.library#L125.

LukasHeimann commented 5 months ago

I've opened https://github.com/SAP/openui5/issues/4074 as suggested :)

akudev commented 5 months ago

@akudev As you might remember, we've excluded sap/ui/qunit from the docs.

Right. More precisely: a bit more than ten years and three months ago. It feels like it was yesterday. ;-)

image

But regardless, at this point I don't see anything that needs to be done within the ui5-typescript repository. Hence closing again.