# Small question about Tutorial App

**URL:** <https://community.dynatrace.com/t/small-question-about-tutorial-app/42005>\
**Category:** Developer Q&A Forum\
**Tags:** custom-app\
**Created:** [October 10, 2023, 10:39am UTC](https://community.dynatrace.com/t/small-question-about-tutorial-app/42005 "2023-10-10T10:39:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [October 10, 2023, 10:39am UTC](https://community.dynatrace.com/t/small-question-about-tutorial-app/42005/1 "2023-10-10T10:39:34Z")

</div>

Hello,

(do no worries everything works now (-😉

Small question about below,

const formatter: FormatOptions\<Unit, ConvertableUnit\> = {  
&nbsp; &nbsp; maximumFractionDigits: chartPrecision,

This means we have a formatter of type FormatOptions expecting two props.

Where in the documentation can I find the FormatOptions type?

I assume this is the interface input-ToUnid and output-FromUnit but I guess this is defined in the Runtime,

Am I missing something?

KR Henk

---

<div class="post-metadata">

**Author:** ![stefan\_eggersto](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_eggersto/32/34114_2.png) [@stefan\_eggersto](https://community.dynatrace.com/u/stefan_eggersto)\
**Post date:** [October 10, 2023, 10:56am UTC](https://community.dynatrace.com/t/small-question-about-tutorial-app/42005/2 "2023-10-10T10:56:28Z")

</div>

Hi again 🙂

You can find the type reference at&nbsp;[Units | Dynatrace Developer](https://developer.dynatrace.com/reference/sdks/units/#formatoptions)

The properties of `FormatOptions` tell the formatter how it should behave, for example, to which unit it should convert the input or if it should abbreviate the number.

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [October 10, 2023, 11:44am UTC](https://community.dynatrace.com/t/small-question-about-tutorial-app/42005/3 "2023-10-10T11:44:04Z")

</div>

Stefan please make my day:grinning\_face:

Looking at your link,

 ![henk_stobbe_0-1696938121166.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/6/f6c6eb920f6481dbc72dc25d9547ee260666c248.png)

Is&nbsp;const formatter: FormatOptions\< **To** Unit, ConvertableUnit\>

Not a better, or am I still missing something?

KR Henk

---

<div class="post-metadata">

**Author:** ![stefan\_eggersto](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/stefan_eggersto/32/34114_2.png) [@stefan\_eggersto](https://community.dynatrace.com/u/stefan_eggersto)\
**Post date:** [October 16, 2023, 11:17am UTC](https://community.dynatrace.com/t/small-question-about-tutorial-app/42005/4 "2023-10-16T11:17:32Z")

</div>

Hi [@henk\_stobbe](https://community.dynatrace.com/user/11427) ,

It took me some time to dig into that since the typing of this package is all but trivial. Long story short:

- The documentation is mixing types (e.g. `ConvertableUnit`) and type parameters (`FromUnit` and `ToUnit`). Only types should be documented there.
- In the tutorial, the definition of `formatter` needs to refer to types, so only `const formatter: FormatOptions<Unit, ConvertableUnit>` is valid, but not `const formatter: FormatOptions<FromUnit, ToUnit>`

Now the longer story with some background information 🙂 The relevant parts of the type definition of `FormatOptions` is following:

```auto
export interface FormatOptions<FromUnit extends Unit, ToUnit extends ConvertableUnit> {
    ...
    input?: FromUnit;
    output?: ToUnit;
    ...
}

```

This means:

- `FormatOptions` is a generic interface with two type parameters
- `Unit` and `ConvertableUnit` are types provided by the SDK. `units.currency.usd` satisfies the type `Unit`, so you can write the following valid assignment: `const myUnit: Unit = units.currency.usd;`
- `FromUnit` and `ToUnit` are just the names of the type parameters and only valid within this type definition
- According to this signature, `FromUnit` needs to be any type that extends `Unit`, `ToUnit` needs to be any type that extends `ConvertableUnit`

To sum it up: `Unit` and `ConvertableUnit` are relevant for consumers, `ToUnit` and `FromUnit` are just the names of the type parameters of `FormatterOptions.`You can read more on generics in TypeScript at [Documentation - Generics](https://www.typescriptlang.org/docs/handbook/2/generics.html)

---

<div class="post-metadata">

**Author:** ![henk\_stobbe](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/henk_stobbe/32/30434_2.png) [@henk\_stobbe](https://community.dynatrace.com/u/henk_stobbe)\
**Post date:** [October 16, 2023, 12:56pm UTC](https://community.dynatrace.com/t/small-question-about-tutorial-app/42005/5 "2023-10-16T12:56:54Z")

</div>

Hello Stefan,

I realy wish I could give you more the one Kudo, great answer. Sorry for giving you the extra work.

It helped met to better understand,

Thx!

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [October 17, 2023, 10:31am UTC](https://community.dynatrace.com/t/small-question-about-tutorial-app/42005/6 "2023-10-17T10:31:19Z")

</div>

Great answer (tip) - thank you!
