Skip to content
Officialv5.5.6MITkubb >=5.0.0node >=22

@kubb/parser-ts

Prints the Kubb AST to TypeScript source with the official TypeScript compiler, so every plugin writes real `.ts`, `.tsx`, `.js`, and `.jsx` files.

typescripttsxparserprinterast
Stijn Van Hulle

Stijn Van Hulle

@stijnvanhulle

Downloads
367.4K/ mo
Stars
1.8K
Bundle size
148.2 kB
Updated
1d ago

@kubb/parser-ts prints Kubb's AST as TypeScript using the official TypeScript compiler. It resolves imports, emits exports and JSDoc, and applies the extension mapping.

ParserFile extensions
parserTs().ts, .js
parserTsx().tsx, .jsx

Both run by default alongside parserMd.

A custom parsers array replaces the default set. Include every parser your plugins need. Unmatched files are written as source text.

Installation

bun add -d @kubb/parser-ts

Dependencies

No plugin dependencies. The parser registers on defineConfig.parsers.

Example

Override import extensions while keeping every default parser registered.

kubb.config.ts
import { defineConfig } from 'kubb'
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()],
})

See also