hyperformula icon indicating copy to clipboard operation
hyperformula copied to clipboard

Add support for inferring return types of a custom function

Open sequba opened this issue 3 years ago • 1 comments

Description

As described in #875 by MartinDawson:

Consider any formula that you do not know the exact return type of or the return type is too large and can change based on parameters :

=GET_FINANCIALS("AMZN", "revenue"), this would return a currency value.

=GET_FINANCIALS("AMZN", "operatingMargin"), this would return a percentage value.

=GET_FINANCIALS("AMZN", "balanceSheet"), this would return an object of currencies & percentages.

Hyperformula currently has this for custom plugins: returnNumberType. This isn't sufficient for functions who's return types can change dynamically.

The percentages should be automatically formatted as percentages. The currencies as currencies.

Currently this is not possible in HF and this causes bugs where other formulas don't work if you put the above as parameters because the cell types are wrong.

However we should not apply it to all functions automatically because some functions such as =TEXT() want to format stuff as strings specifically.

sequba avatar Feb 09 '22 13:02 sequba

Related discussion: https://handsoncode.slack.com/archives/CP3FX2DBM/p1644412898386059 (accessible internally)

sequba avatar Feb 09 '22 16:02 sequba