Skip to content

Typescript Question on subclass extension for different DP/RM/NE configs per subclass #219

Open
@capttrousers

Description

What's the recommended way to create Typescript types for sub types of Big with different configs?

I'd like to have unique types for USD vs BTC, mainly to easily identify the value's expected decimal/rounding behavior, that have different configs like so:

USD.DP = 2; // Maximum 2 decimal places for USD
USD.RM = Big.roundHalfUp; // Round to nearest neighbor, away from zero if equidistant
USD.NE = -3; // Exponential notation for values < 0.01

BTC.DP = 8; // Maximum 8 decimal places for BTC
BTC.RM = Big.roundDown; // Round towards zero
BTC.NE = -9; // Exponential notation for values < .00000001.

I've tried a few different methods but none seem to work, either theres type errors or the rounding / precision configs dont seem to take effect.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions