TypeScript Concepts

Declaration emit — describing exported APIs

Declaration emission writes .d.ts files describing exported types and signatures for consumers, rather than providing runtime implementations. A normal declaration build can emit JavaScript as well; emitDeclarationOnly produces declarations without JS. The example must be compiled with declaration enabled; its generated declaration is checked separately from the runtime result. Observed output: 'item-3'. Local example verified with TypeScript 5.8.3, strict checking, ES2022/CommonJS and Node.js 22.16.0; declarations enabled.

Formal Syntax & Structure

typescript syntaxtypescript
tsc --declaration --outDir dist main.ts

Working Example

Example Snippettypescript
export function label(id: number): string { return `item-${id}`; }console.log(label(3));
TypeScript Reference