microsoft / microsoft/TypeScript
Rename file when renaming default export
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
Currently we can use the rename symbol command and that will rename the symbol and its usages (exports, imports, usages in other files, etc.). That's a great start, but I'd love to see this feature expanded to do the following:
-
Many times a file name will coincide with the symbol being refactored. The refactor option should be available when renaming the file, so everything can be done at once.
-
In addition to the refactor changing symbol references across all files, it'd be nice to have the ability to also update comments, strings, etc. that refer to that symbol.
Code Example:
Shape.js
class Shape {}
export default Shape;
Circle.js - We reference Shape as an import, extends, inside a comment, and inside a string. They should all be refactored.
import Shape from "./Shape";
// Shape subclass
class Circle extends Shape {
constructor() {
super();
console.log('A circle is a Shape.');
}
}
export default Circle;
WebStorm Examples
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing rename symbol command and trace how it updates exports, imports, and usages across files. Use the Shape.js and Circle.js example as the acceptance case: renaming the default export should also rename the matching file and update the shown import, comment, and string references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100