Skip to content

fix(types): export the helper types from the package root (#105) - #183

Merged
ccampbell-aai merged 1 commit into
AssemblyAI:mainfrom
kosesena:fix/105-export-helper-types
Sep 19, 2026
Merged

ccampbell-aai merged 1 commit into
AssemblyAI:mainfrom
kosesena:fix/105-export-helper-types

Conversation

@kosesena

Copy link
Copy Markdown
Contributor

Fixes #105.

The failure

A downstream TypeScript package that exports a value typed by Transcript.language_code, TranscriptParams.language_code or SyncSpeechModel fails its declaration emit:

error TS2742: The inferred type of 'languageOf' cannot be named without a reference to 'assemblyai/dist/types/helpers'. This is likely not portable. A type annotation is necessary.

Those fields are declared with LiteralUnion<...> from src/types/helpers. The main entry never re-exported that module (only the ./streaming entry does), and dist/types/helpers is not in the exports map, so TypeScript has no portable way to spell the type and gives up.

The fix

src/types/index.ts re-exports ./helpers, so the type is nameable as import("assemblyai").LiteralUnion<...>. One line; no runtime change.

Checked

  • Reproduced against the published 4.41.1 with a two-file downstream project (tsc --declaration --emitDeclarationOnly, moduleResolution: NodeNext): TS2742 on two exports. Against this branch's build: clean, and the emitted .d.ts reads import("assemblyai").LiteralUnion<import("assemblyai").TranscriptLanguageCode, string>.
  • tests/unit/exports.test.ts names the affected types through the package root; if the re-export goes, the file stops compiling.
  • pnpm format (no changes), pnpm lint (eslint, tsc, prettier, publint) and pnpm build pass. pnpm test:unit: 337 pass; the three utils user-agent tests fail identically on main without this change.
  • Version bumped to 4.41.2 with a CHANGELOG entry, following the merged external PRs.

🤖 Generated with Claude Code

A downstream TypeScript package that exports a value typed by
`Transcript.language_code`, `TranscriptParams.language_code` or
`SyncSpeechModel` fails its declaration emit with

  TS2742: The inferred type of 'x' cannot be named without a reference
  to 'assemblyai/dist/types/helpers'. This is likely not portable.

Those fields are declared with `LiteralUnion<...>` from `types/helpers`,
and the main entry did not re-export that module: only the `./streaming`
entry did. The `exports` map does not expose `dist/types/helpers`, so
TypeScript had no portable way to spell the type and gave up.

`src/types/index.ts` now re-exports `./helpers`, so the type is nameable
as `import("assemblyai").LiteralUnion<...>`. No runtime change. A unit
test names the affected types through the package root; if the re-export
goes, the test file stops compiling. Reproduced and re-checked with a
downstream `tsc --declaration` build against the published 4.41.1 and
against this tree: the error appears on 4.41.1 and is gone here.

Fixes AssemblyAI#105

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kosesena
kosesena force-pushed the fix/105-export-helper-types branch from 9e3d106 to a3c17a9 Compare September 17, 2026 19:06
@ccampbell-aai
ccampbell-aai merged commit ddf69f1 into AssemblyAI:main Sep 19, 2026
3 checks passed
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.

TypeScript types reference internal modules (causing TS 2742) in downstream packages

2 participants