Skip to content

Commit 2ae6ecc

Browse files
committed
Merge branch 'master' into object-spread
2 parents 988bf1f + 7b34b61 commit 2ae6ecc

203 files changed

Lines changed: 5439 additions & 2038 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.

src/compiler/binder.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ namespace ts {
499499
const saveReturnTarget = currentReturnTarget;
500500
const saveActiveLabels = activeLabels;
501501
const saveHasExplicitReturn = hasExplicitReturn;
502-
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !!getImmediatelyInvokedFunctionExpression(node);
503-
// An IIFE is considered part of the containing control flow. Return statements behave
502+
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasModifier(node, ModifierFlags.Async) && !!getImmediatelyInvokedFunctionExpression(node);
503+
// A non-async IIFE is considered part of the containing control flow. Return statements behave
504504
// similarly to break statements that exit to a label just past the statement body.
505505
if (isIIFE) {
506506
currentReturnTarget = createBranchLabel();
@@ -892,8 +892,13 @@ namespace ts {
892892

893893
function bindDoStatement(node: DoStatement): void {
894894
const preDoLabel = createLoopLabel();
895-
const preConditionLabel = createBranchLabel();
896-
const postDoLabel = createBranchLabel();
895+
const enclosingLabeledStatement = node.parent.kind === SyntaxKind.LabeledStatement
896+
? lastOrUndefined(activeLabels)
897+
: undefined;
898+
// if do statement is wrapped in labeled statement then target labels for break/continue with or without
899+
// label should be the same
900+
const preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel();
901+
const postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement.breakTarget : createBranchLabel();
897902
addAntecedent(preDoLabel, currentFlow);
898903
currentFlow = preDoLabel;
899904
bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
@@ -1111,8 +1116,11 @@ namespace ts {
11111116
if (!activeLabel.referenced && !options.allowUnusedLabels) {
11121117
file.bindDiagnostics.push(createDiagnosticForNode(node.label, Diagnostics.Unused_label));
11131118
}
1114-
addAntecedent(postStatementLabel, currentFlow);
1115-
currentFlow = finishFlowLabel(postStatementLabel);
1119+
if (!node.statement || node.statement.kind !== SyntaxKind.DoStatement) {
1120+
// do statement sets current flow inside bindDoStatement
1121+
addAntecedent(postStatementLabel, currentFlow);
1122+
currentFlow = finishFlowLabel(postStatementLabel);
1123+
}
11161124
}
11171125

11181126
function bindDestructuringTargetFlow(node: Expression) {
@@ -1204,9 +1212,9 @@ namespace ts {
12041212
}
12051213
else {
12061214
forEachChild(node, bind);
1207-
if (operator === SyntaxKind.EqualsToken && !isAssignmentTarget(node)) {
1215+
if (isAssignmentOperator(operator) && !isAssignmentTarget(node)) {
12081216
bindAssignmentTargetFlow(node.left);
1209-
if (node.left.kind === SyntaxKind.ElementAccessExpression) {
1217+
if (operator === SyntaxKind.EqualsToken && node.left.kind === SyntaxKind.ElementAccessExpression) {
12101218
const elementAccess = <ElementAccessExpression>node.left;
12111219
if (isNarrowableOperand(elementAccess.expression)) {
12121220
currentFlow = createFlowArrayMutation(currentFlow, node);
@@ -3093,6 +3101,8 @@ namespace ts {
30933101
case SyntaxKind.InterfaceDeclaration:
30943102
case SyntaxKind.TypeAliasDeclaration:
30953103
case SyntaxKind.ThisType:
3104+
case SyntaxKind.TypeOperator:
3105+
case SyntaxKind.IndexedAccessType:
30963106
case SyntaxKind.LiteralType:
30973107
// Types and signatures are TypeScript syntax, and exclude all other facts.
30983108
transformFlags = TransformFlags.AssertTypeScript;

src/compiler/checker.ts

Lines changed: 416 additions & 337 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,9 +1008,7 @@ namespace ts {
10081008
function convertTypingOptionsFromJsonWorker(jsonOptions: any,
10091009
basePath: string, errors: Diagnostic[], configFileName?: string): TypingOptions {
10101010

1011-
const options: TypingOptions = getBaseFileName(configFileName) === "jsconfig.json"
1012-
? { enableAutoDiscovery: true, include: [], exclude: [] }
1013-
: { enableAutoDiscovery: false, include: [], exclude: [] };
1011+
const options: TypingOptions = { enableAutoDiscovery: getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
10141012
convertOptionsFromJson(typingOptionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_typing_option_0, errors);
10151013
return options;
10161014
}
@@ -1263,12 +1261,13 @@ namespace ts {
12631261
/**
12641262
* Gets directories in a set of include patterns that should be watched for changes.
12651263
*/
1266-
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean) {
1264+
function getWildcardDirectories(include: string[], exclude: string[], path: string, useCaseSensitiveFileNames: boolean): Map<WatchDirectoryFlags> {
12671265
// We watch a directory recursively if it contains a wildcard anywhere in a directory segment
12681266
// of the pattern:
12691267
//
12701268
// /a/b/**/d - Watch /a/b recursively to catch changes to any d in any subfolder recursively
12711269
// /a/b/*/d - Watch /a/b recursively to catch any d in any immediate subfolder, even if a new subfolder is added
1270+
// /a/b - Watch /a/b recursively to catch changes to anything in any recursive subfoler
12721271
//
12731272
// We watch a directory without recursion if it contains a wildcard in the file segment of
12741273
// the pattern:
@@ -1281,15 +1280,14 @@ namespace ts {
12811280
if (include !== undefined) {
12821281
const recursiveKeys: string[] = [];
12831282
for (const file of include) {
1284-
const name = normalizePath(combinePaths(path, file));
1285-
if (excludeRegex && excludeRegex.test(name)) {
1283+
const spec = normalizePath(combinePaths(path, file));
1284+
if (excludeRegex && excludeRegex.test(spec)) {
12861285
continue;
12871286
}
12881287

1289-
const match = wildcardDirectoryPattern.exec(name);
1288+
const match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
12901289
if (match) {
1291-
const key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase();
1292-
const flags = watchRecursivePattern.test(name) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None;
1290+
const { key, flags } = match;
12931291
const existingFlags = wildcardDirectories[key];
12941292
if (existingFlags === undefined || existingFlags < flags) {
12951293
wildcardDirectories[key] = flags;
@@ -1313,6 +1311,20 @@ namespace ts {
13131311
return wildcardDirectories;
13141312
}
13151313

1314+
function getWildcardDirectoryFromSpec(spec: string, useCaseSensitiveFileNames: boolean): { key: string, flags: WatchDirectoryFlags } | undefined {
1315+
const match = wildcardDirectoryPattern.exec(spec);
1316+
if (match) {
1317+
return {
1318+
key: useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(),
1319+
flags: watchRecursivePattern.test(spec) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None
1320+
};
1321+
}
1322+
if (isImplicitGlob(spec)) {
1323+
return { key: spec, flags: WatchDirectoryFlags.Recursive };
1324+
}
1325+
return undefined;
1326+
}
1327+
13161328
/**
13171329
* Determines whether a literal or wildcard file has already been included that has a higher
13181330
* extension priority.

0 commit comments

Comments
 (0)