As we have already learned, an abstract syntax tree, or AST, is a tree-like data structure used to represent the abstract syntactic structure of source code written in a programming language. Each node of the AST represents a construct that occurs in the source code.
We are now going to look at a small TypeScript code snippet to understand the AST in detail. There is nothing very special about the following code snippet—it simply declares an interface named Weapon and a couple of classes, named Katana and Ninja. It then creates an instance of the Ninja class and invokes one of its methods:
interface Weapon { tryHit(fromDistance: number): boolean; } class Katana implements Weapon { public tryHit(fromDistance: ...