Repository navigation
Description
Problem
octane init installs TypeScript at the range @tsrx/typescript-plugin declares as its typescript peer (toolchainTypescriptRange in packages/cli/src/commands/init/index.js). Since @tsrx/typescript-plugin 0.6.0 that range is ^5.9.3 || ^6.0.0 || ^7.1.0-dev.20260923.1. TypeScript's latest tag (7.0.2) is outside it, so npm picks the highest match, today's 7.1 nightly, and the new app records "typescript": "^7.1.0-dev.20261004.1".
On a 7.1 nightly, tsrx-tsc runs native TypeScript with --runExternalCode, which needs a .tsrx content mapper. The scaffolded tsconfig.json declares none, and @tsrx/content-mapper is not installed, so the scaffolded typecheck script fails at once:
tsrx-tsc: …/tsconfig.json declares no content mapper for .tsrx files, so TypeScript 7 would not check them. Install @tsrx/content-mapper next to the project and add "contentMappers": [{ "package": "@tsrx/content-mapper", "extensions": [".tsrx"] }] at the top level of tsconfig.json …
Reproduction, without the CLI: in an empty npm project, npm install "typescript@^5.9.3 || ^6.0.0 || ^7.1.0-dev.20260923.1" @tsrx/[email protected], write the tsconfig template from packages/cli/src/commands/init/templates.js and one src/App.tsrx, then run tsrx-tsc --noEmit -p tsconfig.json. It exits 1 with the message above.
The comments in integrationFor and toolchainTypescriptRange also describe the peer as required. Since @tsrx/typescript-plugin 0.6.1 it is optional, so npm and pnpm no longer install TypeScript on their own, and the CLI's explicit install is the only thing that adds it.
Proposal
Let the user choose the TypeScript line instead of inheriting the plugin's whole peer range:
- A flag:
octane init --typescript <version or range>, for example--typescript 6,--typescript ~5.9or--typescript next. Reject a value outside the plugin's peer range. - A prompt: when the flag is absent and the terminal is interactive, ask which line to use. Offer the classic line (TypeScript 5.9 or 6) as the default, and TypeScript 7.1 (nightly) as an option.
- A safe default: non-interactive runs without the flag install the classic line, for example
^5.9.3 || ^6.0.0, never a nightly. - A complete TypeScript 7.1 setup: choosing 7.1 also adds
@tsrx/content-mapperas a dev dependency and a top-levelcontentMappersentry for.tsrxwithoptions: { compiler: 'octane/compiler/volar' }. TypeScript 5 and 6 ignore that key, so the tsconfig keeps working if the user later switches lines. octane doctor: its TypeScript checks (packages/cli/src/commands/doctor/checks/typescript.js) should accept the 7.1 setup and report a 7.1 project that has no content mapper.
Related
octane/compiler/typescript(the opt-intextTypesfacts used by the Vite and Rspack plugins) andnative-read-types.jsuse the classic TypeScript API. On TypeScript 7,import ts from 'typescript'returns only{ version, versionMajorMinor }; that API moved totypescript/unstable/*.octane's optionaltypescriptpeer is^5.9.3, which also leaves out TypeScript 6. These belong in a separate issue, but they matter for which linesoctane initshould offer.
Found while updating the TSRX toolchain in #1399. Filed by an agent (Claude Code).
Activity