Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions apps/docs/content/docs/3.configuration/1.overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,25 @@ A project is treated as native TypeScript 7 when any of these hold:
- `node_modules/typescript` is at major version 7 or higher
- the `typescript` package ships `lib/getExePath.js` (native launcher)
- the `typescript` package is missing `lib/tsserver.js` (classic entry point)
- `node_modules/@typescript/native` is a TypeScript 7+ build with a `tsc` bin
(TypeScript 7 aliased beside a classic `typescript`)
- a `node_modules/.bin/tsgo` binary is present (`@typescript/native-preview`)

Because it is one server that swaps its own binary, there is a single set of
diagnostics either way — you never get duplicates. To use it, just install a
native TypeScript 7 build in your project:
diagnostics either way — you never get duplicates. To use it, install
TypeScript 7 in your project:

```bash
npm install --save-dev @typescript/native-preview
npm install --save-dev typescript@^7
```

TypeScript 7 drops the classic JavaScript API, so tools that import
`typescript` still need a classic build. typescript-eslint 8.x, for example,
requires `typescript` below 6.1.0. To keep such tools working, install
TypeScript 7 beside the classic package under the `@typescript/native` alias:

```bash
npm install --save-dev typescript@^6 @typescript/native@npm:typescript@^7
```

### tsrs
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
},
"devDependencies": {
"@tailwindcss/vite": "^4.3.3",
"typescript": "^5.9.3"
"typescript": "^6.0.3"
}
}
109 changes: 97 additions & 12 deletions bun.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hooks/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
},
"devDependencies": {
"@types/bun": "latest",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@
"@pleaseai/eslint-config": "^0.0.4",
"@types/bun": "latest",
"@types/node": "^26.6.5",
"@typescript/native": "npm:typescript@^7.0.2",
"eslint": "^10.6.0",
"husky": "^9.1.7",
"lint-staged": "^17.6.0",
"turbo": "^2.10.11",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
},
"lint-staged": {
"*.{ts,tsx,js,jsx,mjs,cjs}": "eslint --fix"
Expand Down
2 changes: 1 addition & 1 deletion packages/binaries/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
},
"devDependencies": {
"@types/bun": "latest",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
}
}
2 changes: 1 addition & 1 deletion packages/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
},
"devDependencies": {
"@types/bun": "latest",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
}
}
2 changes: 1 addition & 1 deletion packages/dora/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
},
"devDependencies": {
"@types/bun": "latest",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
}
}
2 changes: 1 addition & 1 deletion packages/format/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
},
"devDependencies": {
"@types/bun": "latest",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
}
}
2 changes: 1 addition & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@
"devDependencies": {
"@types/bun": "latest",
"pino-pretty": "^13.0.0",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
}
}
4 changes: 3 additions & 1 deletion packages/lsp/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ lsp:
**Native TypeScript 7 (typescript-go):** The single `typescript` server auto-selects
its binary per project root at spawn time. When the workspace ships a native
TypeScript 7 build — `node_modules/typescript` at major version ≥ 7 (or missing
`lib/tsserver.js` / carrying `lib/getExePath.js`), or a `@typescript/native-preview`
`lib/tsserver.js` / carrying `lib/getExePath.js`), a TS 7+ `tsc` aliased as
`@typescript/native` (`npm:typescript@^7`, installed beside a classic `typescript`
that typescript-eslint still needs), or a `@typescript/native-preview`
`tsgo` bin — it spawns `tsc --lsp --stdio` (or `tsgo --lsp --stdio`); otherwise it
falls back to the classic `typescript-language-server --stdio`. There is no separate
server id or config toggle, so there are never duplicate diagnostics. The native
Expand Down
2 changes: 1 addition & 1 deletion packages/lsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
},
"devDependencies": {
"@types/bun": "latest",
"typescript": "^5.7.0"
"typescript": "^6.0.3"
}
}
3 changes: 3 additions & 0 deletions packages/lsp/src/server/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ export function resolveNativeTypeScriptServer(
if (tsc) { return { command: tsc, label: 'native tsc' } }
}

const nativeAlias = findPackageBin(root, '@typescript/native', 'tsc', isNativeTypeScriptPackage)
if (nativeAlias) { return { command: nativeAlias, label: 'native tsc (@typescript/native)' } }
Comment on lines +172 to +173

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Installed native compiler is skipped

If the shared node_modules/.bin/tsc points to classic typescript, this lookup skips the installed @typescript/native alias. Both packages declare tsc, but findPackageBin accepts the alias only when the shared command points to its own executable. Users can therefore install both packages correctly and still get the classic language server.

Resolve the alias's declared executable without depending on which package owns the shared command. Add a test where classic typescript owns it.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/lsp/src/server/typescript.ts
Line: 172-173

Comment:
**Installed native compiler is skipped**

If the shared `node_modules/.bin/tsc` points to classic `typescript`, this lookup skips the installed `@typescript/native` alias. Both packages declare `tsc`, but `findPackageBin` accepts the alias only when the shared command points to its own executable. Users can therefore install both packages correctly and still get the classic language server.

Resolve the alias's declared executable without depending on which package owns the shared command. Add a test where classic `typescript` owns it.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code


// `@typescript/native-preview` installs a `tsgo` bin (can coexist with TS <= 6).
const tsgo = findPackageBin(root, '@typescript/native-preview', 'tsgo')
if (tsgo) { return { command: tsgo, label: 'native tsgo' } }
Expand Down
37 changes: 37 additions & 0 deletions packages/lsp/test/unit/typescript-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,43 @@ describe('resolveNativeTypeScriptServer', () => {
}
})

async function writeNativeAlias(dir: string, version: string): Promise<void> {
const aliasDir = path.join(dir, 'node_modules', '@typescript', 'native')
await fs.mkdir(path.join(aliasDir, 'lib'), { recursive: true })
await fs.writeFile(path.join(aliasDir, 'package.json'), JSON.stringify({ name: 'typescript', version }))
if (!version.startsWith('7')) {
await fs.writeFile(path.join(aliasDir, 'lib', 'tsserver.js'), '// classic entry\n')
}
}

test('selects TS 7 aliased as @typescript/native beside a classic typescript', async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'ts7-alias-'))
try {
await writeTypeScriptPackage(dir, { version: '6.0.3', tsserver: true })
await writeNativeAlias(dir, '7.0.2')
const tsc = await makeBin(dir, 'tsc', '@typescript/native')
const result = resolveNativeTypeScriptServer(dir)
expect(result?.command).toBe(tsc)
expect(result?.label).toBe('native tsc (@typescript/native)')
}
finally {
await fs.rm(dir, { recursive: true, force: true })
}
})

test('skips an @typescript/native alias that points at a classic TypeScript', async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'ts7-alias-classic-'))
try {
await writeTypeScriptPackage(dir, { version: '6.0.3', tsserver: true })
await writeNativeAlias(dir, '6.0.3')
await makeBin(dir, 'tsc', '@typescript/native')
expect(resolveNativeTypeScriptServer(dir)).toBeUndefined()
}
finally {
await fs.rm(dir, { recursive: true, force: true })
}
})

test('falls back to tsgo bin (@typescript/native-preview) when present', async () => {
const dir = await fs.mkdtemp(path.join(os.tmpdir(), 'ts7-tsgo-'))
try {
Expand Down