`enum.rename()` does not rename references when `enum.setIsExported(true)` is called first
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
Great library by the way!
I use the following code to prefix all variables, functions and enums in my file.
```ts
sourceFile.getEnumOrThrow(`MyEnum`).setIsExported(true)
const thingsToRename = [...sourceFile.getVariableDeclarations(), ...sourceFile.getFunctions(), ...sourceFile.getEnums()]
for (const thingToRename of thingsToRename) {
thingToRename.rename(`${prefix}${thingToRename.getName()}`)
}
```
It works great, everything gets renamed.
However, `MyEnum` references are not handled (other enums are fine).
If I call `setIsExported` after doing the renaming, everything is okay.
Contributor guide
Research direction
Reproduce the TypeScript snippet using getEnumOrThrow, setIsExported(true), and rename(), then trace how enum references are handled when these entry points are called in that order. Done means references to the exported enum are renamed correctly regardless of whether setIsExported runs before or after rename, with a regression test for the reported sequence.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100