ChainSafe / fixed-sized-numbers-ts

Fixed Sized BigNumbers in TypeScript
2 stars 4 forks source link

Add Class construction API #2

Open ansermino opened 5 years ago

ansermino commented 5 years ago

(Written by @JonathanLorimer)

As a user I expect to be able to create a new Integer using Class syntax

Expected:

import { Uint8 } from "fixed-sized-numbers-ts";
let one = Uint8(1)
let two = new Uint8(2)

Actual:

import { Uint8 } from "fixed-sized-numbers-ts";
let one = Uint8(1)
let two = new Uint8(2) //ts error Only a void function can be called with the 'new' keyword. [2350]

Note: a constructor can be provided on a function as they are objects in JS, and this way you can get the dual API

For reference of a working example of this look at bignumber.js