Skip to content

Commit abc8110

Browse files
committed
Merge branch 'master' into conditionalTypes
# Conflicts: # src/compiler/checker.ts
2 parents 3f4911f + 5539e11 commit abc8110

571 files changed

Lines changed: 30602 additions & 8370 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.

.gitmodules

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,19 @@
22
path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter
33
url = https://github.com/Microsoft/TypeScript-React-Starter
44
ignore = all
5-
shallow = true
65
[submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"]
76
path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter
87
url = https://github.com/Microsoft/TypeScript-Node-Starter.git
98
ignore = all
10-
shallow = true
119
[submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"]
1210
path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter
1311
url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git
1412
ignore = all
15-
shallow = true
1613
[submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"]
1714
path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter
1815
url = https://github.com/Microsoft/TypeScript-Vue-Starter.git
1916
ignore = all
20-
shallow = true
2117
[submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"]
2218
path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter
2319
url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git
2420
ignore = all
25-
shallow = true

Jakefile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ var harnessSources = harnessCoreSources.concat([
130130
"textStorage.ts",
131131
"moduleResolution.ts",
132132
"tsconfigParsing.ts",
133+
"asserts.ts",
133134
"builder.ts",
134135
"commandLineParsing.ts",
135136
"configurationExtension.ts",

package-lock.json

Lines changed: 484 additions & 291 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"devDependencies": {
3232
"@types/browserify": "latest",
3333
"@types/chai": "latest",
34-
"@types/colors": "latest",
3534
"@types/convert-source-map": "latest",
3635
"@types/del": "latest",
3736
"@types/glob": "latest",
@@ -80,7 +79,7 @@
8079
"ts-node": "latest",
8180
"tslint": "latest",
8281
"vinyl": "latest",
83-
"colors": "latest",
82+
"chalk": "latest",
8483
"typescript": "next"
8584
},
8685
"scripts": {

scripts/tslint/formatters/autolinkableStylishFormatter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Lint from "tslint";
2-
import * as colors from "colors";
2+
import chalk from "chalk";
33
import { sep } from "path";
44
function groupBy<T>(array: ReadonlyArray<T> | undefined, getGroupId: (elem: T, index: number) => number | string): T[][] {
55
if (!array) {
@@ -52,7 +52,7 @@ function getLink(failure: Lint.RuleFailure, color: boolean): string {
5252
if (path.indexOf("/") === -1 && path.indexOf("\\") === -1) {
5353
path = `.${sep}${path}`;
5454
}
55-
return `${color ? (sev === "WARNING" ? colors.blue(sev) : colors.red(sev)) : sev}: ${path}:${lineAndCharacter.line + 1}:${lineAndCharacter.character + 1}`;
55+
return `${color ? (sev === "WARNING" ? chalk.blue(sev) : chalk.red(sev)) : sev}: ${path}:${lineAndCharacter.line + 1}:${lineAndCharacter.character + 1}`;
5656
}
5757

5858
function getLinkMaxSize(failures: Lint.RuleFailure[]): number {
@@ -91,7 +91,7 @@ export class Formatter extends Lint.Formatters.AbstractFormatter {
9191
const nameMaxSize = getNameMaxSize(group);
9292
return `
9393
${currentFile}
94-
${group.map(f => `${pad(getLink(f, /*color*/ true), getLink(f, /*color*/ false).length, linkMaxSize)} ${colors.grey(pad(f.getRuleName(), f.getRuleName().length, nameMaxSize))} ${colors.yellow(f.getFailure())}`).join("\n")}`;
94+
${group.map(f => `${pad(getLink(f, /*color*/ true), getLink(f, /*color*/ false).length, linkMaxSize)} ${chalk.grey(pad(f.getRuleName(), f.getRuleName().length, nameMaxSize))} ${chalk.yellow(f.getFailure())}`).join("\n")}`;
9595
}).join("\n");
9696
}
9797
}

src/compiler/binder.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,10 @@ namespace ts {
749749
return expr1.kind === SyntaxKind.TypeOfExpression && isNarrowableOperand((<TypeOfExpression>expr1).expression) && expr2.kind === SyntaxKind.StringLiteral;
750750
}
751751

752+
function isNarrowableInOperands(left: Expression, right: Expression) {
753+
return left.kind === SyntaxKind.StringLiteral && isNarrowingExpression(right);
754+
}
755+
752756
function isNarrowingBinaryExpression(expr: BinaryExpression) {
753757
switch (expr.operatorToken.kind) {
754758
case SyntaxKind.EqualsToken:
@@ -761,6 +765,8 @@ namespace ts {
761765
isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
762766
case SyntaxKind.InstanceOfKeyword:
763767
return isNarrowableOperand(expr.left);
768+
case SyntaxKind.InKeyword:
769+
return isNarrowableInOperands(expr.left, expr.right);
764770
case SyntaxKind.CommaToken:
765771
return isNarrowingExpression(expr.right);
766772
}

src/compiler/builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ namespace ts {
468468
}
469469

470470
function getReferencedByPaths(referencedFilePath: Path) {
471-
return mapDefinedIter(references.entries(), ([filePath, referencesInFile]) =>
471+
return arrayFrom(mapDefinedIterator(references.entries(), ([filePath, referencesInFile]) =>
472472
referencesInFile.has(referencedFilePath) ? filePath as Path : undefined
473-
);
473+
));
474474
}
475475

476476
function getFilesAffectedByUpdatedShape(program: Program, sourceFile: SourceFile): ReadonlyArray<SourceFile> {
@@ -504,7 +504,7 @@ namespace ts {
504504
}
505505

506506
// Return array of values that needs emit
507-
return flatMapIter(seenFileNamesMap.values(), value => value);
507+
return arrayFrom(mapDefinedIterator(seenFileNamesMap.values(), value => value));
508508
}
509509
}
510510
}

0 commit comments

Comments
 (0)