TypeScript 6 shims are rejected and configured LSP binaries still require tsserver
What happened?
AFT 0.63.5 rejects a project where the installed typescript package is @typescript/[email protected]:
TypeScript 6.0.2 ... has no lib/tsserver.js
That package is a shim. It does not contain lib/tsserver.js, but its runtime dependency @typescript/old is an npm alias to TypeScript 6 and contains the SDK. That dependency resolved to TypeScript 6.0.3.
An explicit lsp.servers.typescript.binary does not avoid the failure. Configuring a TypeScript 7 native binary with --lsp --stdio still triggers AFT's project tsserver lookup before the configured server can start.
Reproduction
Install these dependencies with Bun's isolated linker:
{
"dependencies": {
"typescript": "npm:@typescript/[email protected]",
"@typescript/native": "npm:[email protected]",
"typescript-language-server": "6.0.3"
}
}
Add a tsconfig and a TypeScript file containing a type error, then request AFT diagnostics. The default server is rejected because the shim has no tsserver at its own package path.
The same lookup failure occurs when configuring the TypeScript server to run a native TypeScript 7 binary:
{
"lsp": {
"servers": {
"typescript": {
"binary": "/path/to/native/typescript/tsc",
"args": ["--lsp", "--stdio"]
}
}
}
}
The binary above must be the installed TypeScript 7 native compiler, not a JavaScript TypeScript 5/6 compiler.
Expected behavior
- Resolve a shim's installed SDK through its runtime dependencies aliased to
typescript, following Node-style resolution from the package's real path. This must work with Bun/pnpm symlinks and versionlessnpm:typescriptaliases. - Treat a non-empty configured TypeScript server binary as an explicit override, including the literal name
typescript-language-server. Leave SDK handling to that server, and preserve its arguments and initialization options. - Preserve automatic native-server selection for unconfigured TypeScript 7 projects.
Implementation available
The implementation and regression tests are pushed to domkm/aft:fix/typescript6-shim-tsserver, at commit e75899657.
Alias resolution is cycle-safe, limited to 16 packages, and records probed paths for applicability-cache invalidation. Server sharing compares resolved SDK versions rather than shim versions, with canonical target paths when versions are unreadable. A custom server named typescript-native cannot change the generated native server's platform resolution.
Please review the approach for design approval.
Diagnostics and validation
- Reproduced with AFT 0.63.5 on Linux x64, Bun 1.4.4, the TypeScript 6.0.2 shim resolving to SDK 6.0.3, and typescript-language-server 6.0.3.
- 100 focused Rust library tests passed; one benchmark was ignored. Tests cover shim resolution, server sharing, configured binaries, and the custom-ID collision.
- Formatting, Clippy, and build passed. Clippy reported existing warnings.
- Live checks confirmed separate SDK selection for root and nested packages, versionless alias startup, and the missing-platform error even with a colliding custom server ID.
- The TypeScript 6 shim, configured TypeScript 7, and automatically selected TypeScript 7 all reported the deliberate TS2322 error with the patched binary.
Thanks for the detailed report and the reproduction, and for #1417. Both parts match what the code does today:
- When the project's
typescriptpackage has nolib/tsserver.jsand its version is 6 or earlier, AFT refuses to start the TypeScript server instead of serving the project with another SDK. It looks only at that package's own directory, so a shim like@typescript/typescript6is refused even though the SDK is installed under its aliased dependency. - A
lsp.servers.typescript.binaryfrom config doesn't skip that lookup. Only an explicittsserver.pathin the initialization options, or a--tsserver-pathargument, does. So a configured TypeScript 7 binary is still refused when the project'stypescriptpackage is the 6.x shim.
The approach you describe is the direction we want: a configured server binary is the user's explicit choice and owns its own SDK discovery, and a shim resolves to the SDK it depends on, following Node resolution from the package's real path. Since this area is changing in the release we're finishing (0.64), we'll build the fix ourselves, with your report and branch as the reference, and post here when it ships.
Fixed in v0.64.0: AFT now finds TypeScript through npm:typescript alias installs, including Bun and pnpm layouts, and uses a configured TypeScript server path as given. Closing this; please reopen if your setup still isn't found.