openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Missing documentation for `decimals` in `sap.ui.core.format.FileSizeFormat`

Open neoruien opened this issue 1 year ago • 2 comments

OpenUI5 version: 1.120.2

Browser/version (+device/version):

Any other tested browsers/devices(OK/FAIL):

URL (minimal example if possible):

  • Online example: https://sapui5.hana.ondemand.com/sdk/docs/topics/24f340bdd59e4428aab30a20d14e2ebc.html
  • API: https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.core.format.FileSizeFormat%23methods/sap.ui.core.format.FileSizeFormat.getInstance

User/password (if required and possible - do not post any confidential information here):

Steps to reproduce the problem:

What is the expected result?

What happens instead?

Any other information? (attach screenshot if possible)


For context, I am working on a UI5 project in typescript.

I want to format file size into 2 decimal places, so I referenced the online example: image

I typed FileSizeFormat.getInstance({ decimals: 2 }).format(1048576) into my code. But I got the error: image

I have to suppress the Typescript warning by adding this line:

// @ts-expect-error decimals parameter is not documented in UI5 constructor

I know that decimals: 2 works, because without it, the file size gets formatted to 1.048576 MB. But when I include it, the file size is correctly formatted to 1.05 MB. This might be a simple missing documentation issue.

neoruien avatar Jan 25 '24 06:01 neoruien

Hello @neoruien , Thank you for sharing this finding. I've created an internal incident DINC0049163. The status of the issue will be updated here in GitHub. Regards, Lidiya

LidiyaGeorgieva avatar Jan 25 '24 08:01 LidiyaGeorgieva

Hello, unfortunately it is a bigger topic to improve the JSDoc in the area of Formatters and Format options to properly support typescript. There is already a backlog item for this topic (CPOUI5MODELS-1111). Regards, Sven

SvBe avatar Jan 26 '24 08:01 SvBe