Skip to Content
Learning TypeScript 2.x - Second Edition
book

Learning TypeScript 2.x - Second Edition

by Remo H. Jansen
April 2018
Beginner content levelBeginner
536 pages
13h 21m
English
Packt Publishing
Content preview from Learning TypeScript 2.x - Second Edition

Understanding the abstract syntax tree (AST)

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: ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering TypeScript - Fourth Edition

Mastering TypeScript - Fourth Edition

Nathan Rozentals
Learning TypeScript

Learning TypeScript

Josh Goldberg
TypeScript for Beginners

TypeScript for Beginners

Bharath Thippireddy

Publisher Resources

ISBN: 9781788391474Supplemental Content