[TypeScript] AggregationBindingInfo#groupHeaderFactory incorrectly restricts group keys to string

オープン 初心者向け
#4,489 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript, typescript
領域
api, backend

調査の方向性

issue がリンクしている src/sap.ui.core/src/sap/ui/base/ManagedObject.js の typedef AggregationBindingInfo から始め、キー groupHeaderFactory の型が types/sap.ui.core.d.ts にどのように伝わるかを調べてください。レポートで引用されている Sorter のドキュメントを確認し、サポートされるプリミティブなグループ値を調べてください。生成された宣言が string、boolean、number 型のキーを受け入れ、有効なグルーピングコールバックを拒否しなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

documentation in progress
What is the issue and how can we reproduce it?

Title

Incorrect groupHeaderFactory parameter type: group keys are not limited to strings

Description

In @sapui5/types version 1.153.0, AggregationBindingInfo.groupHeaderFactory is declared as:

groupHeaderFactory?: (p1: { key: string }) => ManagedObject;

The key type is too restrictive. When grouping an OData list by an entity property, the group key depends on the property's runtime type. It can also be a boolean or number, for example when grouping by an Edm.Boolean or Edm.Int32 property.

The sap.ui.model.Sorter documentation explicitly states that grouping can use the raw model property value and that primitive group values are passed to groupHeaderFactory as the key property.

Steps To Reproduce

Bind a list to an OData entity set containing a Boolean property named IsActive, and enable grouping on that property:

import GroupHeaderListItem from "sap/m/GroupHeaderListItem";
import Sorter from "sap/ui/model/Sorter";

list.bindItems({
    path: "/Entities",
    template: itemTemplate,
    sorter: new Sorter("IsActive", false, true),
    groupHeaderFactory: group => new GroupHeaderListItem({
        title: group.key === true ? "Active" : "Inactive"
    })
});

TypeScript reports that comparing string and boolean is invalid, although group.key can be a Boolean at runtime. Grouping by a numeric property causes the equivalent type mismatch.

Expected Behaviour

The callback parameter should allow non-string group keys. At minimum:

groupHeaderFactory?: (
    p1: { key: string | boolean | number }
) => ManagedObject;

Actual Behaviour

The generated definition restricts key to string, requiring unnecessary type workarounds for valid grouping scenarios.

Environment

Which OpenUI5 version is your project targeting?

1.153.0

Is the issue device- or browser-specific?

No response

Confirmation
  • I have searched the existing issues and reviewed the relevant documentation as well as the API reference.
  • I am not disclosing any internal or sensitive information.
主要言語
JavaScript
スター
3.3k
フォーク
1.3k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

UI5/openui5 のほかの issue

UI5/openui5 の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。