Skip to content

Commit b9bbd86

Browse files
committed
Merge remote-tracking branch 'origin/tsserverVS-WIP' into tsserverVS-WIP-mixedcontent
2 parents a1e5eeb + 2f7e738 commit b9bbd86

456 files changed

Lines changed: 13887 additions & 4927 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: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ var run = path.join(builtLocalDirectory, "run.js");
671671
compileFile(
672672
/*outFile*/ run,
673673
/*source*/ harnessSources,
674-
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(harnessSources),
674+
/*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources),
675675
/*prefixes*/ [],
676676
/*useBuiltCompiler:*/ true,
677677
/*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] });
@@ -1016,6 +1016,7 @@ var tslintRules = [
10161016
"noInOperatorRule",
10171017
"noIncrementDecrementRule",
10181018
"objectLiteralSurroundingSpaceRule",
1019+
"noTypeAssertionWhitespaceRule"
10191020
];
10201021
var tslintRulesFiles = tslintRules.map(function(p) {
10211022
return path.join(tslintRuleDir, p + ".ts");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"run-sequence": "latest",
7373
"sorcery": "latest",
7474
"through2": "latest",
75-
"ts-node": "~1.1.0",
75+
"ts-node": "latest",
7676
"tslint": "next",
7777
"typescript": "next"
7878
},
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)