Skip to content

3.7.6 typescript build errors #1448

@jozefchutka

Description

@jozefchutka

System Info

transformers.js: 3.7.6

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

Running a very basic typescript build using transformers.js 3.7.6 fails.

Reproduction

package.json

{
	"devDependencies": {
		"@huggingface/transformers": "^3.7.6"
	}
}

tsconfig.json

{
	"compilerOptions": {
	  "target": "ESNEXT",
	  "lib": ["ESNext", "WebWorker"],
	  "module": "ESNext",
	  "moduleResolution": "bundler",
	  "baseUrl": "./",
	  "paths": {}
	}
  }

Main.mts

import { AutomaticSpeechRecognitionConfig, env, pipeline, ProgressCallback } from "@huggingface/transformers";

runnig tsc command fails with the following errors:

node_modules/@huggingface/transformers/types/models/mgp_str/processing_mgp_str.d.ts:52:5 - error TS2416: Property 'batch_decode' in type 'MgpstrProcessor' is not assignable to the same property in base type 'Processor'.
  Type '([char_logits, bpe_logits, wp_logits]: [Tensor, Tensor, Tensor]) => { generated_text: string[]; scores: number[]; char_preds: string[]; bpe_preds: string[]; wp_preds: string[]; }' is not assignable to type '(batch: number[][] | Tensor, decode_args?: any) => string[]'.
    Types of parameters '__0' and 'batch' are incompatible.
      Type 'number[][] | Tensor' is not assignable to type '[Tensor, Tensor, Tensor]'.
        Type 'number[][]' is not assignable to type '[Tensor, Tensor, Tensor]'.
          Target requires 3 element(s) but source may have fewer.

52     batch_decode([char_logits, bpe_logits, wp_logits]: [import("../../utils/tensor.js").Tensor, import("../../utils/tensor.js").Tensor, import("../../utils/tensor.js").Tensor]): {
       ~~~~~~~~~~~~

node_modules/@huggingface/transformers/types/pipelines.d.ts:1393:59 - error TS2304: Cannot find name 'HTMLCanvasElement'.

1393 export type ImageInput = string | RawImage | URL | Blob | HTMLCanvasElement | OffscreenCanvas;
                                                               ~~~~~~~~~~~~~~~~~

node_modules/@huggingface/transformers/types/utils/image.d.ts:18:57 - error TS2304: Cannot find name 'HTMLCanvasElement'.

18     static read(input: RawImage | string | URL | Blob | HTMLCanvasElement | OffscreenCanvas): Promise<RawImage>;
                                                           ~~~~~~~~~~~~~~~~~

node_modules/@huggingface/transformers/types/utils/image.d.ts:24:31 - error TS2304: Cannot find name 'HTMLCanvasElement'.

24     static fromCanvas(canvas: HTMLCanvasElement | OffscreenCanvas): RawImage;
                                 ~~~~~~~~~~~~~~~~~

node_modules/@huggingface/transformers/types/utils/video.d.ts:11:49 - error TS2304: Cannot find name 'HTMLVideoElement'.

11 export function load_video(src: string | Blob | HTMLVideoElement, { num_frames, fps }?: {
                                                   ~~~~~~~~~~~~~~~~

node_modules/onnxruntime-common/dist/esm/tensor-factory.d.ts:203:29 - error TS2304: Cannot find name 'HTMLImageElement'.

203     fromImage(imageElement: HTMLImageElement, options?: TensorFromImageElementOptions): Promise<TypedTensor<'float32'> | TypedTensor<'uint8'>>;
                                ~~~~~~~~~~~~~~~~


Found 6 errors in 5 files.

Errors  Files
     1  node_modules/@huggingface/transformers/types/models/mgp_str/processing_mgp_str.d.ts:52
     1  node_modules/@huggingface/transformers/types/pipelines.d.ts:1393
     2  node_modules/@huggingface/transformers/types/utils/image.d.ts:18
     1  node_modules/@huggingface/transformers/types/utils/video.d.ts:11
     1  node_modules/onnxruntime-common/dist/esm/tensor-factory.d.ts:203

This issue was originally reported in ticket #1337 which was closed as a part of #1436 merge which landed in 3.7.6 release.

However, the issues originally reported are not fixed in 3.7.6 so I am recreating the closed ticket.

Workaround: #1337 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions