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

# 重新映射导入路径

Bun 会读取你 `tsconfig.json` 文件中的 `paths` 字段以重新写入导入路径。这对于别名包名或避免冗长的相对路径非常有用。

```json tsconfig.json icon="file-json" theme={"theme":{"light":"github-light","dark":"dracula"}}
{
  "compilerOptions": {
    "paths": {
      "my-custom-name": ["zod"],
      "@components/*": ["./src/components/*"]
    }
  }
}
```

***

根据上述 `tsconfig.json`，以下导入语句将被重写：

```ts tsconfig.ts icon="https://mintcdn.com/bun-zhcndoc/cnUTwgMuf4cCrwC-/icons/typescript.svg?fit=max&auto=format&n=cnUTwgMuf4cCrwC-&q=85&s=e7767043c9e885c34f2d6c8fe2a95217" theme={"theme":{"light":"github-light","dark":"dracula"}}
import { z } from "my-custom-name"; // 从 "zod" 导入
import { Button } from "@components/Button"; // 从 "./src/components/Button" 导入
```

***

有关在 Bun 中使用 TypeScript 的更多信息，请参见[文档 > 运行时 > TypeScript](/runtime/typescript)。
