Open one-github opened 3 years ago
Sorry for the delay (vacation time...). Our focus is on the "ts-types-esm" flavor of the type definitions right now, not the "ts-types" definitions which still define all the globals ("sap.m.Button" etc.) which we don't recommend to use anymore. Those "globals" definitions are mostly for code completion support in legacy projects. This doesn't mean we won't handle this issue report, but it is not a top priority right now. Thanks for the reminder, nevertheless. We have internally set up an ignorelist with these errors and put checks in place to prevent the introduction of new issues. So at least they shouldn't get more.
Using skipLibChecks
tsc compiler option may enable to you ignore all these issues at the consumer side
skipLibChecks: true
does suppress the error messages, however calling e.g. sap.m.MessageBox.error()
does not work because Typescript does not recognize error
in MessageBox
. Any updates on this? @akudev
these errors too:
node_modules/@sapui5/ts-types/types/sap.fe.navigation.d.ts:271:28 - error TS2702: 'JQuery' only refers to a type, but is being used as a namespace here.
271 parseNavigation(): JQuery.Promise<any, any, any>;
~~~~~~
node_modules/@sapui5/ts-types/types/sap.fe.navigation.d.ts:338:12 - error TS2702: 'JQuery' only refers to a type, but is being used as a namespace here.
338 ): JQuery.Promise<any, any, any>;
~~~~~~
node_modules/@sapui5/ts-types/types/sap.fe.test.d.ts:3092:13 - error TS2417: Class static side 'typeof ListReport' incorrectly extends base class static side 'typeof TemplatePage'.
Types of property 'actions' are incompatible.
Type 'actions' is missing the following properties from type 'actions': onActionDialog, onConfirmationDialog, onCreateDialog, onDialog, and 3 more.
3092 class ListReport extends sap.fe.test.TemplatePage {
~~~~~~~~~~
node_modules/@sapui5/ts-types/types/sap.fe.test.d.ts:3133:13 - error TS2417: Class static side 'typeof ObjectPage' incorrectly extends base class static side 'typeof TemplatePage'.
Types of property 'actions' are incompatible.
Type 'actions' is missing the following properties from type 'actions': onActionDialog, onConfirmationDialog, onCreateDialog, onDialog, and 3 more.
3133 class ObjectPage extends sap.fe.test.TemplatePage {
~~~~~~~~~~
To not leave these recent comments unanswered: as stated above, the "ts-types" with globals are not in focus anymore. This doesn't mean they'll never get improved, but the more important thing for us is getting the ESM types to production quality, sorry.
fair enough, i use the esm types where i can but in this case i need the old global types for a script i'm injecting onto a page that has window.sap
in it. more specifically, i'm making a playwright selector engine for ui5 - https://github.com/DetachHead/playwright-ui5/blob/0dc3c2db69dc6550ab173ba0de24bb976837cbf6/src/browser/main.ts#L28
if anybody knows of a way to do this with the esm types that would be nice
Hi @DetachHead ,
together with @akudev, we suggest the following and recommend the ESM type defs 😉 :
import type { registry } from 'sap/ui/core/Element'
// @ts-ignore
const ElementRegistry: registry = window.sap.ui.core.Element.registry
[...]
const controls = ElementRegistry.filter((element) => {
There is one caveat, starting with the UI5 type definitions 1.115.0
we reworked the types to better match the runtime code and therefore it will look like this then:
import type UI5Element from 'sap/ui/core/Element'
// @ts-ignore
const ElementRegistry: typeof UI5Element.registry = window.sap.ui.core.Element.registry
Would this be something you can live with?
(or define sap.ui.core.Element locally as custom type which happens to have the same "registry" as Element - this avoids the @ts-ignore)
Would this be something you can live with?
i wanted to avoid this kind of boilerplate though but i guess it's not that big of a deal for my use case where i'm only using one thing from the sap
namespace. thanks
@petermuessig i tried this on the latest version (1.120.1) but 'sap/ui/core/Element'
doesn't seem to be exported anymore?
import type { registry } from 'sap/ui/core/Element'
Cannot find module 'sap/ui/core/Element' or its corresponding type declarations.
@DetachHead Umm... that's one of the most important modules in UI5, I'm pretty sure it is still declared. Make sure the types are loaded.
oops i still was actually still using the global @sapui5/ts-types
package, my bad
When running
tsc
on an empty JavaScript file it gives the following error messages: