Skip to content

Commit a7f37a3

Browse files
committed
Merge branch 'master' into returnValueSurmise
2 parents 94f845a + c8e43d8 commit a7f37a3

File tree

863 files changed

+16079
-4178
lines changed

Some content is hidden

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

863 files changed

+16079
-4178
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ scripts/processDiagnosticMessages.js
5353
scripts/produceLKG.js
5454
scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js
5555
scripts/generateLocalizedDiagnosticMessages.js
56+
scripts/request-pr-review.js
5657
scripts/*.js.map
5758
scripts/typings/
5859
coverage/

Gulpfile.js

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const copyright = "CopyrightNotice.txt";
2222
const cleanTasks = [];
2323

2424
const buildScripts = () => buildProject("scripts");
25+
task("scripts", buildScripts);
26+
task("scripts").description = "Builds files in the 'scripts' folder.";
27+
2528
const cleanScripts = () => cleanProject("scripts");
2629
cleanTasks.push(cleanScripts);
2730

scripts/buildProtocol.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ class DeclarationsWalker {
2121

2222
static getExtraDeclarations(typeChecker: ts.TypeChecker, protocolFile: ts.SourceFile): string {
2323
const walker = new DeclarationsWalker(typeChecker, protocolFile);
24-
let text = "declare namespace ts.server.protocol {\n";
2524
walker.visitTypeNodes(protocolFile);
26-
text = walker.text
25+
let text = walker.text
2726
? `declare namespace ts.server.protocol {\n${walker.text}}`
2827
: "";
2928
if (walker.removedTypes) {

scripts/open-user-pr.ts

+14-11
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,39 @@
44
import { Octokit } from "@octokit/rest";
55
import {runSequence} from "./run-sequence";
66

7-
function padNum(num: number) {
8-
const str = "" + num;
9-
return str.length >= 2 ? str : "0" + str;
10-
}
11-
127
const userName = process.env.GH_USERNAME;
138
const reviewers = process.env.REQUESTING_USER ? [process.env.REQUESTING_USER] : ["weswigham", "sandersn", "RyanCavanaugh"];
149
const now = new Date();
15-
const branchName = `user-update-${process.env.TARGET_FORK}-${now.getFullYear()}${padNum(now.getMonth() + 1)}${padNum(now.getDate())}${process.env.TARGET_BRANCH ? "-" + process.env.TARGET_BRANCH : ""}`;
10+
const masterBranchname = `user-baseline-updates`;
11+
const targetBranch = process.env.TARGET_BRANCH || "master";
12+
const branchName = process.env.TARGET_FORK.toLowerCase() === "microsoft" && (targetBranch === "master" || targetBranch === "refs/heads/master")
13+
? masterBranchname
14+
: `user-update-${process.env.TARGET_FORK}-${process.env.TARGET_BRANCH ? "-" + process.env.TARGET_BRANCH : ""}`;
1615
const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`;
16+
const baseRef = branchName === masterBranchname ? "master" : masterBranchname;
1717
runSequence([
18+
["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork
1819
["git", ["checkout", "."]], // reset any changes
20+
["git", ["fetch", baseRef === "master" ? "origin" : "fork", baseRef]], // fetch target ref in case it's not present locally
21+
["git", ["checkout", baseRef]], // move head to target
1922
["node", ["./node_modules/gulp/bin/gulp.js", "baseline-accept"]], // accept baselines
2023
["git", ["checkout", "-b", branchName]], // create a branch
2124
["git", ["add", "."]], // Add all changes
2225
["git", ["commit", "-m", `"Update user baselines"`]], // Commit all changes
23-
["git", ["remote", "add", "fork", remoteUrl]], // Add the remote fork
2426
["git", ["push", "--set-upstream", "fork", branchName, "-f"]] // push the branch
2527
]);
2628

2729
const gh = new Octokit({
2830
auth: process.argv[2]
2931
});
32+
const prOwner = branchName === masterBranchname ? "microsoft" : userName;
3033
gh.pulls.create({
31-
owner: process.env.TARGET_FORK!,
34+
owner: prOwner,
3235
repo: "TypeScript",
3336
maintainer_can_modify: true,
3437
title: `🤖 User test baselines have changed` + (process.env.TARGET_BRANCH ? ` for ${process.env.TARGET_BRANCH}` : ""),
3538
head: `${userName}:${branchName}`,
36-
base: process.env.TARGET_BRANCH || "master",
39+
base: branchName === masterBranchname ? "master" : masterBranchname,
3740
body:
3841
`${process.env.SOURCE_ISSUE ? `This test run was triggerd by a request on https://github.com/Microsoft/TypeScript/pull/${process.env.SOURCE_ISSUE} `+"\n" : ""}Please review the diff and merge if no changes are unexpected.
3942
You can view the build log [here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary).
@@ -44,7 +47,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
4447
console.log(`Pull request ${num} created.`);
4548
if (!process.env.SOURCE_ISSUE) {
4649
await gh.pulls.createReviewRequest({
47-
owner: process.env.TARGET_FORK!,
50+
owner: prOwner,
4851
repo: "TypeScript",
4952
pull_number: num,
5053
reviewers,
@@ -53,7 +56,7 @@ cc ${reviewers.map(r => "@" + r).join(" ")}`,
5356
else {
5457
await gh.issues.createComment({
5558
issue_number: +process.env.SOURCE_ISSUE,
56-
owner: "Microsoft",
59+
owner: "microsoft",
5760
repo: "TypeScript",
5861
body: `The user suite test run you requested has finished and _failed_. I've opened a [PR with the baseline diff from master](${r.data.html_url}).`
5962
});

scripts/request-pr-review.ts

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/// <reference lib="esnext.asynciterable" />
2+
/// <reference lib="es2015.promise" />
3+
import octokit = require("@octokit/rest");
4+
import Octokit = octokit.Octokit;
5+
import minimist = require("minimist");
6+
7+
const options = minimist(process.argv.slice(2), {
8+
boolean: ["help"],
9+
string: ["token", "pull", "reviewer", "owner", "repo"],
10+
alias: {
11+
pr: "pull",
12+
h: "help",
13+
["?"]: "help"
14+
},
15+
default: {
16+
token: process.env.GH_TOKEN,
17+
pull: process.env.GH_PULL_NUMBER,
18+
reviewer: process.env.REQUESTED_REVIEWER,
19+
owner: "microsoft",
20+
repo: "TypeScript"
21+
}
22+
});
23+
24+
if (options.help) {
25+
printHelpAndExit(0);
26+
}
27+
28+
if (!options.token || !options.pull || !options.reviewer || !options.owner || !options.repo) {
29+
console.error("Invalid arguments");
30+
printHelpAndExit(-1);
31+
}
32+
33+
const pull_number = +options.pull;
34+
if (!isFinite(pull_number)) {
35+
console.error("Invalid arguments");
36+
printHelpAndExit(-2);
37+
}
38+
39+
const reviewers = Array.isArray(options.reviewer) ? options.reviewer : [options.reviewer];
40+
41+
main().catch(console.error);
42+
43+
async function main() {
44+
const gh = new Octokit({ auth: options.token });
45+
const response = await gh.pulls.createReviewRequest({
46+
owner: options.owner,
47+
repo: options.repo,
48+
pull_number,
49+
reviewers,
50+
});
51+
if (response.status === 201) {
52+
console.log(`Added ${reviewers.join(", ")} to ${response.data.url}`);
53+
}
54+
else {
55+
console.log(`Failed to add ${reviewers.join(", ")} to the pull request.`);
56+
}
57+
}
58+
59+
function printHelpAndExit(exitCode: number) {
60+
console.log(`
61+
usage: request-pr-review.js [options]
62+
63+
options:
64+
--token <token> Your GitHub auth token. Uses %GH_TOKEN% if present.
65+
--owner <owner> The GH user or organization for the repo (default: 'microsoft').
66+
--repo <repo> The GH repo for the pull request (default: 'TypeScript').
67+
--pull <pr_number> The pull request number. Uses %GH_PULL_NUMBER% if present.
68+
--reviewer <reviewer> The GH username of reviewer to add. May be specified multiple times.
69+
Uses %REQUESTED_REVIEWER% if present.
70+
-h --help Prints this help message.
71+
`);
72+
return process.exit(exitCode);
73+
}

scripts/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"configurePrerelease.ts",
1818
"buildProtocol.ts",
1919
"produceLKG.ts",
20-
"word2md.ts"
20+
"word2md.ts",
21+
"request-pr-review.ts"
2122
]
2223
}

src/compiler/builder.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ namespace ts {
201201
state.affectedFilesPendingEmit = oldState!.affectedFilesPendingEmit.slice();
202202
state.affectedFilesPendingEmitKind = cloneMapOrUndefined(oldState!.affectedFilesPendingEmitKind);
203203
state.affectedFilesPendingEmitIndex = oldState!.affectedFilesPendingEmitIndex;
204+
state.seenAffectedFiles = createMap();
204205
}
205206
}
206207

@@ -247,8 +248,8 @@ namespace ts {
247248
if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
248249
// Add all files to affectedFilesPendingEmit since emit changed
249250
newProgram.getSourceFiles().forEach(f => addToAffectedFilesPendingEmit(state, f.resolvedPath, BuilderFileEmit.Full));
250-
Debug.assert(state.seenAffectedFiles === undefined);
251-
state.seenAffectedFiles = createMap<true>();
251+
Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
252+
state.seenAffectedFiles = state.seenAffectedFiles || createMap<true>();
252253
}
253254

254255
state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit;

0 commit comments

Comments
 (0)