on 03-13-2023 6:55 AM
Hi Luis,
the error message already indicates it: TypeScript does not find these methods on UI5Element (which stands for the sap.ui.base.Element base class of all Controls etc.).
The TypeScript compiler simply is not aware that this.byId(...) returns an IconTabHeader. It cannot know this, as the returned control type depends on the ID which you give as argument (and there is no functionality which searches the id in the XMLView and tells TypeScript what kind of control has this ID).
The solution is to cast the result of this call to the control type you know is returned:
(this.byId("idIconTabBar") as IconTabBar).getSelectedKey()
This is commonly done in the tutorial and samples linked from the central UI5 & TypeScript entry point (https://sap.github.io/ui5-typescript), so I guess it makes sense to mention this page for those who are getting here and not aware of it.
Regards
Andreas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.