Skip to content

Commit 2821d98

Browse files
author
Andy Hanson
committed
Merge branch 'master' into no_ts_extension
2 parents a8c05a9 + f06413b commit 2821d98

File tree

592 files changed

+17791
-33364
lines changed

Some content is hidden

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

592 files changed

+17791
-33364
lines changed

.travis.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,24 @@ node_js:
77

88
sudo: false
99

10-
os:
11-
- linux
12-
- osx
13-
1410
matrix:
1511
fast_finish: true
12+
include:
13+
- os: osx
14+
node_js: stable
15+
osx_image: xcode7.3
16+
17+
branches:
18+
only:
19+
- master
20+
- transforms
21+
22+
install:
23+
- npm uninstall typescript
24+
- npm uninstall tslint
25+
- npm install
26+
- npm update
27+
28+
cache:
29+
directories:
30+
- node_modules

Gulpfile.ts

+15-35
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ const cmdLineOptions = minimist(process.argv.slice(2), {
5959
browser: process.env.browser || process.env.b || "IE",
6060
tests: process.env.test || process.env.tests || process.env.t,
6161
light: process.env.light || false,
62-
port: process.env.port || process.env.p || "8888",
6362
reporter: process.env.reporter || process.env.r,
6463
lint: process.env.lint || true,
6564
files: process.env.f || process.env.file || process.env.files || "",
@@ -710,7 +709,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
710709
const originalMap = file.sourceMap;
711710
const prebundledContent = file.contents.toString();
712711
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
713-
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
712+
originalMap.sources = originalMap.sources.map(s => path.resolve("src", s));
714713
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
715714
originalMap.file = "built/local/_stream_0.js";
716715

@@ -766,7 +765,7 @@ function writeTestConfigFile(tests: string, light: boolean, taskConfigsFolder?:
766765
}
767766

768767

769-
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --port=, --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
768+
gulp.task("runtests-browser", "Runs the tests using the built run.js file like 'gulp runtests'. Syntax is gulp runtests-browser. Additional optional parameters --tests=[regex], --browser=[chrome|IE]", ["browserify", nodeServerOutFile], (done) => {
770769
cleanTestDirs((err) => {
771770
if (err) { console.error(err); done(err); process.exit(1); }
772771
host = "node";
@@ -781,9 +780,6 @@ gulp.task("runtests-browser", "Runs the tests using the built run.js file like '
781780
}
782781

783782
const args = [nodeServerOutFile];
784-
if (cmdLineOptions["port"]) {
785-
args.push(cmdLineOptions["port"]);
786-
}
787783
if (cmdLineOptions["browser"]) {
788784
args.push(cmdLineOptions["browser"]);
789785
}
@@ -918,37 +914,20 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s
918914
return gulp.src([serverFile, serverFile + ".map"]).pipe(gulp.dest("../TypeScript-Sublime-Plugin/tsserver/"));
919915
});
920916

921-
922-
const tslintRuleDir = "scripts/tslint";
923-
const tslintRules = [
924-
"nextLineRule",
925-
"preferConstRule",
926-
"booleanTriviaRule",
927-
"typeOperatorSpacingRule",
928-
"noInOperatorRule",
929-
"noIncrementDecrementRule",
930-
"objectLiteralSurroundingSpaceRule",
931-
];
932-
const tslintRulesFiles = tslintRules.map(function(p) {
933-
return path.join(tslintRuleDir, p + ".ts");
934-
});
935-
const tslintRulesOutFiles = tslintRules.map(function(p, i) {
936-
const pathname = path.join(builtLocalDirectory, "tslint", p + ".js");
937-
gulp.task(pathname, false, [], () => {
938-
const settings: tsc.Settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ false);
939-
return gulp.src(tslintRulesFiles[i])
940-
.pipe(newer(pathname))
941-
.pipe(sourcemaps.init())
942-
.pipe(tsc(settings))
943-
.pipe(sourcemaps.write("."))
944-
.pipe(gulp.dest(path.join(builtLocalDirectory, "tslint")));
945-
});
946-
return pathname;
917+
gulp.task("build-rules", "Compiles tslint rules to js", () => {
918+
const settings: tsc.Settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ false);
919+
const dest = path.join(builtLocalDirectory, "tslint");
920+
return gulp.src("scripts/tslint/**/*.ts")
921+
.pipe(newer({
922+
dest,
923+
ext: ".js"
924+
}))
925+
.pipe(sourcemaps.init())
926+
.pipe(tsc(settings))
927+
.pipe(sourcemaps.write("."))
928+
.pipe(gulp.dest(dest));
947929
});
948930

949-
gulp.task("build-rules", "Compiles tslint rules to js", tslintRulesOutFiles);
950-
951-
952931
function getLinterOptions() {
953932
return {
954933
configuration: require("./tslint.json"),
@@ -977,6 +956,7 @@ const lintTargets = [
977956
"src/server/**/*.ts",
978957
"scripts/tslint/**/*.ts",
979958
"src/services/**/*.ts",
959+
"tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively
980960
];
981961

982962

Jakefile.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ var run = path.join(builtLocalDirectory, "run.js");
645645
compileFile(
646646
/*outFile*/ run,
647647
/*source*/ harnessSources,
648-
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources),
648+
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
649649
/*prefixes*/ [],
650650
/*useBuiltCompiler:*/ true,
651651
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
@@ -847,11 +847,10 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
847847
exec(cmd);
848848
}, {async: true});
849849

850-
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
850+
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]");
851851
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() {
852852
cleanTestDirs();
853853
host = "node";
854-
port = process.env.port || process.env.p || '8888';
855854
browser = process.env.browser || process.env.b || "IE";
856855
tests = process.env.test || process.env.tests || process.env.t;
857856
var light = process.env.light || false;
@@ -864,7 +863,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi
864863
}
865864

866865
tests = tests ? tests : '';
867-
var cmd = host + " tests/webTestServer.js " + port + " " + browser + " " + JSON.stringify(tests);
866+
var cmd = host + " tests/webTestServer.js " + browser + " " + JSON.stringify(tests);
868867
console.log(cmd);
869868
exec(cmd);
870869
}, {async: true});
@@ -990,6 +989,7 @@ var tslintRules = [
990989
"noInOperatorRule",
991990
"noIncrementDecrementRule",
992991
"objectLiteralSurroundingSpaceRule",
992+
"noTypeAssertionWhitespaceRule"
993993
];
994994
var tslintRulesFiles = tslintRules.map(function(p) {
995995
return path.join(tslintRuleDir, p + ".ts");
@@ -1041,7 +1041,8 @@ var lintTargets = compilerSources
10411041
.concat(serverCoreSources)
10421042
.concat(tslintRulesFiles)
10431043
.concat(servicesSources)
1044-
.concat(["Gulpfile.ts"]);
1044+
.concat(["Gulpfile.ts"])
1045+
.concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]);
10451046

10461047

10471048
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as Lint from "tslint/lib/lint";
2+
import * as ts from "typescript";
3+
4+
5+
export class Rule extends Lint.Rules.AbstractRule {
6+
public static TRAILING_FAILURE_STRING = "Excess trailing whitespace found around type assertion.";
7+
8+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
9+
return this.applyWithWalker(new TypeAssertionWhitespaceWalker(sourceFile, this.getOptions()));
10+
}
11+
}
12+
13+
class TypeAssertionWhitespaceWalker extends Lint.RuleWalker {
14+
public visitNode(node: ts.Node) {
15+
if (node.kind === ts.SyntaxKind.TypeAssertionExpression) {
16+
const refined = node as ts.TypeAssertion;
17+
const leftSideWhitespaceStart = refined.type.getEnd() + 1;
18+
const rightSideWhitespaceEnd = refined.expression.getStart();
19+
if (leftSideWhitespaceStart !== rightSideWhitespaceEnd) {
20+
this.addFailure(this.createFailure(leftSideWhitespaceStart, rightSideWhitespaceEnd, Rule.TRAILING_FAILURE_STRING));
21+
}
22+
}
23+
super.visitNode(node);
24+
}
25+
}

src/compiler/binder.ts

+4-18
Original file line numberDiff line numberDiff line change
@@ -618,18 +618,10 @@ namespace ts {
618618
return false;
619619
}
620620

621-
function isNarrowingNullCheckOperands(expr1: Expression, expr2: Expression) {
622-
return (expr1.kind === SyntaxKind.NullKeyword || expr1.kind === SyntaxKind.Identifier && (<Identifier>expr1).text === "undefined") && isNarrowableOperand(expr2);
623-
}
624-
625621
function isNarrowingTypeofOperands(expr1: Expression, expr2: Expression) {
626622
return expr1.kind === SyntaxKind.TypeOfExpression && isNarrowableOperand((<TypeOfExpression>expr1).expression) && expr2.kind === SyntaxKind.StringLiteral;
627623
}
628624

629-
function isNarrowingDiscriminant(expr: Expression) {
630-
return expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((<PropertyAccessExpression>expr).expression);
631-
}
632-
633625
function isNarrowingBinaryExpression(expr: BinaryExpression) {
634626
switch (expr.operatorToken.kind) {
635627
case SyntaxKind.EqualsToken:
@@ -638,9 +630,8 @@ namespace ts {
638630
case SyntaxKind.ExclamationEqualsToken:
639631
case SyntaxKind.EqualsEqualsEqualsToken:
640632
case SyntaxKind.ExclamationEqualsEqualsToken:
641-
return isNarrowingNullCheckOperands(expr.right, expr.left) || isNarrowingNullCheckOperands(expr.left, expr.right) ||
642-
isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) ||
643-
isNarrowingDiscriminant(expr.left) || isNarrowingDiscriminant(expr.right);
633+
return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
634+
isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
644635
case SyntaxKind.InstanceOfKeyword:
645636
return isNarrowableOperand(expr.left);
646637
case SyntaxKind.CommaToken:
@@ -664,11 +655,6 @@ namespace ts {
664655
return isNarrowableReference(expr);
665656
}
666657

667-
function isNarrowingSwitchStatement(switchStatement: SwitchStatement) {
668-
const expr = switchStatement.expression;
669-
return expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((<PropertyAccessExpression>expr).expression);
670-
}
671-
672658
function createBranchLabel(): FlowLabel {
673659
return {
674660
flags: FlowFlags.BranchLabel,
@@ -718,7 +704,7 @@ namespace ts {
718704
}
719705

720706
function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode {
721-
if (!isNarrowingSwitchStatement(switchStatement)) {
707+
if (!isNarrowingExpression(switchStatement.expression)) {
722708
return antecedent;
723709
}
724710
setFlowNodeReferenced(antecedent);
@@ -1983,7 +1969,7 @@ namespace ts {
19831969
function bindThisPropertyAssignment(node: BinaryExpression) {
19841970
// Declare a 'member' in case it turns out the container was an ES5 class or ES6 constructor
19851971
let assignee: Node;
1986-
if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionDeclaration) {
1972+
if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) {
19871973
assignee = container;
19881974
}
19891975
else if (container.kind === SyntaxKind.Constructor) {

0 commit comments

Comments
 (0)