question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use this lib properly?

See original GitHub issue

Hi 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Sep 17, 2020

@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.

0reactions
deepslamcommented, Sep 17, 2020

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found