
Research
/Security News
jscrambler npm Package Compromised in Supply Chain Attack
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.
@kubb/parser-ts
Advanced tools
TypeScript and TSX source file parser for Kubb. Converts AST nodes into formatted source strings using the TypeScript compiler API.
Converts AST nodes and raw TypeScript code into formatted source strings using the TypeScript compiler API. Handles both .ts and .tsx output.
bun add @kubb/parser-ts
# or
pnpm add @kubb/parser-ts
# or
npm install @kubb/parser-ts
import { defineConfig } from 'kubb'
import { parserTs, parserTsx } from '@kubb/parser-ts'
export default defineConfig({
input: './petstore.yaml',
output: { path: './src/gen' },
parsers: [parserTs(), parserTsx()],
})
Pass an extension map to rewrite the extensions emitted in import/export statements. Keys are the source extension, values the output, and an empty string drops it. Parsers drop the extension by default. Use { '.ts': '.js' } for ESM when the consumer transpiles to JavaScript, or { '.ts': '.ts' } to keep it for Node16/NodeNext resolution:
export default defineConfig({
input: './petstore.yaml',
output: { path: './src/gen' },
parsers: [parserTs({ extension: { '.ts': '.js' } }), parserTsx()],
})
To render compiler AST nodes to source text from inside a plugin, call print on a parser instance:
import { parserTs } from '@kubb/parser-ts'
import ts from 'typescript'
const source = parserTs().print(
ts.factory.createVariableStatement(
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
ts.factory.createVariableDeclarationList(
[ts.factory.createVariableDeclaration('hello', undefined, undefined, ts.factory.createStringLiteral('world'))],
ts.NodeFlags.Const,
),
),
)
// → export const hello = 'world'
parserTs(options?)Factory returning a parser instance for .ts and .js files. Pass to defineConfig({ parsers: [...] }) to emit TypeScript source files. The optional extension map rewrites the extensions written in import/export statements and defaults to { '.ts': '' }.
The returned instance exposes parse(file) to serialize a FileNode to TypeScript source and print(...nodes) to convert TypeScript compiler Node instances to a formatted source string.
parserTsx(options?)Factory returning a parser instance for .tsx and .jsx files. Same API and extension option as parserTs, with JSX support.
Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
FAQs
TypeScript and TSX source file parser for Kubb. Converts AST nodes and raw TypeScript code into formatted source strings using the TypeScript compiler API.
The npm package @kubb/parser-ts receives a total of 37,977 weekly downloads. As such, @kubb/parser-ts popularity was classified as popular.
We found that @kubb/parser-ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
A compromised jscrambler npm release added a malicious preinstall hook that runs hidden native binaries on Linux, macOS, and Windows.

Research
/Security News
A malicious .NET package is typosquatting the Braintree SDK to steal live payment card data, merchant API keys, and host secrets from production apps.

Security News
/Research
Compromised Injective SDK npm version 1.20.21 exfiltrates wallet private keys and mnemonics through fake telemetry functionality.