-
fix(js): resolve package and extension-less tsconfig extends read from the tree (#36271)
发布于
2026-07-28 18:19:49 +00:00 Current Behavior
Generators and migrations that parse a
tsconfig.jsonfrom the devkit
Treeeach build their own host that reads file contents from the
Treebut resolves file existence and paths throughts.sys. That host
cannot follow twoextendsforms:- A package-provided base such as
@tsconfig/node20/tsconfig.json.
TypeScript resolves it to an absolute path, which theTreere-roots
under the workspace, so the base reads as nothing. - An extension-less base such as
./tsconfig. It resolves against the
current working directory, so it only works when the command runs from
the workspace root.
In both cases the base's options silently vanish from the merged result
(the failure surfaces only as aTS5083/TS6053the callers discard).
Theadd-ignore-deprecationsTypeScript 6 migration can then miss a
deprecated option a config inherits from such a base, and generators can
read the wrong compiler options.Expected Behavior
extendsresolves the waytscresolves it, regardless of the
extendsform or the working directory, when a config is parsed from
theTree. A config that inherits a deprecated option through a package
or extension-less base is handled correctly by the TypeScript 6
migration, and generators read the fully-merged compiler options.Implementation Details
A single tree-faithful host,
createTreeParseConfigHost, is extracted
into@nx/jsand adopted at the five sites that each rebuilt one: the
angular and js tsconfig utilities, the jssetup-buildand rollup
configurationgenerators, and theupdate-23-1-0
add-ignore-deprecationsTypeScript 6 migration. It maps absolute paths
under theTreeroot back to tree-relative, falls back tofsfor
paths that resolve outside the workspace (a pnpm store or a
link:/file:target), and answers existence from theTree.
realpathandgetCurrentDirectoryare anchored to theTreeroot, so
resolution is independent of the working directory: TypeScript resolves
a package-form base as a relative path and hands it torealpath, which
ts.syswould re-anchor toprocess.cwd(). The out-of-rootfsbranch
is gated onisFileto matchts.sys, so a directory is never read as
a config file.The migration now warns about a config whose
extendschain is
genuinely unresolvable instead of silently guessing at incomplete
options.Two changes worth calling out: existence at the generator sites now
comes from theTreerather than disk, so a base present on disk but
deleted in theTreeis reported unresolvable; andreadTsConfig's
optionalsysparameter widens fromts.Systemto
ts.ParseConfigHost, a public@nx/jssignature change that stays
source-compatible for existing callers.Host unit tests and package-form and extension-less
extendsfixtures
are added to the migration spec.Related Issue(s)
Fixes NXC-4609
下载附件
- A package-provided base such as