Skip to content

Commit 5c265b5

Browse files
committed
Merge branch 'main' into jabaile/symbol-tweaks
2 parents 11ff08e + 3d33f0e commit 5c265b5

File tree

23,790 files changed

+1105347
-711355
lines changed

Some content is hidden

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

23,790 files changed

+1105347
-711355
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.0.2
3+
version: v2.4.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.7.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/ISSUE_TEMPLATE/01-crash.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Crash
3+
about: Using tsgo or the language server caused a panic
4+
title: ''
5+
labels: Crash
6+
assignees: ''
7+
8+
---
9+
10+
## Stack trace
11+
12+
```
13+
[paste stack trace here]
14+
```
15+
16+
## Steps to reproduce
17+
18+
1.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Behavior Difference
3+
about: tsgo produces different results than TypeScript 5.8
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## Steps to reproduce
11+
12+
<!-- Share a repository link or a code sample -->
13+
14+
## Behavior with `[email protected]`
15+
16+
## Behavior with `tsgo`

.github/ISSUE_TEMPLATE/03-other.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Other
3+
about: Something else
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: '[TypeScript Team Use] Copilot PR porting'
3+
about: Instructions for Copilot to port a PR from microsoft/TypeScript
4+
title: 'Port TypeScript PR #[NNNNN]'
5+
labels: Porting PR
6+
assignees: ''
7+
8+
---
9+
10+
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.
11+
12+
## PR to port
13+
14+
- PR link: <!-- https://github.com/microsoft/TypeScript/pull/NNNNN -->
15+
- Squash commit diff: <!-- Copy the squash commit link and append ".patch", e.g. https://github.com/microsoft/TypeScript/commit/a271797c1a95494e5f7aa8075c01941ad25cad08.patch -->
16+
17+
## Instructions
18+
19+
1. Use `playwright` to view the PR listed above
20+
2. Apply the edits made in that PR to this codebase, translating them from TypeScript to Go.
21+
- 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.
22+
- 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.
23+
- 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.
24+
3. Refer to your copilot_instructions.md for guidance on how to build and test your change. Note the following differences to the typical development workflow:
25+
- Since you are porting the implementation for a behavior that already has tests in the submodule, you don't need to add new tests. Instead, your change should change existing baselines.
26+
- If done correctly, you should see removals in `.diff` baselines. These `.diff` removals are your ultimate source of truth: your change is not correct unless diffs are reduced.

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

Lines changed: 116 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +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-
- name: Go cache
23-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
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
39+
40+
- if: ${{ inputs.create != 'true' }}
41+
name: Restore Go modules
42+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
43+
with:
44+
key: ${{ steps.cache-info.outputs.modules-key }}
45+
path: |
46+
~/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: |
55+
~/.cache/go-build
56+
~/Library/Caches/go-build
57+
~/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/[email protected] || 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
24118
with:
25-
# There is more code downloaded and built than is covered by '**/go.sum',
26-
# so give each job its own cache to try and not end up sharing the wrong
27-
# cache between jobs.
28-
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 }}
29-
restore-keys: |
30-
ts-setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum', '**/Herebyfile.mjs', '**/.custom-gcl.yml') }}
119+
key: ${{ steps.cache-info.outputs.modules-key }}
31120
path: |
32121
~/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: |
33129
~/.cache/go-build
34130
~/Library/Caches/go-build
35131
~/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 }}

.github/codeql/codeql-configuration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ query-filters:
99
# This query takes too long on complicated string manipulations
1010
- exclude:
1111
id: go/unsafe-quoting
12+
# Times out in our code.
13+
- exclude:
14+
id: go/allocation-size-overflow

.github/copilot-instructions.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
This is the codebase for a native port of the TypeScript compiler and language server.
2+
The source directories of interest that we have are:
3+
4+
- `internal` - Contains the compiler and language server code.
5+
- `_extension` - Contains a preview VS Code extension code that integrates with the language server.
6+
- `_submodules/TypeScript` - the stable TypeScript repository, checked out at the appropriate commit.
7+
8+
Most of our development takes place in the `internal` directory, and most behaviors can be tested via compiler tests.
9+
10+
Most development on the codebase is in Go.
11+
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 --tasks` to see all available commands.
13+
14+
```sh
15+
npx hereby build # Build the tsgo binary (not required for tests)
16+
npx hereby test # Run tests
17+
npx hereby format # Format the code
18+
npx hereby lint # Run linters
19+
20+
# To run a specific compiler test:
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+
## Compiler Features, Fixes, and Tests
28+
29+
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.
30+
This project primarily uses snapshot/baseline/golden tests rather than unit tests.
31+
New compiler tests are written in `.ts`/`.tsx` files in the directory `testdata/tests/cases/compiler/`, and are written in the following format:
32+
33+
**Note:** Issues with editor features cannot be tested with compiler tests in `testdata/tests/cases/`. Editor functionality requires integration testing with the language server.
34+
35+
```ts
36+
// @target: esnext
37+
// @module: preserve
38+
// @moduleResolution: bundler
39+
// @strict: true
40+
// @checkJs: true
41+
42+
// @filename: fileA.ts
43+
44+
export interface Person {
45+
name: string;
46+
age: number;
47+
}
48+
49+
// @filename: fileB.js
50+
51+
/** @import { Person } from "./fileA" */
52+
53+
/**
54+
* @param {Person} person
55+
*/
56+
function greet(person) {
57+
console.log(`Hello, ${person.name}!`);
58+
}
59+
```
60+
61+
**New compiler tests should always enable strict mode (`@strict: true`) unless the bug specifically involves non-strict mode behavior.**
62+
63+
Tests don't always need the above `@option`s specified, but they are common to specify or modify.
64+
Tests can be run with multiple settings for a given option by using a comma-separated list (e.g. `@option: settingA,settingB`).
65+
`@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).
66+
You can see more tests in `_submodules/TypeScript/tests/cases/{compiler,conformance}`.
67+
68+
When tests are run, they will produce output files in the `testdata/baselines/local` directory.
69+
**Test failures are fine** if they are just differences in output files.
70+
A reduction/removal of `.diff` file baselines is **ideal** because it indicates the port has converged in behavior with the stable TypeScript codebase.
71+
The new outputs can be diffed against `testdata/baselines/reference` to see if the output has changed.
72+
73+
Running
74+
75+
```sh
76+
npx hereby baseline-accept
77+
```
78+
79+
will update the baselines/snapshots, and `git diff` can be used to see what has changed.
80+
81+
It is ideal to implement features and fixes in the following order, and commit code after each step:
82+
83+
1. Write a minimal test case, or test cases, that demonstrate the bug or feature.
84+
1. Run the tests to ensure it fails (for a bug) or passes (for a feature). Then accept generated baselines (not applicable in the case of a crash).
85+
1. Implement the fix or feature.
86+
1. Run the tests again to ensure everything is working correctly. Accept the baselines.
87+
88+
It is fine to implement more and more of a feature across commits, but be sure to update baselines every time so that reviewers can measure progress.
89+
90+
## Code Porting Reference
91+
92+
The code in `internal` is ported from the code in `_submodules/TypeScript`.
93+
When implementing features or fixing bugs, those files should be searched for similar functions when code is either missing or potentially wrong.
94+
The TypeScript submodule serves as the reference implementation for behavior and functionality.
95+
96+
# Other Instructions
97+
98+
- Do not add or change existing dependencies unless asked to.
99+

0 commit comments

Comments
 (0)