Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
LukasHeimann opened this issue Jun 10, 2024 · 8 comments
Closed

Comments

@LukasHeimann
Copy link

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
Copy link
Member

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

  • the clock parameter of nextUIUpdate is optional and documented as such and
  • waitForThemeApplied was never intended as a public API. Did you find references to it in our documentation?

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
Copy link
Author

LukasHeimann commented Jun 10, 2024

  • clock that might have been my mistake, I was not sure about the JSDoc syntax -- in TypeScript, an explicit ? or | undefined would have been necessary
  • waitForThemeApplied: in our code, we have built exactly the same with deprecated Core APIs. When I looked to find out about nextUIUpdate, didn't find anything in the docs and types, but in the code, I thought using it would also be possible (but broken typewise for the same reasons).

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
Copy link
Contributor

akudev commented Jun 21, 2024

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
Copy link
Author

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

@akudev
Copy link
Contributor

akudev commented Jun 21, 2024

Ok, I'll check.

@akudev akudev reopened this Jun 21, 2024
@codeworrior
Copy link
Member

@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
Copy link
Author

I've opened SAP/openui5#4074 as suggested :)

@akudev
Copy link
Contributor

akudev commented Jun 24, 2024

@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.

@akudev akudev closed this as completed Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants