microsoft / microsoft/TypeScript

Renaming file doesn't update imports in other projects which reference this project

Open
#44,411 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Experience Enhancement Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

rename file folder move project references

💻 Code

Reduced test case: https://github.com/OliverJAsh/ts-project-references-rename-bug-test-44411

tsconfig.json:

{
    "files": [],
    "references": [
        {
            "path": "./app/tsconfig.json"
        },
        {
            "path": "./shared/tsconfig.json"
        }
    ]
}

shared/tsconfig.json:

{
    "compilerOptions": {
        "composite": true
    }
}

shared/foo.ts:

export const foo = 1;

shared/bar.ts:

import { foo } from "./foo";

foo

app/tsconfig.json:

{
  "compilerOptions": {
    "composite": true,

    "paths": {
      "shared/*": ["../shared/*"]
    }
  },
  "references": [
    {
      "path": "../shared/tsconfig.json"
    }
  ]
}

app/main.ts:

import { foo } from "shared/foo";

foo;
Steps to reproduce
  1. Open VS Code and navigate to shared/foo.ts
  2. Wait for VS Code to finish initialising TS.
  3. Rename the file to something else e.g. foo2.ts
🙁 Actual behavior
  • File is renamed
  • Imports in the current project are updated
  • Imports in other projects which reference this project are not updated

tsserver.log

🙂 Expected behavior
  • File is renamed
  • Imports in the current project are updated
  • Imports in other projects which reference this project are updated. For example, app/main.ts which imports shared/foo.ts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reduced test case and reproduce the rename from shared/foo.ts to another name while observing app/main.ts and the project references in the two tsconfig.json files. Review the linked tsserver.log and compare import updates within shared with updates in the referencing app project; done means app/main.ts is updated too.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.