CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-typescript-eslint--types

Type definitions for the TypeScript-ESTree AST specification, including parser options and AST node types

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

index.mddocs/

@typescript-eslint/types

@typescript-eslint/types provides comprehensive TypeScript type definitions for the TypeScript-ESTree Abstract Syntax Tree (AST) specification. As an internal utility package within the typescript-eslint ecosystem, it serves as the foundation for type-safe parsing, analysis, and linting of TypeScript code across all related tools.

Package Information

  • Package Name: @typescript-eslint/types
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @typescript-eslint/types

Core Imports

import { AST_NODE_TYPES, AST_TOKEN_TYPES, ParserOptions, TSESTree, Lib } from "@typescript-eslint/types";

For CommonJS:

const { AST_NODE_TYPES, AST_TOKEN_TYPES, ParserOptions, TSESTree, Lib } = require("@typescript-eslint/types");

Basic Usage

import { AST_NODE_TYPES, ParserOptions, TSESTree } from "@typescript-eslint/types";

// Check AST node types
if (node.type === AST_NODE_TYPES.FunctionDeclaration) {
  // TypeScript now knows this is a function declaration node
  console.log(node.id?.name);
}

// Configure parser options
const parserOptions: ParserOptions = {
  ecmaVersion: 2022,
  sourceType: "module",
  project: "./tsconfig.json",
  lib: ["es2022", "dom"]
};

// Work with strongly-typed AST nodes
function processNode(node: TSESTree.Node): void {
  switch (node.type) {
    case AST_NODE_TYPES.VariableDeclaration:
      // TypeScript provides full type safety
      node.declarations.forEach(declarator => {
        if (declarator.id.type === AST_NODE_TYPES.Identifier) {
          console.log(`Variable: ${declarator.id.name}`);
        }
      });
      break;
  }
}

Architecture

@typescript-eslint/types is built around several key components:

  • AST Node Types: Enum constants for all JavaScript and TypeScript AST node types
  • Token Types: Enum constants for lexical token classification
  • Parser Configuration: Comprehensive interfaces for configuring the TypeScript parser
  • Type System: Complete TypeScript definitions for all AST node structures
  • Parent Relationships: Augmented type definitions that include parent node references

Capabilities

AST Node Type Constants

Comprehensive enumeration of all AST node types for JavaScript and TypeScript, enabling type-safe node identification and processing.

enum AST_NODE_TYPES {
  // Standard JavaScript nodes
  Program = 'Program',
  Identifier = 'Identifier',
  Literal = 'Literal',
  FunctionDeclaration = 'FunctionDeclaration',
  // ... 172 total node types
  
  // TypeScript-specific nodes
  TSInterfaceDeclaration = 'TSInterfaceDeclaration',
  TSTypeAnnotation = 'TSTypeAnnotation',
  TSAsExpression = 'TSAsExpression',
  // ... and many more
}

AST Node Types

Token Type Constants

Enumeration of lexical token types for parsing and syntax highlighting.

enum AST_TOKEN_TYPES {
  Boolean = 'Boolean',
  Identifier = 'Identifier',
  Keyword = 'Keyword',
  Null = 'Null',
  Numeric = 'Numeric',
  Punctuator = 'Punctuator',
  RegularExpression = 'RegularExpression',
  String = 'String',
  Template = 'Template',
  Block = 'Block',      // Block comment
  Line = 'Line',        // Line comment
  // ... 18 total token types
}

Token Types

Parser Configuration

Comprehensive configuration interfaces for the TypeScript parser, including ECMAScript version settings, project configuration, and TypeScript-specific options.

interface ParserOptions {
  // ECMAScript configuration
  ecmaVersion?: EcmaVersion;
  sourceType?: SourceType;
  
  // TypeScript project configuration
  project?: boolean | string | string[] | null;
  projectService?: boolean | ProjectServiceOptions;
  tsconfigRootDir?: string;
  
  // Parser features
  jsxPragma?: string | null;
  jsxFragmentName?: string | null;
  lib?: Lib[];
  
  // Debug and optimization
  debugLevel?: DebugLevel;
  errorOnUnknownASTType?: boolean;
  
  // ... 25+ additional options
}

Parser Configuration

TypeScript Library Targets

Union type defining all available TypeScript library targets for compilation and type checking.

type Lib = 
  | 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' 
  | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023' | 'es2024'
  | 'esnext' | 'dom' | 'webworker' | 'scripthost'
  | 'decorators' | 'decorators.legacy'
  // ... 114 total library targets

TypeScript Libraries

TypeScript ESTree Types

Complete type definitions for all AST node structures with parent relationship augmentations, providing strongly-typed access to the entire syntax tree.

declare namespace TSESTree {
  interface NodeOrTokenData {
    type: string;
    loc: SourceLocation;
    range: Range;
  }
  
  interface BaseNode extends NodeOrTokenData {
    type: AST_NODE_TYPES;
    parent: Node; // Added by @typescript-eslint/types package
  }
  
  interface Program extends NodeOrTokenData {
    type: AST_NODE_TYPES.Program;
    body: ProgramStatement[];
    comments: Comment[] | undefined;
    sourceType: 'module' | 'script';
    tokens: Token[] | undefined;
    parent?: never; // Program has no parent
  }
  
  interface FunctionDeclaration extends BaseNode {
    type: AST_NODE_TYPES.FunctionDeclaration;
    id: Identifier | null;
    params: Parameter[];
    body: BlockStatement;
    // ... complete interface definitions
  }
  
  // ... interfaces for all 172 node types
}

TypeScript ESTree

docs

ast-node-types.md

index.md

parser-configuration.md

token-types.md

typescript-estree.md

typescript-libraries.md

tile.json