Imports & Exports in TypeScript
From the TypeScript cheat sheet · Modules & Namespaces · verified Jul 2026
Imports & Exports
ES6 module syntax for importing and exporting code
typescript
// Named exports
export const API_URL = "https://api.example.com"
export function fetchData() { }
export class User { }
export type UserType = { name: string }
export interface UserInterface { }
// Default export
export default class App { }
// Named imports
import { API_URL, fetchData } from "./api"
import type { UserType } from "./types"
// Default import
import App from "./App"
// Namespace import
import * as Utils from "./utils"
// Combined import
import React, { useState, useEffect } from "react"💡 Use type-only imports for better tree-shaking
📌 Dynamic imports for code splitting
✅ Re-export to create public API