lodestar icon indicating copy to clipboard operation
lodestar copied to clipboard

Remove usage of Number constructor

Open dapplion opened this issue 4 years ago • 3 comments

The Number constructor is very unsafe because:

  • It takes any as parameter. If we change from passing a string to Number to some object Typescript will compile and we'll get NaN.

If you do a text search of the Number constructor there are many occurrences:

  • If Number arg is already an argument, remove
  • If Number arg is a string, use parseInt()
  • If Number arg is a bigint, use a custom util that types like bigintToNumber(bn: bigint): number

If the input of any of those functions is un-trusted data, verify the return is not NaN

dapplion avatar Feb 20 '22 09:02 dapplion

Hello @dapplion and @philknows can I work on this issue?

IjayAbby avatar Mar 11 '25 15:03 IjayAbby

Assigned to you @IjayAbby

philknows avatar Mar 13 '25 03:03 philknows

Hi, has this been solved ? i'll love to work on it

Beutife avatar Oct 01 '25 14:10 Beutife