microsoft / microsoft/TypeScript

Paths from tsconfig are not used if declaration is on a different partition

未关闭
#63,430 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@andrewbranch 已经在做这个了。

开始于 2026年5月15日。

Needs Investigation
主要语言
Go
星标
111k
派生
14.3k
平均合并
2 天 4 小时
30 天内合并 PR
132

描述

🔎 Search Terms

paths drive partition

🕗 Version & Regression Information
  • This changed between versions 5.6 and 5.7 (before this paths was not used in the give example)
⏯ Playground Link

Playground Link

💻 Code
// @declaration
// @filename: C:/src/index.ts
import { D1 } from "./internal"
import { D2 } from "./internal"
export const B1 = D1
export const B2 = D2

// @filename: C:/src/internal.ts
import { LIB as LIB1} from "@lib1";
import { LIB as LIB2 } from "@lib2";

export const D1 = [LIB1] as const
export const D2 = [LIB2] as const

//@filename: tsconfig.json
{
    "compilerOptions": {
        "strict": true,
        "outDir": "../out",
        "declaration": true,
        "paths": {
            "@lib1": ["C:/libs/index.d.ts"],
            "@lib2": ["D:/libs/index.d.ts"]
        }
    }
}

// @filename: C:/libs/lib.ts
export const LIB :unique symbol

// @filename: D:/libs/lib.ts
export const LIB :unique symbol
🙁 Actual behavior

In index.d.ts we get:

export declare const B1: readonly [typeof import("@lib1").LIB];
export declare const B2: readonly [typeof import("D:/dev/tmp/app").LIB];
🙂 Expected behavior

We should get

export declare const B1: readonly [typeof import("@lib1").LIB];
export declare const B2: readonly [typeof import("@lib2").LIB];
Additional information about the issue

The workbench does not actually show the bug since it does not appear to suport windows rooted drive paths. The issue only happens if the d.ts file is on a different drive. There is an explicit check in the code see if the declaration path is relative and only then is the path alias in tsconfig used (which doesn't seem right).

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。