Skip to content

Instantly share code, notes, and snippets.

@Noviny
Last active August 12, 2022 09:46
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noviny/bb6cf1dc81bbd98606fcabc8a2360cbe to your computer and use it in GitHub Desktop.
Save Noviny/bb6cf1dc81bbd98606fcabc8a2360cbe to your computer and use it in GitHub Desktop.
A list of all babels types with an explanation, and a link to astexplorer with an example

The goal is to have a link to ASTexplorer to demonstrate what each type is. Types have been broken into sections if they are not core parts of javascript (JSX, type annotations, typescript types), however are otherwise in alphabetical order.

WIP - un-added types have a leading ^^^^ while I am working on them.

Important Base Parts

Knowing these will help everywhere

  • identifier A named property, such as a declared variable or object property.
  • blockStatement Anything to be run as part of resolving an expression. (Effectively anything that would go between {} brackets, whether that is in a for statement, or function expression. It will be found as the body property of the expression.
  • file identifies that all code within the AST down from this comes from a single javascript file within the filesystem.
  • program The body type of a file, under which the rest of the file's AST sits. (files may also have comments and tokens)
  • expressionStatement func()
  • variableDeclaration var a = 'a';
  • variableDeclarator var a = 'a';

Literal types

Literal types are javascript primitives. They are normally simple values.

Expressions

Expressions can be seen as taking an action, whether adding a new

(possible other bits)

Declarations (declarators?)

Statements

Patterns

Javascript Properties

JSX Properties

These are parts of JSX syntax. For more information on JSX, please see the react documentation.

Other Types Bits

Type types

These properties are used for typing systems, mostly flow.

Declarations

Type Annotations (most likely flow)

These type annotations are the kind used in flow. I recommend reading the flow documentation to understand these types. Each will be found within a typeAnnotation property for an identifier.

Typescript Types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment