Skip to content

Commit 4675779

Browse files
committed
Merge branch 'master' into feature/semicolon-preference
2 parents 2c1eef2 + 2e985e7 commit 4675779

File tree

253 files changed

+10552
-2095
lines changed

Some content is hidden

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

253 files changed

+10552
-2095
lines changed

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,14 @@ tests/cases/user/*/**/*.d.ts
8181
tests/baselines/reference/dt
8282
.failed-tests
8383
TEST-results.xml
84-
package-lock.json
84+
package-lock.json
85+
tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
86+
tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
87+
tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
88+
tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
89+
tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
90+
tests/cases/user/create-react-app/create-react-app
91+
tests/cases/user/webpack/webpack
92+
tests/cases/user/puppeteer/puppeteer
93+
tests/cases/user/axios-src/axios-src
94+
tests/cases/user/prettier/prettier

.gitmodules

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +0,0 @@
1-
[submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"]
2-
path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
3-
url = https://github.com/Microsoft/TypeScript-React-Starter
4-
ignore = all
5-
[submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"]
6-
path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
7-
url = https://github.com/Microsoft/TypeScript-Node-Starter.git
8-
ignore = all
9-
[submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"]
10-
path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
11-
url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git
12-
ignore = all
13-
[submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"]
14-
path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
15-
url = https://github.com/Microsoft/TypeScript-Vue-Starter.git
16-
ignore = all
17-
[submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"]
18-
path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
19-
url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git
20-
ignore = all
21-
[submodule "tests/cases/user/create-react-app/create-react-app"]
22-
path = tests/cases/user/create-react-app/create-react-app
23-
url = https://github.com/facebook/create-react-app.git
24-
ignore = all
25-
[submodule "tests/cases/user/webpack/webpack"]
26-
path = tests/cases/user/webpack/webpack
27-
url = https://github.com/webpack/webpack.git
28-
ignore = all
29-
[submodule "tests/cases/user/puppeteer/puppeteer"]
30-
path = tests/cases/user/puppeteer/puppeteer
31-
url = https://github.com/GoogleChrome/puppeteer.git
32-
ignore = all
33-
[submodule "tests/cases/user/axios-src/axios-src"]
34-
path = tests/cases/user/axios-src/axios-src
35-
url = https://github.com/axios/axios.git
36-
ignore = all
37-
[submodule "tests/cases/user/prettier/prettier"]
38-
path = tests/cases/user/prettier/prettier
39-
url = https://github.com/prettier/prettier.git
40-
ignore = all

.vscode/settings.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
}
77
],
88
"eslint.options": {
9-
"rulePaths": ["../scripts/eslint/built/rules/"],
9+
"rulePaths": ["./scripts/eslint/built/rules/"],
1010
"ext": [".ts"]
11-
},
12-
"eslint.workingDirectories": ["./src", "./scripts"]
11+
}
1312
}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Design changes will not be accepted at this time. If you have a design change pr
7171

7272
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.
7373

74-
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.pdf](https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your github user name along with the agreement. Once we have received the signed CLA, we'll review the request.
74+
Please submit a Contributor License Agreement (CLA) before submitting a pull request. You may visit https://cla.microsoft.com to sign digitally. Alternatively, download the agreement ([Microsoft Contribution License Agreement.pdf](https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf)), sign, scan, and email it back to <cla@microsoft.com>. Be sure to include your GitHub user name along with the agreement. Once we have received the signed CLA, we'll review the request.
7575

7676
## Housekeeping
7777

@@ -148,7 +148,7 @@ You will probably only want to debug one test at a time:
148148
gulp runtests-browser --tests=2dArrays
149149
```
150150

151-
You can specify which browser to use for debugging. Currently Chrome and IE are supported:
151+
You can specify which browser to use for debugging. Currently, Chrome and IE are supported:
152152

153153
```Shell
154154
gulp runtests-browser --tests=2dArrays --browser=chrome

Gulpfile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ task("run-eslint-rules-tests").description = "Runs the eslint rule tests";
333333

334334
const lintFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("lint")); };
335335
const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lint")); };
336+
337+
/** @type { (folder: string) => { (): Promise<any>; displayName?: string } } */
336338
const eslint = (folder) => async () => {
337339
const ESLINTRC_CI = ".eslintrc.ci.json";
338340
const isCIEnv = cmdLineOptions.ci || process.env.CI === "true";

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"xml2js": "^0.4.19"
103103
},
104104
"scripts": {
105+
"prepare": "gulp build-eslint-rules",
105106
"pretest": "gulp tests",
106107
"test": "gulp runtests-parallel --light=false",
107108
"test:eslint-rules": "gulp run-eslint-rules-tests",

scripts/post-vsts-artifact-comment.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ async function main() {
2828
type: "token",
2929
token: process.argv[2]
3030
});
31+
32+
// Please keep the strings "an installable tgz" and "packed" in this message, as well as the devDependencies section,
33+
// so that the playgrounds deployment process can find these comments.
34+
3135
await gh.issues.createComment({
3236
number: +process.env.SOURCE_ISSUE,
3337
owner: "Microsoft",
@@ -43,6 +47,9 @@ async function main() {
4347
and then running \`npm install\`.
4448
`
4549
});
50+
51+
// Send a ping to https://github.com/orta/make-monaco-builds#pull-request-builds
52+
await gh.request("POST /repos/orta/make-monaco-builds/dispatches", { event_type: +process.env.SOURCE_ISSUE })
4653
}
4754

4855
main().catch(async e => {
@@ -61,4 +68,4 @@ main().catch(async e => {
6168
body: `Hey @${process.env.REQUESTING_USER}, something went wrong when looking for the build artifact. ([You can check the log here](https://typescript.visualstudio.com/TypeScript/_build/index?buildId=${process.env.BUILD_BUILDID}&_a=summary)).`
6269
});
6370
}
64-
});
71+
});

scripts/processDiagnosticMessages.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ interface DiagnosticDetails {
66
code: number;
77
reportsUnnecessary?: {};
88
isEarly?: boolean;
9+
elidedInCompatabilityPyramid?: boolean;
910
}
1011

1112
type InputDiagnosticMessageTable = Map<string, DiagnosticDetails>;
@@ -63,14 +64,15 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, inputFil
6364
"// generated from '" + inputFilePathRel + "' by '" + thisFilePathRel.replace(/\\/g, "/") + "'\r\n" +
6465
"/* @internal */\r\n" +
6566
"namespace ts {\r\n" +
66-
" function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}): DiagnosticMessage {\r\n" +
67-
" return { code, category, key, message, reportsUnnecessary };\r\n" +
67+
" function diag(code: number, category: DiagnosticCategory, key: string, message: string, reportsUnnecessary?: {}, elidedInCompatabilityPyramid?: boolean): DiagnosticMessage {\r\n" +
68+
" return { code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid };\r\n" +
6869
" }\r\n" +
6970
" export const Diagnostics = {\r\n";
70-
messageTable.forEach(({ code, category, reportsUnnecessary }, name) => {
71+
messageTable.forEach(({ code, category, reportsUnnecessary, elidedInCompatabilityPyramid }, name) => {
7172
const propName = convertPropertyName(name);
7273
const argReportsUnnecessary = reportsUnnecessary ? `, /*reportsUnnecessary*/ ${reportsUnnecessary}` : "";
73-
result += ` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}),\r\n`;
74+
const argElidedInCompatabilityPyramid = elidedInCompatabilityPyramid ? `${!reportsUnnecessary ? ", /*reportsUnnecessary*/ undefined" : ""}, /*elidedInCompatabilityPyramid*/ ${elidedInCompatabilityPyramid}` : "";
75+
result += ` ${propName}: diag(${code}, DiagnosticCategory.${category}, "${createKey(propName, code)}", ${JSON.stringify(name)}${argReportsUnnecessary}${argElidedInCompatabilityPyramid}),\r\n`;
7476
});
7577

7678
result += " };\r\n}";

scripts/types/ambient.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,15 @@ declare module "undertaker" {
7676
interface TaskFunctionParams {
7777
flags?: Record<string, string>;
7878
}
79+
interface TaskFunctionWrapped {
80+
description: string
81+
flags: { [name: string]: string }
82+
}
7983
}
8084

8185
declare module "gulp-sourcemaps" {
8286
interface WriteOptions {
8387
destPath?: string;
8488
}
85-
}
89+
90+
}

src/compiler/binder.ts

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ namespace ts {
564564
if (!isIIFE) {
565565
currentFlow = { flags: FlowFlags.Start };
566566
if (containerFlags & (ContainerFlags.IsFunctionExpression | ContainerFlags.IsObjectLiteralOrClassExpressionMethod)) {
567-
currentFlow.container = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
567+
currentFlow.node = <FunctionExpression | ArrowFunction | MethodDeclaration>node;
568568
}
569569
}
570570
// We create a return control flow graph for IIFEs and constructors. For constructors
@@ -581,6 +581,7 @@ namespace ts {
581581
if (!(currentFlow.flags & FlowFlags.Unreachable) && containerFlags & ContainerFlags.IsFunctionLike && nodeIsPresent((<FunctionLikeDeclaration>node).body)) {
582582
node.flags |= NodeFlags.HasImplicitReturn;
583583
if (hasExplicitReturn) node.flags |= NodeFlags.HasExplicitReturn;
584+
(<FunctionLikeDeclaration>node).endFlowNode = currentFlow;
584585
}
585586
if (node.kind === SyntaxKind.SourceFile) {
586587
node.flags |= emitFlags;
@@ -671,6 +672,9 @@ namespace ts {
671672
bindJSDoc(node);
672673
return;
673674
}
675+
if (node.kind >= SyntaxKind.FirstStatement && node.kind <= SyntaxKind.LastStatement && !options.allowUnreachableCode) {
676+
node.flowNode = currentFlow;
677+
}
674678
switch (node.kind) {
675679
case SyntaxKind.WhileStatement:
676680
bindWhileStatement(<WhileStatement>node);
@@ -708,6 +712,9 @@ namespace ts {
708712
case SyntaxKind.CaseClause:
709713
bindCaseClause(<CaseClause>node);
710714
break;
715+
case SyntaxKind.ExpressionStatement:
716+
bindExpressionStatement(<ExpressionStatement>node);
717+
break;
711718
case SyntaxKind.LabeledStatement:
712719
bindLabeledStatement(<LabeledStatement>node);
713720
break;
@@ -845,17 +852,11 @@ namespace ts {
845852
}
846853

847854
function createBranchLabel(): FlowLabel {
848-
return {
849-
flags: FlowFlags.BranchLabel,
850-
antecedents: undefined
851-
};
855+
return { flags: FlowFlags.BranchLabel, antecedents: undefined };
852856
}
853857

854858
function createLoopLabel(): FlowLabel {
855-
return {
856-
flags: FlowFlags.LoopLabel,
857-
antecedents: undefined
858-
};
859+
return { flags: FlowFlags.LoopLabel, antecedents: undefined };
859860
}
860861

861862
function setFlowNodeReferenced(flow: FlowNode) {
@@ -885,26 +886,30 @@ namespace ts {
885886
return antecedent;
886887
}
887888
setFlowNodeReferenced(antecedent);
888-
return flowNodeCreated({ flags, expression, antecedent });
889+
return flowNodeCreated({ flags, antecedent, node: expression });
889890
}
890891

891892
function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode {
892893
if (!isNarrowingExpression(switchStatement.expression)) {
893894
return antecedent;
894895
}
895896
setFlowNodeReferenced(antecedent);
896-
return flowNodeCreated({ flags: FlowFlags.SwitchClause, switchStatement, clauseStart, clauseEnd, antecedent });
897+
return flowNodeCreated({ flags: FlowFlags.SwitchClause, antecedent, switchStatement, clauseStart, clauseEnd });
897898
}
898899

899900
function createFlowAssignment(antecedent: FlowNode, node: Expression | VariableDeclaration | BindingElement): FlowNode {
900901
setFlowNodeReferenced(antecedent);
901902
return flowNodeCreated({ flags: FlowFlags.Assignment, antecedent, node });
902903
}
903904

905+
function createFlowCall(antecedent: FlowNode, node: CallExpression): FlowNode {
906+
setFlowNodeReferenced(antecedent);
907+
return flowNodeCreated({ flags: FlowFlags.Call, antecedent, node });
908+
}
909+
904910
function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode {
905911
setFlowNodeReferenced(antecedent);
906-
const res: FlowArrayMutation = flowNodeCreated({ flags: FlowFlags.ArrayMutation, antecedent, node });
907-
return res;
912+
return flowNodeCreated({ flags: FlowFlags.ArrayMutation, antecedent, node });
908913
}
909914

910915
function finishFlowLabel(flow: FlowLabel): FlowNode {
@@ -1030,12 +1035,12 @@ namespace ts {
10301035
function bindForInOrForOfStatement(node: ForInOrOfStatement): void {
10311036
const preLoopLabel = createLoopLabel();
10321037
const postLoopLabel = createBranchLabel();
1038+
bind(node.expression);
10331039
addAntecedent(preLoopLabel, currentFlow);
10341040
currentFlow = preLoopLabel;
10351041
if (node.kind === SyntaxKind.ForOfStatement) {
10361042
bind(node.awaitModifier);
10371043
}
1038-
bind(node.expression);
10391044
addAntecedent(postLoopLabel, currentFlow);
10401045
bind(node.initializer);
10411046
if (node.initializer.kind !== SyntaxKind.VariableDeclarationList) {
@@ -1222,7 +1227,8 @@ namespace ts {
12221227
addAntecedent(postSwitchLabel, currentFlow);
12231228
const hasDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
12241229
// We mark a switch statement as possibly exhaustive if it has no default clause and if all
1225-
// case clauses have unreachable end points (e.g. they all return).
1230+
// case clauses have unreachable end points (e.g. they all return). Note, we no longer need
1231+
// this property in control flow analysis, it's there only for backwards compatibility.
12261232
node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
12271233
if (!hasDefault) {
12281234
addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
@@ -1281,6 +1287,24 @@ namespace ts {
12811287
activeLabels!.pop();
12821288
}
12831289

1290+
function isDottedName(node: Expression): boolean {
1291+
return node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.ThisKeyword ||
1292+
node.kind === SyntaxKind.PropertyAccessExpression && isDottedName((<PropertyAccessExpression>node).expression) ||
1293+
node.kind === SyntaxKind.ParenthesizedExpression && isDottedName((<ParenthesizedExpression>node).expression);
1294+
}
1295+
1296+
function bindExpressionStatement(node: ExpressionStatement): void {
1297+
bind(node.expression);
1298+
// A top level call expression with a dotted function name and at least one argument
1299+
// is potentially an assertion and is therefore included in the control flow.
1300+
if (node.expression.kind === SyntaxKind.CallExpression) {
1301+
const call = <CallExpression>node.expression;
1302+
if (isDottedName(call.expression)) {
1303+
currentFlow = createFlowCall(currentFlow, call);
1304+
}
1305+
}
1306+
}
1307+
12841308
function bindLabeledStatement(node: LabeledStatement): void {
12851309
const preStatementLabel = createLoopLabel();
12861310
const postStatementLabel = createBranchLabel();
@@ -2859,7 +2883,7 @@ namespace ts {
28592883

28602884
// If this is a property-parameter, then also declare the property symbol into the
28612885
// containing class.
2862-
if (isParameterPropertyDeclaration(node)) {
2886+
if (isParameterPropertyDeclaration(node, node.parent)) {
28632887
const classDeclaration = <ClassLikeDeclaration>node.parent.parent;
28642888
declareSymbol(classDeclaration.symbol.members!, classDeclaration.symbol, node, SymbolFlags.Property | (node.questionToken ? SymbolFlags.Optional : SymbolFlags.None), SymbolFlags.PropertyExcludes);
28652889
}

0 commit comments

Comments
 (0)