Skip to content

fix: correct type definitions for AutoTokenizer and AutoModelForCausalLM#1499

Open
VedantMadane wants to merge 1 commit intohuggingface:mainfrom
VedantMadane:fix/type-definitions-auto-classes
Open

fix: correct type definitions for AutoTokenizer and AutoModelForCausalLM#1499
VedantMadane wants to merge 1 commit intohuggingface:mainfrom
VedantMadane:fix/type-definitions-auto-classes

Conversation

@VedantMadane
Copy link

Description

This PR fixes incorrect TypeScript type definitions for AutoTokenizer and AutoModelForCausalLM.

Fixes #1495

Changes

src/models.js

  • PretrainedMixin.from_pretrained: Replaced @type {typeof PreTrainedModel.from_pretrained} with full JSDoc documentation including proper parameter and return type annotations
  • AutoModelForCausalLM: Added explicit from_pretrained override with proper JSDoc to ensure TypeScript correctly types the return value

src/tokenizers.js

  • PreTrainedTokenizer.from_pretrained: Changed @param {PretrainedTokenizerOptions} options to @param {PretrainedTokenizerOptions} [options] to correctly mark as optional
  • AutoTokenizer.from_pretrained: Same fix - marked options parameter as optional

Type Generation

After running npm run typegen, the generated .d.ts files now correctly show:

  • from_pretrained methods with optional options parameter (?)
  • Proper return types (Promise<PreTrainedTokenizer> and Promise<PreTrainedModel>)

Testing

Created a TypeScript test file to validate the fixes - compilation succeeded with no errors.

@VedantMadane
Copy link
Author

Friendly ping - is there anything I can do to help move this PR forward? Happy to make any changes if needed.

@VedantMadane VedantMadane force-pushed the fix/type-definitions-auto-classes branch from 964bb1b to 5fff56a Compare February 10, 2026 13:01
@nico-martin
Copy link
Collaborator

Hi @VedantMadane, we just merged our v4 branch into main, which brings a lot of type improvements. Could you check if your changes are still needed?

@nico-martin nico-martin self-assigned this Feb 13, 2026
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.

Incorrect Type Definitions for AutoTokenizer and AutoModelForCausalLM

2 participants