TypeScript/tests/cases/fourslash/getEditsForFileRename_renameToIndex.ts
Andy d671c7ae96
getEditsForFileRename: Support directory rename (#24305)
* getEditsForFileRename: Support directory rename

* Code review

* Handle imports inside the new file/directory

* Document path updaters

* Shorten relative paths where possible

* Reduce duplicate code

* Rewrite, use moduleSpecifiers.ts to get module specifiers from scratch instead of updating relative paths

* Update additional tsconfig.json fields

* Add test with '.js' extension

* Handle case-insensitive paths

* Better tsconfig handling

* Handle properties inside compilerOptions

* Use getOptionFromName
2018-06-01 08:23:37 -07:00

38 lines
926 B
TypeScript

/// <reference path='fourslash.ts' />
// @Filename: /a.ts
/////// <reference path="./src/old.ts" />
////import old from "./src/old";
// @Filename: /src/a.ts
/////// <reference path="./old.ts" />
////import old from "./old";
// @Filename: /src/foo/a.ts
/////// <reference path="../old.ts" />
////import old from "../old";
// @Filename: /src/old.ts
////
// @Filename: /tsconfig.json
////{ "files": ["a.ts", "src/a.ts", "src/foo/a.ts", "src/old.ts"] }
verify.getEditsForFileRename({
oldPath: "/src/old.ts",
newPath: "/src/index.ts",
newFileContents: {
"/a.ts":
`/// <reference path="./src/index.ts" />
import old from "./src";`,
"/src/a.ts":
`/// <reference path="./index.ts" />
import old from ".";`,
"/src/foo/a.ts":
`/// <reference path="../index.ts" />
import old from "..";`,
"/tsconfig.json":
'{ "files": ["a.ts", "src/a.ts", "src/foo/a.ts", "src/index.ts"] }',
},
});