Type definitions for the TypeScript-ESTree AST specification, including parser options and AST node types
—
Comprehensive configuration interfaces for the TypeScript parser, enabling precise control over parsing behavior, ECMAScript features, TypeScript project integration, and debugging options.
Complete configuration interface for the TypeScript-ESTree parser.
interface ParserOptions {
[additionalProperties: string]: unknown;
// Cache configuration
cacheLifetime?: {
glob?: CacheDurationSeconds;
};
// Core parsing options
debugLevel?: DebugLevel;
ecmaFeatures?: {
[key: string]: unknown;
globalReturn?: boolean | undefined;
jsx?: boolean | undefined;
} | undefined;
ecmaVersion?: EcmaVersion;
sourceType?: SourceType | undefined;
// TypeScript-specific options
emitDecoratorMetadata?: boolean;
errorOnTypeScriptSyntacticAndSemanticIssues?: boolean;
errorOnUnknownASTType?: boolean;
experimentalDecorators?: boolean;
extraFileExtensions?: string[];
filePath?: string;
isolatedDeclarations?: boolean;
// JSDoc and JSX configuration
jsDocParsingMode?: JSDocParsingMode;
jsxFragmentName?: string | null;
jsxPragma?: string | null;
// Library and program configuration
lib?: Lib[];
programs?: Program[] | null;
// Project configuration
project?: boolean | string | string[] | null;
projectFolderIgnoreList?: string[];
projectService?: boolean | ProjectServiceOptions;
// Token and range options
range?: boolean;
tokens?: boolean;
tsconfigRootDir?: string;
// Warnings
warnOnUnsupportedTypeScriptVersion?: boolean;
}Type definitions for parser configuration values.
/**
* Debug level configuration for parser output
*/
type DebugLevel =
| boolean
| ('eslint' | 'typescript' | 'typescript-eslint')[];
/**
* Cache duration specification in seconds
*/
type CacheDurationSeconds = number | 'Infinity';
/**
* ECMAScript version specification
*/
type EcmaVersion =
| 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17
| 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026
| 'latest'
| undefined;
/**
* Source type specification for module resolution
*/
type SourceType = 'commonjs' | SourceTypeClassic;
type SourceTypeClassic = 'module' | 'script';
/**
* JSDoc parsing mode configuration
*/
type JSDocParsingMode = 'all' | 'none' | 'type-info';Options for configuring the TypeScript project service.
/**
* Granular options to configure the project service
*/
interface ProjectServiceOptions {
/**
* Globs of files to allow running with the default project compiler options
* despite not being matched by the project service
*/
allowDefaultProject?: string[];
/**
* Path to a TSConfig to use instead of TypeScript's default project configuration
* @default 'tsconfig.json'
*/
defaultProject?: string;
/**
* Whether to allow TypeScript plugins as configured in the TSConfig
*/
loadTypeScriptPlugins?: boolean;
/**
* The maximum number of files allowDefaultProject may match.
* Each file match slows down linting, so if you do need to use this, please
* file an informative issue on typescript-eslint explaining why - so we can
* help you avoid using it!
* @default 8
*/
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING?: number;
}Usage Examples:
import { ParserOptions, DebugLevel, EcmaVersion } from "@typescript-eslint/types";
// Basic parser configuration
const basicConfig: ParserOptions = {
ecmaVersion: 2022,
sourceType: "module",
project: "./tsconfig.json"
};
// Advanced configuration with TypeScript features
const advancedConfig: ParserOptions = {
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.json", "./packages/*/tsconfig.json"],
tsconfigRootDir: __dirname,
// TypeScript features
experimentalDecorators: true,
emitDecoratorMetadata: true,
isolatedDeclarations: false,
// JSX configuration
ecmaFeatures: {
jsx: true
},
jsxPragma: "React",
jsxFragmentName: "Fragment",
// Library targets
lib: ["es2022", "dom", "dom.iterable"],
// Debug and error handling
debugLevel: ["typescript-eslint"],
errorOnUnknownASTType: true,
warnOnUnsupportedTypeScriptVersion: false,
// Performance options
cacheLifetime: {
glob: 3600 // 1 hour
}
};
// Project service configuration
const projectServiceConfig: ParserOptions = {
projectService: {
allowDefaultProject: ["*.js", "scripts/*.js"],
defaultProject: "tsconfig.base.json",
loadTypeScriptPlugins: true,
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: 16
},
tsconfigRootDir: process.cwd()
};
// Multi-project monorepo configuration
const monorepoConfig: ParserOptions = {
project: [
"./packages/*/tsconfig.json",
"./apps/*/tsconfig.json"
],
projectFolderIgnoreList: [
"**/node_modules/**",
"**/dist/**",
"**/build/**"
],
tsconfigRootDir: __dirname
};Control which ECMAScript features are available:
Configure TypeScript-specific parsing behavior:
Settings for JSX parsing and React integration:
Control parser output and error behavior:
Options to optimize parser performance:
Common Configuration Patterns:
// Strict TypeScript project
const strictConfig: ParserOptions = {
project: true, // Use nearest tsconfig.json
errorOnTypeScriptSyntacticAndSemanticIssues: true,
warnOnUnsupportedTypeScriptVersion: true
};
// Legacy JavaScript with some TypeScript features
const legacyConfig: ParserOptions = {
ecmaVersion: 5,
sourceType: "script",
experimentalDecorators: true // Allow decorators in legacy code
};
// Modern full-stack application
const fullStackConfig: ParserOptions = {
ecmaVersion: "latest",
sourceType: "module",
project: ["./src/tsconfig.json", "./server/tsconfig.json"],
lib: ["es2023", "dom", "node"],
ecmaFeatures: { jsx: true },
jsxPragma: "React",
extraFileExtensions: [".vue", ".svelte"]
};Install with Tessl CLI
npx tessl i tessl/npm-typescript-eslint--types