traceResolution is a TypeScript compiler option for diagnosing module and declaration-file resolution. It reports the locations and settings the compiler checks while locating dependencies. The output can be verbose, especially in complex projects, but a successful-resolution message confirms which file the compiler will use. section 15.3.3 section 15.3.5
Trace a package declaration
Run the compiler from the project folder: tsc --traceResolution For the debug package, the output can include: ======== Module name 'debug' was successfully resolved to 'C:/usingjs/types/debug.d.cts'. ======== For Chalk, it can identify the package declaration and package version: ======== Module name 'chalk' was successfully resolved to 'C:/usingjs/node_modules/chalk/index.d.ts' with Package ID 'chalk/index.d.ts@4.1.2'. ======== Use the trace when a package appears not to have usable types or when the compiler resolves an unexpected file. section 15.3.3 section 15.3.5
Listing 15.26 Running the compiler
tsc --traceResolution
Shows the command-line form used to request resolution diagnostics. section 15.3.3
Listing 15.23 Configuring the compiler in the tsconfig.json file in the usingjs folder
{
"compilerOptions": {
"target": "ES2022",
"outDir": "./dist",
"rootDir": "./src",
"module": "Node16",
"allowJs": true,
"checkJs": true,
"baseUrl": ".",
"paths": {
"*": ["types/*.d.cts", "types/*.d.mts", "types/*.d.ts"]
},
}
}
Shows a project configuration whose paths settings help the compiler locate custom declaration files. section 15.3.3
