Skip to content

Conversation

nico-martin
Copy link
Collaborator

@nico-martin nico-martin commented Oct 10, 2025

The following errors from #1409 are adressed by this PR:

  • Added a type definition (@typedef) that tells TypeScript what PretrainedProcessorOptions is
  • Changed the parameter type from "an array of Tensors" to "exactly 3 Tensors" (char, bpe, wp)
  • The sharp import error (needs esModuleInterop)

Closes #1337
Closes #1409

@nico-martin nico-martin requested a review from xenova October 10, 2025 17:09
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@xenova xenova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks ✅

just a minor nit + comments

*/
// @ts-expect-error The type of this method is not compatible with the one
// in the base class. It might be a good idea to fix this.
// @ts-expect-error The type of this method is not compatible with the one in the base class.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah thanks! Probably why it wasn't being registered correctly.

"noEmit": false,
"emitDeclarationOnly": true
"emitDeclarationOnly": true,
"esModuleInterop": true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this do (specifically needed for this PR)? 👀 https://www.typescriptlang.org/tsconfig/#esModuleInterop

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an error file investigation this issue:

../types/utils/image.d.ts:140:8 - error TS1259: Module '"/path/transformers.js/node_modules/sharp/lib/index"' can only be default-imported using the 'esModuleInterop' flag

140 import sharp from 'sharp';

The problem is that sharp is using commonJS (require). This will ensure that interop between CommonJS ed es modules works better. As far as I know it doesn't affect runtime behavior. It only helps TypeScript understand CommonJS modules better during type checking and generation.

.gitignore Outdated
.DS_STORE
deno.lock
.idea
demo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
demo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I removed it.

@xenova xenova changed the title This is a fix for the ts-errors from Issue 1409 Type error fixes Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Getting TS2304: Cannot find name 'PretrainedProcessorOptions'. error 3.5.2 typescript build errors

3 participants