Skip to content

Commit add65f1

Browse files
Merge branch 'master' into trylessCatchesFinallyParseNicely
Conflicts: src/compiler/diagnosticMessages.json
2 parents 79735b4 + fee596b commit add65f1

File tree

103 files changed

+9103
-5300
lines changed

Some content is hidden

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

103 files changed

+9103
-5300
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TypeScript is currently accepting contributions in the form of bug fixes. A bug
44
## Contributing features
55
Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (marked as "Milestone == Community" by a TypeScript coordinator with the message "Approved") in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted.
66

7-
Design changes will not be accepted at this time. If you have a design change proposal, please log a suggesion issue.
7+
Design changes will not be accepted at this time. If you have a design change proposal, please log a suggestion issue.
88

99
## Legal
1010
You will need to complete a Contributor License Agreement (CLA). Briefly, this agreement testifies that you are granting us permission to use the submitted change according to the terms of the project's license, and that the work being submitted is under appropriate copyright.

bin/services.js

Lines changed: 4094 additions & 2496 deletions
Large diffs are not rendered by default.

bin/tc.js

Lines changed: 4178 additions & 2441 deletions
Large diffs are not rendered by default.

src/compiler/binder.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,30 +136,27 @@ module ts {
136136
// but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way
137137
// when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope.
138138
var exportKind = 0;
139-
var exportExcludes = 0;
140139
if (symbolKind & SymbolFlags.Value) {
141140
exportKind |= SymbolFlags.ExportValue;
142-
exportExcludes |= SymbolFlags.Value;
143141
}
144142
if (symbolKind & SymbolFlags.Type) {
145143
exportKind |= SymbolFlags.ExportType;
146-
exportExcludes |= SymbolFlags.Type;
147144
}
148145
if (symbolKind & SymbolFlags.Namespace) {
149146
exportKind |= SymbolFlags.ExportNamespace;
150-
exportExcludes |= SymbolFlags.Namespace;
151147
}
152148
if (node.flags & NodeFlags.Export || (node.kind !== SyntaxKind.ImportDeclaration && isAmbientContext(container))) {
153149
if (exportKind) {
154-
var local = declareSymbol(container.locals, undefined, node, exportKind, exportExcludes);
150+
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
155151
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
152+
node.localSymbol = local;
156153
}
157154
else {
158155
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
159156
}
160157
}
161158
else {
162-
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes | exportKind);
159+
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
163160
}
164161
}
165162

src/compiler/checker.ts

Lines changed: 200 additions & 47 deletions
Large diffs are not rendered by default.

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ module ts {
140140
A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2163, category: DiagnosticCategory.Error, key: "A signature with an implementation cannot use a string literal type." },
141141
Interface_0_cannot_simultaneously_extend_types_1_and_2_Colon: { code: 2189, category: DiagnosticCategory.Error, key: "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}':" },
142142
Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: { code: 2190, category: DiagnosticCategory.Error, key: "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it." },
143+
Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: { code: 2192, category: DiagnosticCategory.Error, key: "Individual declarations in merged declaration {0} must be all exported or all local." },
143144
super_cannot_be_referenced_in_constructor_arguments: { code: 2193, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." },
144145
Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2194, category: DiagnosticCategory.Error, key: "Return type of constructor signature must be assignable to the instance type of the class" },
145146
Ambient_external_module_declaration_cannot_specify_relative_module_name: { code: 2196, category: DiagnosticCategory.Error, key: "Ambient external module declaration cannot specify relative module name." },
@@ -157,9 +158,12 @@ module ts {
157158
Duplicate_number_index_signature: { code: 2233, category: DiagnosticCategory.Error, key: "Duplicate number index signature." },
158159
All_declarations_of_an_interface_must_have_identical_type_parameters: { code: 2234, category: DiagnosticCategory.Error, key: "All declarations of an interface must have identical type parameters." },
159160
Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter: { code: 2235, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter." },
160-
Constructor_implementation_expected: { code: 2240, category: DiagnosticCategory.Error, key: "Constructor implementation expected." },
161+
Function_implementation_name_must_be_0: { code: 2239, category: DiagnosticCategory.Error, key: "Function implementation name must be '{0}'." },
162+
Constructor_implementation_is_missing: { code: 2240, category: DiagnosticCategory.Error, key: "Constructor implementation is missing." },
161163
An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2245, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." },
162164
A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2246, category: DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." },
165+
Function_overload_must_be_static: { code: 2247, category: DiagnosticCategory.Error, key: "Function overload must be static." },
166+
Function_overload_must_not_be_static: { code: 2248, category: DiagnosticCategory.Error, key: "Function overload must not be static." },
163167
Circular_definition_of_import_alias_0: { code: 3000, category: DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." },
164168
Cannot_find_name_0: { code: 3001, category: DiagnosticCategory.Error, key: "Cannot find name '{0}'." },
165169
Module_0_has_no_exported_member_1: { code: 3002, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." },
@@ -211,6 +215,7 @@ module ts {
211215
Could_not_write_file_0_Colon_1: { code: 5033, category: DiagnosticCategory.Error, key: "Could not write file '{0}': {1}" },
212216
Option_mapRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5038, category: DiagnosticCategory.Error, key: "Option mapRoot cannot be specified without specifying sourcemap option." },
213217
Option_sourceRoot_cannot_be_specified_without_specifying_sourcemap_option: { code: 5039, category: DiagnosticCategory.Error, key: "Option sourceRoot cannot be specified without specifying sourcemap option." },
218+
Version_0: { code: 6029, category: DiagnosticCategory.Message, key: "Version {0}" },
214219
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
215220
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
216221
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
@@ -275,7 +280,7 @@ module ts {
275280
Types_of_parameters_0_and_1_are_incompatible_Colon: { code: -9999999, category: DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible:" },
276281
Unknown_identifier_0: { code: -9999999, category: DiagnosticCategory.Error, key: "Unknown identifier '{0}'." },
277282
Property_0_is_inaccessible: { code: -9999999, category: DiagnosticCategory.Error, key: "Property '{0}' is inaccessible." },
278-
Function_implementation_expected: { code: -9999999, category: DiagnosticCategory.Error, key: "Function implementation expected." },
283+
Function_implementation_is_missing_or_not_immediately_following_the_declaration: { code: -9999999, category: DiagnosticCategory.Error, key: "Function implementation is missing or not immediately following the declaration." },
279284
Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: -9999999, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." },
280285
Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: -9999999, category: DiagnosticCategory.Error, key: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." },
281286
Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: -9999999, category: DiagnosticCategory.Error, key: "Numeric index type '{0}' is not assignable to string index type '{1}'." },
@@ -294,6 +299,7 @@ module ts {
294299
A_module_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: -9999999, category: DiagnosticCategory.Error, key: "A module declaration cannot be located prior to a class or function with which it is merged" },
295300
Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: -9999999, category: DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." },
296301
Import_declaration_conflicts_with_local_declaration_of_0: { code: -9999999, category: DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" },
302+
Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: -9999999, category: DiagnosticCategory.Error, key: "Module '{0}' is hidden by a local declaration with the same name" },
297303
Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: -9999999, category: DiagnosticCategory.Error, key: "Filename '{0}' differs from already included filename '{1}' only in casing" },
298304
Argument_for_module_option_must_be_commonjs_or_amd: { code: -9999999, category: DiagnosticCategory.Error, key: "Argument for '--module' option must be 'commonjs' or 'amd'." },
299305
Argument_for_target_option_must_be_es3_or_es5: { code: -9999999, category: DiagnosticCategory.Error, key: "Argument for '--target' option must be 'es3' or 'es5'." },

src/compiler/diagnosticMessages.json

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@
552552
"category": "Error",
553553
"code": 2190
554554
},
555+
"Individual declarations in merged declaration {0} must be all exported or all local.": {
556+
"category": "Error",
557+
"code": 2192
558+
},
555559
"'super' cannot be referenced in constructor arguments.":{
556560
"category": "Error",
557561
"code": 2193
@@ -619,8 +623,12 @@
619623
"Expression resolves to variable declaration '_i' that compiler uses to initialize rest parameter.": {
620624
"category": "Error",
621625
"code": 2235
622-
},
623-
"Constructor implementation expected.": {
626+
},
627+
"Function implementation name must be '{0}'.": {
628+
"category": "Error",
629+
"code": 2239
630+
},
631+
"Constructor implementation is missing.": {
624632
"category": "Error",
625633
"code": 2240
626634
},
@@ -632,7 +640,14 @@
632640
"category": "Error",
633641
"code": 2246
634642
},
635-
643+
"Function overload must be static.": {
644+
"category": "Error",
645+
"code": 2247
646+
},
647+
"Function overload must not be static.": {
648+
"category": "Error",
649+
"code": 2248
650+
},
636651
"Circular definition of import alias '{0}'.": {
637652
"category": "Error",
638653
"code": 3000
@@ -840,6 +855,11 @@
840855
"code": 5039
841856
},
842857

858+
"Version {0}": {
859+
"category": "Message",
860+
"code": 6029
861+
},
862+
843863
"Variable '{0}' implicitly has an '{1}' type.": {
844864
"category": "Error",
845865
"code": 7005
@@ -897,7 +917,6 @@
897917
"category": "Error",
898918
"code": 7020
899919
},
900-
901920
"Variable declaration list cannot be empty.": {
902921
"category": "Error",
903922
"code": -9999999
@@ -1118,7 +1137,7 @@
11181137
"category": "Error",
11191138
"code": -9999999
11201139
},
1121-
"Function implementation expected.": {
1140+
"Function implementation is missing or not immediately following the declaration.": {
11221141
"category": "Error",
11231142
"code": -9999999
11241143
},
@@ -1198,6 +1217,10 @@
11981217
"category": "Error",
11991218
"code": -9999999
12001219
},
1220+
"Module '{0}' is hidden by a local declaration with the same name": {
1221+
"category": "Error",
1222+
"code": -9999999
1223+
},
12011224
"Filename '{0}' differs from already included filename '{1}' only in casing": {
12021225
"category": "Error",
12031226
"code": -9999999

src/compiler/parser.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,14 +2106,20 @@ module ts {
21062106
function parseObjectLiteral(): ObjectLiteral {
21072107
var node = <ObjectLiteral>createNode(SyntaxKind.ObjectLiteral);
21082108
parseExpected(SyntaxKind.OpenBraceToken);
2109-
if (scanner.hasPrecedingLineBreak()) node.flags |= NodeFlags.MultiLine;
2110-
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, TrailingCommaBehavior.Preserve);
2109+
if (scanner.hasPrecedingLineBreak()) {
2110+
node.flags |= NodeFlags.MultiLine;
2111+
}
2112+
2113+
// ES3 itself does not accept a trailing comma in an object literal, however, we'd like to preserve it in ES5.
2114+
var trailingCommaBehavior = languageVersion === ScriptTarget.ES3 ? TrailingCommaBehavior.Allow : TrailingCommaBehavior.Preserve;
2115+
2116+
node.properties = parseDelimitedList(ParsingContext.ObjectLiteralMembers, parseObjectLiteralMember, trailingCommaBehavior);
21112117
parseExpected(SyntaxKind.CloseBraceToken);
21122118

21132119
var seen: Map<SymbolFlags> = {};
21142120
var Property = 1;
21152121
var GetAccessor = 2;
2116-
var SetAccesor = 4;
2122+
var SetAccesor = 4;
21172123
var GetOrSetAccessor = GetAccessor | SetAccesor;
21182124
forEach(node.properties, (p: Declaration) => {
21192125
if (p.kind === SyntaxKind.OmittedExpression) {
@@ -2908,7 +2914,16 @@ module ts {
29082914
node.typeParameters = sig.typeParameters;
29092915
node.parameters = sig.parameters;
29102916
node.type = sig.type;
2911-
node.body = parseBody(/* ignoreMissingOpenBrace */ false);
2917+
2918+
// A common error is to try to declare an accessor in an ambient class.
2919+
if (inAmbientContext && canParseSemicolon()) {
2920+
parseSemicolon();
2921+
node.body = createMissingNode();
2922+
}
2923+
else {
2924+
node.body = parseBody(/* ignoreMissingOpenBrace */ false);
2925+
}
2926+
29122927
return finishNode(node);
29132928
}
29142929

0 commit comments

Comments
 (0)