Microsoft/TypeScript

tsconfig extends with bare path ".." works when it should not

開放

#51,782 建立於 2022年12月6日

 (1 則留言) (1 個反應) (0 位負責人)TypeScript (13,395 個分叉)batch import
BugDomain: Module ResolutionHelp Wanted

倉庫指標

星標
 (108,860 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Bug Report

🔎 Search Terms

tsconfig extends parent

🕗 Version & Regression Information

  • This changed between versions 3.1.8 and 3.2.1

⏯ Playground Link

Playground links with relevant code: A. https://stackblitz.com/edit/node-adwy3r B. https://stackblitz.com/edit/node-aiwgcb

💻 Code

Playground A

tsconfig.json:

{}

foo/tsconfig.json:

{"extends": ".."}

Playground B

tsconfig.json:

{"extends": "./foo"}

foo/tsconfig.json:

{}

🙁 Actual behavior

In playground A, running tsc --showConfig in directory foo works.

In playground B, running tsc --showConfig in project root fails:

tsconfig.json:2:14 - error TS6053: File './foo' not found.

2   "extends": "./foo"
               ~~~~~~~

🙂 Expected behavior

Both playgrounds are kind of symmetrical. I expect either both A and B to work, or both of them to fail.

I expect the "extends" specification to be either followed: "The value of extends is a string which contains a path to another configuration file to inherit from. The path may use Node.js style resolution.", or adjusted to reflect the actual behaviour.

I expected the Typescript 3.2 changelog to be either followed: "TypeScript 3.2 now resolves tsconfig.jsons from node_modules. When using a bare path for the extends field in tsconfig.json, TypeScript will dive into node_modules packages for us." or adjusted to reflect the actual behaviour.

Neither of .. and ./foo are located inside node_modules. Both of them do have package.json and node_modules. I don't see what causes the different behaviour.

貢獻者指南