@kubb/parser-ts 5.0.0-beta.3 → 5.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extension.yaml +100 -0
- package/package.json +4 -3
package/extension.yaml
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
$schema: https://kubb.dev/schemas/extension.json
|
|
2
|
+
kind: parser
|
|
3
|
+
id: parser-ts
|
|
4
|
+
name: TypeScript
|
|
5
|
+
description: TypeScript and TSX file parser for Kubb. Converts the universal AST to `.ts`/`.tsx` source code using the official TypeScript compiler.
|
|
6
|
+
category: typescript
|
|
7
|
+
type: official
|
|
8
|
+
npmPackage: '@kubb/parser-ts'
|
|
9
|
+
docsPath: /parsers/parser-ts
|
|
10
|
+
repo: https://github.com/kubb-labs/kubb
|
|
11
|
+
maintainers:
|
|
12
|
+
- name: Stijn Van Hulle
|
|
13
|
+
github: stijnvanhulle
|
|
14
|
+
compatibility:
|
|
15
|
+
kubb: '>=5.0.0'
|
|
16
|
+
node: '>=22'
|
|
17
|
+
tags:
|
|
18
|
+
- typescript
|
|
19
|
+
- tsx
|
|
20
|
+
- parser
|
|
21
|
+
- printer
|
|
22
|
+
- ast
|
|
23
|
+
resources:
|
|
24
|
+
documentation: https://kubb.dev/parsers/parser-ts
|
|
25
|
+
repository: https://github.com/kubb-labs/kubb
|
|
26
|
+
issues: https://github.com/kubb-labs/kubb/issues
|
|
27
|
+
changelog: https://github.com/kubb-labs/kubb/blob/main/packages/parser-ts/CHANGELOG.md
|
|
28
|
+
featured: true
|
|
29
|
+
icon:
|
|
30
|
+
light: https://kubb.dev/feature/typescript.svg
|
|
31
|
+
intro: |-
|
|
32
|
+
The TypeScript parser is the default file parser used by Kubb when no `parsers` option is set in `defineConfig`. It converts Kubb's universal AST into `.ts` and `.tsx` source code using the official [TypeScript compiler](https://www.typescriptlang.org/).
|
|
33
|
+
|
|
34
|
+
Two parser instances are exported:
|
|
35
|
+
|
|
36
|
+
- `parserTs` — handles `.ts` and `.js` files
|
|
37
|
+
- `parserTsx` — handles `.tsx` and `.jsx` files
|
|
38
|
+
|
|
39
|
+
Both are configured globally in `defineConfig` and apply to every file produced by every plugin.
|
|
40
|
+
options:
|
|
41
|
+
- name: extname
|
|
42
|
+
type: "'.ts' | '.js' | '.tsx' | '.jsx' | string"
|
|
43
|
+
required: false
|
|
44
|
+
default: "'.ts'"
|
|
45
|
+
description: |-
|
|
46
|
+
File extension used when rewriting relative import paths. Set to `.js` for ESM-friendly emit, `.tsx` for React projects, or leave unset to keep TypeScript's default behaviour.
|
|
47
|
+
|
|
48
|
+
Extension rewriting is configured via `output.extension` in `defineConfig`, not as a parser argument.
|
|
49
|
+
codeBlock:
|
|
50
|
+
lang: typescript
|
|
51
|
+
title: kubb.config.ts
|
|
52
|
+
twoslash: false
|
|
53
|
+
code: |-
|
|
54
|
+
import { defineConfig } from 'kubb'
|
|
55
|
+
import { adapterOas } from '@kubb/adapter-oas'
|
|
56
|
+
import { parserTs } from '@kubb/parser-ts'
|
|
57
|
+
|
|
58
|
+
export default defineConfig({
|
|
59
|
+
input: { path: './petstore.yaml' },
|
|
60
|
+
output: { path: './src/gen', extension: { '.ts': '.js' } },
|
|
61
|
+
adapter: adapterOas(),
|
|
62
|
+
parsers: [parserTs],
|
|
63
|
+
})
|
|
64
|
+
examples:
|
|
65
|
+
- name: TypeScript (default)
|
|
66
|
+
files:
|
|
67
|
+
- name: kubb.config.ts
|
|
68
|
+
lang: typescript
|
|
69
|
+
twoslash: false
|
|
70
|
+
code: |-
|
|
71
|
+
import { defineConfig } from 'kubb'
|
|
72
|
+
import { adapterOas } from '@kubb/adapter-oas'
|
|
73
|
+
import { parserTs } from '@kubb/parser-ts'
|
|
74
|
+
|
|
75
|
+
export default defineConfig({
|
|
76
|
+
input: { path: './petstore.yaml' },
|
|
77
|
+
output: { path: './src/gen' },
|
|
78
|
+
adapter: adapterOas(),
|
|
79
|
+
parsers: [parserTs],
|
|
80
|
+
})
|
|
81
|
+
- name: TSX (React)
|
|
82
|
+
files:
|
|
83
|
+
- name: kubb.config.ts
|
|
84
|
+
lang: typescript
|
|
85
|
+
twoslash: false
|
|
86
|
+
code: |-
|
|
87
|
+
import { defineConfig } from 'kubb'
|
|
88
|
+
import { adapterOas } from '@kubb/adapter-oas'
|
|
89
|
+
import { parserTsx } from '@kubb/parser-ts'
|
|
90
|
+
|
|
91
|
+
export default defineConfig({
|
|
92
|
+
input: { path: './petstore.yaml' },
|
|
93
|
+
output: { path: './src/gen' },
|
|
94
|
+
adapter: adapterOas(),
|
|
95
|
+
parsers: [parserTsx],
|
|
96
|
+
})
|
|
97
|
+
notes:
|
|
98
|
+
- type: tip
|
|
99
|
+
body: |-
|
|
100
|
+
`parser-ts` is bundled with Kubb and used automatically when no `parsers` option is provided. You only need to install it explicitly when combining it with other parsers or providing a fully custom parsers list.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/parser-ts",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.4",
|
|
4
4
|
"description": "TypeScript and TSX file parser for Kubb, converting generated files to strings using the TypeScript compiler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generator",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"src",
|
|
22
22
|
"dist",
|
|
23
|
+
"extension.yaml",
|
|
23
24
|
"!/**/**.test.**",
|
|
24
25
|
"!/**/__tests__/**",
|
|
25
26
|
"!/**/__snapshots__/**"
|
|
@@ -42,11 +43,11 @@
|
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"typescript": "^6.0.3",
|
|
45
|
-
"@kubb/core": "5.0.0-beta.
|
|
46
|
+
"@kubb/core": "5.0.0-beta.4"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@internals/utils": "0.0.0",
|
|
49
|
-
"@kubb/ast": "5.0.0-beta.
|
|
50
|
+
"@kubb/ast": "5.0.0-beta.4"
|
|
50
51
|
},
|
|
51
52
|
"engines": {
|
|
52
53
|
"node": ">=22"
|