Skip to content

Commit ced5f62

Browse files
committed
Merge branch 'master' into disallowBadCommas
2 parents 5b3c272 + 65d40f8 commit ced5f62

File tree

2,292 files changed

+29972
-14960
lines changed

Some content is hidden

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

2,292 files changed

+29972
-14960
lines changed

Jakefile.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ var servicesSources = [
126126
"classifier.ts",
127127
"completions.ts",
128128
"documentHighlights.ts",
129+
"documentRegistry.ts",
129130
"findAllReferences.ts",
130131
"goToDefinition.ts",
131132
"jsDoc.ts",
@@ -1003,15 +1004,18 @@ function acceptBaseline(containerFolder) {
10031004
var deleteEnding = '.delete';
10041005
for (var i in files) {
10051006
var filename = files[i];
1006-
if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) {
1007-
filename = filename.substr(0, filename.length - deleteEnding.length);
1008-
fs.unlinkSync(path.join(targetFolder, filename));
1009-
} else {
1010-
var target = path.join(targetFolder, filename);
1011-
if (fs.existsSync(target)) {
1012-
fs.unlinkSync(target);
1007+
var fullLocalPath = path.join(sourceFolder, filename);
1008+
if (fs.statSync(fullLocalPath).isFile()) {
1009+
if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) {
1010+
filename = filename.substr(0, filename.length - deleteEnding.length);
1011+
fs.unlinkSync(path.join(targetFolder, filename));
1012+
} else {
1013+
var target = path.join(targetFolder, filename);
1014+
if (fs.existsSync(target)) {
1015+
fs.unlinkSync(target);
1016+
}
1017+
fs.renameSync(path.join(sourceFolder, filename), target);
10131018
}
1014-
fs.renameSync(path.join(sourceFolder, filename), target);
10151019
}
10161020
}
10171021
}

lib/lib.es2015.collection.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface Map<K, V> {
2020
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
2121
get(key: K): V | undefined;
2222
has(key: K): boolean;
23-
set(key: K, value?: V): this;
23+
set(key: K, value: V): this;
2424
readonly size: number;
2525
}
2626

@@ -36,7 +36,7 @@ interface WeakMap<K, V> {
3636
delete(key: K): boolean;
3737
get(key: K): V | undefined;
3838
has(key: K): boolean;
39-
set(key: K, value?: V): this;
39+
set(key: K, value: V): this;
4040
}
4141

4242
interface WeakMapConstructor {

src/compiler/binder.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@ namespace ts {
591591
case SyntaxKind.PrefixUnaryExpression:
592592
bindPrefixUnaryExpressionFlow(<PrefixUnaryExpression>node);
593593
break;
594+
case SyntaxKind.PostfixUnaryExpression:
595+
bindPostfixUnaryExpressionFlow(<PostfixUnaryExpression>node);
596+
break;
594597
case SyntaxKind.BinaryExpression:
595598
bindBinaryExpressionFlow(<BinaryExpression>node);
596599
break;
@@ -1106,6 +1109,16 @@ namespace ts {
11061109
}
11071110
else {
11081111
forEachChild(node, bind);
1112+
if (node.operator === SyntaxKind.PlusEqualsToken || node.operator === SyntaxKind.MinusMinusToken) {
1113+
bindAssignmentTargetFlow(node.operand);
1114+
}
1115+
}
1116+
}
1117+
1118+
function bindPostfixUnaryExpressionFlow(node: PostfixUnaryExpression) {
1119+
forEachChild(node, bind);
1120+
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
1121+
bindAssignmentTargetFlow(node.operand);
11091122
}
11101123
}
11111124

src/compiler/checker.ts

Lines changed: 182 additions & 172 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ namespace ts {
294294
"classic": ModuleResolutionKind.Classic,
295295
}),
296296
description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
297+
paramType: Diagnostics.STRATEGY,
297298
},
298299
{
299300
name: "allowUnusedLabels",

src/compiler/diagnosticMessages.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,6 @@
10631063
"category": "Error",
10641064
"code": 2353
10651065
},
1066-
"No best common type exists among return expressions.": {
1067-
"category": "Error",
1068-
"code": 2354
1069-
},
10701066
"A function whose declared type is neither 'void' nor 'any' must return a value.": {
10711067
"category": "Error",
10721068
"code": 2355
@@ -1631,10 +1627,6 @@
16311627
"category": "Error",
16321628
"code": 2503
16331629
},
1634-
"No best common type exists among yield expressions.": {
1635-
"category": "Error",
1636-
"code": 2504
1637-
},
16381630
"A generator cannot have a 'void' type annotation.": {
16391631
"category": "Error",
16401632
"code": 2505
@@ -2476,6 +2468,10 @@
24762468
"category": "Message",
24772469
"code": 6038
24782470
},
2471+
"STRATEGY": {
2472+
"category": "Message",
2473+
"code": 6039
2474+
},
24792475
"Compilation complete. Watching for file changes.": {
24802476
"category": "Message",
24812477
"code": 6042
@@ -2875,7 +2871,7 @@
28752871
"Element implicitly has an 'any' type because index expression is not of type 'number'.": {
28762872
"category": "Error",
28772873
"code": 7015
2878-
},
2874+
},
28792875
"Index signature of object type implicitly has an 'any' type.": {
28802876
"category": "Error",
28812877
"code": 7017

src/compiler/emitter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ const _super = (function (geti, seti) {
252252

253253
// Emit helpers from all the files
254254
if (isBundledEmit && moduleKind) {
255-
forEach(sourceFiles, emitEmitHelpers);
255+
for (const sourceFile of sourceFiles) {
256+
emitEmitHelpers(sourceFile);
257+
}
256258
}
257259

258260
// Print each transformed source file.

src/compiler/transformers/es6.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ namespace ts {
541541
*
542542
* @param node A ClassDeclaration node.
543543
*/
544-
function visitClassDeclaration(node: ClassDeclaration): Statement {
544+
function visitClassDeclaration(node: ClassDeclaration): VisitResult<Statement> {
545545
// [source]
546546
// class C { }
547547
//
@@ -552,8 +552,17 @@ namespace ts {
552552
// return C;
553553
// }());
554554

555+
const modifierFlags = getModifierFlags(node);
556+
const isExported = modifierFlags & ModifierFlags.Export;
557+
const isDefault = modifierFlags & ModifierFlags.Default;
558+
559+
// Add an `export` modifier to the statement if needed (for `--target es5 --module es6`)
560+
const modifiers = isExported && !isDefault
561+
? filter(node.modifiers, isExportModifier)
562+
: undefined;
563+
555564
const statement = createVariableStatement(
556-
/*modifiers*/ undefined,
565+
modifiers,
557566
createVariableDeclarationList([
558567
createVariableDeclaration(
559568
getDeclarationName(node, /*allowComments*/ true),
@@ -566,9 +575,26 @@ namespace ts {
566575

567576
setOriginalNode(statement, node);
568577
startOnNewLine(statement);
578+
579+
// Add an `export default` statement for default exports (for `--target es5 --module es6`)
580+
if (isExported && isDefault) {
581+
const statements: Statement[] = [statement];
582+
statements.push(createExportAssignment(
583+
/*decorators*/ undefined,
584+
/*modifiers*/ undefined,
585+
/*isExportEquals*/ false,
586+
getDeclarationName(node, /*allowComments*/ false)
587+
));
588+
return statements;
589+
}
590+
569591
return statement;
570592
}
571593

594+
function isExportModifier(node: Modifier) {
595+
return node.kind === SyntaxKind.ExportKeyword;
596+
}
597+
572598
/**
573599
* Visits a ClassExpression and transforms it into an expression.
574600
*

src/compiler/transformers/generators.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,7 @@ namespace ts {
26292629
* Flush the final label of the generator function body.
26302630
*/
26312631
function flushFinalLabel(operationIndex: number): void {
2632-
if (!lastOperationWasCompletion) {
2632+
if (isFinalLabelReachable(operationIndex)) {
26332633
tryEnterLabel(operationIndex);
26342634
withBlockStack = undefined;
26352635
writeReturn(/*expression*/ undefined, /*operationLocation*/ undefined);
@@ -2642,6 +2642,34 @@ namespace ts {
26422642
updateLabelExpressions();
26432643
}
26442644

2645+
/**
2646+
* Tests whether the final label of the generator function body
2647+
* is reachable by user code.
2648+
*/
2649+
function isFinalLabelReachable(operationIndex: number) {
2650+
// if the last operation was *not* a completion (return/throw) then
2651+
// the final label is reachable.
2652+
if (!lastOperationWasCompletion) {
2653+
return true;
2654+
}
2655+
2656+
// if there are no labels defined or referenced, then the final label is
2657+
// not reachable.
2658+
if (!labelOffsets || !labelExpressions) {
2659+
return false;
2660+
}
2661+
2662+
// if the label for this offset is referenced, then the final label
2663+
// is reachable.
2664+
for (let label = 0; label < labelOffsets.length; label++) {
2665+
if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
2666+
return true;
2667+
}
2668+
}
2669+
2670+
return false;
2671+
}
2672+
26452673
/**
26462674
* Appends a case clause for the last label and sets the new label.
26472675
*

src/compiler/transformers/module/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ namespace ts {
705705
createFunctionDeclaration(
706706
/*decorators*/ undefined,
707707
/*modifiers*/ undefined,
708-
/*asteriskToken*/ undefined,
708+
node.asteriskToken,
709709
name,
710710
/*typeParameters*/ undefined,
711711
node.parameters,

0 commit comments

Comments
 (0)