> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Default Import

A default import is an ECMAScript module (ESM) syntax construct used to bind a module's single `default` export to a local identifier. Unlike named imports, a default import does not use curly braces (`{}`) and allows the importing module to assign an arbitrary local name to the imported binding.

```typescript theme={"dark"}
import LocalIdentifier from "./module-path";
```

## Mechanical Requirements

For a default import to resolve successfully, the target module must explicitly declare an entity using the `export default` keywords. A module is strictly limited to one default export.

**Source Module (`source.ts`):**

```typescript theme={"dark"}
export default class PrimaryService {
    constructor() {}
}
```

**Importing Module (`consumer.ts`):**

```typescript theme={"dark"}
// The local identifier 'ServiceAlias' binds to the 'PrimaryService' class
import ServiceAlias from "./source"; 
```

## Syntax Variations

Default imports can be combined with named imports or namespace imports in a single declaration. The default import must always precede the named or namespace bindings.

**Combined with Named Imports:**

```typescript theme={"dark"}
import DefaultBinding, { NamedBindingA, NamedBindingB } from "./module-path";
```

**Combined with Namespace Imports:**

```typescript theme={"dark"}
import DefaultBinding, * as NamespaceBinding from "./module-path";
```

## TypeScript Compiler Interoperability

When TypeScript compiles ESM syntax to CommonJS (`module.exports`), default imports require specific compiler configurations to handle the impedance mismatch between the two module systems.

If you attempt to default-import a CommonJS module that does not have a `default` property, TypeScript will throw an error unless the `esModuleInterop` flag is enabled in the `tsconfig.json`.

```json theme={"dark"}
{
  "compilerOptions": {
    "esModuleInterop": true
  }
}
```

When `esModuleInterop` is enabled, TypeScript emits a helper function (`__importDefault`) during compilation. This helper checks if the target module is an ES module; if it is not, it wraps the CommonJS module object in an object with a `default` key, allowing the default import syntax to function correctly at runtime.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor TypeScript Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
