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.
- 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 are javascript primitives. They are normally simple values.
- booleanLiteral
true
orfalse
- directiveLiteral
"use strict"
- nullLiteral
null
- numericLiteral Any number
- regExpLiteral
/asdf/
- stringLiteral
'this kind of thing'
or"this kind of thing"
- templateLiteral
`something like this`
Expressions can be seen as taking an action, whether adding a new
- arrayExpression
['a']
- arrowFunctionExpression
() => {}
- assignmentExpression
a = 1 + 2
Assignment outside of an initial instantiation (reassigning a variable, or object property) - awaitExpression
await func()
- binaryExpression An operation with two sides, such as base mathematical operations or concatenation
- bindExpression
let a = ::b.c
- callExpression
func()
- classExpression
var foo = class {}
- conditionalExpression
a ? b : c
- doExpression
let a = do {}
- functionExpression
var x = function() {}
- logicalExpression
a || b
ora && b
- memberExpression
a.b()
- newExpression
new a
- objectExpression
const a = {}
- ^^^^parenthesizedExpression
- sequenceExpression
(1, 2, 3)
- taggedTemplateExpression
func`a`
- thisExpression
this
- unaryExpression Operators with a single argument;
typeof
ordelete
- updateExpression
++a
- yieldExpression
function* a () { yield b }
(possible other bits)
- arrayPattern
function a ([ b, c ]) {}
- assignmentPattern
function a (b = 1) {}
- breakStatement
while (true) { break }
- catchClause
try {} catch (e) {}
- classBody The body of a classDeclaration
- classDeclaration
class a {}
- classImplements
class a implements b {}
- classMethod
class b { constructor() {} }
the constructor is an example of a class method - classProperty Assigned property within a class
- continueStatement
while (true) { continue }
- debuggerStatement
debugger
- decorator
- directive
"use strict"
- doWhileStatement
do {} while (true)
- ^^^^emptyStatement
- exportAllDeclaration
export * from './place';
- exportDefaultDeclaration
export default a
- ^^^^exportDefaultSpecifier
- exportNamedDeclaration
export { a }
- ^^^^exportNamespaceSpecifier
- exportSpecifier
export { a as b }
- forInStatement
for (let a in b) { /* do something over an object's properties */ }
- forOfStatement
for (let a of b) { /* do something over an array's items */ }
- forStatement
for (var i = 0; i < val; i++) {}
- functionDeclaration
function a () {}
- ifStatement
if (true) {}
- ^^^^import
- importDeclaration
import a from 'a'
- importDefaultSpecifier
import a from 'a'
- importNamespaceSpecifier
import * as a from 'a'
- importSpecifier
import { a } from 'a'
- ^^^^inferredPredicate
- ^^^^interfaceDeclaration
- ^^^^interfaceExtends
- ^^^^labeledStatement
- ^^^^metaProperty
- ^^^^noop
- objectMethod
let a = { a () {} }
- objectPattern
function a ({ b }) {}
- objectProperty Any value added to an object.
- restElement
function a (...a) {}
- returnStatement
() => { return }
- spreadElement
let a = [...b]
- super
class a extends b { constructor () { super() } }
- switchCase
case a: // the case results
- switchStatement the whole switch statement beginning with
switch (a) {
- templateElement
ab
- throwStatement throw
a
- tryStatement
try {} catch (e) {}
ortry {} finally {}
- whileStatement
while (true) {}
- withStatement mdn recommends don't use with statements.
These are parts of JSX syntax. For more information on JSX, please see the react documentation.
- jSXAttribute
<B c="c" />
- jSXClosingElement
<div>a</div>
- jSXClosingFragment
<></>
- jSXElement
<div>a</div>
- jSXEmptyExpression
<B>{}</B>
- jSXExpressionContainer
<B c={c} />
- jSXFragment
<></>
- jSXIdentifier
<B />
- ^^^^jSXMemberExpression
- ^^^^jSXNamespacedName
- jSXOpeningElement
<div>a</div>
- jSXOpeningFragment
<></>
- jSXSpreadAttribute <B {...c} />
- jSXSpreadChild
<B>{...c}</B>
- jSXText
<div>a</div>
These properties are used for typing systems, mostly flow.
- typeCastExpression
func(a: string)
- functionTypeParam
type a = (b: string) => mixed
- opaqueType
opaque type a = string;
- ^^^^qualifiedTypeIdentifier
- typeAlias
type a = string
- typeAnnotation
let a: string = 'a'
- ^^^^typeParameter
- ^^^^typeParameterDeclaration
- typeParameterInstantiation
type a = A<*>
- ^^^^objectTypeCallProperty
- ^^^^objectTypeIndexer
- objectTypeProperty
type a = { b: string }
- objectTypeSpreadProperty
type a = { ...string }
- declareClass
declare class a {}
- ^^^^declareExportAllDeclaration
- declareExportDeclaration
declare export default boolean
- declareFunction
declare function a(b: number): string;
- ^^^^declareInterface
- declareModule
declare module 'a' {}
- ^^^^declareModuleExports
declare module.exports: 'a';
- ^^^^declareOpaqueType
- declareTypeAlias
declare type a = boolean
- declareVariable
declare var a: boolean
- ^^^^declaredPredicate
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.
- anyTypeAnnotation
type a = any;
- arrayTypeAnnotation
type a = number[]
- booleanLiteralTypeAnnotation
type a = true
- booleanTypeAnnotation
type a= boolean
- ^^^^emptyTypeAnnotation
- existsTypeAnnotation
type a = *
- functionTypeAnnotation
type a = () => {}
- genericTypeAnnotation
type a = b
- intersectionTypeAnnotation
type a = string & 'a'
- mixedTypeAnnotation
type a = mixed
- nullLiteralTypeAnnotation
type a = null
- nullableTypeAnnotation
type a = ?string
- numberLiteralTypeAnnotation
type a = 5
- numberTypeAnnotation
type a = number
- objectTypeAnnotation
type a = {}
- stringLiteralTypeAnnotation
type a = 'a'
- stringTypeAnnotation
type a = string
- thisTypeAnnotation
type a = this
- tupleTypeAnnotation
type a = [b, c]
- typeofTypeAnnotation
type a = typeof b
- unionTypeAnnotation
type a = string | number
- voidTypeAnnotation
type a = void
- ^^^^tSAnyKeyword
- ^^^^tSArrayType
- ^^^^tSAsExpression
- ^^^^tSBooleanKeyword
- ^^^^tSCallSignatureDeclaration
- ^^^^tSConstructSignatureDeclaration
- ^^^^tSConstructorType
- ^^^^tSDeclareFunction
- ^^^^tSDeclareMethod
- ^^^^tSEnumDeclaration
- ^^^^tSEnumMember
- ^^^^tSExportAssignment
- ^^^^tSExpressionWithTypeArguments
- ^^^^tSExternalModuleReference
- ^^^^tSFunctionType
- ^^^^tSImportEqualsDeclaration
- ^^^^tSIndexSignature
- ^^^^tSIndexedAccessType
- ^^^^tSInterfaceBody
- ^^^^tSInterfaceDeclaration
- ^^^^tSIntersectionType
- ^^^^tSLiteralType
- ^^^^tSMappedType
- ^^^^tSMethodSignature
- ^^^^tSModuleBlock
- ^^^^tSModuleDeclaration
- ^^^^tSNamespaceExportDeclaration
- ^^^^tSNeverKeyword
- ^^^^tSNonNullExpression
- ^^^^tSNullKeyword
- ^^^^tSNumberKeyword
- ^^^^tSObjectKeyword
- ^^^^tSParameterProperty
- ^^^^tSParenthesizedType
- ^^^^tSPropertySignature
- ^^^^tSQualifiedName
- ^^^^tSStringKeyword
- ^^^^tSSymbolKeyword
- ^^^^tSThisType
- ^^^^tSTupleType
- ^^^^tSTypeAliasDeclaration
- ^^^^tSTypeAnnotation
- ^^^^tSTypeAssertion
- ^^^^tSTypeLiteral
- ^^^^tSTypeOperator
- ^^^^tSTypeParameter
- ^^^^tSTypeParameterDeclaration
- ^^^^tSTypeParameterInstantiation
- ^^^^tSTypePredicate
- ^^^^tSTypeQuery
- ^^^^tSTypeReference
- ^^^^tSUndefinedKeyword
- ^^^^tSUnionType
- ^^^^tSVoidKeyword