Skip to content
AgileLogics
3 min read

Modules in TypeScript

TypeScript uses the same import/export syntax as modern JavaScript — types can be imported and exported exactly like values.

// user.ts
export interface User {
    name: string;
}

export function greet(user: User): string {
    return `Hello, ${user.name}`;
}
// main.ts
import { User, greet } from "./user";

An interface-only import can be marked explicitly with import type { User } from "./user", making clear it's erased entirely at compile time and adds no runtime import.