Skip to content
TypeScript

TypeScript

Officialv5.8.3

@kubb/parser-ts

kubb add parser-ts

Options

parserTs and parserTsx accept the same single option, extension, which rewrites the import and export extensions the TypeScript parser emits.

Options overview

OptionPurposeDefault
extensionRewrite the extensions emitted in import/export statements.{ '.ts': '' }

Option details

extension

Rewrites the extensions emitted in import/export statements. Keys are the source extension, values the output, and '' drops it. Only the module-specifier string changes, never the on-disk filename.

Use it to emit .js imports from .ts sources for an ESM dual package, or to keep the source extension for Node16/NodeNext resolution.

The same mapping applies to runtime templates a plugin copies into the output, such as the .kubb/ runtime files of @kubb/plugin-fetch. Their top-level import and export … from statements become import and export nodes, so the whole output follows one convention.

TypeRecord<string, string>
Requiredfalse
Default{ '.ts': '' }
parserTs({ extension: { '.ts': '.js' } }) // import './api.js' instead of './api'
parserTs({ extension: { '.ts': '.ts' } }) // import './api.ts' instead of './api'