Skip to content

Instantly share code, notes, and snippets.

@omar-dulaimi
Created December 31, 2022 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omar-dulaimi/f5ce10a67088f203e861eb9eb72fa394 to your computer and use it in GitHub Desktop.
Save omar-dulaimi/f5ce10a67088f203e861eb9eb72fa394 to your computer and use it in GitHub Desktop.
Read a class using ts-morph
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