Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 3, 2025

This PR implements deprecation of the baseUrl compiler option, which will be removed in TypeScript 7.0. The baseUrl option currently performs two functions that can be confusing to users:

  1. Acts as a prefix for all entries in paths
  2. Acts as a fallback resolution point for bare module imports (often unintended)

Problem

When users configure:

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@app/*": ["app/*"],
      "@lib/*": ["lib/*"]
    }
  }
}

An import like import * as blah from "blah.js" might resolve to:

  • ./src/app/blah.js
  • ./src/lib/blah.js
  • ./src/blah.js ⚠️ (often undesirable)

The last resolution path is usually unintentional and can cause confusion.

Solution

Starting in TypeScript 6.0, using baseUrl will show a deprecation warning:

Option 'baseUrl' is deprecated and will stop functioning in TypeScript 7.0. 
Specify compilerOption '"ignoreDeprecations": "6.0"' to silence this error.

Users should migrate to explicit path mappings:

Before:

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@app/*": ["app/*"],
      "@lib/*": ["lib/*"]
    }
  }
}

After:

{
  "compilerOptions": {
    "paths": {
      "@app/*": ["./src/app/*"],
      "@lib/*": ["./src/lib/*"]
    }
  }
}

To preserve baseUrl fallback behavior (optional):

{
  "compilerOptions": {
    "paths": {
      "*": ["./src/*"],
      "@app/*": ["./src/app/*"],
      "@lib/*": ["./src/lib/*"]
    }
  }
}

Implementation

  • Added deprecation check in src/compiler/program.ts using existing deprecation infrastructure
  • Supports ignoreDeprecations: "6.0" to silence warnings during transition period
  • Added comprehensive test coverage including migration examples
  • Updated 70 existing tests to use ignoreDeprecations to prevent test breakage
  • All existing functionality preserved - this is a warning-only change

Fixes #62207.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Deprecate, remove support for baseUrl Deprecate baseUrl compiler option in TypeScript 6.0 Sep 3, 2025
Copilot finished work on behalf of DanielRosenwasser September 3, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate, remove support for baseUrl
2 participants