Skip to content

Setting return type of pipeline in TypeScript results in TS2590: Expression produces a union type that is too complex to represent. #1299

Open
@allout58

Description

@allout58

System Info

@huggingface/transformers: 3.5.0
typescript: 5.6.3
Angular: 19.1.3

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

When trying to add types to my use of pipeline(), I use the following snippet

import {pipeline, AutomaticSpeechRecognitionPipeline} from '@huggingface/transformers';
...
     const instance: Promise<AutomaticSpeechRecognitionPipeline> = pipeline(
       'automatic-speech-recognition',
       'Xenova/whisper-base',
       {progress_callback},
     );

My editor now complains about the pipeline invocation with TS2590: Expression produces a union type that is too complex to represent.

Reproduction

See https://stackblitz.com/edit/vitejs-vite-bvwhnlwn?file=src%2Fmain.ts&view=editor

In a project with Typescript and @huggingface/transformers, attempt to set the type returned by pipeline

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