Skip to main content
The SyntaxKind enum identifies the type of each node in the TypeScript Abstract Syntax Tree (AST). Every node has a kind property that determines its type and structure.
export const enum SyntaxKind {
  Unknown,
  EndOfFileToken,
  // ... hundreds of kinds
}

Trivia and Tokens

Trivia (Comments and Whitespace)

KindValueDescription
Unknown0Unknown token
EndOfFileToken1End of file marker
SingleLineCommentTrivia2// comment
MultiLineCommentTrivia3/* comment */
NewLineTrivia4Line break
WhitespaceTrivia5Spaces and tabs
ShebangTrivia6#!/usr/bin/env node
ConflictMarkerTrivia7Git conflict markers

Literals

Primary Literals

KindDescriptionExample
NumericLiteralNumber literal42, 3.14
BigIntLiteralBigInt literal100n
StringLiteralString literal"hello", 'world'
RegularExpressionLiteralRegex literal/pattern/g
NoSubstitutionTemplateLiteralTemplate without expressions`text`

Template Literals

KindDescription
TemplateHead `start ${
TemplateMiddle} middle ${
TemplateTail} end`

Punctuation

Braces and Brackets

KindSymbol
OpenBraceToken{
CloseBraceToken}
OpenParenToken(
CloseParenToken)
OpenBracketToken[
CloseBracketToken]

Operators

KindSymbolDescription
PlusToken+Addition
MinusToken-Subtraction
AsteriskToken*Multiplication
AsteriskAsteriskToken**Exponentiation
SlashToken/Division
PercentToken%Modulo
PlusPlusToken++Increment
MinusMinusToken--Decrement
LessThanToken<Less than
GreaterThanToken>Greater than
LessThanEqualsToken<=Less than or equal
GreaterThanEqualsToken>=Greater than or equal
EqualsEqualsToken==Equality
ExclamationEqualsToken!=Inequality
EqualsEqualsEqualsToken===Strict equality
ExclamationEqualsEqualsToken!==Strict inequality
EqualsGreaterThanToken=>Arrow function
AmpersandToken&Bitwise AND
BarToken``Bitwise OR
CaretToken^Bitwise XOR
TildeToken~Bitwise NOT
AmpersandAmpersandToken&&Logical AND
BarBarToken``Logical OR
QuestionQuestionToken??Nullish coalescing

Other Punctuation

KindSymbol
DotToken.
DotDotDotToken...
SemicolonToken;
CommaToken,
QuestionToken?
ColonToken:
AtToken@
QuestionDotToken?.
ExclamationToken!

Assignment Operators

KindSymbol
EqualsToken=
PlusEqualsToken+=
MinusEqualsToken-=
AsteriskEqualsToken*=
AsteriskAsteriskEqualsToken**=
SlashEqualsToken/=
PercentEqualsToken%=
AmpersandEqualsToken&=
BarEqualsToken`=`
CaretEqualsToken^=
AmpersandAmpersandEqualsToken&&=
BarBarEqualsToken`=`
QuestionQuestionEqualsToken??=

Keywords

Reserved Words

KeywordSyntaxKind
breakBreakKeyword
caseCaseKeyword
catchCatchKeyword
classClassKeyword
constConstKeyword
continueContinueKeyword
debuggerDebuggerKeyword
defaultDefaultKeyword
deleteDeleteKeyword
doDoKeyword
elseElseKeyword
enumEnumKeyword
exportExportKeyword
extendsExtendsKeyword
falseFalseKeyword
finallyFinallyKeyword
forForKeyword
functionFunctionKeyword
ifIfKeyword
importImportKeyword
inInKeyword
instanceofInstanceOfKeyword
newNewKeyword
nullNullKeyword
returnReturnKeyword
superSuperKeyword
switchSwitchKeyword
thisThisKeyword
throwThrowKeyword
trueTrueKeyword
tryTryKeyword
typeofTypeOfKeyword
varVarKeyword
voidVoidKeyword
whileWhileKeyword
withWithKeyword

Strict Mode Reserved Words

KeywordSyntaxKind
implementsImplementsKeyword
interfaceInterfaceKeyword
letLetKeyword
packagePackageKeyword
privatePrivateKeyword
protectedProtectedKeyword
publicPublicKeyword
staticStaticKeyword
yieldYieldKeyword

Contextual Keywords

KeywordSyntaxKindUsage
abstractAbstractKeywordAbstract classes/methods
accessorAccessorKeywordAuto-accessor fields
anyAnyKeywordAny type
asAsKeywordType assertions
assertsAssertsKeywordAssertion signatures
assertAssertKeywordImport assertions
asyncAsyncKeywordAsync functions
awaitAwaitKeywordAwait expressions
booleanBooleanKeywordBoolean type
constructorConstructorKeywordConstructors
declareDeclareKeywordAmbient declarations
getGetKeywordGetter methods
inferInferKeywordType inference
intrinsicIntrinsicKeywordIntrinsic types
isIsKeywordType predicates
keyofKeyOfKeywordKeyof operator
moduleModuleKeywordModule declarations
namespaceNamespaceKeywordNamespaces
neverNeverKeywordNever type
numberNumberKeywordNumber type
objectObjectKeywordObject type
outOutKeywordCovariance annotation
overrideOverrideKeywordOverride modifier
readonlyReadonlyKeywordReadonly modifier
requireRequireKeywordRequire calls
satisfiesSatisfiesKeywordSatisfies operator
setSetKeywordSetter methods
stringStringKeywordString type
symbolSymbolKeywordSymbol type
typeTypeKeywordType aliases
undefinedUndefinedKeywordUndefined type
uniqueUniqueKeywordUnique symbols
unknownUnknownKeywordUnknown type
usingUsingKeywordUsing declarations
fromFromKeywordImport from
globalGlobalKeywordGlobal augmentation
bigintBigIntKeywordBigInt type
ofOfKeywordFor-of loops
deferDeferKeywordDeferred evaluation

Parse Tree Nodes

Names

  • QualifiedName - A.B.C
  • ComputedPropertyName - [expr]

Type Members

  • PropertySignature
  • PropertyDeclaration
  • MethodSignature
  • MethodDeclaration
  • Constructor
  • GetAccessor
  • SetAccessor
  • CallSignature
  • ConstructSignature
  • IndexSignature

Types

  • TypePredicate
  • TypeReference
  • FunctionType
  • ConstructorType
  • TypeQuery
  • TypeLiteral
  • ArrayType
  • TupleType
  • UnionType
  • IntersectionType
  • ConditionalType
  • InferType
  • MappedType
  • TemplateLiteralType
  • ImportType

Expressions

  • ArrayLiteralExpression
  • ObjectLiteralExpression
  • PropertyAccessExpression
  • ElementAccessExpression
  • CallExpression
  • NewExpression
  • TaggedTemplateExpression
  • TypeAssertionExpression
  • ParenthesizedExpression
  • FunctionExpression
  • ArrowFunction
  • DeleteExpression
  • TypeOfExpression
  • VoidExpression
  • AwaitExpression
  • PrefixUnaryExpression
  • PostfixUnaryExpression
  • BinaryExpression
  • ConditionalExpression
  • YieldExpression
  • SpreadElement
  • ClassExpression
  • AsExpression
  • NonNullExpression
  • SatisfiesExpression

Statements

  • Block
  • VariableStatement
  • ExpressionStatement
  • IfStatement
  • DoStatement
  • WhileStatement
  • ForStatement
  • ForInStatement
  • ForOfStatement
  • ContinueStatement
  • BreakStatement
  • ReturnStatement
  • WithStatement
  • SwitchStatement
  • LabeledStatement
  • ThrowStatement
  • TryStatement
  • DebuggerStatement

Declarations

  • VariableDeclaration
  • FunctionDeclaration
  • ClassDeclaration
  • InterfaceDeclaration
  • TypeAliasDeclaration
  • EnumDeclaration
  • ModuleDeclaration
  • ImportDeclaration
  • ExportDeclaration
  • ImportEqualsDeclaration
  • ExportAssignment

JSX

  • JsxElement
  • JsxSelfClosingElement
  • JsxOpeningElement
  • JsxClosingElement
  • JsxFragment
  • JsxAttribute
  • JsxSpreadAttribute
  • JsxExpression

Other

  • SourceFile - Root node
  • Bundle - Multiple source files
  • SyntaxList - List of nodes

Helper Markers

The enum includes helper values for ranges:
FirstAssignment = EqualsToken,
LastAssignment = CaretEqualsToken,
FirstReservedWord = BreakKeyword,
LastReservedWord = WithKeyword,
FirstKeyword = BreakKeyword,
LastKeyword = DeferKeyword,
FirstPunctuation = OpenBraceToken,
LastPunctuation = CaretEqualsToken,

Usage

Checking Node Kind

import ts from 'typescript';

if (node.kind === ts.SyntaxKind.FunctionDeclaration) {
  console.log('Found a function declaration');
}

// Or use type guards
if (ts.isFunctionDeclaration(node)) {
  console.log('Found a function declaration');
}

Getting Kind Name

const kindName = ts.SyntaxKind[node.kind];
console.log(`Node kind: ${kindName}`);

See Also

Build docs developers (and LLMs) love