Repository navigation
[Feature Request] Allow configuring a custom TypeScript compiler executable for type checking #101130
Replies: 1 comment
|
This is a timely and well-structured RFC. With the rapid evolution of native TypeScript type-checkers (such as Addressing your three open questions from a Next.js internals perspective: 1. API Shape:
|
Uh oh!
There was an error while loading. Please reload this page.
Goals
tsrs,tsgo, or an absolute path to a native binary) innext.config.ts.typescript.ignoreBuildErrors.Non-Goals
tsrs.Background
Next.js already supports invoking the native TypeScript CLI through
experimental.useTypeScriptCli. However, there is currently no documented way to configure the actual compiler executable that Next.js invokes duringnext build.Projects such as tsrs, a Rust implementation of the TypeScript 7 compiler, aim to provide compatible type checking with improved performance and memory efficiency.
Developers can already run these tools independently:
pnpm exec tsrs --noEmitHowever, integrating them into the normal Next.js build workflow currently requires a workaround:
typescript.ignoreBuildErrors: true.While functional, this approach introduces additional configuration and separates type checking from the framework's existing build pipeline.
A related discussion already exists: #100963 — Opt-in for tsrs.
This proposal expands on that idea by requesting a generic compiler executable configuration option rather than a compiler-specific integration.
Proposal
Introduce an optional configuration property that allows Next.js to invoke a custom TypeScript-compatible CLI executable during build-time type checking.
For example:
Alternatively, developers could provide an absolute path to a native executable:
Expected behavior
When
typescript.compilerPathis configured:next build, Next.js invokes the configured executable instead of the default TypeScript CLI.When
compilerPathis not configured, Next.js continues using its existing TypeScript integration without any behavior changes.Implementation considerations
This could potentially extend the existing
experimental.useTypeScriptCliimplementation rather than introducing an entirely separate type-checking pipeline.An initial implementation could focus on compiler executables that support the standard TypeScript CLI arguments, including
--project,--noEmit, and--pretty.Platform-specific executable handling (such as
.exeon Windows), argument forwarding, and compiler compatibility could remain explicitly documented limitations.Benefits
tsrs.Open questions
typescript.compilerPath, or extendexperimental.useTypeScriptClito accept a path?I'm interested in hearing whether the Next.js team would consider supporting this as an extension of the existing TypeScript CLI integration.
All reactions