Skip to content

Commit 431dce7

Browse files
committed
Merge branch 'master' into APIReviewCleanup
Conflicts: src/services/outliningElementsCollector.ts
2 parents 03685f4 + f231d6a commit 431dce7

File tree

355 files changed

+6692
-1417
lines changed

Some content is hidden

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

355 files changed

+6692
-1417
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Your pull request should:
2525
* Tests should include reasonable permutations of the target fix/change
2626
* Include baseline changes with your change
2727
* All changed code must have 100% code coverage
28-
* Follow the code conventions descriped in [Coding guidlines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidlines)
28+
* Follow the code conventions descriped in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
2929
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
3030

3131
## Running the Tests

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ module ts {
540540
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
541541
break;
542542
case SyntaxKind.ExportAssignment:
543-
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
543+
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
544544
// An export default clause with an identifier exports all meanings of that identifier
545545
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
546546
}

src/compiler/checker.ts

Lines changed: 117 additions & 89 deletions
Large diffs are not rendered by default.

src/compiler/core.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ module ts {
434434
return path.replace(/\\/g, "/");
435435
}
436436

437-
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/")
437+
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
438438
export function getRootLength(path: string): number {
439439
if (path.charCodeAt(0) === CharacterCodes.slash) {
440440
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
@@ -448,6 +448,8 @@ module ts {
448448
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
449449
return 2;
450450
}
451+
let idx = path.indexOf('://');
452+
if (idx !== -1) return idx + 3
451453
return 0;
452454
}
453455

src/compiler/declarationEmitter.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,20 +442,41 @@ module ts {
442442
emitLines(node.statements);
443443
}
444444

445+
// Return a temp variable name to be used in `export default` statements.
446+
// The temp name will be of the form _default_counter.
447+
// Note that export default is only allowed at most once in a module, so we
448+
// do not need to keep track of created temp names.
449+
function getExportDefaultTempVariableName(): string {
450+
let baseName = "_default";
451+
if (!hasProperty(currentSourceFile.identifiers, baseName)) {
452+
return baseName;
453+
}
454+
let count = 0;
455+
while (true) {
456+
let name = baseName + "_" + (++count);
457+
if (!hasProperty(currentSourceFile.identifiers, name)) {
458+
return name;
459+
}
460+
}
461+
}
462+
445463
function emitExportAssignment(node: ExportAssignment) {
446-
write(node.isExportEquals ? "export = " : "export default ");
447464
if (node.expression.kind === SyntaxKind.Identifier) {
465+
write(node.isExportEquals ? "export = " : "export default ");
448466
writeTextOfNode(currentSourceFile, node.expression);
449467
}
450468
else {
469+
// Expression
470+
let tempVarName = getExportDefaultTempVariableName();
471+
write("declare var ");
472+
write(tempVarName);
451473
write(": ");
452-
if (node.type) {
453-
emitType(node.type);
454-
}
455-
else {
456-
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
457-
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
458-
}
474+
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
475+
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
476+
write(";");
477+
writeLine();
478+
write(node.isExportEquals ? "export = " : "export default ");
479+
write(tempVarName);
459480
}
460481
write(";");
461482
writeLine();

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ module ts {
159159
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
160160
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
161161
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
162-
A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." },
163162
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
164163
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
165164
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
@@ -345,8 +344,8 @@ module ts {
345344
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
346345
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." },
347346
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." },
348-
The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." },
349-
The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." },
347+
Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." },
348+
An_iterator_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." },
350349
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
351350
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
352351
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,6 @@
623623
"category": "Error",
624624
"code": 1200
625625
},
626-
"A type annotation on an export statement is only allowed in an ambient external module declaration.": {
627-
"category": "Error",
628-
"code": 1201
629-
},
630626
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
631627
"category": "Error",
632628
"code": 1202
@@ -1367,11 +1363,11 @@
13671363
"category": "Error",
13681364
"code": 2487
13691365
},
1370-
"The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": {
1366+
"Type must have a '[Symbol.iterator]()' method that returns an iterator.": {
13711367
"category": "Error",
13721368
"code": 2488
13731369
},
1374-
"The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": {
1370+
"An iterator must have a 'next()' method.": {
13751371
"category": "Error",
13761372
"code": 2489
13771373
},

0 commit comments

Comments
 (0)