Skip to content

getEditsForFileRename missing change #25327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amcasey opened this issue Jun 29, 2018 · 9 comments
Closed

getEditsForFileRename missing change #25327

amcasey opened this issue Jun 29, 2018 · 9 comments
Labels
Bug A bug in TypeScript Needs More Info The issue still hasn't been fully clarified

Comments

@amcasey
Copy link
Member

amcasey commented Jun 29, 2018

Repro

Folder1/tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "lib": ["es6"],
    "sourceMap": true
  },
  "exclude": [
    "node_modules"
  ],
  "files": [
    "../Folder1/file1.ts",
    "../Folder1/file2.ts"
  ]
}

Folder2/file1.ts

import "./file1";
export const cd = 1;

Folder2/file2.ts

import { cd } from "./file1";
const d = cd;

Move file2.ts from Folder2 to Folder1.

Expected: tsconfig and file2 are updated
Actual: only tsconfig is updated

@amcasey amcasey added the Bug A bug in TypeScript label Jun 29, 2018
@amcasey amcasey assigned ghost Jun 29, 2018
@ghost
Copy link

ghost commented Jul 3, 2018

The following test passes:

/// <reference path='fourslash.ts' />

// @Filename: /Folder2/file1.ts
////import "./file1";
////export const cd = 1;

// @Filename: /Folder2/file2.ts
////import { cd } from "./file1";
////const d = cd;

// @Filename: /tsconfig.json
////{
////  "compilerOptions": {
////    "module": "commonjs",
////    "target": "es6",
////    "lib": ["es6"],
////    "sourceMap": true
////  },
////  "exclude": [
////    "node_modules"
////  ],
////  "files": [
////    "../NewFolder9/app9.ts",
////    "../NewFolder9/TypeScript2.ts"
////  ]
////}

verify.getEditsForFileRename({
    oldPath: "/Folder2/file2.ts",
    newPath: "/Folder1/file2.ts",
    newFileContents: {
        "/Folder2/file2.ts":
`import { cd } from "../Folder2/file1";
const d = cd;`,
    },
});

Maybe you pasted the wrong tsconfig.json? That seems to reference unrelated files.

@ghost
Copy link

ghost commented Jul 3, 2018

On second thought, maybe this is an error that would only come up in a session with multiple projects. So we should fix #25420 before investigating further.

@amcasey
Copy link
Member Author

amcasey commented Jul 5, 2018

Sorry, I forgot to rename the tsconfig entries when I simplified my repro.

@ghost
Copy link

ghost commented Jul 9, 2018

@mjbvz Testing this again and I don't see getEditsFromFileRename being called in tsserver.log. It does get called if I rename file1.ts to fileX.ts, but not if I drag file2.ts from Folder2 to Folder1.

@amcasey
Copy link
Member Author

amcasey commented Jul 9, 2018

FWIW, my repro was in VS.

@ghost
Copy link

ghost commented Jul 10, 2018

@amcasey Could you try to get a tsserver.log from Visual Studio?

@ghost ghost added the Needs More Info The issue still hasn't been fully clarified label Jul 10, 2018
@amcasey
Copy link
Member Author

amcasey commented Jul 10, 2018

Should be no problem.

@amcasey
Copy link
Member Author

amcasey commented Jul 10, 2018

gh25327.zip

@ghost
Copy link

ghost commented Jul 10, 2018

Actually, this looks like the same cause as #25536. The tsconfig.json is in Folder1, but the files are in Folder2. Looking at the logs, file2.ts is in an inferred project.

@mhegazy mhegazy closed this as completed Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

2 participants