openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Documentation: Several types in namespace `sap.ui.model.type` are missing supported formatting options

Open fbunsmann opened this issue 3 years ago • 4 comments

OpenUI5 version: 1.108.0

For the typescript type definitions, it would be very useful if the constructor documentation for all Types in the sap.ui.model.type namespace would contain all supported formatting options.

As an example, the documentation for type sap.ui.model.type.Float states that all supported formatting options of NumberFormat are accepted. Two of those options (out of many) are listed explicitly:

https://github.com/SAP/openui5/blob/ed3ff6eee9058a6929b5c82cc3552af7da0ccb43/src/sap.ui.core/src/sap/ui/model/type/Float.js#L30-L35

This is pretty much the same for all type classes in the package (besides Boolean and String, which don't accept formatting options). Could you add the missing formatting options to the documentation? This would give type safety to developers and also allows to get rid of casts to handover formatting options to the different constructors, which are not explicitly documented.

Outside the sap.ui.model.type namespace, I saw the method NumberFormat.getInstance(..) where the formatting options are also not listed.

Thanks for considering this!

Regards, Florian

fbunsmann avatar Nov 14 '22 14:11 fbunsmann

Hello @fbunsmann,

Thank you for sharing this finding. I've created an internal incident 2280175520. The status of the issue will be updated here in GitHub.

Regards, Niya

niyap avatar Nov 22 '22 18:11 niyap

Hi @fbunsmann

The reason not all FormatOptions of the NumberFormat are documented at the types is that there are 29 FormatOptions and 11 sap.ui.model.type.* types. That would mean keeping 30 different JsDocs in sync and it is not feasable.

Please note NumberFormat.getInstance(...) is not a public API and the FormatOptions are all documented at the public API like NumberFormat.getFloatInstance(...).

Also please note that we only document the FormatOptions at the types that have a different defaulting or treatment by the type than by the NumberFormat itself.

Regarding the typescript type definitions we are working closely with a colleague of ours to support this, but we have to prioritize such activities according to the backlog demanded by our stakeholders.

We will update this issue once we know what we will do.

Greetings, Peter.

PeterBuchholz avatar Nov 23 '22 15:11 PeterBuchholz

The reason not all FormatOptions of the NumberFormat are documented at the types is that there are 29 FormatOptions and 11 sap.ui.model.type.* types. That would mean keeping 30 different JsDocs in sync and it is not feasable.

Yes, that's understandable. Thanks for the information!

fbunsmann avatar Nov 25 '22 06:11 fbunsmann

We are discussing internally how to achieve the requested functionality without creating redundancies. This is tracked internally as CPOUI5MODELS-1111.

uhlmannm avatar Nov 25 '22 18:11 uhlmannm