SAP / ui5-typescript

Tooling to enable TypeScript support in SAPUI5/OpenUI5 projects
https://sap.github.io/ui5-typescript
Apache License 2.0
200 stars 28 forks source link

[@types/openui5@1.115] localizationChanged event parameters missing #398

Closed HappyHepo closed 1 week ago

HappyHepo commented 1 year ago

Describe the bug The 1.115 type definitions do not contain event parameters for the localizationChanged event (see https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.core.Core%23events/localizationChanged). Consequently, the attach function does not contain the proper function signature for the callback.

Additional context Package: @types/openui5@1.115.0

akudev commented 1 year ago

Thanks for reporting! It's because Core is not an EventProvider - only for them the APIs are generated automatically. In the Core, these methods (attach... detach... etc. are explicitly written, so the JSDoc has to write the complete signature.

akudev commented 1 week ago

After enough time has passed without fix, this can probably be closed: the localizationChanged event is deprecated and will be removed in 2.x. The replacement can already be used since 1.120 and has the event parameters fully typed:

declare module "sap/base/i18n/Localization" {
  import LanguageTag from "sap/base/i18n/LanguageTag";

  /**
   * Configuration for localization specific parameters
   *
   * @since 1.118
   */
  interface Localization {
    /**
     * Attaches the `fnFunction` event handler to the {@link #event:change change} event of `module:sap/base/i18n/Localization`.
     *
     * @since 1.120.0
     */
    attachChange(
      /**
       * The function to be called when the event occurs
       */
      fnFunction: (p1: Localization$ChangeEvent) => void
    ): void;

and

  /**
   * The localization change event. Contains only the parameters which were changed.
   *
   * The list below shows the possible combinations of parameters available as part of the change event.
   *
   *
   *     - {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage}:
   *    `language`
   *     - `rtl?` (only if language change also changed RTL)
   *     - {@link module:sap/base/i18n/Localization.setRTL Localization.setRTL}:
   *    `rtl`
   *     - {@link module:sap/base/i18n/Localization.setTimezone Localization.setTimezone}:
   *    `timezone`
   *
   * @since 1.120.0
   */
  export type Localization$ChangeEvent = {
    /**
     * The newly set language.
     */
    language?: string;
    /**
     * Whether the page uses the RTL text direction.
     */
    rtl?: boolean;
    /**
     * The newly set timezone.
     */
    timezone?: string;
  };
}

Thanks nevertheless. Without this deprecation, I would have moved this issue to the openui5 repo now (where it belonged, anyway).