TypeScript Syntax
export equals — single CommonJS export assignment
An export assignment describes a module whose exported value is a single object, function or other supported expression. In CommonJS output it assigns module.exports. It cannot be combined with ordinary exported declarations in the same module. Multi-file example: save each labeled file separately in one directory and compile the project. Observed output: '#4'. Local verification: TypeScript 5.8.3, strict mode, ES2022, CommonJS, Node.js 22.16.0. Disposable library declarations are enabled for the fixture suite.
Formal Syntax & Structure
typescript syntaxtypescript
export = value;Working Example
Example Snippettypescript
// File: catalog.tsfunction format(id: number) { return `#${id}`; }export = format;
// File: main.tsimport format = require("./catalog");console.log(format(4));