Skip to content

Renaming alias in export specifier no longer works in 3.8 RC when name equals propertyName #36695

Closed
@dsherret

Description

@dsherret

TypeScript Version: 3.8.0-dev.20200208

Search Terms: rename export specifier alias

This actually works for me in VS code for some reason when using @next, but not when using the compiler api directly. Maybe my VS code setup is wrong though.

Why?

This bug will block me from doing a ts-morph release unless I come up with a new solution for renaming only the exported name. Previously it worked to change the export to export { name } to export { name as name} then use rename on the language service to go to export { name as newAlias }.

Code

// a.ts
export class name {}

// b.ts
import { name } from "./a"; export { name as name /* rename this identifier */ };

// c.ts
import { name } from "./b";

Expected behavior:

// a.ts
export class name {}

// b.ts
import { name } from "./a"; export { name as newAlias };

// c.ts
import { newAlias } from "./b";

Actual behavior:

// a.ts
export class newAlias {}

// b.ts
import { newAlias } from "./a"; export { newAlias as newAlias };

// c.ts
import { newAlias } from "./b";

Result of calling languageService.findRenameLocations("/b.ts", 45, false, false, false):

[ { textSpan: { start: 9, length: 4 },
    fileName: '/b.ts',
    contextSpan: { start: 0, length: 27 } },
  { textSpan: { start: 37, length: 4 },
    fileName: '/b.ts',
    contextSpan: { start: 28, length: 24 } },
  { textSpan: { start: 13, length: 4 },
    fileName: '/a.ts',
    contextSpan: { start: 0, length: 20 } },
  { textSpan: { start: 9, length: 4 },
    fileName: '/c.ts',
    contextSpan: { start: 0, length: 27 } },
  { textSpan: { start: 45, length: 4 },
    fileName: '/b.ts',
    contextSpan: { start: 28, length: 24 } } ]

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions