dinerojs / dinero.js

Create, calculate, and format money in JavaScript and TypeScript.

Home Page:https://v2.dinerojs.com/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v2 - Default TAmount=number for DineroSnapshot

dawidcxx opened this issue · comments

commented

Since the default dinero instance is of type Dinero<number> (and I think that is a sensible default). It would perhaps also make sense to default the generic param TAmount in https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/types/DineroSnapshot.ts to number. Essentially

+ export type DineroSnapshot<TAmount = number> = {
- export type DineroSnapshot<TAmount> = {

The reason why I propose this change is that writing DineroSnapshot<number> within my DTO/model declarations make seem more complicated/repetitive than it needs to be.

Hey @dawidcxx!

What about creating a wrapper type in your codebase instead?

type DineroSnapshotNumber = DineroSnapshot<number>

Dinero.js indeed provides a number implementation, but I don't think this choice should be reflected at the abstraction level.