How to use this lib properly?
See original GitHub issueHi guys!
At first, thank you for this amazing lib! But I’m a bit misunderstood - how can I get classes from a source file?
I do the following:
const project = await getProject();
await project.addSourceFileAtPathIfExists(
"./src/templates/NewFeature.ts"
);
project.getSourceFiles().forEach((sourceFile) => {
const allChildren = sourceFile.getChildren();
sourceFile.forEachChild((node) => {
console.log("----");
console.log(node.kind);
console.log(node.getText());
});
});
The question is - how can I get the classes? (for example) According to the doc, the should be a method getClasses but neither sourceFile not node don’t include getClasses. I suppose that I’m doing something wrongly.
Could you please help me? Thank you!
– Regards, Dmitry
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to properly use lib and reference options when compiling ...
In order to create the server.exe file, and it works. c:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library server.cs. In order ...
Read more >How to properly use a .lib file? - C Board
Hello, I have a quick question regarding the usage of a .lib file. I have compiled a .dll and am linking to its...
Read more >How To Install And Use A C++ Standard Library
This C++ Libraries tutorial will explain what are Libraries in C++, their types along with installation and usage of a C++ Standard Library....
Read more >Walkthrough: Create and use a static library (C++)
To create a static library project in Visual Studio. On the menu bar, choose File > New > Project to open the Create...
Read more >How To Properly Use Frontend UI Component Libraries
Remember, you can apply this knowledge to any library out there if that makes sense. Don't import the same packages across the whole...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@deepslam it’s no problem! Sorry it’s confusing. I need to think of a better way of managing this and it might be moving out the bootstrap project to a separate repo.
Ohh, shame on me, sorry. I used createProject from @ts-morph/bootstrap and there I definitely don’t see getClass. Your code works. Thanks, friend!