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

Abierto Apto para principiantes
#4,489 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
javascript, typescript
Área
api, backend

Línea de trabajo

Empieza con el typedef AggregationBindingInfo en src/sap.ui.core/src/sap/ui/base/ManagedObject.js, al que enlaza el issue, e inspecciona cómo llega el tipo de la clave groupHeaderFactory a types/sap.ui.core.d.ts. Consulta la documentación de Sorter citada en el informe para ver los valores primitivos admitidos para los grupos. La tarea estará terminada cuando la declaración generada acepte claves de tipo string, boolean y number sin rechazar callbacks de agrupación válidos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
JavaScript
Estrellas
3.3k
Forks
1.3k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de UI5/openui5

Todos los issues de UI5/openui5

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.