Skip to article
detaID ↗
← Back home

Running TypeScript 7 and ESLint Side by Side

How to use the native TypeScript 7 compiler for builds and type-checking while keeping TypeScript 6 available for the Compiler API required by ESLint.

2 min read
#TypeScript#ESLint#pnpm#Compiler

TypeScript 7 introduces a much faster native compiler written in Go. However, TypeScript 7.0 does not yet provide the programmatic Compiler API required by tools such as typescript-eslint.

The official solution is to run TypeScript 6 and 7 side by side using npm aliases.

Configuration

In pnpm-workspace.yaml:

yaml
catalog: typescript: npm:@typescript/typescript6@~6.0.0 'typescript-7': npm:typescript@~7.0.0

Then add both packages as dependencies:

json
{ "devDependencies": { "typescript": "catalog:", "typescript-7": "catalog:" } }

Why Does This Work?

Modules and executables are resolved through different paths:

  • typescript-eslint imports the module named typescript, which points to TypeScript 6.
  • Scripts that run tsc use the binary provided by TypeScript 7.

The TypeScript 6 package provides a tsc6 binary, while TypeScript 7 provides tsc:

text
node_modules/.bin/tsc6 -> TypeScript 6 node_modules/.bin/tsc -> TypeScript 7

As a result, existing scripts do not need to change:

json
{ "typecheck": "tsc --noEmit" }

This command automatically uses TypeScript 7, while ESLint continues to use the TypeScript 6 API.

Result

With this approach:

  • ESLint runs reliably using the TypeScript 6 API.
  • Builds and type-checking use the TypeScript 7 compiler.
  • No source code or build script changes are required.
  • The TypeScript 6 alias can be removed once the tooling supports the TypeScript 7 API.

References: TypeScript 7.0 announcement and pnpm dependency aliases.

More writing

A few more notes from my archive.

TypeScript 5.8 and the --erasableSyntaxOnly Flag: Enhancing JavaScript Compatibility and Future-Proofing Codebases

TypeScript 5.8 introduces the --erasableSyntaxOnly compiler flag, designed to enhance compatibility with JavaScript's evolving type systems. This flag restricts the use of non-erasable syntax elements, such as enums, namespaces, and parameter properties, that require runtime transformations, promoting a cleaner separation between type annotations and executable code. This article delves into the implications of this feature, its alignment with current JavaScript proposals, and its potential impact on TypeScript development practices.

Build a State Machine with XState and Use It Across React Components (TypeScript)

Learn how to build a state machine with XState and use it across React components in TypeScript.

A Comprehensive Comparison of Zod's safeParse and parse Methods

Understanding the differences between Zod's safeParse and parse is essential for effective data validation in TypeScript. This article explores their distinct behaviors, use cases, and when to choose one over the other to ensure robust and predictable error handling in your applications.

Understanding Partial Type in TypeScript

This article examines the `Partial` utility type in TypeScript, focusing on its functionality, use cases, and practical applications for managing optional properties efficiently in various scenarios.

Leave a comment