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

TypeScript missing Dialog$EscapeHandler #4178

Open
daletman opened this issue Dec 28, 2024 · 1 comment
Open

TypeScript missing Dialog$EscapeHandler #4178

daletman opened this issue Dec 28, 2024 · 1 comment

Comments

@daletman
Copy link

I cannot find a Type for the Dialog escapeHandler.

Used Version: 1.120

@codeworrior
Copy link
Member

codeworrior commented Dec 28, 2024

Seems that sap.m.Dialog does not define a (named) type for the escapeHandler. The getter getEscapeHandler and the setter setEscapeHandler are only typed inline:

class Dialog {
    getEscapeHandler():
      ((p1: {
          resolve: Function;
          reject: Function;
        }) => void)
      | null;

    setEscapeHandler(
      fnEscapeHandler?: (p1: {
        resolve: Function;
        reject: Function;
      }) => void
    ): this;
}

As a workaround, you might derive your own type from the signature of the Dialog's setEscapeHandler method:

import Dialog from "sap/m/Dialog";
type DialogEscapeHandler = Required<Parameters<Dialog["setEscapeHandler"]>>[0];

const myHandler: DialogEscapeHandler = ({resolve, reject}) => {};

If interested, see https://www.typescriptlang.org/docs/handbook/utility-types.html for details about the used utility types Required and Parameters.

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