Skip to content

Conversation

@RyanMyrvold
Copy link

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:

  • Provide clear diagnostics to guide developers toward effective solutions.
  • Prevent silent failures, saving time and reducing confusion.

Ensured tsc builds successfully with current configurations.
Added foundational tests for files: [] and composite edge cases.
Verified behavior for ambiguous container projects, such as tsconfig.json with no actionable task.
Confirmed alignment with TypeScript’s existing design goals, including:
Non-breaking changes.
No impact on JavaScript output or runtime behavior.
…Baselines

Verified and accepted changes to ensure consistency with the expected output.

Fixed a bug where configFileParsingDiagnostics could be undefined, causing runtime errors (Cannot read properties of undefined (reading 'push')).

Added guards to ensure diagnostics arrays are always initialized before use.

Improved code resilience and prevented potential runtime errors in edge cases.
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 24, 2024
@typescript-bot
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Change the behavior of tsc on a tsconfig solution

2 participants