Skip to content

Commit ce1d76c

Browse files
committed
Merge branch 'master' of https://github.com/microsoft/TypeScript
2 parents 07c92e8 + cdafb71 commit ce1d76c

File tree

757 files changed

+81254
-3939
lines changed

Some content is hidden

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

757 files changed

+81254
-3939
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ yarn-error.log
4343
.parallelperf.*
4444
.failed-tests
4545
TEST-results.xml
46-
package-lock.json
4746
tests
4847
.vscode
4948
.git
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name : CodeQL Configuration
2+
3+
paths:
4+
- './src'

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ jobs:
3030
run: |
3131
npm uninstall typescript --no-save
3232
npm uninstall tslint --no-save
33-
- run: npm install
34-
- run: npm update
33+
- run: npm ci
3534

3635
# Re: https://github.com/actions/setup-node/pull/125
3736
- name: Register Problem Matcher for TSC
@@ -45,4 +44,4 @@ jobs:
4544

4645
- name: Validate the browser can import TypeScript
4746
run: gulp test-browser-integration
48-
47+

.github/workflows/codeql.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: "Code scanning - action"
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 19 * * 0'
8+
9+
jobs:
10+
CodeQL-Build:
11+
12+
# CodeQL runs on ubuntu-latest and windows-latest
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
with:
19+
# We must fetch at least the immediate parents so that if this is
20+
# a pull request then we can checkout the head.
21+
fetch-depth: 2
22+
23+
# If this run was triggered by a pull request event, then checkout
24+
# the head of the pull request instead of the merge commit.
25+
- run: git checkout HEAD^2
26+
if: ${{ github.event_name == 'pull_request' }}
27+
28+
# Initializes the CodeQL tools for scanning.
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v1
31+
with:
32+
config-file: ./.github/codeql/codeql-configuration.yml
33+
# Override language selection by uncommenting this and choosing your languages
34+
# with:
35+
# languages: go, javascript, csharp, python, cpp, java
36+
37+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
38+
# If this step fails, then you should remove it and run the build manually (see below)
39+
- name: Autobuild
40+
uses: github/codeql-action/autobuild@v1
41+
42+
# ℹ️ Command-line programs to run using the OS shell.
43+
# 📚 https://git.io/JvXDl
44+
45+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
46+
# and modify them (or add more) to build your code if your project
47+
# uses a compiled language
48+
49+
#- run: |
50+
# make bootstrap
51+
# make release
52+
53+
- name: Perform CodeQL Analysis
54+
uses: github/codeql-action/analyze@v1

.github/workflows/new-release-branch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
2424
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
2525
sed -i -e 's/const version = `${versionMajorMinor}.0-.*`/const version = `${versionMajorMinor}.0-${{ github.event.client_payload.core_tag || 'dev' }}`/g' src/compiler/corePublic.ts
26-
npm install
26+
npm ci
2727
gulp LKG
2828
npm test
2929
git diff
@@ -32,7 +32,7 @@ jobs:
3232
git add tests/baselines/reference/api/typescript.d.ts
3333
git add tests/baselines/reference/api/tsserverlibrary.d.ts
3434
git add ./lib
35-
git config user.email "ts_bot@rcavanaugh.com"
35+
git config user.email "typescriptbot@microsoft.com"
3636
git config user.name "TypeScript Bot"
3737
git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG'
3838
git push --set-upstream origin ${{ github.event.client_payload.branch_name }}

.github/workflows/release-branch-artifact.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ jobs:
2121
npm uninstall tslint --no-save
2222
- name: npm install and test
2323
run: |
24-
npm install
25-
npm update
24+
npm ci
2625
npm test
2726
env:
2827
CI: true
@@ -41,4 +40,3 @@ jobs:
4140
with:
4241
name: tgz
4342
path: typescript.tgz
44-

.github/workflows/set-version.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/typescript.d.ts
3030
sed -i -e 's/const versionMajorMinor = ".*"/const versionMajorMinor = "${{ github.event.client_payload.core_major_minor }}"/g' tests/baselines/reference/api/tsserverlibrary.d.ts
3131
sed -i -e 's/const version = .*;/const version = "${{ github.event.client_payload.package_version }}" as string;/g' src/compiler/corePublic.ts
32-
npm install
32+
npm ci
3333
gulp LKG
3434
npm test
3535
git diff
@@ -38,7 +38,7 @@ jobs:
3838
git add tests/baselines/reference/api/typescript.d.ts
3939
git add tests/baselines/reference/api/tsserverlibrary.d.ts
4040
git add ./lib
41-
git config user.email "ts_bot@rcavanaugh.com"
41+
git config user.email "typescriptbot@microsoft.com"
4242
git config user.name "TypeScript Bot"
4343
git commit -m 'Bump version to ${{ github.event.client_payload.package_version }} and LKG'
4444
git push

.github/workflows/sync-branch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
# required client_payload members:
2626
# branch_name - the target branch
2727
- run: |
28-
git config user.email "ts_bot@rcavanaugh.com"
28+
git config user.email "typescriptbot@microsoft.com"
2929
git config user.name "TypeScript Bot"
3030
git fetch origin master
3131
git merge origin/master --no-ff
32-
npm install
32+
npm ci
3333
npm test
3434
git push

.github/workflows/update-lkg.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717

1818
- name: Configure Git and Update LKG
1919
run: |
20-
git config user.email "ts_bot@rcavanaugh.com"
20+
git config user.email "typescriptbot@microsoft.com"
2121
git config user.name "TypeScript Bot"
22-
npm install
22+
npm ci
2323
gulp LKG
2424
npm test
2525
git diff
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Update package-lock.json
2+
3+
on:
4+
schedule:
5+
# This is probably 6am UTC, which is 10pm PST or 11pm PDT
6+
# Alternatively, 6am local is also fine
7+
- cron: '0 6 * * *'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v1
16+
with:
17+
node-version: 12
18+
registry-url: https://registry.npmjs.org/
19+
20+
- name: Configure git and update package-lock.json
21+
run: |
22+
git config user.email "[email protected]"
23+
git config user.name "TypeScript Bot"
24+
npm install --package-lock-only
25+
git add -f package-lock.json
26+
if git commit -m "Update package-lock.json"; then
27+
git push
28+
fi

.npmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ branches:
1818

1919
install:
2020
- npm uninstall typescript --no-save
21-
- npm install
21+
- npm ci
2222

2323
cache:
2424
directories:

.vscode/launch.template.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,24 @@
4747
"console": "integratedTerminal",
4848
"outFiles": [
4949
"${workspaceRoot}/built/local/run.js"
50-
]
50+
],
51+
52+
// NOTE: To use this, you must switch the "type" above to "pwa-node". You may also need to follow the instructions
53+
// here: https://github.com/microsoft/vscode-js-debug#nightly-extension to use the js-debug nightly until
54+
// this feature is shipping in insiders or to a release:
55+
// "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
5156
},
5257
{
5358
// See: https://github.com/microsoft/TypeScript/wiki/Debugging-Language-Service-in-VS-Code
5459
"type": "node",
5560
"request": "attach",
5661
"name": "Attach to VS Code TS Server via Port",
57-
"processId": "${command:PickProcess}"
62+
"processId": "${command:PickProcess}",
63+
64+
// NOTE: To use this, you must switch the "type" above to "pwa-node". You may also need to follow the instructions
65+
// here: https://github.com/microsoft/vscode-js-debug#nightly-extension to use the js-debug nightly until
66+
// this feature is shipping in insiders or to a release:
67+
// "customDescriptionGenerator": "'__tsDebuggerDisplay' in this ? this.__tsDebuggerDisplay(defaultValue) : defaultValue"
5868
}
5969
]
6070
}

CONTRIBUTING.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ In general, things we find useful when reviewing suggestions are:
4747

4848
# Instructions for Contributing Code
4949

50+
## What You'll Need
51+
52+
0. [A bug or feature you want to work on](https://github.com/microsoft/TypeScript/labels/help%20wanted)!
53+
1. [A GitHub account](https://github.com/join).
54+
2. A copy of the TypeScript code. See the next steps for instructions.
55+
3. [Node](https://nodejs.org), which runs JavaScript locally. Current or LTS will both work.
56+
4. An editor. [VS Code](https://code.visualstudio.com) is the best place to start for TypeScript.
57+
5. The gulp command line tool, for building and testing changes. See the next steps for how to install it.
58+
59+
## Get Started
60+
61+
1. Install node using the version you downloaded from [nodejs.org](https://nodejs.org).
62+
2. Open a terminal.
63+
3. Make a fork—your own copy—of TypeScript on your GitHub account, then make a clone—a local copy—on your computer. ([Here are some step-by-step instructions](https://github.com/anitab-org/mentorship-android/wiki/Fork%2C-Clone-%26-Remote)). Add `--depth=1` to the end of the `git clone` command to save time.
64+
4. Install the gulp command line tool: `npm install -g gulp-cli`
65+
5. Change to the TypeScript folder you made: `cd TypeScript`
66+
6. Install dependencies: `npm ci`
67+
7. Make sure everything builds and tests pass: `gulp runtests-parallel`
68+
8. Open the Typescript folder in your editor.
69+
9. Follow the directions below to add and debug a test.
70+
5071
## Tips
5172

5273
### Faster clones
@@ -65,8 +86,6 @@ TypeScript is currently accepting contributions in the form of bug fixes. A bug
6586

6687
Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (labelled ["help wanted"](https://github.com/Microsoft/TypeScript/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) or in the "Backlog" milestone) by a TypeScript project maintainer in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted.
6788

68-
Design changes will not be accepted at this time. If you have a design change proposal, please log a suggestion issue.
69-
7089
## Legal
7190

7291
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright. Upon submitting a pull request, you will automatically be given instructions on how to sign the CLA.
@@ -76,16 +95,11 @@ You will need to complete a Contributor License Agreement (CLA). Briefly, this a
7695
Your pull request should:
7796

7897
* Include a description of what your change intends to do
79-
* Be a child commit of a reasonably recent commit in the **master** branch
80-
* Requests need not be a single commit, but should be a linear sequence of commits (i.e. no merge commits in your PR)
81-
* It is desirable, but not necessary, for the tests to pass at each commit
82-
* Have clear commit messages
83-
* e.g. "Minor refactor in goToTypeDefinition", "Fix iterated type in for-await-of", "Add test for preserveWatchOutput on command line"
98+
* Be based on reasonably recent commit in the **master** branch
8499
* Include adequate tests
85100
* At least one test should fail in the absence of your non-test code changes. If your PR does not match this criteria, please specify why
86101
* Tests should include reasonable permutations of the target fix/change
87102
* Include baseline changes with your change
88-
* All changed code must have 100% code coverage
89103
* Follow the code conventions described in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
90104
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
91105

@@ -149,37 +163,35 @@ You can also use the [provided VS Code launch configuration](./.vscode/launch.te
149163

150164
## Adding a Test
151165

152-
To add a new test case, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making.
166+
To add a new test case, add a `.ts` file in `tests\cases\compiler` with code that shows the your bug is now fixed, or your new feature now works.
153167

154168
These files support metadata tags in the format `// @metaDataName: value`.
155169
The supported names and values are the same as those supported in the compiler itself, with the addition of the `fileName` flag.
156170
`fileName` tags delimit sections of a file to be used as separate compilation units.
157-
They are useful for tests relating to modules.
171+
They are useful for testing modules.
158172
See below for examples.
159173

160-
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder.
161-
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common.
174+
**Note** that if you have a test corresponding to a specific area of spec compliance, you can put it in the appropriate subfolder of `tests\cases\conformance`.
175+
**Note** that test filenames must be distinct from all other test names, so you may have to work a bit to find a unique name if it's something common.
162176

163177
### Tests for multiple files
164178

165-
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such:
179+
When you need to mimic having multiple files in a single test to test features such as "import", use the `filename` tag:
166180

167-
```TypeScript
168-
// @fileName: file1.ts
181+
```ts
182+
// @filename: file1.ts
169183
export function f() {
170184
}
171185

172-
// @fileName: file2.ts
186+
// @filename: file2.ts
173187
import { f as g } from "file1";
174188

175189
var x = g();
176190
```
177191

178-
One can also write a project test, but it is slightly more involved.
179-
180192
## Managing the Baselines
181193

182-
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output.
194+
Compiler tests generate baselines: one file each for the emitted `.js`, the errors produced by the compiler, the type of each expression, and symbol for each identifier. Additionally, some tests generate baselines for the source map output.
183195

184196
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use
185197

@@ -193,7 +205,8 @@ After verifying that the changes in the baselines are correct, run
193205
gulp baseline-accept
194206
```
195207

196-
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines.
208+
This will change the files in `tests\baselines\reference`, which should be included as part of your commit.
209+
Be sure to validate the changes carefully -- apparently unrelated changes to baselines can be clues about something you didn't think of.
197210

198211
## Localization
199212

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
FROM node:current
33
COPY . /typescript
44
WORKDIR /typescript
5-
RUN npm install
5+
RUN npm ci
66
RUN npm i -g gulp-cli
77
RUN gulp configure-insiders && gulp LKG && gulp clean && npm pack .

Gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ const cleanTypesMap = () => del("built/local/typesMap.json");
413413
cleanTasks.push(cleanTypesMap);
414414

415415
// Drop a copy of diagnosticMessages.generated.json into the built/local folder. This allows
416-
// it to be synced to the Azure DevOps repo, so that it can get picked up by the build
416+
// it to be synced to the Azure DevOps repo, so that it can get picked up by the build
417417
// pipeline that generates the localization artifacts that are then fed into the translation process.
418418
const builtLocalDiagnosticMessagesGeneratedJson = "built/local/diagnosticMessages.generated.json";
419419
const copyBuiltLocalDiagnosticMessages = () => src(diagnosticMessagesGeneratedJson)
@@ -591,7 +591,7 @@ task("LKG").flags = {
591591
" --built": "Compile using the built version of the compiler.",
592592
};
593593

594-
const generateSpec = () => exec("cscript", ["//nologo", "scripts/word2md.js", path.resolve("doc/TypeScript Language Specification.docx"), path.resolve("doc/spec.md")]);
594+
const generateSpec = () => exec("cscript", ["//nologo", "scripts/word2md.js", path.resolve("doc/TypeScript Language Specification - ARCHIVED.docx"), path.resolve("doc/spec-ARCHIVED.md")]);
595595
task("generate-spec", series(buildScripts, generateSpec));
596596
task("generate-spec").description = "Generates a Markdown version of the Language Specification";
597597

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ with any additional questions or comments.
4444

4545
* [TypeScript in 5 minutes](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html)
4646
* [Programming handbook](https://www.typescriptlang.org/docs/handbook/basic-types.html)
47-
* [Language specification](https://github.com/microsoft/TypeScript/blob/master/doc/spec.md)
4847
* [Homepage](https://www.typescriptlang.org/)
4948

5049
## Building
@@ -67,7 +66,7 @@ Install [Gulp](https://gulpjs.com/) tools and dev dependencies:
6766

6867
```bash
6968
npm install -g gulp
70-
npm install
69+
npm ci
7170
```
7271

7372
Use one of the following to build and test:

doc/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This directory contains miscellaneous documentation such as the TypeScript language specification and logo.
44
If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook).
55

6-
# Spec Contributions
7-
8-
The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats.
9-
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that **any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new)** rather than sent as pull requests.
6+
7+
# Archived Spec
8+
9+
NOTE: the files in this directory are NOT meant to be edited. They are a snapshot of the out-of-date specification which is no longer being updated. We will not be accepting changes to these documents.

0 commit comments

Comments
 (0)