@kubb/parser-ts
Advanced tools
+3
-4
| { | ||
| "name": "@kubb/parser-ts", | ||
| "version": "5.0.0-beta.52", | ||
| "version": "5.0.0-beta.53", | ||
| "description": "TypeScript and TSX source file parser for Kubb. Converts AST nodes and raw TypeScript code into formatted source strings using the TypeScript compiler API.", | ||
@@ -22,3 +22,2 @@ "keywords": [ | ||
| "dist", | ||
| "extension.yaml", | ||
| "!/**/**.test.**", | ||
@@ -46,7 +45,7 @@ "!/**/__tests__/**", | ||
| "typescript": "^6.0.3", | ||
| "@kubb/core": "5.0.0-beta.52" | ||
| "@kubb/core": "5.0.0-beta.53" | ||
| }, | ||
| "devDependencies": { | ||
| "@internals/utils": "0.0.0", | ||
| "@kubb/ast": "5.0.0-beta.52" | ||
| "@kubb/ast": "5.0.0-beta.53" | ||
| }, | ||
@@ -53,0 +52,0 @@ "engines": { |
-101
| $schema: https://kubb.dev/schemas/extension.json | ||
| kind: parser | ||
| id: parser-ts | ||
| name: TypeScript | ||
| description: Default file parser for Kubb. Converts the universal AST to `.ts`/`.tsx` source using the official TypeScript compiler. | ||
| category: typescript | ||
| type: official | ||
| npmPackage: '@kubb/parser-ts' | ||
| docsPath: /parsers/parser-ts | ||
| repo: https://github.com/kubb-labs/kubb | ||
| maintainers: | ||
| - name: Stijn Van Hulle | ||
| github: stijnvanhulle | ||
| compatibility: | ||
| kubb: '>=5.0.0' | ||
| node: '>=22' | ||
| tags: | ||
| - typescript | ||
| - tsx | ||
| - parser | ||
| - printer | ||
| - ast | ||
| resources: | ||
| documentation: https://kubb.dev/parsers/parser-ts | ||
| repository: https://github.com/kubb-labs/kubb | ||
| issues: https://github.com/kubb-labs/kubb/issues | ||
| changelog: https://github.com/kubb-labs/kubb/blob/main/packages/parser-ts/CHANGELOG.md | ||
| featured: true | ||
| icon: | ||
| light: https://kubb.dev/feature/typescript.svg | ||
| intro: |- | ||
| `@kubb/parser-ts` takes the `FileNode` staged by your plugins and prints it as TypeScript source using the official [TypeScript compiler](https://www.typescriptlang.org/). It resolves import paths, deduplicates declarations, prints JSDoc, and rewrites extensions based on `output.extension`. | ||
| Two parsers are exported: | ||
| - `parserTs` — handles `.ts` and `.js` files. | ||
| - `parserTsx` — handles `.tsx` and `.jsx` files. Use this for React projects so JSX in generated components is preserved. | ||
| options: | ||
| - name: extname | ||
| type: "'.ts' | '.js' | '.tsx' | '.jsx' | string" | ||
| required: false | ||
| default: "'.ts'" | ||
| description: |- | ||
| Controls which extension is written into the generated import specifiers. Set `.js` for ESM-compatible output, `.tsx` for React projects. Leave unset for the TypeScript default. | ||
| To rewrite extensions in the generated source (e.g. `./foo` → `./foo.js`), use `output.extension` in `defineConfig`, not this option. | ||
| codeBlock: | ||
| lang: typescript | ||
| title: kubb.config.ts | ||
| twoslash: false | ||
| code: |- | ||
| 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', extension: { '.ts': '.js' } }, | ||
| adapter: adapterOas(), | ||
| parsers: [parserTs], | ||
| plugins: [], | ||
| }) | ||
| examples: | ||
| - name: TypeScript (default) | ||
| files: | ||
| - name: kubb.config.ts | ||
| lang: typescript | ||
| twoslash: false | ||
| code: |- | ||
| 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: [], | ||
| }) | ||
| - name: TSX (React) | ||
| files: | ||
| - name: kubb.config.ts | ||
| lang: typescript | ||
| twoslash: false | ||
| code: |- | ||
| import { defineConfig } from 'kubb' | ||
| import { adapterOas } from '@kubb/adapter-oas' | ||
| import { parserTsx } from '@kubb/parser-ts' | ||
| export default defineConfig({ | ||
| input: { path: './petStore.yaml' }, | ||
| output: { path: './src/gen' }, | ||
| adapter: adapterOas(), | ||
| parsers: [parserTsx], | ||
| plugins: [], | ||
| }) | ||
| notes: | ||
| - type: tip | ||
| body: |- | ||
| `@kubb/parser-ts` is bundled with Kubb and used automatically when no `parsers` option is set. Install it explicitly only when combining it with other parsers or providing a fully custom parser list. |
127580
-2.79%14
-6.67%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated