Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.1.2 typescript build errors #1093

Open
1 of 5 tasks
jozefchutka opened this issue Dec 10, 2024 · 1 comment
Open
1 of 5 tasks

3.1.2 typescript build errors #1093

jozefchutka opened this issue Dec 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jozefchutka
Copy link

jozefchutka commented Dec 10, 2024

System Info

transformers.js: 3.1.2
node: 22.12.0
typescript: 5.7.2

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.1.2 will fail.

Reproduction

package.json

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

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 will fail with following errors

node_modules/@huggingface/transformers/types/models/auto/processing_auto.d.ts:32:76 - error TS2304: Cannot find name 'PretrainedProcessorOptions'.

32     static from_pretrained(pretrained_model_name_or_path: string, options: PretrainedProcessorOptions): Promise<Processor>;
                                                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~

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[]) => { generated_text: string[]; scores: number[]; char_preds: string[]; bpe_preds: string[]; wp_preds: string[]; }' is not assignable to type '(...args: any[]) => string[]'.
    Type '{ generated_text: string[]; scores: number[]; char_preds: string[]; bpe_preds: string[]; wp_preds: string[]; }' is missing the following properties from type 'string[]': length, pop, push, concat, and 35 more.

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

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/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 4 errors in 4 files.

Errors  Files
     1  node_modules/@huggingface/transformers/types/models/auto/processing_auto.d.ts:32
     1  node_modules/@huggingface/transformers/types/models/mgp_str/processing_mgp_str.d.ts:52
     1  node_modules/@huggingface/transformers/types/utils/image.d.ts:24
     1  node_modules/onnxruntime-common/dist/esm/tensor-factory.d.ts:203
@jozefchutka jozefchutka added the bug Something isn't working label Dec 10, 2024
@Debbl
Copy link

Debbl commented Dec 12, 2024

I seem to have the same problem.

this is reproduction.

  • pnpm install
  • pnpm build

There is a file use the ProgressInfo type.
image

but it has a type error when run build.

image

If use ProgressInfo like this.
image

it can right export.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants