Skip to content

Commit de20274

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/typescript-go into fix/1374
2 parents d1c76ce + 6d4ae18 commit de20274

File tree

2,663 files changed

+713033
-48802
lines changed

Some content is hidden

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

2,663 files changed

+713033
-48802
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.3.0
44

55
destination: ./_tools
66

.dprint.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
// Note: if adding new languages, make sure settings.template.json is updated too.
6060
// Also, if updating typescript, update the one in package.json.
6161
"plugins": [
62-
"https://plugins.dprint.dev/typescript-0.95.7.wasm",
62+
"https://plugins.dprint.dev/typescript-0.95.8.wasm",
6363
"https://plugins.dprint.dev/json-0.20.0.wasm",
6464
"https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.1.wasm",
6565
"https://plugins.dprint.dev/exec-0.5.1.json@492414e39dea4dccc07b4af796d2f4efdb89e84bae2bd4e1e924c0cc050855bf"

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

Lines changed: 108 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ inputs:
55
go-version:
66
description: Go version range to set up.
77
default: '>=1.24.0'
8-
cache-name:
9-
description: Name of scoped cache for this set up.
10-
default: 'cache'
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
@@ -19,18 +23,111 @@ runs:
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
39+
40+
- if: ${{ inputs.create != 'true' }}
41+
name: Restore Go modules
42+
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
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@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
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@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
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
2572
26-
- name: Go cache
27-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
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+
run: npx hereby test
93+
94+
- if: ${{ inputs.create == 'true' }}
95+
shell: bash
96+
run: npx hereby test --coverage
97+
98+
- if: ${{ inputs.create == 'true' }}
99+
shell: bash
100+
run: npx hereby lint
101+
102+
- if: ${{ inputs.create == 'true' }}
103+
shell: bash
104+
run: npx hereby lint --noembed
105+
106+
- if: ${{ inputs.create == 'true' }}
107+
shell: bash
108+
run: npx dprint check
109+
110+
- if: ${{ inputs.create == 'true' }}
111+
name: Save Go modules
112+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
28113
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 }}-
114+
key: ${{ steps.cache-info.outputs.modules-key }}
32115
path: |
33116
~/go/pkg/mod
117+
118+
- if: ${{ inputs.create == 'true' }}
119+
name: Save Go build cache
120+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
121+
with:
122+
key: ${{ steps.cache-info.outputs.build-key }}-${{ github.run_id }}
123+
path: |
34124
~/.cache/go-build
35125
~/Library/Caches/go-build
36126
~/AppData/Local/go-build
127+
128+
- if: ${{ inputs.create == 'true' }}
129+
name: Save golangci-lint cache
130+
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
131+
with:
132+
key: ${{ steps.cache-info.outputs.lint-key }}-${{ github.run_id }}
133+
path: ${{ env.GOLANGCI_LINT_CACHE }}

.github/copilot-instructions.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ export interface Person {
5656
function greet(person) {
5757
console.log(`Hello, ${person.name}!`);
5858
}
59-
```
60-
59+
```
60+
61+
**New compiler tests should always enable strict mode (`@strict: true`) unless the bug specifically involves non-strict mode behavior.**
62+
6163
Tests don't always need the above `@option`s specified, but they are common to specify or modify.
6264
Tests can be run with multiple settings for a given option by using a comma-separated list (e.g. `@option: settingA,settingB`).
6365
`@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).

.github/workflows/ci.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2929
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
3030
- uses: ./.github/actions/setup-go
31-
with:
32-
cache-name: build
3331

3432
# Avoid duplicate PR annotations.
3533
- name: Disable PR annotations
@@ -112,8 +110,6 @@ jobs:
112110
node-version: 'lts/*'
113111
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
114112
- uses: ./.github/actions/setup-go
115-
with:
116-
cache-name: test
117113

118114
# Avoid duplicate PR annotations.
119115
- if: ${{ ! matrix.config.main }}
@@ -200,7 +196,7 @@ jobs:
200196
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
201197
- uses: ./.github/actions/setup-go
202198
with:
203-
cache-name: lint${{ (matrix.config.noembed && '-noembed') || ''}}
199+
lint-cache: 'true'
204200

205201
# Avoid duplicate PR annotations.
206202
- if: ${{ ! matrix.config.main }}
@@ -222,8 +218,6 @@ jobs:
222218
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
223219
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
224220
- uses: ./.github/actions/setup-go
225-
with:
226-
cache-name: format
227221

228222
- run: npm ci
229223

@@ -240,15 +234,13 @@ jobs:
240234
node-version: '>=22.16.0'
241235
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
242236
- uses: ./.github/actions/setup-go
243-
with:
244-
cache-name: generate
245237

246238
- run: npm ci
247239

248240
- run: npx hereby generate
249241

250-
- run: node ./internal/lsp/lsproto/_generate/fetchModel.mjs
251-
- run: node ./internal/lsp/lsproto/_generate/generate.mjs
242+
- run: node --experimental-strip-types ./internal/lsp/lsproto/_generate/fetchModel.mts
243+
- run: node --experimental-strip-types ./internal/lsp/lsproto/_generate/generate.mts
252244

253245
- name: Regenerate fourslash tests and update failing test list
254246
run: npm run updatefailing
@@ -261,8 +253,6 @@ jobs:
261253
steps:
262254
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
263255
- uses: ./.github/actions/setup-go
264-
with:
265-
cache-name: tidy
266256

267257
- run: go mod tidy -diff
268258
- run: go -C ./_tools mod tidy -diff
@@ -276,8 +266,6 @@ jobs:
276266
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
277267
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
278268
- uses: ./.github/actions/setup-go
279-
with:
280-
cache-name: smoke
281269

282270
# Avoid duplicate PR annotations.
283271
- name: Disable PR annotations
@@ -302,8 +290,6 @@ jobs:
302290
steps:
303291
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
304292
- uses: ./.github/actions/setup-go
305-
with:
306-
cache-name: misc
307293

308294
- run: go -C ./_tools run ./cmd/checkmodpaths $PWD
309295

@@ -316,8 +302,6 @@ jobs:
316302
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
317303
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
318304
- uses: ./.github/actions/setup-go
319-
with:
320-
cache-name: baselines
321305

322306
- run: npm ci
323307

.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@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
51+
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 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@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
61+
uses: github/codeql-action/autobuild@51f77329afa6477de8c49fc9c7046c15b9a4e79d # 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@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
75+
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ jobs:
2525
with:
2626
# Updated to 1.25.0-rc.1 to improve compilation time
2727
go-version: '>=1.25.0-rc.1'
28-
cache-name: copilot-setup-steps
28+
lint-cache: 'true'
2929
- run: npm i -g @playwright/[email protected]
3030
- run: npm ci
3131
# pull dprint caches before network access is blocked
3232
- run: npx hereby check:format || true
33-
# cache build and lint operations
34-
- run: npx hereby build || true
35-
- run: npx hereby lint || true

.github/workflows/create-cache.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Create CI cache
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
schedule:
9+
# Run every day at 10:00 UTC / 03:00 PST
10+
- cron: '0 10 * * *'
11+
12+
permissions:
13+
contents: read
14+
15+
# Ensure scripts are run with pipefail. See:
16+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
jobs:
22+
cache:
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
os:
27+
- ubuntu-latest
28+
- windows-latest
29+
- macos-latest
30+
go-version:
31+
- '>=1.24.0'
32+
33+
include:
34+
# Temporary for the Copilot setup steps
35+
- os: ubuntu-latest
36+
go-version: '>=1.25.0-rc.1'
37+
38+
runs-on: ${{ matrix.os }}
39+
40+
steps:
41+
- run: git config --system core.longpaths true
42+
if: ${{ matrix.os == 'windows-latest' }}
43+
44+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45+
with:
46+
submodules: true
47+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
48+
- uses: dtolnay/rust-toolchain@fcf085fcb4b4b8f63f96906cd713eb52181b5ea4 # stable
49+
50+
- uses: ./.github/actions/setup-go
51+
with:
52+
go-version: ${{ matrix.go-version }}
53+
create: 'true'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,4 @@ custom-gcl.hash
198198
!NOTICE.txt
199199

200200
!internal/fourslash/_scripts/failingTests.txt
201+
!internal/fourslash/_scripts/manualTests.txt

.golangci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ linters:
1515
- canonicalheader
1616
- copyloopvar
1717
- customlint
18+
- depguard
1819
- durationcheck
1920
- errcheck
2021
- errchkjson
@@ -62,10 +63,18 @@ linters:
6263
customlint:
6364
type: module
6465

66+
depguard:
67+
rules:
68+
main:
69+
deny:
70+
- pkg: 'encoding/json$'
71+
desc: 'Use "github.com/go-json-experiment/json" instead.'
72+
6573
exclusions:
6674
rules:
6775
- path: internal/fourslash/tests/gen/
68-
linters: misspell
76+
linters:
77+
- misspell
6978

7079
presets:
7180
- comments

0 commit comments

Comments
 (0)