TIP
@kubb/parser-ts ships with Kubb and runs by default. Install it on its own only when you set a custom parsers list or add other parsers next to it.
@kubb/parser-ts takes the FileNode your plugins stage and prints it as TypeScript source with the official TypeScript compiler. It resolves import paths, writes the import and export statements, prints JSDoc, and rewrites import extensions based on output.extension.
The package exports two parsers:
parserTshandles.tsand.jsfiles.parserTsxhandles.tsxand.jsxfiles. Use it for React projects so JSX in generated components is preserved.
See Options for the configuration reference.
Installation
shell
bun add -d @kubb/parser-ts@betashell
pnpm add -D @kubb/parser-ts@betashell
npm install --save-dev @kubb/parser-ts@betashell
yarn add -D @kubb/parser-ts@betaExample
typescript
import { defineConfig } from 'kubb'
import { adapterOas } from '@kubb/adapter-oas'
import { parserTs } from '@kubb/parser-ts'
export default defineConfig({
input: { path: './petStore.yaml' },
output: { path: './src/gen' },
adapter: adapterOas(),
parsers: [parserTs],
plugins: [],
})typescript
import { } from 'kubb'
import { } from '@kubb/adapter-oas'
import { } from '@kubb/parser-ts'
export default ({
: { : './petStore.yaml' },
: { : './src/gen' },
: (),
: [],
: [],
})