parsers: [parserTs()]TypeScript
@kubb/parser-ts
Prints the Kubb AST to TypeScript source with the official TypeScript compiler.
- Downloads383.7K/ monthnpm, last 30 days
- GitHub stars1.8Kkubb-labs/kubb
- Unpacked size122.5kBv5.8.3 on npm
- Latest release2h agov5.8.3 · Oct 13, 2026
The TypeScript parser prints Kubb's AST as source code with the official TypeScript compiler. It resolves imports, writes exports and JSDoc, and handles .ts and .js files.
The package also exports parserTsx, which handles .tsx and .jsx files with the same options. Kubb registers parserTs, parserTsx, and parserMd by default.
Installation
bun add -d @kubb/parser-tspnpm add -D @kubb/parser-tsnpm install --save-dev @kubb/parser-tsyarn add -D @kubb/parser-tsOr run kubb add parser-ts to install the version the Kubb registry pins and add parserTs() to kubb.config.ts.
Setup
Set defineConfig.parsers only to change an option. A custom parsers array replaces the default set, so list every parser your plugins need. Files no parser claims are written as their source text.
Options
extension rewrites the extension of relative imports and exports. Keys are the source extension and values the output, and '' drops it. By default .ts imports have no extension. Use { '.ts': '.js' } for ESM packages, or { '.ts': '.ts' } for Node.js NodeNext resolution. Package imports stay unchanged. See Options for its type and default.
Example
Override import extensions while keeping every default parser registered.
import { defineConfig } from 'kubb/config'
import { parserTs, parserTsx } from '@kubb/parser-ts'
import { parserMd } from '@kubb/parser-md'
import { pluginTs } from '@kubb/plugin-ts'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
parsers: [parserTs({ extension: { '.ts': '.js' } }), parserTsx(), parserMd()],
plugins: [pluginTs()],
})Dependencies
No extension dependencies.