Skip to content

Commit e363a0b

Browse files
committed
Merge main and use getRangeOfNode helper
2 parents fb261c4 + 0487292 commit e363a0b

File tree

21,155 files changed

+502552
-613929
lines changed

Some content is hidden

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

21,155 files changed

+502552
-613929
lines changed

.custom-gcl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json
22

3-
version: v2.3.0
3+
version: v2.5.0
44

55
destination: ./_tools
66

.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.24", "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.8.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
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 'VS Code Editor Issue'
2+
description: 'Issue using tsgo in VS Code'
3+
labels: 'Domain: Editor'
4+
assignees: []
5+
body:
6+
- type: input
7+
id: extension_version
8+
attributes:
9+
label: Extension Version
10+
description: The version of the TypeScript (native preview) extension
11+
placeholder: '0.20251016.x'
12+
validations:
13+
required: true
14+
- type: input
15+
id: vscode_version
16+
attributes:
17+
label: VS Code Version
18+
description: The version of the VS Code you are using
19+
placeholder: '1.105.x'
20+
validations:
21+
required: true
22+
- type: input
23+
id: os_version
24+
attributes:
25+
label: Operating system Version
26+
description: Your operating system and version
27+
validations:
28+
required: true
29+
- type: textarea
30+
id: steps
31+
attributes:
32+
label: 'Steps to reproduce'
33+
description: |
34+
Information about how to reproduce the issue and expected behavior
35+
value: |
36+
1.
37+
2.
38+
3.
39+
validations:
40+
required: true
41+
- type: textarea
42+
id: bug_info
43+
attributes:
44+
label: 'Issue'
45+
description: |
46+
Information about the bug, such as expected vs actual behavior
47+
validations:
48+
required: true
File renamed without changes.
File renamed without changes.

.github/actions/setup-go/action.yml

Lines changed: 115 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,135 @@ description: Setup Go
44
inputs:
55
go-version:
66
description: Go version range to set up.
7-
default: '>=1.24.0'
8-
cache-name:
9-
description: Name of scoped cache for this set up.
10-
default: 'cache'
7+
default: '>=1.25.0'
8+
create:
9+
description: Create the cache
10+
default: 'false'
11+
lint-cache:
12+
description: Restore the golangci-lint cache
13+
default: 'false'
1114

1215
runs:
1316
using: composite
17+
1418
steps:
1519
- name: Install Go
1620
id: install-go
17-
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
21+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
1822
with:
1923
go-version: ${{ inputs.go-version }}
2024
cache: false
2125

22-
# There is more code downloaded and built than is covered by '**/go.sum',
23-
# so give each job its own cache to try and not end up sharing the wrong
24-
# cache between jobs, and hash the Herebyfile and golancgi-lint version.
26+
# Avoid hardcoding the cache keys more than once.
27+
- name: Get cache info
28+
shell: bash
29+
id: cache-info
30+
env:
31+
MODULES_KEY: go-modules-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }}
32+
LINT_KEY: golangci-lint-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/.custom-gcl.yml') }}
33+
BUILD_KEY: go-build-cache-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}
34+
run: |
35+
echo "modules-key=$MODULES_KEY" >> $GITHUB_OUTPUT
36+
echo "lint-key=$LINT_KEY" >> $GITHUB_OUTPUT
37+
echo "build-key=$BUILD_KEY" >> $GITHUB_OUTPUT
38+
echo "GOLANGCI_LINT_CACHE=$RUNNER_TEMP/golangci-lint-cache" >> $GITHUB_ENV
2539
26-
- name: Go cache
27-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
40+
- if: ${{ inputs.create != 'true' }}
41+
name: Restore Go modules
42+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
2843
with:
29-
key: ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs', '**/.custom-gcl.yml') }}-${{ github.workflow }}-${{ inputs.cache-name }}
30-
restore-keys: |
31-
ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs', '**/.custom-gcl.yml') }}-${{ github.workflow }}-
44+
key: ${{ steps.cache-info.outputs.modules-key }}
3245
path: |
3346
~/go/pkg/mod
47+
48+
- if: ${{ inputs.create != 'true' }}
49+
name: Restore Go build cache
50+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
51+
with:
52+
key: unused-key-${{ github.run_id }}
53+
restore-keys: ${{ steps.cache-info.outputs.build-key }}-
54+
path: |
3455
~/.cache/go-build
3556
~/Library/Caches/go-build
3657
~/AppData/Local/go-build
58+
59+
- if: ${{ inputs.create != 'true' && inputs.lint-cache == 'true' }}
60+
name: Restore golangci-lint cache
61+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
62+
with:
63+
key: unused-key-${{ github.run_id }}
64+
restore-keys: ${{ steps.cache-info.outputs.lint-key }}-
65+
path: ${{ env.GOLANGCI_LINT_CACHE }}
66+
67+
- name: Set mtimes
68+
shell: bash
69+
run: |
70+
find . -type f ! -path ./.git/\*\* | go run github.com/slsyy/mtimehash/cmd/mtimehash@v1.0.0 || true
71+
find . -type d ! -path ./.git/\*\* -exec touch -d '1970-01-01T00:00:01Z' {} + || true
72+
73+
# All steps below are only run if the cache is being created.
74+
75+
- if: ${{ inputs.create == 'true' }}
76+
shell: bash
77+
run: npm ci
78+
79+
- if: ${{ inputs.create == 'true' }}
80+
shell: bash
81+
run: |
82+
go mod download
83+
cd _tools
84+
go mod download
85+
86+
- if: ${{ inputs.create == 'true' }}
87+
shell: bash
88+
run: npx hereby build
89+
90+
- if: ${{ inputs.create == 'true' }}
91+
shell: bash
92+
id: setup-go-test
93+
run: npx hereby test
94+
95+
- if: ${{ failure() && inputs.create == 'true' && steps.setup-go-test.conclusion == 'failure' }}
96+
shell: bash
97+
run: git diff --diff-filter=AM --no-index ./testdata/baselines/reference ./testdata/baselines/local
98+
99+
- if: ${{ inputs.create == 'true' }}
100+
shell: bash
101+
run: npx hereby test --coverage
102+
103+
- if: ${{ inputs.create == 'true' }}
104+
shell: bash
105+
run: npx hereby lint
106+
107+
- if: ${{ inputs.create == 'true' }}
108+
shell: bash
109+
run: npx hereby lint --noembed
110+
111+
- if: ${{ inputs.create == 'true' }}
112+
shell: bash
113+
run: npx dprint check
114+
115+
- if: ${{ inputs.create == 'true' }}
116+
name: Save Go modules
117+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
118+
with:
119+
key: ${{ steps.cache-info.outputs.modules-key }}
120+
path: |
121+
~/go/pkg/mod
122+
123+
- if: ${{ inputs.create == 'true' }}
124+
name: Save Go build cache
125+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
126+
with:
127+
key: ${{ steps.cache-info.outputs.build-key }}-${{ github.run_id }}
128+
path: |
129+
~/.cache/go-build
130+
~/Library/Caches/go-build
131+
~/AppData/Local/go-build
132+
133+
- if: ${{ inputs.create == 'true' }}
134+
name: Save golangci-lint cache
135+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
136+
with:
137+
key: ${{ steps.cache-info.outputs.lint-key }}-${{ github.run_id }}
138+
path: ${{ env.GOLANGCI_LINT_CACHE }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Strada to Corsa Port Expert
3+
description: A Go and TypeScript expert who can easily figure out how to port PRs from one language to another
4+
---
5+
6+
This repository is a port of `microsoft/TypeScript` from TypeScript to Go. Since the port began, the following pull request was applied to microsoft/TypeScript. An equivalent change now needs to be applied here. The user will give you a link to the PR and you will need to try to port it to this repo.
7+
8+
Instructions
9+
- Use `curl` to fetch e.g. `https://api.github.com/repos/microsoft/typescript/pulls/59767` to view the merge commit SHA
10+
- Then use `curl` to fetch e.g. `https://github.com/microsoft/TypeScript/commit/bd3d70058c30253209199cc9dfeb85e72330d79b.patch` to download the diff patch
11+
- Use Playwright MCP if you have other information from github you need, since you won't have MCP access to the TypeScript repo
12+
- Apply the edits made in that PR to this codebase, translating them from TypeScript to Go.
13+
- The change may or may not be applicable. It may have already been ported. Do not make any significant changes outside the scope of the diff. If the change cannot be applied without significant out-of-scope changes, explain why and stop working.
14+
- Tip: search for functions and identifiers from the diff to find the right location to apply edits. Some files in microsoft/TypeScript have been split into multiple.
15+
- Tip: some changes have already been ported, like changes to diagnostic message text. Tests do not need to be ported as they are imported from the submodule.
16+
- Check that the code builds by running npx hereby build in the terminal.
17+
- Run tests. It is expected that tests will fail due to baseline changes.
18+
- Run `npx hereby test` in a terminal. They should fail with messages about baseline changes.
19+
- Tip: to run a single baseline test from the submodule, run go test ./internal/testrunner -run '^TestSubmodule/NAME_OF_TEST_FILE'
20+
- Run npx hereby baseline-accept to adopt the baseline changes.
21+
- Run git diff 'testdata/**/*.diff'. If your change is correct, these diff files will be reduced or completely deleted.
22+
- Iterate until you are satisfied with your change. Commit everything, including the baseline changes in testdata, and open a PR.

.github/copilot-instructions.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,34 @@ Most of our development takes place in the `internal` directory, and most behavi
99

1010
Most development on the codebase is in Go.
1111
Standard Go commands and practices apply, but we primarily use a tool called `hereby` to build, run tests, and other tasks.
12-
Run `npx hereby --list` to see all available commands.
12+
Run `npx hereby --tasks` to see all available commands.
1313

1414
```sh
15-
npx hereby build # Build the project
15+
npx hereby build # Build the tsgo binary (not required for tests)
1616
npx hereby test # Run tests
1717
npx hereby format # Format the code
1818
npx hereby lint # Run linters
1919

2020
# To run a specific compiler test:
21-
go test -run='TestSubmodule/<test name>' ./internal/testrunner # For submodule tests in _submodules/TypeScript
22-
go test -run='TestLocal/<test name>' ./internal/testrunner # For local tests in testdata/tests/cases
21+
go test -run='TestSubmodule/<test name>' ./internal/testrunner # For pre-existing "submodule" tests in _submodules/TypeScript
22+
go test -run='TestLocal/<test name>' ./internal/testrunner # For new "local" tests created in testdata/tests/cases
23+
```
24+
25+
Always make sure code is formatted, linted, and tested before sending a pull request.
26+
27+
<critical>
28+
YOU MUST RUN THESE COMMANDS AT THE END OF YOUR SESSION!
29+
IF THESE COMMANDS FAIL, CI WILL FAIL, AND YOUR PR WILL BE REJECTED OUT OF HAND.
30+
FIXING ERRORS FROM THESE COMMANDS IS YOUR HIGHEST PRIORITY.
31+
ENSURE YOU DO THE RIGHT THINGS TO MAKE THEM PASS.
32+
```sh
33+
npx hereby build # Build the project
34+
npx hereby test # Run tests
35+
npx hereby lint # Run linters
36+
npx hereby format # Format the code
2337
```
38+
</critical>
2439

25-
Always make sure code is formatted, linted, and tested before sending a pull request.
26-
2740
## Compiler Features, Fixes, and Tests
2841

2942
When fixing a bug or implementing a new feature, at least one minimal test case should always be added in advance to verify the fix.
@@ -56,10 +69,10 @@ export interface Person {
5669
function greet(person) {
5770
console.log(`Hello, ${person.name}!`);
5871
}
59-
```
60-
61-
**New compiler tests should always enable strict mode (`@strict: true`) unless the bug specifically involves non-strict mode behavior.**
62-
72+
```
73+
74+
**New compiler tests should always enable strict mode (`@strict: true`) unless the bug specifically involves non-strict mode behavior.**
75+
6376
Tests don't always need the above `@option`s specified, but they are common to specify or modify.
6477
Tests can be run with multiple settings for a given option by using a comma-separated list (e.g. `@option: settingA,settingB`).
6578
`@filename` is only required when a test has multiple files, or when writing a test for a single JavaScript file (where `allowJs` or `checkJs` is enabled).
@@ -96,4 +109,4 @@ The TypeScript submodule serves as the reference implementation for behavior and
96109
# Other Instructions
97110

98111
- Do not add or change existing dependencies unless asked to.
99-
112+
- Do not remove any debug assertions or panic calls. Existing assertions are never too strict or incorrect.

0 commit comments

Comments
 (0)