jessealama / decimal128

JavaScript userland partial implementation of IEEE 754 Decimal128 decimal floating-point arithmetic
BSD 2-Clause "Simplified" License
19 stars 8 forks source link

decimal128 does not play nicely with tsc #119

Open ljani opened 1 week ago

ljani commented 1 week ago

Summary

I tried to use this with Vite's react-ts template. While it works nicely in npm run dev mode, npm run build fails, because TypeScript tries to compile package's .mts file for unknown reason.

Steps to reproduce

Here's a repository where you can reproduce the issue:

git clone https://github.com/ljani/decimal128-tsc-issue
cd decimal128-tsc-issue
npm run ci
npm run build

Expected result

The build completes fine.

Actual result

The build fails with:

node_modules/decimal128/src/Decimal.mts:3:7 - error TS6133: 'ratOne' is declared but its value is never read.

3 const ratOne = new Rational(1n, 1n);
        ~~~~~~

node_modules/decimal128/src/Decimal.mts:4:7 - error TS6133: 'ratTen' is declared but its value is never read.

4 const ratTen = new Rational(10n, 1n);
        ~~~~~~

node_modules/decimal128/src/Decimal.mts:49:14 - error TS6133: 'dec' is declared but its value is never read.

49         let [dec, exp] = s.split(/[eE]/);
                ~~~

node_modules/decimal128/src/Decimal128.mts:45:5 - error TS6133: 'd' is declared but its value is never read.

45     d: "0" | "-0" | Rational,
       ~

node_modules/decimal128/src/Rational.mts:7:5 - error TS6133: 'ROUNDING_MODE_HALF_EXPAND' is declared but its value is never read.

7     ROUNDING_MODE_HALF_EXPAND,
      ~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/decimal128/src/Rational.mts:321:9 - error TS6133: 'penultimateDigit' is declared but its value is never read.

321         penultimateDigit: Digit,
            ~~~~~~~~~~~~~~~~

node_modules/decimal128/src/Rational.mts:337:9 - error TS6133: 'penultimateDigit' is declared but its value is never read.

337         penultimateDigit: Digit,
            ~~~~~~~~~~~~~~~~

node_modules/decimal128/src/Rational.mts:354:9 - error TS6133: 'penultimateDigit' is declared but its value is never read.

354         penultimateDigit: Digit,
            ~~~~~~~~~~~~~~~~

node_modules/decimal128/src/Rational.mts:355:9 - error TS6133: 'finalDigit' is declared but its value is never read.

355         finalDigit: Digit,
            ~~~~~~~~~~

Found 9 errors.

Steps to reproduce (the long way)

npm create vite@latest decimal128-tsc-issue -- --template react-ts
cd decimal128-tsc-issue
npm install
npm install --save decimal128
nvim ./src/App.tsx
# Use decimal128 in App.tsx
npm run build

→ same result

Notes