Skip to content
Officialv5.8.2MITkubb >=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
383.7K/ mo
Stars
1.8K
Bundle size
120.6 kB
Updated
1h ago

Print Kubb's AST with the official TypeScript compiler.

  • Resolve imports and emit exports and JSDoc.
  • Rewrite import extensions with extension.
  • parserTs and parserTsx run by default alongside parserMd.
ParserFile extensions
parserTs().ts, .js
parserTsx().tsx, .jsx
A custom parsers array replaces the default set. Include every parser your plugins need. Unmatched files are written as source text.

Installation

Ships with kubb, no extra install.

Dependencies

  • No plugin dependencies.
  • Register custom parsers on defineConfig.parsers.

Example

Override import extensions while keeping every default parser registered.

kubb.config.ts
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()],
})