microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
101.21k stars 12.51k forks source link

Fixes: #60479 - Change the behavior of tsc on a tsconfig solution #60574

Open RyanMyrvold opened 23 hours ago

RyanMyrvold commented 23 hours ago

Fixes #60479


This PR improves the TypeScript compiler's behavior when encountering ambiguous configurations in tsconfig.json, such as when the files array is empty. The goal is to ensure users get clear, actionable feedback instead of silent failures or confusing results.


  1. New Diagnostic Added
    A new error message, TS6042, helps developers understand what to do when there’s no actionable task in their configuration.
    Example message: "No actionable task. Add 'composite': true, valid 'references', or use 'tsc -b'."

  2. Clearer Guidance for Edge Cases
    Handles configurations like files: [], ensuring diagnostics are surfaced instead of failing silently.
    Helps developers understand best practices, such as enabling composite or using project references.

  3. Additional Tests
    Added new tests to cover the following scenarios:

    • Nested configurations where a parent tsconfig.json has an empty files array and valid child references.
    • Scenarios with composite: true but no references.
    • Configurations with the --noEmit flag, ensuring the flag works alongside the new diagnostics.

When a tsconfig.json has an empty files array or lacks actionable tasks, it can be frustrating to debug why nothing happens. These updates aim to:

typescript-bot commented 23 hours ago

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.