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 working solution for event.getParameter("value") #409

Closed
EricVanEldik opened this issue Jul 24, 2023 · 3 comments
Closed

Missing working solution for event.getParameter("value") #409

EricVanEldik opened this issue Jul 24, 2023 · 3 comments

Comments

@EricVanEldik
Copy link

EricVanEldik commented Jul 24, 2023

According to the release notes of 1.115.0 in https://sap.github.io/ui5-typescript/releasenotes.html evt.getParameter("eventParamName"); now returns a typescript error: Argument of type 'string' is not assignable to parameter of type 'never'.ts(2345)

However the solution provided:
public handleChange(evt: UI5Event<$InputBaseChangeEventParameters>) : void { ... } doesn't seem to work, because UI5Event is not defined as a type in "@sapui5/types": "^1.116.0"

I tried the following solution which does exists:

async onInputEmployeeChange(event: Event<Input$ChangeEventParameters>) {
        const input = event.getSource() as Input;
        const path = input.getBinding("value").getPath();
        const id = (event.getParameter("value") as string).trim();

but still gives the type error: Argument of type 'string' is not assignable to parameter of type 'never'.ts(2345)

@akudev
Copy link
Contributor

akudev commented Jul 24, 2023

Right, the solution involving UI5Event may be unintuitive, as it is not clear where UI5Event is supposed to come from - it should despite its name be imported from sap/ui/base/Event. Sometimes we choose Names like UI5Element and UI5Event to prevent confusion with DOM Elements/Events, but of course they only work with the correct import.

Regarding the existing solution you tried, please check from which module you have imported Input$ChangeEventParameters - I'm pretty sure it's from the web components library ("sap.ui.webc..."), while the Input you are using is a "sap.m.Input". The WebComponents Input has a "change" event with no parameters, hence the "never".

Try with "InputBase$ChangeEventParameters" and import { InputBase$ChangeEventParameters } from "sap/m/InputBase"; instead. The event is defined on this base class.
Or when using 1.115.1 or 1.116.0, you can directly use InputBase$ChangeEvent instead of Event<InputBase$ChangeEventParameters>.

@akudev akudev closed this as completed Jul 24, 2023
@akudev
Copy link
Contributor

akudev commented Jul 24, 2023

I see the Input$ChangeEvent has also been mentioned in the release notes. 7d37027 fixes this and changes usages of UI5Event to Event, including the import now.

@EricVanEldik
Copy link
Author

EricVanEldik commented Jul 25, 2023

thank you, this solves it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants