You can export a single class in TypeScript like this:

class Person {

  private firstName: string;
  private lastName: string;

  constructor(firstName: string, lastName: string) {
    this.firstName = firstName;
    this.lastName = lastName;
  }

  public getFullName() {
    return `${this.firstName} ${this.lastName}`;
  }
}

export = Person;

And here is how it's going to be used:

var Person = require('./dist/commonjs/Person.js');

var homer = new Person('Homer', 'Simpson');
var name = homer.getFullName();

console.log(name); // Homer Simpson

To be complete, here is my tsconfig.json (I am using TypeScript v2.0.3):

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "outDir": "dist/commonjs",
    "rootDir": "src/ts",
    "target": "es5"
  },
  "exclude": [
    "dist",
    "node_modules"
  ]
}
Answer from Benny Neugebauer on Stack Overflow
🌐
TypeScript
typescriptlang.org › docs › handbook › 2 › modules.html
TypeScript: Documentation - Modules
For focus, the handbook will cover ... in the reference section under Modules. In TypeScript, just as in ECMAScript 2015, any file containing a top-level import or export is considered a module....
🌐
Medium
medium.com › @robinviktorsson › typescript-and-es-modules-best-practices-for-imports-and-exports-9ce200e75a88
TypeScript and ES Modules: Best Practices for Imports and Exports | by Robin Viktorsson | Medium
March 10, 2025 - TypeScript supports both import and require statements, but it’s best practice to avoid mixing the two. Stick with import statements for consistency and to fully embrace the ES module system. Using require is more common in older CommonJS modules. ... TypeScript introduces a helpful feature for type-only imports and exports.
🌐
TypeScript
typescriptlang.org › docs › handbook › modules › reference.html
TypeScript: Documentation - Modules - Reference
This syntax was used over its JavaScript counterparts since variable declarations and property assignments could not refer to TypeScript types, whereas special TypeScript syntax could: ... module.exports = Options; // Error: 'Options' only refers to a type, but is being used as a value here.
🌐
DEV Community
dev.to › mindplay › typescript-module-multiple-exports-where-do-you-begin-1on9
Typescript module, multiple exports, where do you begin? - DEV Community
March 3, 2022 - At least one of the packages is going to have multiple exports in package.json - that is, it will contain multiple modules in the same package. This will make sense for packages that ship with optional modules - keeping them close at hand, but loading them is optional. The Typescript source module structure won't necessarily match the published modules - that is, I might decide to use more TS modules published as fewer compiled ES modules, just for cleaner structure, so I will probably need some sort of bundler as well.
🌐
TypeScript
typescriptlang.org › docs › handbook › declaration-files › templates › module-d-ts.html
TypeScript: Documentation - Modules .d.ts
A module using CommonJS patterns uses module.exports to describe the exported values. For example, here is a module which exports a function and a numerical constant: ... The TypeScript playground can show you the .d.ts equivalent for JavaScript code.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-modules-in-typescript
How To Use Modules in TypeScript | DigitalOcean
February 7, 2022 - This file is still using the syntax for importing the default export of a module, but you are now overwriting the exported object, so you do not have a default export anymore. Using both syntaxes together is incompatible. There are two ways to solve this: Using import = require() and setting the esModuleInterop property to true in the TypeScript Compiler configuration file.
Find elsewhere
🌐
Total TypeScript
totaltypescript.com › books › total-typescript-essentials › modules-scripts-and-declaration-files
Modules, Scripts, and Declaration Files | Total TypeScript
TypeScript has two ways of understanding what a .ts file is. It can be treated either as a module, containing imports and exports, or a script, which executes in the global scope.
🌐
Mimo
mimo.org › glossary › typescript › module
TypeScript Module: Syntax, Usage, and Examples
Use TypeScript modules to organize code, prevent conflicts, and enable reusability with export and import across files.
🌐
TypeScript
typescriptlang.org › docs › handbook › modules › appendices › esm-cjs-interop.html
TypeScript: Documentation - Modules - ESM/CJS Interoperability
When we transpile an ES module to CJS, let’s add a special extra field to the output: ... The __esModule flag first appeared in Traceur, then in Babel, SystemJS, and Webpack shortly after. TypeScript added the allowSyntheticDefaultImports in 1.8 to allow the type checker to link default imports directly to the exports, rather than the exports.default, of any module types that lacked an export default declaration.
🌐
Total TypeScript
totaltypescript.com › tips › turn-a-module-into-a-type
Turn a module into a type | Total TypeScript
So if we go to types, what we can do is we can say export type ActionModule. And we're going to use this funky little bits of TypeScript syntax.
Published   May 30, 2023
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Statements › export
export - JavaScript | MDN
In order to use the export declaration in a source file, the file must be interpreted by the runtime as a module. In HTML, this is done by adding type="module" to the <script> tag, or by being imported by another module.
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-to-import-a-module-in-typescript
How to import a module in Typescript ? - GeeksforGeeks
July 23, 2025 - The module is designed to arrange a code written in TypeScript and used as a local scope. Modules are basically scripts written in separate files. Import allows you to reference their source location in an existing file. Now we will understand different ways to import external models, and know how to use that module in the desired location. Approach: Before importing any module we need to export it from another file.
🌐
LogRocket
blog.logrocket.com › home › publishing node modules with typescript and es modules
Publishing Node modules with TypeScript and ES modules - LogRocket Blog
June 4, 2024 - ES6 modules introduced the use of the import and export keywords for defining and exporting modules that are compatible with CommonJS’s require() and module.exports or exports keywords. ... To use Node modules outside, particularly in web applications, we use build systems such as webpack, rollup, or babel to convert the Node modules to browser-compatible formats. Next, we have to decide which module system we’ll use for this project. Note that this isn’t which module system we’re going to author in, but which module system TypeScript’s compiler will use when it outputs the code.
🌐
Node.js
nodejs.org › api › modules.html
Modules: CommonJS modules | Node.js v25.9.0 Documentation
To have a module execute code multiple times, export a function, and call that function. Modules are cached based on their resolved filename.
🌐
webpack
webpack.js.org › guides › package-exports
Package exports | webpack
Write your source code as ESM and transpile to CJS via babel, typescript or similar tools. Either use .cjs or type: "commonjs" in package.json to clearly mark source code as CommonJs. This makes it statically detectable for tools if CommonJs or ESM is used. This is important for tools that only support ESM and no CommonJs. ESM used in packages support the following types of requests: module requests are supported, pointing to other packages with a package.json.
🌐
Devchallenges
devchallenges.io › learn › 3-javascript › typescript-modules
TypeScript Modules: Comprehensive Guide for Developers | devChallenges
Master TypeScript modules with our comprehensive guide. Learn ES6, CommonJS, AMD, UMD, and advanced techniques for efficient code structure.
🌐
W3Schools
w3schools.com › js › js_modules.asp
W3Schools.com
Modules are code blocks that can export and/or import functions and values.
🌐
TypeScript
typescriptlang.org › tsconfig › module
TypeScript: TSConfig Option: module
In --module preserve (added in TypeScript 5.4), ECMAScript imports and exports written in input files are preserved in the output, and CommonJS-style import x = require("...") and export = ... statements are emitted as CommonJS require and module.exports.
🌐
Node.js
nodejs.org › api › packages.html
Modules: Packages | Node.js v25.9.0 Documentation
Both fields apply to both ES module and CommonJS module entry points. The "main" field is supported in all versions of Node.js, but its capabilities are limited: it only defines the main entry point of the package. The "exports" provides a modern alternative to "main" allowing multiple entry points to be defined, conditional entry resolution support between environments, and preventing any other entry points besides those defined in "exports".