Feature Request: Option to simplify generated operation types
Problem
When generating TypeScript types for API operations, Kubb creates multiple type aliases that are often redundant:
// Generated in models/orderManagement/OrderManagementGetAllPortfolioTrades.ts
// Alias 1: Status code specific
export type OrderManagementGetAllPortfolioTrades200 = PortfolioTradesResponseCO;
// Alias 2: Error type
export type OrderManagementGetAllPortfolioTrades422 = HTTPValidationError;
// Alias 3: Another alias of alias
export type OrderManagementGetAllPortfolioTradesMutationResponse = OrderManagementGetAllPortfolioTrades200;
// Alias 4: Composite type
export type OrderManagementGetAllPortfolioTradesMutation = {
Response: OrderManagementGetAllPortfolioTrades200;
Request: OrderManagementGetAllPortfolioTradesMutationRequest;
Errors: OrderManagementGetAllPortfolioTrades422;
};
In practice, I only need to import the base business type (PortfolioTradesResponseCO) directly. The operation-level aliases add noise and increase bundle size.
Proposed Solution
Add a configuration option like simplifiedTypes or operationTypes: false to skip generating operation-level type aliases:
pluginTs({
output: { path: './models' },
operationTypes: false, // Skip OrderManagementGetAllPortfolioTrades200, etc.
}),
pluginClient({
output: { path: './api' },
operationTypes: false, // Use base types directly in generated functions
}),
Expected Behavior
With operationTypes: false, the generated client function would directly use the base types:
// Before
import type {
OrderManagementGetAllPortfolioTradesMutationRequest,
OrderManagementGetAllPortfolioTradesMutationResponse,
OrderManagementGetAllPortfolioTrades422,
} from "../../models/...";
export async function orderManagementGetAllPortfolioTrades(
data: OrderManagementGetAllPortfolioTradesMutationRequest,
...
): Promise
// After (simplified)
import type {
PortfolioTradesQueryCO,
PortfolioTradesResponseCO,
} from "../../models";
export async function orderManagementGetAllPortfolioTrades(
data: PortfolioTradesQueryCO,
...
): Promise
Use Case
- Projects that don't need fine-grained error type handling per status code
- Cleaner imports in business code
- Smaller generated output
Alternatives Considered
- Import base types manually - Works but defeats the purpose of generated types
- Post-processing script - Adds complexity to the build pipeline
Would love to hear if this aligns with Kubb's design philosophy or if there's an existing way to achieve this. Thanks!
Feature Request: Option to simplify generated operation types
Problem
When generating TypeScript types for API operations, Kubb creates multiple type aliases that are often redundant:
In practice, I only need to import the base business type (PortfolioTradesResponseCO) directly. The operation-level aliases add noise and increase bundle size.
Proposed Solution
Add a configuration option like simplifiedTypes or operationTypes: false to skip generating operation-level type aliases:
pluginTs({
output: { path: './models' },
operationTypes: false, // Skip OrderManagementGetAllPortfolioTrades200, etc.
}),
pluginClient({
output: { path: './api' },
operationTypes: false, // Use base types directly in generated functions
}),
Expected Behavior
With operationTypes: false, the generated client function would directly use the base types:
// Before
import type {
OrderManagementGetAllPortfolioTradesMutationRequest,
OrderManagementGetAllPortfolioTradesMutationResponse,
OrderManagementGetAllPortfolioTrades422,
} from "../../models/...";
export async function orderManagementGetAllPortfolioTrades(
data: OrderManagementGetAllPortfolioTradesMutationRequest,
...
): Promise
// After (simplified)
import type {
PortfolioTradesQueryCO,
PortfolioTradesResponseCO,
} from "../../models";
export async function orderManagementGetAllPortfolioTrades(
data: PortfolioTradesQueryCO,
...
): Promise
Use Case
Alternatives Considered
Would love to hear if this aligns with Kubb's design philosophy or if there's an existing way to achieve this. Thanks!