Skip to content

Commit 606bc4b

Browse files
authored
Merge branch 'main' into copilot/fix-61714-2
2 parents 88c9bfa + c6a1812 commit 606bc4b

File tree

290 files changed

+26124
-6097
lines changed

Some content is hidden

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

290 files changed

+26124
-6097
lines changed

.github/copilot-instructions.md

Lines changed: 71 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
# TypeScript Test Writing Guide for Copilot
1+
# Guide for Copilot
22

33
This document provides a concise guide for writing TypeScript fourslash tests and compiler tests, along with build instructions.
44

55
## Build Instructions Summary
66

77
### Setup
88
1. Install Node.js (current or LTS)
9-
2. Install hereby: `npm install -g hereby`
10-
3. Clone the repository: `git clone --depth=1 https://github.com/microsoft/TypeScript`
11-
4. Install dependencies: `npm ci`
9+
2. Clone the repository: `git clone --depth=1 https://github.com/microsoft/TypeScript`
10+
3. Install dependencies: `npm ci`
1211

1312
### Common Build Tasks
1413
```bash
15-
hereby local # Build the compiler into built/local
16-
hereby clean # Delete the built compiler
17-
hereby tests # Build the test infrastructure
18-
hereby runtests # Run all tests
19-
hereby runtests-parallel # Run tests in parallel (recommended)
20-
hereby runtests --runner=fourslash # Run only fourslash tests
21-
hereby runtests --runner=compiler # Run only compiler tests
22-
hereby runtests --tests=<testPath> # Run specific test
23-
hereby baseline-accept # Accept new test baselines
24-
hereby lint # Run eslint
25-
hereby format # Run code formatting
14+
npx hereby local # Build the compiler into built/local
15+
npx hereby clean # Delete the built compiler
16+
npx hereby tests # Build the test infrastructure
17+
npx hereby runtests # Run all tests
18+
npx hereby runtests-parallel # Run tests in parallel 🚨 MANDATORY BEFORE FINISHING!
19+
npx hereby runtests --runner=fourslash # Run only fourslash tests
20+
npx hereby runtests --runner=compiler # Run only compiler tests
21+
npx hereby runtests --tests=<testPath> # Run specific test
22+
npx hereby baseline-accept # Accept new test baselines
23+
npx hereby lint # Run eslint 🚨 MANDATORY BEFORE FINISHING!
24+
npx hereby format # Run code formatting 🚨 MANDATORY BEFORE FINISHING!
2625
```
2726

2827
## Fourslash Test Syntax Guide
@@ -248,30 +247,69 @@ const config3: Config = { optional: 42 }; // Should error - missing required
248247

249248
```bash
250249
# Run a specific fourslash test
251-
hereby runtests --tests=tests/cases/fourslash/completionForObjectProperty.ts
250+
npx hereby runtests --tests=tests/cases/fourslash/completionForObjectProperty.ts
252251

253252
# Run a specific compiler test
254-
hereby runtests --tests=tests/cases/compiler/abstractClassUnionInstantiation.ts
253+
npx hereby runtests --tests=tests/cases/compiler/abstractClassUnionInstantiation.ts
255254

256255
# Run tests matching a pattern
257-
hereby runtests --tests=tests/cases/fourslash/completion*.ts
256+
npx hereby runtests --tests=tests/cases/fourslash/completion*.ts
258257
```
259258

260259
## Important Guidelines
261260

261+
### 🚨 CRITICAL: Before Finishing Your Work 🚨
262+
263+
**THESE STEPS ARE MANDATORY BEFORE COMMITTING/PUSHING ANY CHANGES:**
264+
265+
1. **MUST RUN:** `npx hereby runtests-parallel` (even though it takes 10-15 minutes)
266+
2. **MUST RUN:** `npx hereby lint` and fix ALL lint issues
267+
3. **MUST RUN:** `npx hereby format` as the final step
268+
269+
**❌ PRs that fail these checks will be rejected without review.**
270+
271+
### Keeping Things Tidy
272+
273+
- You can assume lint, tests, and formatting are clean on a fresh clone
274+
- Only run these verification steps AFTER making changes to code
275+
- Run `npx hereby lint` and fix ALL issues after making changes
276+
- Run `npx hereby format` as your final step after making changes
277+
262278
### Test Locations
279+
263280
- Only add testcases in `tests/cases/compiler` or `tests/cases/fourslash`
281+
- Filenames in `tests/cases/compiler` must always end with `.ts`, not `.d.ts`
264282
- Do not write direct unit tests as they are almost never the correct test format for our repo
265283

266284
### Performance Expectations
285+
267286
- Running a set of tests may take up to 4 minutes
268287
- A full test run may take up to 15 minutes
269-
- Always run `hereby lint` and `hereby format` before you're done
270288

271289
### Working with Issues
290+
272291
- Maintainer comments in the issue should generally take priority over OP's comments
273292
- Maintainers might give you hints on where to start. They are not always right, but a good place to start
274293

294+
### Debugging Tips
295+
296+
printf debugging is going to be very useful as you are figuring things out.
297+
To do this, use `console.log`, but you'll need to `ts-ignore` it.
298+
Write something like this:
299+
```ts,diff
300+
function checkSomething(n: Node) {
301+
doSomething(n);
302+
+ // @ts-ignore DEBUG CODE ONLY, REMOVE ME WHEN DONE
303+
+ console.log(`Got node with pos = ${n.pos}`);
304+
doSomethingElse(n);
305+
}
306+
```
307+
We have a lot of enums so you might want to print back their symbolic name, to do this, index back into the name of the enum
308+
```ts
309+
// @ts-ignore DEBUG CODE ONLY, REMOVE ME WHEN DONE
310+
console.log(`Got node with kind = ${SyntaxKind[n.kind]}`);
311+
```
312+
275313
## Recommended Workflow
276314

277315
When fixing bugs or implementing features, follow this workflow:
@@ -287,6 +325,18 @@ When fixing bugs or implementing features, follow this workflow:
287325
- Ensure the baselines change in a way that demonstrates that the bug is fixed
288326
- Put this baseline diff in its own commit
289327

290-
4. **Run all other tests to ensure you didn't break anything**
291-
- Some collateral baseline changes are normal
328+
4. **Add more testing**
329+
- Once you've got the basics figured out, enhance your test to cover edge cases and other variations
330+
- Run the test again and commit the baseline diff along with the test edit
331+
332+
5. **🚨 MANDATORY: Run all other tests to ensure you didn't break anything**
333+
- **REQUIRED:** Run `npx hereby runtests-parallel` and wait for it to finish (10-15 minutes is normal!)
334+
- **THIS STEP CANNOT BE SKIPPED** - patience is essential!
335+
- Some collateral baseline changes are normal, but review for correctness
292336
- Put these diffs in another commit
337+
338+
6. **🚨 MANDATORY: Lint and format your changes**
339+
- **REQUIRED:** Run `npx hereby lint` and fix ALL issues
340+
- **REQUIRED:** Run `npx hereby format` before you're done
341+
- **YOU CANNOT FINISH WITHOUT THESE STEPS**
342+
- Double-check your line endings. Source files in this repo typically use CRLF line endings. Fix all line endings to be consistent before you wrap up

.github/workflows/accept-baselines-fix-lints.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Accept Baselines and Fix Lints
1+
name: Accept Baselines, Fix Lints, and Format
22

33
on:
44
workflow_dispatch: {}
@@ -32,8 +32,9 @@ jobs:
3232
git rm -r --quiet tests/baselines/reference
3333
npx hereby runtests-parallel --ci --fix || true
3434
npx hereby baseline-accept
35+
npx hereby format
3536
git add ./src
3637
git add ./tests/baselines/reference
3738
git diff --cached
38-
git commit -m "Update Baselines and/or Applied Lint Fixes"
39+
git commit -m "Update Baselines, Applied Lint Fixes, and/or Formatted"
3940
git push

.github/workflows/ci.yml

Lines changed: 120 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
branches:
1010
- main
1111
- release-*
12+
merge_group:
13+
branches:
14+
- main
15+
# - release-*
1216

1317
permissions:
1418
contents: read
@@ -24,43 +28,107 @@ jobs:
2428
strategy:
2529
fail-fast: false
2630
matrix:
27-
os:
28-
- ubuntu-latest
29-
- windows-latest
30-
- macos-latest
31-
node-version:
32-
- '22'
33-
- '20'
34-
- '18'
35-
- '16'
36-
- '14'
37-
bundle:
38-
- 'true'
39-
include:
40-
- node-version: 'lts/*'
31+
config:
32+
# Main builds
33+
- os: ubuntu-latest
34+
node-version: '24'
35+
bundle: true
36+
37+
# Other builds (skipped in merge queues)
38+
- os: windows-latest
39+
node-version: '24'
40+
bundle: true
41+
skip: ${{ github.event_name == 'merge_group' }}
42+
- os: macos-latest
43+
node-version: '24'
44+
bundle: true
45+
skip: ${{ github.event_name == 'merge_group' }}
46+
- os: ubuntu-latest
47+
node-version: '22'
48+
bundle: true
49+
- os: windows-latest
50+
node-version: '22'
51+
bundle: true
52+
skip: ${{ github.event_name == 'merge_group' }}
53+
# Skip macOS for this version; resources are limited.
54+
# - os: macos-latest
55+
# node-version: '22'
56+
# bundle: true
57+
# skip: ${{ github.event_name == 'merge_group' }}
58+
- os: ubuntu-latest
59+
node-version: '20'
60+
bundle: true
61+
- os: windows-latest
62+
node-version: '20'
63+
bundle: true
64+
skip: ${{ github.event_name == 'merge_group' }}
65+
# Skip macOS for this version; resources are limited.
66+
# - os: macos-latest
67+
# node-version: '20'
68+
# bundle: true
69+
# skip: ${{ github.event_name == 'merge_group' }}
70+
- os: ubuntu-latest
71+
node-version: '18'
72+
bundle: true
73+
- os: windows-latest
74+
node-version: '18'
75+
bundle: true
76+
skip: ${{ github.event_name == 'merge_group' }}
77+
# Skip macOS for this version; resources are limited.
78+
# - os: macos-latest
79+
# node-version: '18'
80+
# bundle: true
81+
# skip: ${{ github.event_name == 'merge_group' }}
82+
- os: ubuntu-latest
83+
node-version: '16'
84+
bundle: true
85+
- os: windows-latest
86+
node-version: '16'
87+
bundle: true
88+
skip: ${{ github.event_name == 'merge_group' }}
89+
- os: macos-latest
90+
node-version: '16'
91+
bundle: true
92+
skip: ${{ github.event_name == 'merge_group' }}
93+
- os: ubuntu-latest
94+
node-version: '14'
95+
bundle: true
96+
skip: ${{ github.event_name == 'merge_group' }}
97+
- os: windows-latest
98+
node-version: '14'
99+
bundle: true
100+
skip: ${{ github.event_name == 'merge_group' }}
101+
# No Node 14 on ARM macOS
102+
# - os: macos-latest
103+
# node-version: '14'
104+
# bundle: true
105+
# skip: ${{ github.event_name == 'merge_group' }}
106+
107+
- os: ubuntu-latest
108+
node-version: 'lts/*'
41109
bundle: false
42-
os: ubuntu-latest
110+
skip: ${{ github.event_name == 'merge_group' }}
111+
43112
exclude:
44-
# No Node 14 on ARM macOS
45-
- node-version: '14'
46-
os: macos-latest
113+
- config:
114+
skip: true
47115

48-
runs-on: ${{ matrix.os }}
49-
name: Test Node ${{ matrix.node-version }} on ${{ matrix.os }}${{ (!matrix.bundle && ' with --no-bundle') || '' }}
116+
runs-on: ${{ matrix.config.os }}
117+
name: Test Node ${{ matrix.config.node-version }} on ${{ matrix.config.os }}${{ (!matrix.config.bundle && ' with --no-bundle') || '' }}
50118

51119
steps:
52120
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
53-
- name: Use node version ${{ matrix.node-version }}
121+
- name: Use node version ${{ matrix.config.node-version }}
54122
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
55123
with:
56-
node-version: ${{ matrix.node-version }}
124+
node-version: ${{ matrix.config.node-version }}
57125
check-latest: true
58126
- run: npm ci
59127

60128
- name: Tests
61129
id: test
62130
# run tests, but lint separately
63-
run: npm run test -- --no-lint --bundle=${{ matrix.bundle }}
131+
run: npm run test -- --no-lint --bundle=${{ matrix.config.bundle }}
64132

65133
- name: Print baseline diff on failure
66134
if: ${{ failure() && steps.test.conclusion == 'failure' }}
@@ -70,6 +138,8 @@ jobs:
70138
git diff --staged --exit-code
71139
72140
coverage:
141+
if: ${{ github.event_name != 'merge_group' }}
142+
73143
runs-on:
74144
- 'self-hosted'
75145
- '1ES.Pool=TypeScript-1ES-GitHub-Large'
@@ -95,7 +165,7 @@ jobs:
95165
name: coverage
96166
path: coverage
97167

98-
- uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
168+
- uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
99169
with:
100170
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}
101171
disable_search: true
@@ -294,6 +364,8 @@ jobs:
294364
run: npx hereby build-src --built
295365

296366
baselines:
367+
if: ${{ github.event_name != 'merge_group' }}
368+
297369
runs-on: ubuntu-latest
298370

299371
steps:
@@ -338,3 +410,27 @@ jobs:
338410
with:
339411
name: fix_baselines.patch
340412
path: fix_baselines.patch
413+
414+
required:
415+
runs-on: ubuntu-latest
416+
if: ${{ always() }}
417+
needs:
418+
- test
419+
- coverage
420+
- lint
421+
- knip
422+
- format
423+
- browser-integration
424+
- typecheck
425+
- smoke
426+
- package-size
427+
- misc
428+
- self-check
429+
- baselines
430+
431+
steps:
432+
- name: Check required jobs
433+
env:
434+
NEEDS: ${{ toJson(needs) }}
435+
run: |
436+
! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select((.result == "success" or .result == "skipped") | not)'

.github/workflows/codeql.yml

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

4747
# Initializes the CodeQL tools for scanning.
4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
49+
uses: github/codeql-action/init@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
5050
with:
5151
config-file: ./.github/codeql/codeql-configuration.yml
5252
# Override language selection by uncommenting this and choosing your languages
@@ -56,7 +56,7 @@ jobs:
5656
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5757
# If this step fails, then you should remove it and run the build manually (see below).
5858
- name: Autobuild
59-
uses: github/codeql-action/autobuild@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
59+
uses: github/codeql-action/autobuild@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
6060

6161
# ℹ️ Command-line programs to run using the OS shell.
6262
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -70,4 +70,4 @@ jobs:
7070
# make release
7171

7272
- name: Perform CodeQL Analysis
73-
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
73+
uses: github/codeql-action/analyze@39edc492dbe16b1465b0cafca41432d857bdb31a # v3.29.1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Copilot Setup Steps'
2+
on: workflow_dispatch
3+
4+
jobs:
5+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
6+
copilot-setup-steps:
7+
runs-on: ubuntu-latest
8+
9+
# Set the permissions to the lowest permissions possible needed for your steps.
10+
# Copilot will be given its own token for its operations.
11+
permissions:
12+
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
13+
contents: read
14+
15+
# You can define any steps you want, and they will run before the agent starts.
16+
# If you do not check out your code, Copilot will do this for you.
17+
steps:
18+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
20+
- run: npm ci
21+
# pull dprint caches before network access is blocked
22+
- run: npx hereby check-format || true

0 commit comments

Comments
 (0)