Skip to content

Commit 20f4139

Browse files
committed
Merge branch 'main' into jabaile/optimize-bin
2 parents 7da81c8 + 241df12 commit 20f4139

662 files changed

Lines changed: 26713 additions & 5078 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"image": "mcr.microsoft.com/devcontainers/go:dev-1.26-bookworm",
77
// Features to add to the dev container. More info: https://containers.dev/features.
88
"features": {
9-
"ghcr.io/devcontainers/features/node:1": {
9+
"ghcr.io/devcontainers/features/node:2": {
1010
"version": "lts",
1111
"pnpmVersion": "latest",
1212
"nvmVersion": "latest"

.dprint.jsonc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"**/node_modules",
4747
"**/*-lock.json",
4848
"**/testdata",
49+
"_extension/l10n/**",
4950
"_submodules/**",
5051
"internal/bundled/libs/**",
5152
"internal/lsp/lsproto/_generate/*.json",
@@ -60,6 +61,6 @@
6061
"https://plugins.dprint.dev/typescript-0.96.1.wasm",
6162
"https://plugins.dprint.dev/json-0.21.3.wasm",
6263
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.6.0.wasm",
63-
"https://plugins.dprint.dev/jakebailey/gofumpt-v0.0.11.wasm"
64+
"https://plugins.dprint.dev/jakebailey/gofumpt-v0.0.12.wasm"
6465
]
6566
}

.github/workflows/ci.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
docker-images: false
3131
swap-storage: false
3232
dotnet: false
33-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3434
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
3535
- uses: ./.github/actions/setup-go
3636

@@ -50,7 +50,7 @@ jobs:
5050
if: ${{ github.repository == 'microsoft/typescript-go' && github.event_name != 'merge_group' }}
5151
runs-on: TypeScript-1ES-GitHub-XL-2
5252
steps:
53-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
53+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
5454
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
5555
with:
5656
node-version: 'lts/*'
@@ -72,7 +72,7 @@ jobs:
7272
extension:
7373
runs-on: ubuntu-latest
7474
steps:
75-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
75+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
7676
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
7777

7878
- run: npm ci
@@ -137,7 +137,7 @@ jobs:
137137
- run: git config --system core.longpaths true
138138
if: ${{ matrix.config.os == 'windows-latest' }}
139139

140-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
140+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
141141
with:
142142
submodules: ${{ !matrix.config.no-submodules }}
143143
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -176,7 +176,7 @@ jobs:
176176

177177
- run: git add .
178178

179-
- uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6.0.1
179+
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
180180
if: ${{ always() && matrix.config.coverage && github.event_name != 'merge_group' }}
181181
with:
182182
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}
@@ -231,7 +231,7 @@ jobs:
231231
docker-images: false
232232
swap-storage: false
233233
dotnet: false
234-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
234+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
235235
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
236236
- uses: ./.github/actions/setup-go
237237

@@ -251,7 +251,7 @@ jobs:
251251
format:
252252
runs-on: ubuntu-slim
253253
steps:
254-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
254+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
255255
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
256256
- uses: ./.github/actions/setup-go
257257

@@ -268,7 +268,7 @@ jobs:
268268
docker-images: false
269269
swap-storage: false
270270
dotnet: false
271-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
271+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
272272
with:
273273
submodules: true
274274
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -281,10 +281,14 @@ jobs:
281281
- run: npx hereby generate
282282
- run: npx hereby generate:enums
283283
- run: npx hereby generate:ast
284+
- run: npx hereby generate:vendor
284285

285286
- run: node --experimental-strip-types ./internal/lsp/lsproto/_generate/fetchModel.mts
286287
- run: node --experimental-strip-types ./internal/lsp/lsproto/_generate/generate.mts
287288

289+
- name: generate files for extension
290+
run: npx hereby generate:extension
291+
288292
- name: Regenerate fourslash tests and update failing test list
289293
run: |
290294
set -x
@@ -303,7 +307,7 @@ jobs:
303307
tidy:
304308
runs-on: ubuntu-slim
305309
steps:
306-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
310+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
307311
- uses: ./.github/actions/setup-go
308312

309313
- run: go mod tidy -diff
@@ -318,7 +322,7 @@ jobs:
318322
docker-images: false
319323
swap-storage: false
320324
dotnet: false
321-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
325+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
322326
with:
323327
submodules: true
324328
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -345,7 +349,7 @@ jobs:
345349
misc:
346350
runs-on: ubuntu-latest
347351
steps:
348-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
352+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
349353
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
350354
- uses: ./.github/actions/setup-go
351355

.github/workflows/codeql.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ jobs:
4444

4545
steps:
4646
- name: Checkout repository
47-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
47+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
4848

4949
# Initializes the CodeQL tools for scanning.
5050
- name: Initialize CodeQL
51-
uses: github/codeql-action/init@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
51+
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
5252
with:
5353
config-file: ./.github/codeql/codeql-configuration.yml
5454
# Override language selection by uncommenting this and choosing your languages
@@ -58,7 +58,7 @@ jobs:
5858
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5959
# If this step fails, then you should remove it and run the build manually (see below).
6060
- name: Autobuild
61-
uses: github/codeql-action/autobuild@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
61+
uses: github/codeql-action/autobuild@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
6262

6363
# ℹ️ Command-line programs to run using the OS shell.
6464
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -72,4 +72,4 @@ jobs:
7272
# make release
7373

7474
- name: Perform CodeQL Analysis
75-
uses: github/codeql-action/analyze@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4.36.0
75+
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
docker-images: false
2727
swap-storage: false
2828
dotnet: false
29-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3030
with:
3131
submodules: true
3232
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ go.work.sum
178178
# Re-add baseline references
179179
!testdata/baselines/reference/**/*.txt
180180

181+
# Re-add vendored license/notice files (see hereby generate:vendor)
182+
!_packages/native-preview/vendor/**/*.txt
183+
181184
# Local baselines
182185
testdata/baselines/local
183186
testdata/baselines/tmp

CHANGES.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,31 @@ Corsa no longer parses the following JSDoc tags with a specific node type. They
126126

127127
### Miscellaneous
128128

129+
#### Template literal type inference pulls off a full Unicode code point for empty placeholders.
130+
131+
When inferring through a template literal type with an empty delimiter, Corsa consumes a full Unicode code point rather than a single UTF-16 code unit.
132+
This diverges from Strada, which advances one UTF-16 code unit at a time and therefore splits a supplementary-plane character such as an emoji into its surrogate halves:
133+
134+
```ts
135+
type Head<S> = S extends `${infer H}${string}` ? H : never;
136+
type Rest<S> = S extends `${string}${infer R}` ? R : never;
137+
138+
type H = Head<"😀abc">; // Strada: "\uD83D"
139+
type R = Rest<"😀abc">; // Strada: "\uDE00abc"
140+
```
141+
142+
In Corsa the emoji stays together:
143+
144+
```ts
145+
type Head<S> = S extends `${infer H}${string}` ? H : never;
146+
type Rest<S> = S extends `${string}${infer R}` ? R : never;
147+
148+
type H = Head<"😀abc">; // Corsa: "😀"
149+
type R = Rest<"😀abc">; // Corsa: "abc"
150+
```
151+
152+
This means supplementary-plane characters such as emoji are not split into surrogate halves during template literal type inference.
153+
129154
#### With `"strict": false`, Corsa no longer allows omitting arguments for parameters with type `undefined`, `unknown`, or `any`:
130155

131156
```js

CONTRIBUTING.md

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,50 @@ To debug and run the VS Code extension without installing it globally:
7272
* Copy `.vscode/launch.template.json` to `.vscode/launch.json`
7373
* <kbd>F5</kbd> (or `Debug: Start Debugging` from the command palette)
7474

75-
This will launch a new VS Code instance which uses the Corsa LS as the backend. If correctly set up, you should see "tsgo" in the status bar when a TypeScript or JavaScript file is open:
75+
This will launch a new VS Code instance which uses the Corsa LS as the backend.
7676

77-
![LSP Server Screenshot](.github/ls-screenshot.png)
77+
#### Collecting Logs
78+
79+
The extension provides a single output channel, **typescript-native-preview**, in VS Code's Output panel. It shows both server log messages and (optionally) LSP protocol traces.
80+
81+
The output channel's **log level** (the gear icon next to the channel dropdown) controls what is visible:
82+
83+
| Log level | What you'll see |
84+
|---|---|
85+
| **Error** | Crashes and internal errors while handling requests |
86+
| **Warning** | Unexpected conditions, e.g. unknown LSP methods |
87+
| **Info** (default) | Server lifecycle events, project loading, file changes |
88+
| **Debug** | All of the above, plus verbose server details (cache statistics, project trees) |
89+
| **Trace** | All of the above, plus full LSP request/response protocol traces |
90+
91+
The **`typescript.native-preview.trace.server`** setting controls the detail level of LSP traces when the log level is set to Trace:
92+
93+
| Setting value | Effect at Trace log level |
94+
|---|---|
95+
| `"off"` | No LSP traces |
96+
| `"messages"` | Request/response names and timing |
97+
| **`"verbose"`** (default) | Full JSON bodies of every request and response |
98+
99+
When filing an issue, copy the relevant section of log output and include it in your report.
100+
101+
> [!WARNING]
102+
> Logs contain personally identifiable information (mostly file paths). When the log level is set to Trace and `typescript.native-preview.trace.server` is set to `"verbose"`, this includes the full contents of open files. Always review log content before sharing.
103+
104+
#### Collecting Heap Profiles
105+
106+
Heap profiles are essential for diagnosing high memory usage. When the language server is consuming too much memory:
107+
108+
1. Open the VS Code command palette (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> / <kbd>⌘</kbd>+<kbd>⇧</kbd>+<kbd>P</kbd>).
109+
2. Run **TypeScript Native Preview: Save Heap Profile**.
110+
3. Choose a directory to save the profile to.
111+
4. Attach the resulting `.pb.gz` file to your issue.
112+
113+
#### Collecting CPU Profiles
114+
115+
CPU profiles help diagnose hangs and slow operations:
116+
117+
1. Open the VS Code command palette.
118+
2. Run **TypeScript Native Preview: Start CPU Profile** and choose a directory.
119+
3. Reproduce the slow operation.
120+
4. Run **TypeScript Native Preview: Stop CPU Profile**.
121+
5. Attach the resulting `.pb.gz` file to your issue.

Herebyfile.mjs

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,14 @@ export const generate = task({
296296
},
297297
});
298298

299+
export const generateExtension = task({
300+
name: "generate:extension",
301+
description: "Generates files in the extension",
302+
run: async () => {
303+
await $`npm run -w _extension generateLocBundle`;
304+
},
305+
});
306+
299307
// ── Enum generation from Go source ──────────────────────────────
300308

301309
/**
@@ -304,7 +312,6 @@ export const generate = task({
304312
* goPrefix: string;
305313
* goFile: string;
306314
* outDir: string;
307-
* constEnum?: boolean;
308315
* }} EnumDef
309316
*/
310317

@@ -322,8 +329,9 @@ const enumDefs = [
322329
{ name: "NodeFlags", goPrefix: "NodeFlags", goFile: "internal/ast/nodeflags.go", outDir: "_packages/native-preview/src/enums" },
323330
{ name: "OuterExpressionKinds", goPrefix: "OEK", goFile: "internal/ast/utilities.go", outDir: "_packages/native-preview/src/enums" },
324331
{ name: "ModifierFlags", goPrefix: "ModifierFlags", goFile: "internal/ast/modifierflags.go", outDir: "_packages/native-preview/src/enums" },
325-
{ name: "TokenFlags", goPrefix: "TokenFlags", goFile: "internal/ast/tokenflags.go", outDir: "_packages/native-preview/src/enums", constEnum: true },
332+
{ name: "TokenFlags", goPrefix: "TokenFlags", goFile: "internal/ast/tokenflags.go", outDir: "_packages/native-preview/src/enums" },
326333
{ name: "NodeBuilderFlags", goPrefix: "Flags", goFile: "internal/nodebuilder/types.go", outDir: "_packages/native-preview/src/enums" },
334+
{ name: "CompletionItemKind", goPrefix: "CompletionItemKind", goFile: "internal/lsp/lsproto/lsp_generated.go", outDir: "_packages/native-preview/src/enums" },
327335
];
328336

329337
/**
@@ -442,9 +450,8 @@ function topoSortMembers(members) {
442450
function renderEnumTS(def, members) {
443451
const header = `// Code generated by Herebyfile.mjs generate:enums from ${def.goFile}. DO NOT EDIT.\n\n`;
444452

445-
const constKeyword = def.constEnum ? "const " : "";
446453
const lines = members.map(m => ` ${m.name} = ${m.value},`);
447-
return `${header}export ${constKeyword}enum ${def.name} {\n${lines.join("\n")}\n}\n`;
454+
return `${header}export enum ${def.name} {\n${lines.join("\n")}\n}\n`;
448455
}
449456

450457
async function runGenerateEnums() {
@@ -509,6 +516,34 @@ export const generateAST = task({
509516
run: () => $`node --experimental-strip-types --no-warnings ./_scripts/generate.ts`,
510517
});
511518

519+
// ── Vendored npm dependencies ───────────────────────────────────
520+
521+
const vendorJsonrpcDir = "_packages/native-preview/vendor/vscode-jsonrpc";
522+
const vendorJsonrpcSrc = "node_modules/vscode-jsonrpc";
523+
// Files copied verbatim from the installed vscode-jsonrpc package into the
524+
// vendored copy. Only the runtime files needed by the `#vscode-jsonrpc/node`
525+
// import (lib + typings + package.json) plus license/readme are vendored.
526+
const vendorJsonrpcFiles = ["package.json", "README.md", "License.txt", "lib", "typings"];
527+
528+
async function runGenerateVendor() {
529+
const src = path.join(__dirname, vendorJsonrpcSrc);
530+
const dest = path.join(__dirname, vendorJsonrpcDir);
531+
if (!fs.existsSync(src)) {
532+
throw new Error(`${vendorJsonrpcSrc} is not installed; run \`npm ci\` first.`);
533+
}
534+
await rimraf(dest);
535+
await fs.promises.mkdir(dest, { recursive: true });
536+
for (const file of vendorJsonrpcFiles) {
537+
await cpRecursive(path.join(src, file), path.join(dest, file));
538+
}
539+
}
540+
541+
export const generateVendor = task({
542+
name: "generate:vendor",
543+
description: "Updates the vendored copy of vscode-jsonrpc from node_modules.",
544+
run: runGenerateVendor,
545+
});
546+
512547
const coverageDir = path.join(__dirname, "coverage");
513548

514549
const ensureCoverageDirExists = memoize(() => {
@@ -1520,6 +1555,7 @@ async function runBuildNativePreviewPackages() {
15201555
const inputPackageJson = JSON.parse(fs.readFileSync(path.join(inputDir, "package.json"), "utf8"));
15211556
inputPackageJson.version = getVersion();
15221557
delete inputPackageJson.private;
1558+
inputPackageJson.files = [...new Set([...(inputPackageJson.files ?? []), "NOTICE.txt"])];
15231559
stripSourceConditions(inputPackageJson);
15241560

15251561
const { stdout: gitHead } = await $pipe`git rev-parse HEAD`;
@@ -1543,7 +1579,7 @@ async function runBuildNativePreviewPackages() {
15431579

15441580
await fs.promises.writeFile(path.join(mainPackageDir, "package.json"), JSON.stringify(mainPackage, undefined, 4));
15451581
await fs.promises.copyFile("LICENSE", path.join(mainPackageDir, "LICENSE"));
1546-
// No NOTICE.txt here; does not ship the binary or libs. If this changes, we should add it.
1582+
await fs.promises.copyFile("NOTICE.txt", path.join(mainPackageDir, "NOTICE.txt"));
15471583

15481584
// Build JS API and copy dist into the package.
15491585
await $`npm run -w @typescript/native-preview build`;
@@ -1579,6 +1615,7 @@ async function runBuildNativePreviewPackages() {
15791615
const packageJson = {
15801616
...inputPackageJson,
15811617
bin: undefined,
1618+
files: ["lib", "NOTICE.txt"],
15821619
imports: undefined,
15831620
scripts: undefined,
15841621
dependencies: undefined,

0 commit comments

Comments
 (0)