UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

35 lines (24 loc) 533 B
--- title: Renaming --- ## Renaming Given the source file for following code: ```typescript enum MyEnum { myMember } const myVar = MyEnum.myMember; ``` Renaming can be done as follows: ```typescript const myEnum = sourceFile.getEnum("MyEnum")!; myEnum.rename("NewEnum"); ``` Which will rename all usages of `MyEnum` to `NewEnum` across _all_ files. So the file above would now contain the following code: ```typescript enum NewEnum { myMember } const myVar = NewEnum.myMember; ```