Giter VIP home page Giter VIP logo

Comments (6)

joshmarinacci avatar joshmarinacci commented on August 25, 2024 1

I just fixed a bunch of typescript and doc bugs. Can you confirm that this is fixed for you in release 0.4.10? All of the type defs should be in the same dist dir now, along with the source and source maps.

from node-pureimage.

lmagder avatar lmagder commented on August 25, 2024

Installing the two missing packages via npm npm install --save-dev @types/mocha @types/node gets me farther:

node_modules/esbuild/lib/main.d.ts:650:16 - error TS2503: Cannot find namespace 'WebAssembly'.

650   wasmModule?: WebAssembly.Module
                   ~~~~~~~~~~~

node_modules/tinybench/dist/index.d.ts:31:108 - error TS2304: Cannot find name 'AddEventListenerOptions'.

31     addEventListener<K extends TaskEvents, T = TaskEventsMap[K]>(type: K, listener: T, options?: boolean | AddEventListenerOptions): void;
                                                                                                              ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/tinybench/dist/index.d.ts:32:111 - error TS2304: Cannot find name 'EventListenerOptions'.

32     removeEventListener<K extends TaskEvents, T = TaskEventsMap[K]>(type: K, listener: T, options?: boolean | EventListenerOptions): void;
                                                                                                                 ~~~~~~~~~~~~~~~~~~~~

node_modules/tinybench/dist/index.d.ts:320:110 - error TS2304: Cannot find name 'AddEventListenerOptions'.

320     addEventListener<K extends BenchEvents, T = BenchEventsMap[K]>(type: K, listener: T, options?: boolean | AddEventListenerOptions): void;
                                                                                                                 ~~~~~~~~~~~~~~~~~~~~~~~

node_modules/tinybench/dist/index.d.ts:321:113 - error TS2304: Cannot find name 'EventListenerOptions'.

321     removeEventListener<K extends BenchEvents, T = BenchEventsMap[K]>(type: K, listener: T, options?: boolean | EventListenerOptions): void;
                                                                                                                    ~~~~~~~~~~~~~~~~~~~~

node_modules/vite/types/customEvent.d.ts:26:14 - error TS2304: Cannot find name 'WebSocket'.

26   webSocket: WebSocket
                ~~~~~~~~~

node_modules/vite/types/importGlob.d.ts:36:11 - error TS2304: Cannot find name 'Worker'.

36   worker: Worker
             ~~~~~~

node_modules/vitest/dist/types-3c7dbfa5.d.ts:15:25 - error TS2307: Cannot find module 'rollup' or its corresponding type declarations.

15 import * as rollup from 'rollup';
                           ~~~~~~~~

src/bitmap.ts:1:9 - error TS6133: 'NAMED_COLORS' is declared but its value is never read.

1 import {NAMED_COLORS, OPAQUE_BLACK} from './named_colors.js';
          ~~~~~~~~~~~~

src/bitmap.ts:23:36 - error TS6133: 'options' is declared but its value is never read.

23     constructor(w:number,h:number, options?) {
                                      ~~~~~~~

src/browser.ts:4:18 - error TS2584: Cannot find name 'document'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.

4     let canvas = document.createElement('canvas')
                   ~~~~~~~~

src/context.ts:6:57 - error TS6133: 'shiftLeft' is declared but its value is never read.

6 import {and, fromBytesBigEndian, getBytesBigEndian, or, shiftLeft, toUint32} from './uint32';
                                                          ~~~~~~~~~

src/context.ts:6:68 - error TS6133: 'toUint32' is declared but its value is never read.

6 import {and, fromBytesBigEndian, getBytesBigEndian, or, shiftLeft, toUint32} from './uint32';
                                                                     ~~~~~~~~

src/context.ts:10:5 - error TS2305: Module '"./types.js"' has no exported member 'Font'.

10     Font,
       ~~~~

src/context.ts:37:13 - error TS6133: 'pathStart' is declared but its value is never read.

37     private pathStart?: Point;
               ~~~~~~~~~

src/context.ts:42:25 - error TS2749: 'Transform' refers to a value, but is being used as a type here. Did you mean 'typeof Transform'?

42     private _transform: Transform;
                           ~~~~~~~~~

src/context.ts:63:27 - error TS2554: Expected 1 arguments, but got 0.

63         this._transform = new Transform();
                             ~~~~~~~~~~~~~~~

  src/transform.ts:20:27
    20 export function Transform(context) {
                                 ~~~~~~~
    An argument for 'context' was not provided.

src/context.ts:108:13 - error TS2322: Type 'CanvasGradient' is not assignable to type 'string'.

108             this._strokeStyle_text = val
                ~~~~~~~~~~~~~~~~~~~~~~

src/context.ts:140:29 - error TS2304: Cannot find name 'clamp'.

140         this._globalAlpha = clamp(val, 0, 1);
                                ~~~~~

src/context.ts:358:45 - error TS2345: Argument of type 'number | ColorGradient' is not assignable to parameter of type 'number'.
  Type 'LinearGradient' is not assignable to type 'number'.

358             this._bitmap.setPixelRGBA(x, j, this._strokeColor);
                                                ~~~~~~~~~~~~~~~~~

src/context.ts:359:49 - error TS2345: Argument of type 'number | ColorGradient' is not assignable to parameter of type 'number'.

359             this._bitmap.setPixelRGBA(x + w, j, this._strokeColor);
                                                    ~~~~~~~~~~~~~~~~~

src/context.ts:449:15 - error TS6133: 'i' is declared but its value is never read.

449     composite(i, j, old_pixel, new_pixel) {
                  ~

src/context.ts:449:18 - error TS6133: 'j' is declared but its value is never read.

449     composite(i, j, old_pixel, new_pixel) {
                     ~

src/context.ts:465:38 - error TS6133: 'comp' is declared but its value is never read.

465         const C = A.slice(0, 3).map((comp, i) => compit(A[i], B[i], A[3], B[3]));
                                         ~~~~

src/context.ts:508:26 - error TS6133: 'x' is declared but its value is never read.

508     calculateRGBA_stroke(x, y) {
                             ~

src/context.ts:508:29 - error TS6133: 'y' is declared but its value is never read.

508     calculateRGBA_stroke(x, y) {
                                ~

src/context.ts:669:14 - error TS2551: Property 'pathstart' does not exist on type 'Context'. Did you mean 'pathStart'?

669         this.pathstart = pt;
                 ~~~~~~~~~

  src/context.ts:37:13
    37     private pathStart?: Point;
                   ~~~~~~~~~
    'pathStart' is declared here.

src/context.ts:886:53 - error TS2551: Property 'pathstart' does not exist on type 'Context'. Did you mean 'pathStart'?

886             this.path.push([PATH_COMMAND.LINE, this.pathstart]);
                                                        ~~~~~~~~~

  src/context.ts:37:13
    37     private pathStart?: Point;
                   ~~~~~~~~~
    'pathStart' is declared here.

src/context.ts:1016:23 - error TS2345: Argument of type 'number | ColorGradient' is not assignable to parameter of type 'number'.

1016         let rgb = and(this._strokeColor, 0xFFFFFF00);
                           ~~~~~~~~~~~~~~~~~

src/context.ts:1017:22 - error TS2345: Argument of type 'number | ColorGradient' is not assignable to parameter of type 'number'.

1017         let a1 = and(this._strokeColor, 0x000000FF);
                          ~~~~~~~~~~~~~~~~~

src/context.ts:1075:25 - error TS2345: Argument of type 'number | ColorGradient' is not assignable to parameter of type 'number'.

1075         const rgb = and(this._fillColor, 0xFFFFFF00)
                             ~~~~~~~~~~~~~~~

src/context.ts:1076:27 - error TS2345: Argument of type 'number | ColorGradient' is not assignable to parameter of type 'number'.

1076         const alpha = and(this._fillColor, 0xFF)
                               ~~~~~~~~~~~~~~~

src/context.ts:1121:15 - error TS6133: 'rgb' is declared but its value is never read.

1121         const rgb = and(this._fillColor, 0xFFFFFF00)
                   ~~~

src/context.ts:1121:25 - error TS2345: Argument of type 'number | ColorGradient' is not assignable to parameter of type 'number'.

1121         const rgb = and(this._fillColor, 0xFFFFFF00)
                             ~~~~~~~~~~~~~~~

src/context.ts:1266:15 - error TS7030: Not all code paths return a value.

1266     A.forEach(cmd => {
                   ~~~~~~~~

src/context.ts:1341:14 - error TS6133: 'average' is declared but its value is never read.

1341     function average(a, b) {
                  ~~~~~~~

src/context.ts:1351:56 - error TS2339: Property 'clone' does not exist on type 'number'.

1351             outside.push([PATH_COMMAND.MOVE,path_start.clone()])
                                                            ~~~~~

src/context.ts:1354:18 - error TS6133: 'first' is declared but its value is never read.

1354         function first(arr) {
                      ~~~~~

src/context.ts:1357:18 - error TS6133: 'last' is declared but its value is never read.

1357         function last(arr) {
                      ~~~~

src/context.ts:1458:10 - error TS6133: 'calcBezierAtT' is declared but its value is never read.

1458 function calcBezierAtT(p, t) {
              ~~~~~~~~~~~~~

src/context.ts:1473:29 - error TS6133: 'debug' is declared but its value is never read.

1473 function splitCurveAtT(p,t, debug) {
                                 ~~~~~

src/context.ts:1520:44 - error TS2304: Cannot find name 'MinimumBounds'.

1520 function calcMinimumBounds(lines: Line[]): MinimumBounds {
                                                ~~~~~~~~~~~~~

src/context.ts:1528:29 - error TS2304: Cannot find name 'PointIsh'.

1528     function checkPoint(pt: PointIsh) {
                                 ~~~~~~~~

src/text.ts:153:18 - error TS2531: Object is possibly 'null'.

153     const path = font.font.getPath(text, x, y, size);
                     ~~~~~~~~~

src/text.ts:183:20 - error TS2531: Object is possibly 'null'.

183     const glyphs = font.font.stringToGlyphs(text);
                       ~~~~~~~~~

src/text.ts:188:24 - error TS2531: Object is possibly 'null'.

188         width: advance/font.font.unitsPerEm*fsize,
                           ~~~~~~~~~

src/text.ts:189:25 - error TS2531: Object is possibly 'null'.

189         emHeightAscent: font.font.ascender/font.font.unitsPerEm*fsize,
                            ~~~~~~~~~

src/text.ts:189:44 - error TS2531: Object is possibly 'null'.

189         emHeightAscent: font.font.ascender/font.font.unitsPerEm*fsize,
                                               ~~~~~~~~~

src/text.ts:190:26 - error TS2531: Object is possibly 'null'.

190         emHeightDescent: font.font.descender/font.font.unitsPerEm*fsize,
                             ~~~~~~~~~

src/text.ts:190:46 - error TS2531: Object is possibly 'null'.

190         emHeightDescent: font.font.descender/font.font.unitsPerEm*fsize,
                                                 ~~~~~~~~~

src/transform.ts:15:6 - error TS6196: 'Matrix' is declared but never used.

15 type Matrix = [number,number,number,number,number,number];
        ~~~~~~

src/transform.ts:47:21 - error TS2554: Expected 1 arguments, but got 0.

47         let trans = new Transform()
                       ~~~~~~~~~~~~~~~

  src/transform.ts:20:27
    20 export function Transform(context) {
                                 ~~~~~~~
    An argument for 'context' was not provided.

src/util.ts:2:1 - error TS6133: 'uint32' is declared but its value is never read.

2 import * as uint32 from './uint32.js';
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/bugs/bug_143.js:2:1 - error TS6133: 'Line' is declared but its value is never read.

2 import {Line} from "../../src/line.js"
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/bugs/bug_143.js:3:1 - error TS6133: 'Point' is declared but its value is never read.

3 import {Point} from "../../src/point.js"
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/clipping.test.ts:48:17 - error TS2554: Expected 9 arguments, but got 5.

48         context.drawImage(src,75,75,50,50)
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~

  src/context.ts:567:39
    567     drawImage(bitmap, sx, sy, sw, sh, dx, dy, dw, dh) {
                                              ~~
    An argument for 'dx' was not provided.

test/imagedata.test.ts:7:9 - error TS6133: 'src' is declared but its value is never read.

7     let src;
          ~~~

test/imagedata.test.ts:10:11 - error TS6133: 'BLACK' is declared but its value is never read.

10     const BLACK = 0x000000FF
             ~~~~~

test/line.test.ts:1:27 - error TS6133: 'beforeEach' is declared but its value is never read.

1 import {describe, expect, beforeEach, it} from "vitest"
                            ~~~~~~~~~~

test/line.test.ts:26:31 - error TS2345: Argument of type '[{}, "spaghetti", "hello world", undefined[]]' is not assignable to parameter of type 'LineConstructorOptions'.
  Type '[{}, "spaghetti", "hello world", undefined[]]' is not assignable to type '[number, number, number, number]'.
    Type at position 0 in source is not compatible with type at position 0 in target.
      Type '{}' is not assignable to type 'number'.

26         expect(() => new Line({}, "spaghetti", "hello world", [])).to.throw(TypeError);
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/line.test.ts:35:22 - error TS2345: Argument of type '[]' is not assignable to parameter of type 'LineConstructorOptions'.
  Type '[]' is not assignable to type '[Point, Point]'.
    Source has 0 element(s) but target requires 2.

35         expect(() => new Line()).to.throw(errorMsg);
                        ~~~~~~~~~~

test/line.test.ts:36:31 - error TS2345: Argument of type '[12]' is not assignable to parameter of type 'LineConstructorOptions'.
  Type '[12]' is not assignable to type '[Point, Point]'.
    Source has 1 element(s) but target requires 2.

36         expect(() => new Line(12)).to.throw(errorMsg);
                                 ~~

test/line.test.ts:37:31 - error TS2345: Argument of type '[12, 30, 92]' is not assignable to parameter of type 'LineConstructorOptions'.
  Type '[12, 30, 92]' is not assignable to type '[number, number, number, number]'.
    Source has 3 element(s) but target requires 4.

37         expect(() => new Line(12, 30, 92)).to.throw(errorMsg);
                                 ~~~~~~~~~~

test/line.test.ts:38:31 - error TS2345: Argument of type '[12, 30, 92, 10, 99]' is not assignable to parameter of type 'LineConstructorOptions'.
  Type '[12, 30, 92, 10, 99]' is not assignable to type '[number, number, number, number]'.
    Source has 5 element(s) but target allows only 4.

38         expect(() => new Line(12, 30, 92, 10, 99)).to.throw(errorMsg);
                                 ~~~~~~~~~~~~~~~~~~

test/readwrite.test.ts:14:9 - error TS6133: 'context' is declared but its value is never read.

14     let context
           ~~~~~~~

test/readwrite.test.ts:42:47 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'Bitmap'.

42             await pureimage.encodePNGToStream('this is a string, not a bitmap buffer', new PassThrough())
                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/readwrite.test.ts:80:9 - error TS6133: 'context' is declared but its value is never read.

80     let context
           ~~~~~~~

test/readwrite.test.ts:109:48 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'Bitmap'.

109             await pureimage.encodeJPEGToStream('this is a string, not a bitmap buffer', new PassThrough())
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/readwrite.test.ts:126:114 - error TS2554: Expected 1 arguments, but got 2.

126         const jpeg = await pureimage.decodeJPEGFromStream(fs.createReadStream(FIXTURES_DIR + 'images/bird.jpg'), {
                                                                                                                     ~
127             tolerantDecoding: true,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128             maxMemoryUsageInMB: 1024,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129         })
    ~~~~~~~~~

test/unit/matchers/toBeOfFileType.js:1:22 - error TS2307: Cannot find module 'file-type' or its corresponding type declarations.

1 import fileType from "file-type"
                       ~~~~~~~~~~~

test/unit/matchers/toBeOfFileType.js:20:12 - error TS2304: Cannot find name 'result'.

20     return result;
              ~~~~~~

test/unit/runtests.js:5:20 - error TS2307: Cannot find module 'tape' or its corresponding type declarations.

5 var test = require('tape');
                     ~~~~~~

test/unit/runtests.js:8:5 - error TS6133: 'assert' is declared but its value is never read.

8 var assert = require('assert');
      ~~~~~~

test/unit/runtests.js:9:22 - error TS2307: Cannot find module '../../src/pureimage' or its corresponding type declarations.

9 var PImage = require('../../src/pureimage');
                       ~~~~~~~~~~~~~~~~~~~~~

test/unit/runtests.js:19:7 - error TS6133: 'RED' is declared but its value is never read.

19 const RED   = 0xFF0000FF;
         ~~~

test/unit/runtests.js:23:7 - error TS6133: 'GREEN' is declared but its value is never read.

23 const GREEN = 0x00FF00FF;
         ~~~~~

test/unit/runtests.js:165:15 - error TS6133: 'e' is declared but its value is never read.

165     }).catch((e) => {
                  ~

test/weather/render.js:1:1 - error TS6192: All imports in import declaration are unused.

1 import chai, {expect} from "chai"
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/weather/render.js:2:1 - error TS6133: 'os' is declared but its value is never read.

2 import os from "os"
  ~~~~~~~~~~~~~~~~~~~

test/weather/render.js:48:11 - error TS6133: 'sunOriginX' is declared but its value is never read.

48     const sunOriginX = 100;
             ~~~~~~~~~~

test/weather/render.js:49:11 - error TS6133: 'sunOriginY' is declared but its value is never read.

49     const sunOriginY = chartOriginY - chartHeight - 8;
             ~~~~~~~~~~

test/weather/render.js:51:11 - error TS6133: 'moonOriginX' is declared but its value is never read.

51     const moonOriginX = 100;
             ~~~~~~~~~~~

test/weather/render.js:52:11 - error TS6133: 'moonOriginY' is declared but its value is never read.

52     const moonOriginY = chartOriginY - chartHeight - 16;
             ~~~~~~~~~~~


Found 83 errors in 19 files.

Errors  Files
     1  node_modules/esbuild/lib/main.d.ts:650
     4  node_modules/tinybench/dist/index.d.ts:31
     1  node_modules/vite/types/customEvent.d.ts:26
     1  node_modules/vite/types/importGlob.d.ts:36
     1  node_modules/vitest/dist/types-3c7dbfa5.d.ts:15
     2  src/bitmap.ts:1
     1  src/browser.ts:4
    32  src/context.ts:6
     7  src/text.ts:153
     2  src/transform.ts:15
     1  src/util.ts:2
     2  test/bugs/bug_143.js:2
     1  test/clipping.test.ts:48
     2  test/imagedata.test.ts:7
     6  test/line.test.ts:1
     5  test/readwrite.test.ts:14
     2  test/unit/matchers/toBeOfFileType.js:1
     6  test/unit/runtests.js:5
     6  test/weather/render.js:1

from node-pureimage.

eugbyte avatar eugbyte commented on August 25, 2024

I am facing the same error

from node-pureimage.

sspenst avatar sspenst commented on August 25, 2024

Same here, with v0.4.9 and import * as PImage from 'pureimage' I am getting the classic:

Could not find a declaration file for module 'pureimage'. '/Users/sspenst/Documents/pathology/node_modules/pureimage/dist/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/pureimage` if it exists or add a new declaration (.d.ts) file containing `declare module 'pureimage';`ts(7016)

from node-pureimage.

sspenst avatar sspenst commented on August 25, 2024

@joshmarinacci is a fix planned for this? I've gotten around the errors for now by adding my own type declaration file: https://github.com/sspenst/pathology/blob/main/types/pureimage.d.ts

from node-pureimage.

sspenst avatar sspenst commented on August 25, 2024

I just fixed a bunch of typescript and doc bugs. Can you confirm that this is fixed for you in release 0.4.10? All of the type defs should be in the same dist dir now, along with the source and source maps.

Perfect that worked! Thanks for the fix

from node-pureimage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.