Skip to content

Commit ec4c6fe

Browse files
committed
Merge branch 'master' into lint-nested-++
2 parents 710b379 + 0debd2b commit ec4c6fe

31 files changed

+490
-561
lines changed

Jakefile.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -911,11 +911,19 @@ function lintFileAsync(options, path, cb) {
911911
});
912912
}
913913

914+
var servicesLintTargets = [
915+
"services.ts",
916+
"outliningElementsCollector.ts",
917+
"navigateTo.ts",
918+
"patternMatcher.ts",
919+
].map(function (s) {
920+
return path.join(servicesDirectory, s);
921+
});
914922
var lintTargets = compilerSources
915923
.concat(harnessCoreSources)
916924
.concat(serverCoreSources)
917925
.concat(tslintRulesFiles)
918-
.concat([path.join(servicesDirectory, "services.ts")]);
926+
.concat(servicesLintTargets);
919927

920928
desc("Runs tslint on the compiler sources");
921929
task("lint", ["build-rules"], function() {
-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

+4-4
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

+6-2
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
}

scripts/word2md.js

-235
This file was deleted.

scripts/word2md.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ module Word {
7272
listFormat: ListFormat;
7373
tables: Tables;
7474
text: string;
75+
textRetrievalMode: {
76+
includeHiddenText: boolean;
77+
}
7578
words: Ranges;
7679
}
7780

@@ -258,13 +261,27 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
258261

259262
function writeParagraph(p: Word.Paragraph) {
260263

261-
var text = p.range.text;
264+
var range = p.range;
265+
var text = range.text;
262266
var style = p.style.nameLocal;
263-
var inTable = p.range.tables.count > 0;
267+
var inTable = range.tables.count > 0;
264268
var level = 1;
265269
var sectionBreak = text.indexOf("\x0C") >= 0;
266270

267271
text = trimEndFormattingMarks(text);
272+
if (text === "/") {
273+
// An inline image shows up in the text as a "/". When we see a paragraph
274+
// consisting of nothing but "/", we check to see if the paragraph contains
275+
// hidden text and, if so, emit that instead. The hidden text is assumed to
276+
// contain an appropriate markdown image link.
277+
range.textRetrievalMode.includeHiddenText = true;
278+
var fullText = range.text;
279+
range.textRetrievalMode.includeHiddenText = false;
280+
if (text !== fullText) {
281+
text = "&emsp;&emsp;" + fullText.substr(1);
282+
}
283+
}
284+
268285
if (inTable) {
269286
style = "Table";
270287
}
@@ -280,7 +297,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
280297

281298
case "Heading":
282299
case "Appendix":
283-
var section = p.range.listFormat.listString;
300+
var section = range.listFormat.listString;
284301
write("####".substr(0, level) + ' <a name="' + section + '"/>' + section + " " + text + "\n\n");
285302
break;
286303

@@ -291,7 +308,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
291308
break;
292309

293310
case "List Paragraph":
294-
write(" ".substr(0, p.range.listFormat.listLevelNumber * 2 - 2) + "* " + text + "\n");
311+
write(" ".substr(0, range.listFormat.listLevelNumber * 2 - 2) + "* " + text + "\n");
295312
break;
296313

297314
case "Grammar":
@@ -310,7 +327,7 @@ function convertDocumentToMarkdown(doc: Word.Document): string {
310327

311328
case "Table":
312329
if (!lastInTable) {
313-
tableColumnCount = p.range.tables.item(1).columns.count + 1;
330+
tableColumnCount = range.tables.item(1).columns.count + 1;
314331
tableCellIndex = 0;
315332
}
316333
if (tableCellIndex < tableColumnCount) {

0 commit comments

Comments
 (0)