Skip to content

Commit cde12ef

Browse files
committed
Merge branch 'master' into glob2
2 parents c224917 + 669e733 commit cde12ef

File tree

221 files changed

+5651
-2193
lines changed

Some content is hidden

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

221 files changed

+5651
-2193
lines changed

Jakefile.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,6 @@ var serverCoreSources = [
108108
return path.join(serverDirectory, f);
109109
});
110110

111-
var scriptSources = [
112-
"tslint/booleanTriviaRule.ts",
113-
"tslint/nextLineRule.ts",
114-
"tslint/noNullRule.ts",
115-
"tslint/preferConstRule.ts",
116-
"tslint/typeOperatorSpacingRule.ts",
117-
"tslint/noInOperatorRule.ts"
118-
].map(function (f) {
119-
return path.join(scriptsDirectory, f);
120-
});
121-
122111
var serverSources = serverCoreSources.concat(servicesSources);
123112

124113
var languageServiceLibrarySources = [
@@ -880,7 +869,8 @@ var tslintRules = ([
880869
"preferConstRule",
881870
"booleanTriviaRule",
882871
"typeOperatorSpacingRule",
883-
"noInOperatorRule"
872+
"noInOperatorRule",
873+
"noIncrementDecrementRule"
884874
]);
885875
var tslintRulesFiles = tslintRules.map(function(p) {
886876
return path.join(tslintRuleDir, p + ".ts");
@@ -923,10 +913,19 @@ function lintFileAsync(options, path, cb) {
923913
});
924914
}
925915

916+
var servicesLintTargets = [
917+
"services.ts",
918+
"outliningElementsCollector.ts",
919+
"navigateTo.ts",
920+
"patternMatcher.ts",
921+
].map(function (s) {
922+
return path.join(servicesDirectory, s);
923+
});
926924
var lintTargets = compilerSources
927925
.concat(harnessCoreSources)
928926
.concat(serverCoreSources)
929-
.concat(scriptSources);
927+
.concat(tslintRulesFiles)
928+
.concat(servicesLintTargets);
930929

931930
desc("Runs tslint on the compiler sources");
932931
task("lint", ["build-rules"], function() {

doc/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
This directory contains miscellaneous documentation such as the TypeScript language specification and logo.
2+
If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook).
3+
4+
# Spec Contributions
5+
6+
The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats.
7+
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests.
-228 Bytes
Binary file not shown.

doc/images/image1.png

11.4 KB
Loading

doc/images/image2.png

10 KB
Loading

doc/images/image3.png

5.86 KB
Loading

doc/images/image4.png

15.7 KB
Loading

doc/spec.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function f() {
262262

263263
To benefit from this inference, a programmer can use the TypeScript language service. For example, a code editor can incorporate the TypeScript language service and use the service to find the members of a string object as in the following screen shot.
264264

265-
/
265+
  ![](images/image1.png)
266266

267267
In this example, the programmer benefits from type inference without providing type annotations. Some beneficial tools, however, do require the programmer to provide type annotations. In TypeScript, we can express a parameter requirement as in the following code fragment.
268268

@@ -410,7 +410,7 @@ This signature denotes that a function may be passed as the parameter of the '$'
410410
411411
A typical client would not need to add any additional typing but could just use a community-supplied typing to discover (through statement completion with documentation tips) and verify (through static checking) correct use of the library, as in the following screen shot.
412412
413-
/
413+
  ![](images/image2.png)
414414
415415
Section [3.3](#3.3) provides additional information about object types.
416416
@@ -627,7 +627,7 @@ An important goal of TypeScript is to provide accurate and straightforward types
627627

628628
JavaScript programming interfaces often include functions whose behavior is discriminated by a string constant passed to the function. The Document Object Model makes heavy use of this pattern. For example, the following screen shot shows that the 'createElement' method of the 'document' object has multiple signatures, some of which identify the types returned when specific strings are passed into the method.
629629

630-
/
630+
  ![](images/image3.png)
631631

632632
The following code fragment uses this feature. Because the 'span' variable is inferred to have the type 'HTMLSpanElement', the code can reference without static error the 'isMultiline' property of 'span'.
633633

@@ -638,7 +638,7 @@ span.isMultiLine = false; // OK: HTMLSpanElement has isMultiline property
638638

639639
In the following screen shot, a programming tool combines information from overloading on string parameters with contextual typing to infer that the type of the variable 'e' is 'MouseEvent' and that therefore 'e' has a 'clientX' property.
640640

641-
/
641+
  ![](images/image4.png)
642642

643643
Section [3.9.2.4](#3.9.2.4) provides details on how to use string literals in function signatures.
644644

scripts/tslint/booleanTriviaRule.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class BooleanTriviaWalker extends Lint.RuleWalker {
2626
for (let index = 0; index < targetParameters.length; index++) {
2727
const param = targetParameters[index];
2828
const arg = node.arguments[index];
29-
if (!(arg && param)) continue;
29+
if (!(arg && param)) {
30+
continue;
31+
}
3032

3133
const argType = this.checker.getContextualType(arg);
3234
if (argType && (argType.getFlags() & ts.TypeFlags.Boolean)) {
@@ -38,7 +40,9 @@ class BooleanTriviaWalker extends Lint.RuleWalker {
3840
if (ranges && ranges.length === 1 && ranges[0].kind === ts.SyntaxKind.MultiLineCommentTrivia) {
3941
triviaContent = arg.getFullText().slice(ranges[0].pos + 2, ranges[0].end - 2); // +/-2 to remove /**/
4042
}
41-
if (triviaContent !== param.getName()) {
43+
44+
const paramName = param.getName();
45+
if (triviaContent !== paramName && triviaContent !== paramName + ":") {
4246
this.addFailure(this.createFailure(arg.getStart(source), arg.getWidth(source), Rule.FAILURE_STRING_FACTORY(param.getName(), triviaContent)));
4347
}
4448
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 POSTFIX_FAILURE_STRING = "Don't use '++' or '--' postfix operators outside statements or for loops.";
7+
public static PREFIX_FAILURE_STRING = "Don't use '++' or '--' prefix operators.";
8+
9+
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
10+
return this.applyWithWalker(new IncrementDecrementWalker(sourceFile, this.getOptions()));
11+
}
12+
}
13+
14+
class IncrementDecrementWalker extends Lint.RuleWalker {
15+
16+
visitPostfixUnaryExpression(node: ts.PostfixUnaryExpression) {
17+
super.visitPostfixUnaryExpression(node);
18+
if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) {
19+
this.visitIncrementDecrement(node);
20+
}
21+
}
22+
23+
visitPrefixUnaryExpression(node: ts.PrefixUnaryExpression) {
24+
super.visitPrefixUnaryExpression(node);
25+
if (node.operator === ts.SyntaxKind.PlusPlusToken || node.operator == ts.SyntaxKind.MinusMinusToken) {
26+
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.PREFIX_FAILURE_STRING));
27+
}
28+
}
29+
30+
visitIncrementDecrement(node: ts.UnaryExpression) {
31+
if (node.parent && (node.parent.kind === ts.SyntaxKind.ExpressionStatement ||
32+
node.parent.kind === ts.SyntaxKind.ForStatement)) {
33+
return;
34+
}
35+
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.POSTFIX_FAILURE_STRING));
36+
}
37+
}

scripts/word2md.js

Lines changed: 0 additions & 235 deletions
This file was deleted.

0 commit comments

Comments
 (0)