Skip to content

octane init: let the user choose the TypeScript version (it installs a 7.1 nightly today) #1729

Closed

Description

@leonidaz

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.9 or --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-mapper as a dev dependency and a top-level contentMappers entry for .tsrx with options: { 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-in textTypes facts used by the Vite and Rspack plugins) and native-read-types.js use the classic TypeScript API. On TypeScript 7, import ts from 'typescript' returns only { version, versionMajorMinor }; that API moved to typescript/unstable/*. octane's optional typescript peer is ^5.9.3, which also leaves out TypeScript 6. These belong in a separate issue, but they matter for which lines octane init should offer.

Found while updating the TSRX toolchain in #1399. Filed by an agent (Claude Code).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions