axetroy / deno_math

Deno module for high-precision calculations and scientific computing
23 stars 3 forks source link

Package is broken. How to fix it? #4

Closed pevkoff closed 4 years ago

pevkoff commented 4 years ago

I tried to run a small demo that I wrote but the package is not even imported.

Demo:

import { abs } from 'https://deno.land/x/math/abs.ts'

console.log(abs(-1))

Result:

Download https://deno.land/x/math/abs.ts
Download https://deno.land/x/math/big/mod.ts
error TS2564: Property 's' has no initializer and is not definitely assigned in the constructor.

► https://deno.land/x/math/big/mod.ts:126:10

126   public s: number;
             ^

error TS2564: Property 'e' has no initializer and is not definitely assigned in the constructor.

► https://deno.land/x/math/big/mod.ts:130:10

130   public e: number;
             ^

error TS2564: Property 'c' has no initializer and is not definitely assigned in the constructor.

► https://deno.land/x/math/big/mod.ts:134:10

134   public c: number[];
             ^

error TS2322: Type 'number' is not assignable to type 'never'.

► https://deno.land/x/math/big/mod.ts:267:7

267       qc[qi++] = cmp ? n : ++n;
          ~~~~~~~~

error TS2454: Variable 'cmp' is used before being assigned.

► https://deno.land/x/math/big/mod.ts:267:18

267       qc[qi++] = cmp ? n : ++n;
                     ~~~

error TS2454: Variable 'cmp' is used before being assigned.

► https://deno.land/x/math/big/mod.ts:270:19

270       if (r[0] && cmp) r[rl] = a[ai] || 0;
                      ~~~

error TS2532: Object is possibly 'undefined'.

► https://deno.land/x/math/big/mod.ts:686:44

686     return stringify(this, 2, dp, this.e + dp);
                                               ~~

error TS2532: Object is possibly 'undefined'.

► https://deno.land/x/math/big/mod.ts:696:35

696     return stringify(this, 3, sd, sd - 1);
                                      ~~

error TS2532: Object is possibly 'undefined'.

► https://deno.land/x/math/big/mod.ts:846:9

846     n = k - x.e;
            ^

error TS2532: Object is possibly 'undefined'.

► https://deno.land/x/math/big/mod.ts:849:24

849     if (x.c.length > ++k) round(x, n, Big.RM);
                           ^

error TS2532: Object is possibly 'undefined'.

► https://deno.land/x/math/big/mod.ts:855:25

855     for (; x.c.length < k; ) x.c.push(0);
                            ^

error TS2532: Object is possibly 'undefined'.

► https://deno.land/x/math/big/mod.ts:865:29

865     (id == 1 || (id == 3 && k <= e) || e <= Big.NE || e >= Big.PE)
                                ^

Found 12 errors.

How to fix it?

axetroy commented 4 years ago

Hi. use a pinned version for the module.

and it should work for the latest version of Deno

import { abs } from 'https://deno.land/x/math@v1.1.0/abs.ts'

console.log(abs(-1))