Skip to content

Commit c56f465

Browse files
authored
Merge branch 'main' into fix-go-to-def-2
2 parents 2c41fbe + 806c619 commit c56f465

File tree

386 files changed

+54999
-2256
lines changed

Some content is hidden

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

386 files changed

+54999
-2256
lines changed

.dprint.jsonc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@
3939
},
4040
"exec": {
4141
"cwd": "${configDir}",
42-
"cacheKey": "4",
4342
"commands": [
44-
{ "command": "go tool mvdan.cc/gofumpt -lang=go1.25", "exts": ["go"] }
43+
{ "command": "go tool mvdan.cc/gofumpt", "exts": ["go"], "cacheKeyFiles": ["go.mod"] }
4544
]
4645
},
4746
"excludes": [
@@ -59,9 +58,9 @@
5958
// Note: if adding new languages, make sure settings.template.json is updated too.
6059
// Also, if updating typescript, update the one in package.json.
6160
"plugins": [
62-
"https://plugins.dprint.dev/typescript-0.95.9.wasm",
61+
"https://plugins.dprint.dev/typescript-0.95.11.wasm",
6362
"https://plugins.dprint.dev/json-0.20.0.wasm",
6463
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
65-
"https://plugins.dprint.dev/exec-0.5.1.json@492414e39dea4dccc07b4af796d2f4efdb89e84bae2bd4e1e924c0cc050855bf"
64+
"https://plugins.dprint.dev/exec-0.6.0.json@a054130d458f124f9b5c91484833828950723a5af3f8ff2bd1523bd47b83b364"
6665
]
6766
}

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
runs-on: ubuntu-latest
2626
steps:
2727
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
28-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
28+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2929
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
3030
- uses: ./.github/actions/setup-go
3131

@@ -45,7 +45,7 @@ jobs:
4545
runs-on: ubuntu-latest
4646
steps:
4747
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
48-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
48+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
4949
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
5050

5151
- run: npm ci
@@ -105,7 +105,7 @@ jobs:
105105
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
106106
with:
107107
submodules: ${{ !matrix.config.no-submodules }}
108-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
108+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
109109
with:
110110
node-version: 'lts/*'
111111
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
@@ -142,7 +142,7 @@ jobs:
142142

143143
- run: git add .
144144

145-
- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
145+
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
146146
if: ${{ always() && matrix.config.coverage && github.event_name != 'merge_group' }}
147147
with:
148148
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}
@@ -192,7 +192,7 @@ jobs:
192192

193193
steps:
194194
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
195-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
195+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
196196
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
197197
- uses: ./.github/actions/setup-go
198198
with:
@@ -215,7 +215,7 @@ jobs:
215215
runs-on: ubuntu-latest
216216
steps:
217217
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
218-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
218+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
219219
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
220220
- uses: ./.github/actions/setup-go
221221

@@ -229,7 +229,7 @@ jobs:
229229
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
230230
with:
231231
submodules: true
232-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
232+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
233233
with:
234234
node-version: '>=22.16.0'
235235
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
@@ -263,7 +263,7 @@ jobs:
263263
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
264264
with:
265265
submodules: true
266-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
266+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
267267
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
268268
- uses: ./.github/actions/setup-go
269269

@@ -299,7 +299,7 @@ jobs:
299299
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
300300
with:
301301
submodules: true
302-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
302+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
303303
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
304304
- uses: ./.github/actions/setup-go
305305

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
# Initializes the CodeQL tools for scanning.
5050
- name: Initialize CodeQL
51-
uses: github/codeql-action/init@96f518a34f7a870018057716cc4d7a5c014bd61c # v3.29.5
51+
uses: github/codeql-action/init@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3.29.5
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@96f518a34f7a870018057716cc4d7a5c014bd61c # v3.29.5
61+
uses: github/codeql-action/autobuild@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3.29.5
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@96f518a34f7a870018057716cc4d7a5c014bd61c # v3.29.5
75+
uses: github/codeql-action/analyze@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3.29.5

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
2020
with:
2121
submodules: true
22-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
22+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2323
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
2424
- uses: ./.github/actions/setup-go
2525
with:

.github/workflows/create-cache.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
4040
with:
4141
submodules: true
42-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
42+
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
4343
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
4444

4545
- uses: ./.github/actions/setup-go

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Contributing
2+
3+
## How to Build and Run
4+
5+
This repo uses [Go 1.25 or higher](https://go.dev/dl/), [Rust 1.85 or higher](https://www.rust-lang.org/tools/install), [Node.js with npm](https://nodejs.org/), and [`hereby`](https://www.npmjs.com/package/hereby).
6+
7+
For tests and code generation, this repo contains a git submodule to the main TypeScript repo pointing to the commit being ported.
8+
When cloning, you'll want to clone with submodules:
9+
10+
```sh
11+
git clone --recurse-submodules https://github.com/microsoft/typescript-go.git
12+
```
13+
14+
If you have already cloned the repo, you can initialize the submodule with:
15+
16+
```sh
17+
git submodule update --init --recursive
18+
```
19+
20+
With the submodule in place and `npm ci`, you can run tasks via `hereby`, similar to the TypeScript repo:
21+
22+
```sh
23+
hereby build # Build the tsgo binary (not required for tests)
24+
hereby test # Run tests
25+
hereby format # Format the code
26+
hereby lint # Run linters
27+
hereby install-tools # Install additional tools such as linters
28+
hereby generate # Generate all Go code (e.g. diagnostics, committed to repo)
29+
```
30+
31+
Additional tasks are a work in progress.
32+
33+
`hereby` is not required to work on the repo; the regular `go` tooling (e.g., `go build`, `go test ./...`) will work as expected.
34+
`hereby` tasks are provided as a convenience for those familiar with the TypeScript repo.
35+
36+
### Running `tsgo`
37+
38+
After running `hereby build`, you can run `built/local/tsgo`, which behaves mostly the same as `tsc`.
39+
40+
### LSP Server
41+
42+
To debug and run the VS Code extension without installing it globally:
43+
44+
* Run VS Code in the repo workspace (`code .`)
45+
* Copy `.vscode/launch.template.json` to `.vscode/launch.json`
46+
* <kbd>F5</kbd> (or `Debug: Start Debugging` from the command palette)
47+
48+
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:
49+
50+
![LSP Server Screenshot](.github/ls-screenshot.png)

Herebyfile.mjs

Lines changed: 132 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,15 +751,16 @@ let signCount = 0;
751751
/**
752752
* @typedef {{
753753
* SignFileRecordList: {
754-
* SignFileList: { SrcPath: string; DstPath: string | null; }[];
754+
* SignFileList: { SrcPath: string; DstPath: string | null }[];
755755
* Certs: Cert;
756+
* MacAppName: string | undefined
756757
* }[]
757758
* }} DDSignFileList
758759
*
759760
* @param {DDSignFileList} filelist
760761
*/
761-
async function sign(filelist) {
762-
const data = JSON.stringify(filelist, undefined, 4);
762+
async function sign(filelist, unchangedOutputOkay = false) {
763+
let data = JSON.stringify(filelist, undefined, 4);
763764
console.log("filelist:", data);
764765

765766
if (!process.env.MBSIGN_APPFOLDER) {
@@ -802,6 +803,71 @@ async function sign(filelist) {
802803
return;
803804
}
804805

806+
const signingWorkaround = true;
807+
808+
/** @type {{ source: string; target: string }[]} */
809+
const signingWorkaroundFiles = [];
810+
811+
if (signingWorkaround) {
812+
// DstPath is currently broken in the signing tool.
813+
// Copy all of the files to a new tempdir and then leave DstPath unset
814+
// so that it's overwritten, then move the file to the destination.
815+
console.log("Working around DstPath bug");
816+
817+
/** @type {DDSignFileList} */
818+
const newFileList = {
819+
SignFileRecordList: filelist.SignFileRecordList.map(list => {
820+
return {
821+
Certs: list.Certs,
822+
SignFileList: list.SignFileList.map(file => {
823+
const dstPath = file.DstPath;
824+
if (dstPath === null) {
825+
return file;
826+
}
827+
828+
const src = file.SrcPath;
829+
// File extensions must be preserved; use a prefix.
830+
const dstPathTemp = `${path.dirname(src)}/signing-temp-${path.basename(src)}`;
831+
832+
console.log(`Copying: ${src} -> ${dstPathTemp}`);
833+
fs.cpSync(src, dstPathTemp);
834+
835+
signingWorkaroundFiles.push({ source: dstPathTemp, target: dstPath });
836+
837+
return {
838+
SrcPath: dstPathTemp,
839+
DstPath: null,
840+
};
841+
}),
842+
MacAppName: list.MacAppName,
843+
};
844+
}),
845+
};
846+
847+
data = JSON.stringify(newFileList, undefined, 4);
848+
console.log("new filelist:", data);
849+
}
850+
851+
/** @type {Map<string, string>} */
852+
const srcHashes = new Map();
853+
854+
for (const record of filelist.SignFileRecordList) {
855+
for (const file of record.SignFileList) {
856+
const src = file.SrcPath;
857+
const dst = file.DstPath ?? src;
858+
859+
if (!fs.existsSync(src)) {
860+
throw new Error(`Source file does not exist: ${src}`);
861+
}
862+
863+
const hash = crypto.createHash("sha256").update(fs.readFileSync(src)).digest("hex");
864+
srcHashes.set(src, hash);
865+
866+
console.log(`Will sign ${src} -> ${dst}`);
867+
console.log(` sha256: ${hash}`);
868+
}
869+
}
870+
805871
const tmp = await getSignTempDir();
806872
const filelistPath = path.resolve(tmp, `signing-filelist-${signCount++}.json`);
807873
await fs.promises.writeFile(filelistPath, data);
@@ -814,6 +880,61 @@ async function sign(filelist) {
814880
finally {
815881
await fs.promises.unlink(filelistPath);
816882
}
883+
884+
if (signingWorkaround) {
885+
// Now, copy the files back.
886+
for (const { source, target } of signingWorkaroundFiles) {
887+
console.log(`Moving signed file: ${source} -> ${target}`);
888+
await fs.promises.rename(source, target);
889+
}
890+
}
891+
892+
/** @type {string[]} */
893+
let failures = [];
894+
895+
for (const record of filelist.SignFileRecordList) {
896+
for (const file of record.SignFileList) {
897+
const src = file.SrcPath;
898+
const dst = file.DstPath ?? src;
899+
900+
if (!fs.existsSync(dst)) {
901+
failures.push(`Signed file does not exist: ${dst}`);
902+
const newSrcHash = crypto.createHash("sha256").update(fs.readFileSync(src)).digest("hex");
903+
const oldSrcHash = srcHashes.get(src);
904+
assert(oldSrcHash);
905+
if (oldSrcHash !== newSrcHash) {
906+
failures.push(` Source file changed during signing: ${src}\n before: ${oldSrcHash}\n after: ${newSrcHash}`);
907+
}
908+
continue;
909+
}
910+
911+
const srcHash = srcHashes.get(src);
912+
assert(srcHash);
913+
const dstHash = crypto.createHash("sha256").update(fs.readFileSync(dst)).digest("hex");
914+
if (srcHash === dstHash) {
915+
const message = `Signed file is identical to source file (not signed?): ${src} -> ${dst}\n sha256: ${dstHash}`;
916+
if (unchangedOutputOkay) {
917+
console.log(message);
918+
}
919+
else {
920+
failures.push(message);
921+
continue;
922+
}
923+
}
924+
925+
if (src === dst) {
926+
console.log(`Signed ${src}`);
927+
}
928+
else {
929+
console.log(`Signed ${src} -> ${dst}`);
930+
}
931+
console.log(` sha256: ${dstHash}`);
932+
}
933+
}
934+
935+
if (failures.length) {
936+
throw new Error("Some files failed to sign:\n" + failures.map(f => " - " + f).join("\n"));
937+
}
817938
}
818939

819940
/**
@@ -1065,12 +1186,14 @@ export const signNativePreviewPackages = task({
10651186
filelist.SignFileRecordList.push({
10661187
SignFileList: filelistPaths.map(p => ({ SrcPath: p.path, DstPath: null })),
10671188
Certs: cert,
1189+
MacAppName: undefined,
10681190
});
10691191
break;
10701192
case "LinuxSign":
10711193
filelist.SignFileRecordList.push({
10721194
SignFileList: filelistPaths.map(p => ({ SrcPath: p.path, DstPath: p.path + ".sig" })),
10731195
Certs: cert,
1196+
MacAppName: undefined,
10741197
});
10751198
break;
10761199
case "MacDeveloperHarden":
@@ -1095,6 +1218,7 @@ export const signNativePreviewPackages = task({
10951218
filelist.SignFileRecordList.push({
10961219
SignFileList: macZips.map(p => ({ SrcPath: p.unsignedZipPath, DstPath: p.signedZipPath })),
10971220
Certs: cert,
1221+
MacAppName: undefined, // MacAppName is only for notarization
10981222
});
10991223
break;
11001224
default:
@@ -1115,11 +1239,14 @@ export const signNativePreviewPackages = task({
11151239
{
11161240
SignFileList: macZips.map(p => ({ SrcPath: p.signedZipPath, DstPath: p.notarizedZipPath })),
11171241
Certs: "8020", // "MacNotarize" (friendly name not supported by the tooling)
1242+
MacAppName: "MicrosoftTypeScript",
11181243
},
11191244
],
11201245
};
11211246

1122-
await sign(notarizeFilelist);
1247+
// Notarizing does not change the file, it just sends it to Apple, so ignore the case
1248+
// where the input files are the same as the output files.
1249+
await sign(notarizeFilelist, /*unchangedOutputOkay*/ true);
11231250

11241251
// Finally, unzip the notarized files and move them back to their original locations.
11251252

@@ -1234,6 +1361,7 @@ export const signNativePreviewExtensions = task({
12341361
{
12351362
SignFileList: extensions.map(({ vsixSignaturePath }) => ({ SrcPath: vsixSignaturePath, DstPath: null })),
12361363
Certs: "VSCodePublisher",
1364+
MacAppName: undefined,
12371365
},
12381366
],
12391367
});

0 commit comments

Comments
 (0)