Libraries
Advanced
Library API and Declaration Design
Design public TypeScript APIs, generated declarations, and SDK types that enterprise consumers can trust.
40 min
3 sections
declarations
sdk
public-api
libraries
1
2
3
01. Public Types Are Product Surface
Section 1 of 3
If another team imports a type, that type is now a contract. Keep public types small, intentional, and stable. Avoid leaking database rows, vendor SDK details, or internal helper types into package exports.
typescript
// Good public API
export type CreateCustomerInput = {
legalName: string;
billingEmail: string;
plan: "starter" | "business" | "enterprise";
};
export type CustomerSummary = {
id: string;
legalName: string;
plan: "starter" | "business" | "enterprise";
};
export interface CustomerClient {
create(input: CreateCustomerInput): Promise<CustomerSummary>;
}Back to Course