Created
December 31, 2022 07:42
-
-
Save omar-dulaimi/f5ce10a67088f203e861eb9eb72fa394 to your computer and use it in GitHub Desktop.
Read a class using ts-morph
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
import { project } from './project'; | |
const sourceFile = project.addSourceFileAtPath( | |
path.join(cwd(), 'src', './file.ts'), | |
); | |
const resolverClass = sourceFile.getClass('otherFile'); | |
for (const method of resolverClass.getMethods()) { | |
const decorators = []; | |
for (const decorator of method.getDecorators()) { | |
decorators.push(decorator.getName()) | |
} | |
console.log(method.getName()); | |
console.log(decorators.join(" | ")) | |
console.log(";-----------------------;") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment