Skip to content

feat(migrate): auto-fix tsconfig baseUrl to enable typeAware/typeCheck by default #743

@fengmk2

Description

@fengmk2

Problem

When running vp migrate, we want to enable typeAware and typeCheck in the oxlint configuration by default — these are key features that provide significantly better linting quality. However, if tsconfig.json contains compilerOptions.baseUrl, we currently skip enabling these options because oxlint's TypeScript checker does not yet support baseUrl.

This means projects using baseUrl silently miss out on type-aware linting, which is one of the core value propositions of migrating to Vite+.

Currently we log a warning (added in #739) suggesting users run npx @andrewbranch/ts5to6 --fixBaseUrl . manually, but this is a manual step that users may overlook.

Background

  • TypeScript 6.0 deprecated compilerOptions.baseUrl for module resolution (it now only affects path mapping when paths is set).
  • TypeScript 7.0 removed baseUrl entirely.
  • The official migration tool @andrewbranch/ts5to6 provides --fixBaseUrl which automatically:
    • Rewrites relative imports that relied on baseUrl to proper relative paths
    • Updates paths mappings if needed
    • Removes baseUrl from tsconfig.json when it's no longer needed
  • The TypeScript 5.x → 6.0 Migration Guide documents this change.

Proposal

Integrate baseUrl removal as a step in vp migrate so that typeAware and typeCheck can always be enabled by default:

1. Auto-fix baseUrl during migration

When vp migrate detects tsconfig.json with baseUrl:

  • Interactive mode: Prompt the user to run the ts5to6 fix:

    Your tsconfig.json contains `baseUrl`, which prevents enabling type-aware linting.
    baseUrl was deprecated in TypeScript 6.0 and removed in 7.0.
    
    ○ Run `npx @andrewbranch/ts5to6 --fixBaseUrl .` to remove baseUrl? (recommended)
      › Yes / No
    

    If accepted, run the fix automatically, then enable typeAware/typeCheck.

  • Non-interactive mode (--no-interactive): Automatically run the fix and enable typeAware/typeCheck. Log a message about what was changed.

2. Handle edge cases

  • Multiple tsconfig files: Some projects have tsconfig.json, tsconfig.build.json, tsconfig.app.json, etc. The fix should apply to all relevant configs.
  • Monorepo: Each workspace package may have its own tsconfig.json with baseUrl. The fix should be applied per-package.
  • Failure handling: If ts5to6 fails or the user declines, fall back to the current behavior (skip typeAware/typeCheck with a warning).

3. Also apply in vp lint --init

The applyToolInitConfigToViteConfig() path (triggered by vp lint --init) should offer the same fix when baseUrl is detected.

Current behavior

Scenario typeAware typeCheck User action needed
No baseUrl in tsconfig ✅ enabled ✅ enabled None
baseUrl in tsconfig ❌ skipped ❌ skipped Manual npx @andrewbranch/ts5to6 --fixBaseUrl .

Desired behavior

Scenario typeAware typeCheck User action needed
No baseUrl in tsconfig ✅ enabled ✅ enabled None
baseUrl in tsconfig ✅ enabled (after auto-fix) ✅ enabled (after auto-fix) None (auto-fixed)

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions