Skip to content

Port --traceResolutions #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions internal/testutil/harnessutil/harnessutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,17 +516,39 @@ func (h *cachedCompilerHost) GetSourceFile(opts ast.SourceFileParseOptions) *ast
}

type tracer struct {
fs vfs.FS
currentDirectory string
packageJsonCache map[tspath.Path]bool
builder strings.Builder
fs vfs.FS
currentDirectory string
packageJsonCache map[tspath.Path]bool
builder strings.Builder
specifiTypesVersionMessage bool
noTypesVersionMessage bool
}

func (t *tracer) trace(msg string) {
fmt.Fprintln(&t.builder, t.sanitizeTrace(msg))
}

func (t *tracer) sanitizeTrace(msg string) string {
if msg == "'package.json' has a 'typesVersions' field with version-specific path mappings." {
t.specifiTypesVersionMessage = true
t.noTypesVersionMessage = false
return msg
}
if msg == "'package.json' does not have a 'typesVersions' field." {
t.noTypesVersionMessage = true
t.specifiTypesVersionMessage = false
return msg
}
if strings.HasPrefix(msg, "'package.json' has a 'typesVersions' entry '") && !t.specifiTypesVersionMessage {
fmt.Fprintln(&t.builder, "'package.json' has a 'typesVersions' field with version-specific path mappings.")
}
if (msg == "'package.json' does not have a 'typings' field." ||
strings.HasPrefix(msg, "'package.json' has 'typings' field '")) &&
!t.noTypesVersionMessage {
fmt.Fprintln(&t.builder, "'package.json' does not have a 'typesVersions' field.")
}
t.noTypesVersionMessage = false
t.specifiTypesVersionMessage = false
// Version
if str := strings.Replace(msg, "'"+core.Version()+"'", "'"+FakeTSVersion+"'", 1); str != msg {
return str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Module resolution kind is not specified, using 'NodeNext'.
Resolving in CJS mode with conditions 'require', 'types', 'node'.
Loading module as file / folder, candidate module location '/.src/node_modules/@types/react/', target file types: TypeScript, JavaScript, Declaration.
File '/.src/node_modules/@types/react/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references '/.src/node_modules/@types/react/index.d.ts'.
File '/.src/node_modules/@types/react/index.d.ts' exists - use it as a name resolution result.
Expand All @@ -24,6 +25,7 @@ Module resolution kind is not specified, using 'NodeNext'.
Resolving in CJS mode with conditions 'require', 'types', 'node'.
Loading module as file / folder, candidate module location '/.src/node_modules/@types/react/', target file types: TypeScript, JavaScript, Declaration.
File '/.src/node_modules/@types/react/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references '/.src/node_modules/@types/react/index.d.ts'.
File '/.src/node_modules/@types/react/index.d.ts' exists - use it as a name resolution result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Module resolution kind is not specified, using 'NodeNext'.
Resolving in CJS mode with conditions 'require', 'types', 'node'.
Loading module as file / folder, candidate module location '/.src/node_modules/@types/react/', target file types: TypeScript, JavaScript, Declaration.
File '/.src/node_modules/@types/react/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references '/.src/node_modules/@types/react/index.d.ts'.
File '/.src/node_modules/@types/react/index.d.ts' exists - use it as a name resolution result.
Expand All @@ -25,6 +26,7 @@ Module resolution kind is not specified, using 'NodeNext'.
Resolving in CJS mode with conditions 'require', 'types', 'node'.
Loading module as file / folder, candidate module location '/.src/node_modules/@types/react/', target file types: TypeScript, JavaScript, Declaration.
File '/.src/node_modules/@types/react/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references '/.src/node_modules/@types/react/index.d.ts'.
File '/.src/node_modules/@types/react/index.d.ts' exists - use it as a name resolution result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Resolving with primary search path '/foo/types'.
File '/foo/types/jquery.d.ts' does not exist.
Found 'package.json' at '/foo/types/jquery/package.json'.
'package.json' does not have a 'typesVersions' field.
'package.json' has 'typings' field 'jquery.d.ts' that references '/foo/types/jquery/jquery.d.ts'.
File '/foo/types/jquery/jquery.d.ts' exists - use it as a name resolution result.
Resolving real path for '/foo/types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Resolving with primary search path '/types'.
File '/types/jquery.d.ts' does not exist.
Found 'package.json' at '/types/jquery/package.json'.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.
File '/types/jquery/jquery.d.ts' exists - use it as a name resolution result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ File '/package.json' does not exist according to earlier cached lookups.
Loading module 'just-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Found 'package.json' at '/node_modules/just-types-versions/package.json'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '*' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'foo'.
Module name 'foo', matched pattern 'foo'.
Trying substitution './types/foo.d.ts', candidate module location: './types/foo.d.ts'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ File '/package.json' does not exist according to earlier cached lookups.
Loading module 'just-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Found 'package.json' at '/node_modules/just-types-versions/package.json'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '*' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'foo'.
Module name 'foo', matched pattern 'foo'.
Trying substitution './types/foo.d.ts', candidate module location: './types/foo.d.ts'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ File '/package.json' does not exist according to earlier cached lookups.
Loading module 'just-types-versions/foo' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Found 'package.json' at '/node_modules/just-types-versions/package.json'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '*' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'foo'.
Module name 'foo', matched pattern 'foo'.
Trying substitution './types/foo.d.ts', candidate module location: './types/foo.d.ts'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ File '/node_modules/bar/index.tsx' does not exist according to earlier cached lo
File '/node_modules/bar/index.d.ts' does not exist according to earlier cached lookups.
File '/node_modules/@types/bar/package.json' exists according to earlier cached lookups.
File '/node_modules/@types/bar.d.ts' does not exist.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references '/node_modules/@types/bar/index.d.ts'.
File '/node_modules/@types/bar/index.d.ts' exists - use it as a name resolution result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ File '/node_modules/bar/index.js.tsx' does not exist.
File '/node_modules/bar/index.js.d.ts' does not exist.
Directory '/node_modules/bar/index.js' does not exist, skipping all lookups in it.
File '/node_modules/@types/bar/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references '/node_modules/@types/bar/index.d.ts'.
File '/node_modules/@types/bar/index.d.ts' exists - use it as a name resolution result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ File '/.src/node_modules/ext.ts' does not exist.
File '/.src/node_modules/ext.tsx' does not exist.
File '/.src/node_modules/ext.d.ts' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index' that references '/.src/node_modules/ext/index'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Expand All @@ -30,19 +32,22 @@ File '/package.json' does not exist according to earlier cached lookups.
Loading module 'ext/other' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
File '/.src/node_modules/ext/package.json' exists according to earlier cached lookups.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'other'.
Module name 'other', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.
File '/.src/node_modules/ext/ts3.1/other.ts' does not exist.
File '/.src/node_modules/ext/ts3.1/other.tsx' does not exist.
File '/.src/node_modules/ext/ts3.1/other.d.ts' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Loading module as file / folder, candidate module location '/.src/node_modules/ext/ts3.1/other/ts3.1/index', target file types: TypeScript, Declaration.
File '/.src/node_modules/ext/other.ts' does not exist.
File '/.src/node_modules/ext/other.tsx' does not exist.
File '/.src/node_modules/ext/other.d.ts' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Expand All @@ -52,17 +57,20 @@ Directory '/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.
File '/.src/node_modules/ext/package.json' exists according to earlier cached lookups.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'other'.
Module name 'other', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.
File '/.src/node_modules/ext/ts3.1/other.js' does not exist.
File '/.src/node_modules/ext/ts3.1/other.jsx' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Loading module as file / folder, candidate module location '/.src/node_modules/ext/ts3.1/other/ts3.1/index', target file types: JavaScript, JSON.
File '/.src/node_modules/ext/other.js' does not exist.
File '/.src/node_modules/ext/other.jsx' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ File '/.src/node_modules/ext.ts' does not exist.
File '/.src/node_modules/ext.tsx' does not exist.
File '/.src/node_modules/ext.d.ts' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index' that references '/.src/node_modules/ext/index'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Expand All @@ -30,6 +32,7 @@ File '/package.json' does not exist according to earlier cached lookups.
Loading module 'ext/other' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
File '/.src/node_modules/ext/package.json' exists according to earlier cached lookups.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'other'.
Module name 'other', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ File '/.src/node_modules/ext.ts' does not exist.
File '/.src/node_modules/ext.tsx' does not exist.
File '/.src/node_modules/ext.d.ts' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index' that references '/.src/node_modules/ext/index'.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Expand All @@ -30,19 +32,22 @@ File '/package.json' does not exist according to earlier cached lookups.
Loading module 'ext/other' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
File '/.src/node_modules/ext/package.json' exists according to earlier cached lookups.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'other'.
Module name 'other', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.
File '/.src/node_modules/ext/ts3.1/other.ts' does not exist.
File '/.src/node_modules/ext/ts3.1/other.tsx' does not exist.
File '/.src/node_modules/ext/ts3.1/other.d.ts' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Loading module as file / folder, candidate module location '/.src/node_modules/ext/ts3.1/other/ts3.1/index', target file types: TypeScript, Declaration.
File '/.src/node_modules/ext/other.ts' does not exist.
File '/.src/node_modules/ext/other.tsx' does not exist.
File '/.src/node_modules/ext/other.d.ts' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Expand All @@ -52,17 +57,20 @@ Directory '/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Searching all ancestor node_modules directories for fallback extensions: JavaScript, JSON.
File '/.src/node_modules/ext/package.json' exists according to earlier cached lookups.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'other'.
Module name 'other', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.
File '/.src/node_modules/ext/ts3.1/other.js' does not exist.
File '/.src/node_modules/ext/ts3.1/other.jsx' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Loading module as file / folder, candidate module location '/.src/node_modules/ext/ts3.1/other/ts3.1/index', target file types: JavaScript, JSON.
File '/.src/node_modules/ext/other.js' does not exist.
File '/.src/node_modules/ext/other.jsx' does not exist.
'package.json' has a 'typesVersions' field with version-specific path mappings.
'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version 'FakeTSVersion', looking for a pattern to match module name 'index'.
Module name 'index', matched pattern '*'.
Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/index'.
Expand Down
Loading
Loading