Type fabric-core
The Type component generates TypeScript type declarations including types, interfaces, and type aliases.
Use Type when: You need to generate TypeScript type definitions programmatically.
Perfect for: Schema-to-TypeScript generators, API client type generation, SDK type definitions.
NOTE
This is the Fabric Core version using the functional API. For the React version, see Type (React Fabric).
Usage
Generate TypeScript type declarations with the Type component.
Example: Create an exported type definition.
tsx
import { createFabric } from '@kubb/fabric-core'
import { fsxPlugin } from '@kubb/fabric-core/plugins'
import { Type } from '@kubb/fabric-core'
const fabric = createFabric()
fabric.use(fsxPlugin)
const component = Type({
name: 'User',
export: true
}).children(['{ id: number; name: string }'])
const output = await fabric.render(component)ts
export type User = { id: number; name: string }Component Props
name
Name of the type.
| Type: | string |
|---|---|
| Required: | true |
export
Export the type.
| Type: | boolean |
|---|---|
| Required: | false |
| Default: | false |
JSDoc
JSDoc comments.
| Type: | JSDoc |
|---|---|
| Required: | false |
Examples
Union Type
tsx
import { createFabric } from '@kubb/fabric-core'
import { fsxPlugin } from '@kubb/fabric-core/plugins'
import { Type } from '@kubb/fabric-core'
const fabric = createFabric()
fabric.use(fsxPlugin)
const component = Type({
name: 'Status',
export: true
}).children(["'pending' | 'success' | 'error'"])
const output = await fabric.render(component)ts
export type Status = 'pending' | 'success' | 'error'See Also
- Type (React Fabric) - React version
- Function - Function declarations
- Const - Constant declarations
