Q49. What is moduleResolution?
Module resolution describes how TypeScript finds the files or package entry points referenced by imports. Settings should align with the execution environment, such as Node's module rules or a bundler. Package exports, extensions, and package metadata can affect resolution.
A project should not copy NodeNext settings into a bundler project without checking the framework's conventions.
Note
Interview approach: define the concept, explain why it matters, then mention one trade-off or limitation.
TypeScript concept
// Illustrative TypeScript contract
type Identifier = string;
const id: Identifier = "item-1";💡 The example demonstrates the compile-time contract discussed in this question.
Key Takeaways
- Explain the concept in your own words.
- Know the practical trade-off and its limits.
- Use a small example to demonstrate the idea.
Knowledge Check
Why should module resolution match the runtime or bundler?