Skip to content

Commit c27ee81

Browse files
committed
Merge branch 'master' into extract-method-2
2 parents 24de14a + a6a27ab commit c27ee81

File tree

318 files changed

+5137
-2062
lines changed

Some content is hidden

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

318 files changed

+5137
-2062
lines changed

Jakefile.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
534534
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
535535

536536
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
537-
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");
538537
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
539538
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
540539
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
@@ -573,22 +572,6 @@ compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].conc
573572
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
574573
});
575574

576-
compileFile(
577-
servicesFileInBrowserTest,
578-
servicesSources,
579-
[builtLocalDirectory, copyright].concat(servicesSources),
580-
/*prefixes*/[copyright],
581-
/*useBuiltCompiler*/ true,
582-
{
583-
noOutFile: false,
584-
generateDeclarations: true,
585-
preserveConstEnums: true,
586-
keepComments: true,
587-
noResolve: false,
588-
stripInternal: true,
589-
inlineSourceMap: true
590-
});
591-
592575
file(typescriptServicesDts, [servicesFile]);
593576

594577
var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js");
@@ -726,7 +709,7 @@ compileFile(
726709
/*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
727710
/*prefixes*/[],
728711
/*useBuiltCompiler:*/ true,
729-
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" });
712+
/*opts*/ { types: ["node", "mocha", "chai"], lib: "es6" });
730713

731714
var internalTests = "internal/";
732715

@@ -962,13 +945,14 @@ var nodeServerInFile = "tests/webTestServer.ts";
962945
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true, lib: "es6" });
963946

964947
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
965-
task("browserify", ["tests", run, builtLocalDirectory, nodeServerOutFile], function() {
966-
var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -d -o built/local/bundle.js';
948+
task("browserify", [], function() {
949+
// Shell out to `gulp`, since we do the work to handle sourcemaps correctly w/o inline maps there
950+
var cmd = 'gulp browserify --silent';
967951
exec(cmd);
968952
}, { async: true });
969953

970954
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], browser=[chrome|IE]");
971-
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function () {
955+
task("runtests-browser", ["browserify", nodeServerOutFile], function () {
972956
cleanTestDirs();
973957
host = "node";
974958
browser = process.env.browser || process.env.b || (os.platform() === "linux" ? "chrome" : "IE");
@@ -1123,14 +1107,15 @@ task("update-sublime", ["local", serverFile], function () {
11231107

11241108
var tslintRuleDir = "scripts/tslint";
11251109
var tslintRules = [
1126-
"nextLineRule",
11271110
"booleanTriviaRule",
1128-
"typeOperatorSpacingRule",
1129-
"noInOperatorRule",
1111+
"debugAssertRule",
1112+
"nextLineRule",
1113+
"noBomRule",
11301114
"noIncrementDecrementRule",
1131-
"objectLiteralSurroundingSpaceRule",
1115+
"noInOperatorRule",
11321116
"noTypeAssertionWhitespaceRule",
1133-
"noBomRule"
1117+
"objectLiteralSurroundingSpaceRule",
1118+
"typeOperatorSpacingRule",
11341119
];
11351120
var tslintRulesFiles = tslintRules.map(function (p) {
11361121
return path.join(tslintRuleDir, p + ".ts");

scripts/tslint/booleanTriviaRule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
3434
switch (methodName) {
3535
case "apply":
3636
case "assert":
37+
case "assertEqual":
3738
case "call":
3839
case "equal":
3940
case "fail":
@@ -69,7 +70,7 @@ function walk(ctx: Lint.WalkContext<void>): void {
6970

7071
const ranges = ts.getTrailingCommentRanges(sourceFile.text, arg.pos) || ts.getLeadingCommentRanges(sourceFile.text, arg.pos);
7172
if (ranges === undefined || ranges.length !== 1 || ranges[0].kind !== ts.SyntaxKind.MultiLineCommentTrivia) {
72-
ctx.addFailureAtNode(arg, "Tag boolean argument with parameter name");
73+
ctx.addFailureAtNode(arg, "Tag argument with parameter name");
7374
return;
7475
}
7576

scripts/tslint/debugAssertRule.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import * as Lint from "tslint/lib";
2+
import * as ts from "typescript";
3+
4+
export class Rule extends Lint.Rules.AbstractRule {
5+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
6+
return this.applyWithFunction(sourceFile, ctx => walk(ctx));
7+
}
8+
}
9+
10+
function walk(ctx: Lint.WalkContext<void>): void {
11+
ts.forEachChild(ctx.sourceFile, function recur(node) {
12+
if (ts.isCallExpression(node)) {
13+
checkCall(node);
14+
}
15+
ts.forEachChild(node, recur);
16+
});
17+
18+
function checkCall(node: ts.CallExpression) {
19+
if (!isDebugAssert(node.expression) || node.arguments.length < 2) {
20+
return;
21+
}
22+
23+
const message = node.arguments[1];
24+
if (!ts.isStringLiteral(message)) {
25+
ctx.addFailureAtNode(message, "Second argument to 'Debug.assert' should be a string literal.");
26+
}
27+
28+
if (node.arguments.length < 3) {
29+
return;
30+
}
31+
32+
const message2 = node.arguments[2];
33+
if (!ts.isStringLiteral(message2) && !ts.isArrowFunction(message2)) {
34+
ctx.addFailureAtNode(message, "Third argument to 'Debug.assert' should be a string literal or arrow function.");
35+
}
36+
}
37+
38+
function isDebugAssert(expr: ts.Node): boolean {
39+
return ts.isPropertyAccessExpression(expr) && isName(expr.expression, "Debug") && isName(expr.name, "assert");
40+
}
41+
42+
function isName(expr: ts.Node, text: string): boolean {
43+
return ts.isIdentifier(expr) && expr.text === text;
44+
}
45+
}

src/compiler/binder.ts

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -806,43 +806,26 @@ namespace ts {
806806
return antecedent;
807807
}
808808
setFlowNodeReferenced(antecedent);
809-
return <FlowCondition>{
810-
flags,
811-
expression,
812-
antecedent
813-
};
809+
return { flags, expression, antecedent };
814810
}
815811

816812
function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode {
817813
if (!isNarrowingExpression(switchStatement.expression)) {
818814
return antecedent;
819815
}
820816
setFlowNodeReferenced(antecedent);
821-
return <FlowSwitchClause>{
822-
flags: FlowFlags.SwitchClause,
823-
switchStatement,
824-
clauseStart,
825-
clauseEnd,
826-
antecedent
827-
};
817+
return { flags: FlowFlags.SwitchClause, switchStatement, clauseStart, clauseEnd, antecedent };
828818
}
829819

830820
function createFlowAssignment(antecedent: FlowNode, node: Expression | VariableDeclaration | BindingElement): FlowNode {
831821
setFlowNodeReferenced(antecedent);
832-
return <FlowAssignment>{
833-
flags: FlowFlags.Assignment,
834-
antecedent,
835-
node
836-
};
822+
return { flags: FlowFlags.Assignment, antecedent, node };
837823
}
838824

839825
function createFlowArrayMutation(antecedent: FlowNode, node: CallExpression | BinaryExpression): FlowNode {
840826
setFlowNodeReferenced(antecedent);
841-
return <FlowArrayMutation>{
842-
flags: FlowFlags.ArrayMutation,
843-
antecedent,
844-
node
845-
};
827+
const res: FlowArrayMutation = { flags: FlowFlags.ArrayMutation, antecedent, node };
828+
return res;
846829
}
847830

848831
function finishFlowLabel(flow: FlowLabel): FlowNode {
@@ -2921,7 +2904,10 @@ namespace ts {
29212904
function computeCatchClause(node: CatchClause, subtreeFlags: TransformFlags) {
29222905
let transformFlags = subtreeFlags;
29232906

2924-
if (node.variableDeclaration && isBindingPattern(node.variableDeclaration.name)) {
2907+
if (!node.variableDeclaration) {
2908+
transformFlags |= TransformFlags.AssertESNext;
2909+
}
2910+
else if (isBindingPattern(node.variableDeclaration.name)) {
29252911
transformFlags |= TransformFlags.AssertES2015;
29262912
}
29272913

0 commit comments

Comments
 (0)