Accessing class details with ts-simple-ast

The following code snippet demonstrates how we can use the ts-simple-ast APIs to access and manipulate class declarations.

Note that the preceding example is not meant to be executed. It is a showcase of the available methods in the ts-simple-ast API, but it is not an executable demo.

Just like in the preceding examples, we are going to use the getAst, getSourceFiles, and getClasses methods to find all the class declarations in our source code.

We will then use some tools to access the details of the class declaration, including methods, derived classes, and properties, among others. We will also demonstrate how we can modify the class declaration by performing operations such as adding a base class ...

Get Learning TypeScript 2.x - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.