Repository navigation
Support decimal values and arithmetic #2872
Description
Activity
- addedOut of ScopeThis idea sits outside of the TypeScript language design constraintsThis idea sits outside of the TypeScript language design constraints
on Apr 22, 2015 DanielRosenwasser commented
on Apr 22, 2015 MemberMore actionsProvide additional runtime functionality or libraries. Instead, use TypeScript to describe existing libraries.
As you've said:
There are a number of JS decimal implementations to take inspiration from:
https://github.com/MikeMcl/decimal.js
https://github.com/MikeMcl/bignumber.js
https://www.npmjs.com/package/jsdecimal
https://github.com/iriscouch/bigdecimal.jsAs our non-goal suggests, those libraries should be sufficiently usable from TypeScript itself. DefinitelyTyped currently currently has typings for decimal.js
- addedSuggestionAn idea for TypeScriptAn idea for TypeScript
on Apr 22, 2015 Does Typescript have like bool.parse(), decimal.parse(), etc.? Does Typescript have datatype conversion features? Just wondering cuz we don't want to have baggage issues we're struggling with, from adding too many 3rd party libraries.
RyanCavanaugh commented
on Apr 23, 2015 MemberMore actionsTypeScript doesn't provide any built-in run-time libraries.
As our non-goal suggests, those libraries should be sufficiently usable from TypeScript itself. DefinitelyTyped currently currently has typings for decimal.js
Looks like it's significantly outdated. The link doens't even work anymore. Any alternative to this problem so far?
- locked and limited conversation to collaborators
on Jun 18, 2018
TypeScript should support decimal values and arithmetic, similar to .NET's
Decimaland/or Java'sBigDecimaltype. This would solve some serious problems when writing business applications in JavaScript.For the following TS code:
the JS output should be something like this:
where
Decimalis the class that implements the decimal arithmetic and conversions.There are a number of JS decimal implementations to take inspiration from:
https://github.com/MikeMcl/decimal.js
https://github.com/MikeMcl/bignumber.js
https://www.npmjs.com/package/jsdecimal
https://github.com/iriscouch/bigdecimal.js