Skip to content

Commit 2cb3122

Browse files
committed
Merge remote-tracking branch 'origin/master' into tsserverVS-WIP
2 parents 01c1bdb + 0c131fa commit 2cb3122

486 files changed

Lines changed: 14751 additions & 5225 deletions

File tree

Some content is hidden

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

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ os:
1313

1414
matrix:
1515
fast_finish: true
16+
exclude:
17+
- os: osx
18+
node_js: '4'
19+
- os: osx
20+
node_js: '0.10'
21+
22+
branches:
23+
only:
24+
- master
25+
- transforms

Gulpfile.ts

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo
710710
const originalMap = file.sourceMap;
711711
const prebundledContent = file.contents.toString();
712712
// 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));
713+
originalMap.sources = originalMap.sources.map(s => path.resolve("src", s));
714714
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
715715
originalMap.file = "built/local/_stream_0.js";
716716

@@ -918,37 +918,20 @@ gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", s
918918
return gulp.src([serverFile, serverFile + ".map"]).pipe(gulp.dest("../TypeScript-Sublime-Plugin/tsserver/"));
919919
});
920920

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;
921+
gulp.task("build-rules", "Compiles tslint rules to js", () => {
922+
const settings: tsc.Settings = getCompilerSettings({ module: "commonjs" }, /*useBuiltCompiler*/ false);
923+
const dest = path.join(builtLocalDirectory, "tslint");
924+
return gulp.src("scripts/tslint/**/*.ts")
925+
.pipe(newer({
926+
dest,
927+
ext: ".js"
928+
}))
929+
.pipe(sourcemaps.init())
930+
.pipe(tsc(settings))
931+
.pipe(sourcemaps.write("."))
932+
.pipe(gulp.dest(dest));
947933
});
948934

949-
gulp.task("build-rules", "Compiles tslint rules to js", tslintRulesOutFiles);
950-
951-
952935
function getLinterOptions() {
953936
return {
954937
configuration: require("./tslint.json"),

Jakefile.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,15 +491,6 @@ task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "r
491491
exec(cmd);
492492
});
493493

494-
var scriptsTsdJson = path.join(scriptsDirectory, "tsd.json");
495-
file(scriptsTsdJson);
496-
497-
task("tsd-scripts", [scriptsTsdJson], function () {
498-
var cmd = "tsd --config " + scriptsTsdJson + " install";
499-
console.log(cmd);
500-
exec(cmd);
501-
}, { async: true });
502-
503494
var importDefinitelyTypedTestsDirectory = path.join(scriptsDirectory, "importDefinitelyTypedTests");
504495
var importDefinitelyTypedTestsJs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.js");
505496
var importDefinitelyTypedTestsTs = path.join(importDefinitelyTypedTestsDirectory, "importDefinitelyTypedTests.ts");
@@ -680,7 +671,7 @@ var run = path.join(builtLocalDirectory, "run.js");
680671
compileFile(
681672
/*outFile*/ run,
682673
/*source*/ harnessSources,
683-
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources),
674+
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
684675
/*prefixes*/ [],
685676
/*useBuiltCompiler:*/ true,
686677
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
@@ -1025,6 +1016,7 @@ var tslintRules = [
10251016
"noInOperatorRule",
10261017
"noIncrementDecrementRule",
10271018
"objectLiteralSurroundingSpaceRule",
1019+
"noTypeAssertionWhitespaceRule"
10281020
];
10291021
var tslintRulesFiles = tslintRules.map(function(p) {
10301022
return path.join(tslintRuleDir, p + ".ts");

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
"sorcery": "latest",
7474
"through2": "latest",
7575
"ts-node": "latest",
76-
"tsd": "latest",
7776
"tslint": "next",
7877
"typescript": "next"
7978
},

scripts/tsd.json

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
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

Lines changed: 4 additions & 18 deletions
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)