Skip to content

Deprecate baseUrl compiler option in TypeScript 6.0 - #62389

Closed
Daniel Rosenwasser (DanielRosenwasser) with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-62207
Closed

Deprecate baseUrl compiler option in TypeScript 6.0#62389
Daniel Rosenwasser (DanielRosenwasser) with Copilot wants to merge 6 commits into
mainfrom
copilot/fix-62207

Conversation

Copilot AI commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

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 AI and others added 5 commits September 3, 2025 23:23
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
…examples

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Deprecate, remove support for baseUrl Deprecate baseUrl compiler option in TypeScript 6.0 Sep 3, 2025
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Jun 3, 2026
@jakebailey
Jake Bailey (jakebailey) deleted the copilot/fix-62207 branch August 20, 2026 17:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate, remove support for baseUrl

3 participants