Last active
August 9, 2022 11:35
-
-
Save ahonn/c97c870b58a52b2802c48201f3284747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Project, ts } = require('ts-morph'); | |
const path = require('path'); | |
const filePath = path.join(process.cwd(), './simple_types.ts'); | |
const project = new Project(); | |
project.addExistingSourceFile(filePath); | |
const sourceFile = project.getSourceFile(filePath); | |
const enums = sourceFile.getEnums(); | |
enums.forEach((e) => { | |
const members = e.getMembers(); | |
members.forEach((member, index) => { | |
console.log(e.getName(), member.getName(), index); | |
member.setValue(index + 1); | |
}); | |
}); | |
sourceFile.saveSync(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment