cli: find stable TypeScript 7 in side-by-side installs (#55384)
https://github.com/get-convex/convex-js/pull/178
### Summary
- Resolve `node_modules/@typescript/native/bin/tsc` when the stable TypeScript 7 alias is explicitly installed.
- Preserve `node_modules/typescript/bin/tsc` for normal TypeScript 6 and 7 installations.
- Keep `@typescript/native-preview` and `"tsgo"` behavior unchanged.
- Add focused compiler-resolution coverage.
Fixes https://github.com/get-convex/convex-js/issues/177.
### Why
TypeScript 7.0 does not expose the legacy JavaScript compiler API. For tools that still import it, the TypeScript team recommends installing the TypeScript 6 compatibility package under the name `typescript` and aliasing stable TypeScript 7 as `@typescript/native`:
```json
{
"devDependencies": {
"@typescript/native": "npm:typescript@^7.0.2",
"typescript": "npm:@typescript/typescript6@^6.0.2"
}
}
```
npm and Bun expose `tsc` from `@typescript/native` in this layout. Convex bypasses the project bin link and currently checks only `node_modules/typescript/bin/tsc`; the compatibility package exposes `tsc6` instead, so Convex reports that TypeScript is not installed.
The CLI intentionally invokes compiler JavaScript entry points through Node rather than executing `node_modules/.bin` wrappers. This change preserves that approach and adds explicit resolution for the official stable alias.
When both full TypeScript 6 and aliased TypeScript 7 are installed, npm and Bun expose the alias as the project's `tsc`; this change follows that behavior. Existing TypeScript 6-only projects are unchanged because the alias is absent. The `"tsgo"` selection remains associated with `@typescript/native-preview` for backward compatibility.
`typescriptCompiler` is already optional and defaults to `"tsc"`. Stable TypeScript 7 works through that default; this PR does not add another compiler setting or remove the existing preview escape hatch.
### Verification
- Focused compiler-resolution tests, including precedence and both preview entry names
- Repository typecheck and build
- Public format and lint checks
- Built CLI against normal `typescript@7.0.2`: passes
- Built CLI against the npm and Bun side-by-side layouts: passes
- Full TypeScript 6 + aliased stable TypeScript 7: selects TS7, matching npm and Bun's `tsc`
- Built CLI against TypeScript 6 + `@typescript/native-preview`: passes
- Intentional stable-TS7 type error: fails with the expected diagnostic
The focused test makes the alias precedence and retained preview behavior explicit. I am happy to drop it if maintainers prefer to cover this in the internal test suite.
### Scope
This PR does not change config discovery or walk parent `node_modules` directories, and it does not resolve https://github.com/get-convex/convex-js/issues/153. Stable-installation documentation is covered by the companion get-convex/convex-backend#504.
By submitting pull requests, you confirm that Convex can use, modify, copy, and redistribute the contribution, under the terms of its choice.
Co-authored-by: Eliot Gevers <eliot.gevers@gmail.com>
GitOrigin-RevId: dd9ffc8892e1d94dc4b365af48ee995da972c7ad N
Nicolas Ettlin committed
1debd56bba6da2248d78346d84dc1a42e8f2ce3b
Parent: a85fec3
Committed by Convex, Inc. <no-reply@convex.dev>
on 7/29/2026, 12:03:57 AM