Skip to content

Commit 1a18133

Browse files
committed
Merge branch 'master' into decorators_types
2 parents 98c56ae + 5e7343f commit 1a18133

File tree

125 files changed

+2697
-1509
lines changed

Some content is hidden

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

125 files changed

+2697
-1509
lines changed

Jakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ var harnessSources = [
144144
"services/colorization.ts",
145145
"services/documentRegistry.ts",
146146
"services/preProcessFile.ts",
147-
"services/patternMatcher.ts"
147+
"services/patternMatcher.ts",
148+
"versionCache.ts"
148149
].map(function (f) {
149150
return path.join(unittestsDirectory, f);
150151
})).concat([

src/compiler/binder.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,23 +388,28 @@ module ts {
388388
bindChildren(node, /*symbolKind:*/ 0, /*isBlockScopeContainer:*/ true);
389389
}
390390

391-
function bindBlockScopedVariableDeclaration(node: Declaration) {
391+
function bindBlockScopedDeclaration(node: Declaration, symbolKind: SymbolFlags, symbolExcludes: SymbolFlags) {
392392
switch (blockScopeContainer.kind) {
393393
case SyntaxKind.ModuleDeclaration:
394-
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
394+
declareModuleMember(node, symbolKind, symbolExcludes);
395395
break;
396396
case SyntaxKind.SourceFile:
397397
if (isExternalModule(<SourceFile>container)) {
398-
declareModuleMember(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
398+
declareModuleMember(node, symbolKind, symbolExcludes);
399399
break;
400400
}
401+
// fall through.
401402
default:
402403
if (!blockScopeContainer.locals) {
403404
blockScopeContainer.locals = {};
404405
}
405-
declareSymbol(blockScopeContainer.locals, undefined, node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
406+
declareSymbol(blockScopeContainer.locals, undefined, node, symbolKind, symbolExcludes);
406407
}
407-
bindChildren(node, SymbolFlags.BlockScopedVariable, /*isBlockScopeContainer*/ false);
408+
bindChildren(node, symbolKind, /*isBlockScopeContainer*/ false);
409+
}
410+
411+
function bindBlockScopedVariableDeclaration(node: Declaration) {
412+
bindBlockScopedDeclaration(node, SymbolFlags.BlockScopedVariable, SymbolFlags.BlockScopedVariableExcludes);
408413
}
409414

410415
function getDestructuringParameterName(node: Declaration) {
@@ -493,7 +498,7 @@ module ts {
493498
bindCatchVariableDeclaration(<CatchClause>node);
494499
break;
495500
case SyntaxKind.ClassDeclaration:
496-
bindDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes, /*isBlockScopeContainer*/ false);
501+
bindBlockScopedDeclaration(<Declaration>node, SymbolFlags.Class, SymbolFlags.ClassExcludes);
497502
break;
498503
case SyntaxKind.InterfaceDeclaration:
499504
bindDeclaration(<Declaration>node, SymbolFlags.Interface, SymbolFlags.InterfaceExcludes, /*isBlockScopeContainer*/ false);

src/compiler/checker.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module ts {
7474
isImplementationOfOverload,
7575
getAliasedSymbol: resolveAlias,
7676
getEmitResolver,
77-
getExportsOfExternalModule,
77+
getExportsOfModule: getExportsOfModuleAsArray,
7878
};
7979

8080
let unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown");
@@ -899,6 +899,10 @@ module ts {
899899
return moduleSymbol.exports["export="];
900900
}
901901

902+
function getExportsOfModuleAsArray(moduleSymbol: Symbol): Symbol[] {
903+
return symbolsToArray(getExportsOfModule(moduleSymbol));
904+
}
905+
902906
function getExportsOfSymbol(symbol: Symbol): SymbolTable {
903907
return symbol.flags & SymbolFlags.Module ? getExportsOfModule(symbol) : symbol.exports || emptySymbols;
904908
}
@@ -3043,17 +3047,6 @@ module ts {
30433047
return result;
30443048
}
30453049

3046-
function getExportsOfExternalModule(node: ImportDeclaration): Symbol[] {
3047-
if (!node.moduleSpecifier) {
3048-
return emptyArray;
3049-
}
3050-
let module = resolveExternalModuleName(node, node.moduleSpecifier);
3051-
if (!module) {
3052-
return emptyArray;
3053-
}
3054-
return symbolsToArray(getExportsOfModule(module));
3055-
}
3056-
30573050
function getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature {
30583051
let links = getNodeLinks(declaration);
30593052
if (!links.resolvedSignature) {
@@ -9846,6 +9839,10 @@ module ts {
98469839
grammarErrorOnNode(node, Diagnostics.class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration);
98479840
}
98489841

9842+
if (!node.name && !(node.flags & NodeFlags.Default)) {
9843+
grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
9844+
}
9845+
98499846
checkGrammarClassDeclarationHeritageClauses(node);
98509847
checkDecorators(node);
98519848
if (node.name) {
@@ -12729,7 +12726,16 @@ module ts {
1272912726
let identifier = <Identifier>name;
1273012727
if (contextNode && (contextNode.parserContextFlags & ParserContextFlags.StrictMode) && isEvalOrArgumentsIdentifier(identifier)) {
1273112728
let nameText = declarationNameToString(identifier);
12732-
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
12729+
12730+
// We are checking if this name is inside class declaration or class expression (which are under class definitions inside ES6 spec.)
12731+
// if so, we would like to give more explicit invalid usage error.
12732+
// This will be particularly helpful in the case of "arguments" as such case is very common mistake.
12733+
if (getAncestor(name, SyntaxKind.ClassDeclaration) || getAncestor(name, SyntaxKind.ClassExpression)) {
12734+
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode, nameText);
12735+
}
12736+
else {
12737+
return grammarErrorOnNode(identifier, Diagnostics.Invalid_use_of_0_in_strict_mode, nameText);
12738+
}
1273312739
}
1273412740
}
1273512741
}

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ module ts {
167167
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
168168
Cannot_compile_non_external_modules_when_the_separateCompilation_flag_is_provided: { code: 1208, category: DiagnosticCategory.Error, key: "Cannot compile non-external modules when the '--separateCompilation' flag is provided." },
169169
Ambient_const_enums_are_not_allowed_when_the_separateCompilation_flag_is_provided: { code: 1209, category: DiagnosticCategory.Error, key: "Ambient const enums are not allowed when the '--separateCompilation' flag is provided." },
170+
Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: DiagnosticCategory.Error, key: "Invalid use of '{0}'. Class definitions are automatically in strict mode." },
171+
A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: DiagnosticCategory.Error, key: "A class declaration without the 'default' modifier must have a name" },
170172
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
171173
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
172174
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -505,6 +507,22 @@ module ts {
505507
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
506508
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
507509
You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." },
510+
import_can_only_be_used_in_a_ts_file: { code: 8002, category: DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." },
511+
export_can_only_be_used_in_a_ts_file: { code: 8003, category: DiagnosticCategory.Error, key: "'export=' can only be used in a .ts file." },
512+
type_parameter_declarations_can_only_be_used_in_a_ts_file: { code: 8004, category: DiagnosticCategory.Error, key: "'type parameter declarations' can only be used in a .ts file." },
513+
implements_clauses_can_only_be_used_in_a_ts_file: { code: 8005, category: DiagnosticCategory.Error, key: "'implements clauses' can only be used in a .ts file." },
514+
interface_declarations_can_only_be_used_in_a_ts_file: { code: 8006, category: DiagnosticCategory.Error, key: "'interface declarations' can only be used in a .ts file." },
515+
module_declarations_can_only_be_used_in_a_ts_file: { code: 8007, category: DiagnosticCategory.Error, key: "'module declarations' can only be used in a .ts file." },
516+
type_aliases_can_only_be_used_in_a_ts_file: { code: 8008, category: DiagnosticCategory.Error, key: "'type aliases' can only be used in a .ts file." },
517+
_0_can_only_be_used_in_a_ts_file: { code: 8009, category: DiagnosticCategory.Error, key: "'{0}' can only be used in a .ts file." },
518+
types_can_only_be_used_in_a_ts_file: { code: 8010, category: DiagnosticCategory.Error, key: "'types' can only be used in a .ts file." },
519+
type_arguments_can_only_be_used_in_a_ts_file: { code: 8011, category: DiagnosticCategory.Error, key: "'type arguments' can only be used in a .ts file." },
520+
parameter_modifiers_can_only_be_used_in_a_ts_file: { code: 8012, category: DiagnosticCategory.Error, key: "'parameter modifiers' can only be used in a .ts file." },
521+
can_only_be_used_in_a_ts_file: { code: 8013, category: DiagnosticCategory.Error, key: "'?' can only be used in a .ts file." },
522+
property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." },
523+
enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." },
524+
type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." },
525+
decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." },
508526
yield_expressions_are_not_currently_supported: { code: 9000, category: DiagnosticCategory.Error, key: "'yield' expressions are not currently supported." },
509527
Generators_are_not_currently_supported: { code: 9001, category: DiagnosticCategory.Error, key: "Generators are not currently supported." },
510528
Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." },

src/compiler/diagnosticMessages.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,14 @@
659659
"category": "Error",
660660
"code": 1209
661661
},
662+
"Invalid use of '{0}'. Class definitions are automatically in strict mode.": {
663+
"category": "Error",
664+
"code": 1210
665+
},
666+
"A class declaration without the 'default' modifier must have a name": {
667+
"category": "Error",
668+
"code": 1211
669+
},
662670
"Duplicate identifier '{0}'.": {
663671
"category": "Error",
664672
"code": 2300
@@ -2013,6 +2021,71 @@
20132021
"category": "Error",
20142022
"code": 8001
20152023
},
2024+
"'import ... =' can only be used in a .ts file.": {
2025+
"category": "Error",
2026+
"code": 8002
2027+
},
2028+
"'export=' can only be used in a .ts file.": {
2029+
"category": "Error",
2030+
"code": 8003
2031+
},
2032+
"'type parameter declarations' can only be used in a .ts file.": {
2033+
"category": "Error",
2034+
"code": 8004
2035+
},
2036+
"'implements clauses' can only be used in a .ts file.": {
2037+
"category": "Error",
2038+
"code": 8005
2039+
},
2040+
"'interface declarations' can only be used in a .ts file.": {
2041+
"category": "Error",
2042+
"code": 8006
2043+
},
2044+
"'module declarations' can only be used in a .ts file.": {
2045+
"category": "Error",
2046+
"code": 8007
2047+
},
2048+
"'type aliases' can only be used in a .ts file.": {
2049+
"category": "Error",
2050+
"code": 8008
2051+
},
2052+
"'{0}' can only be used in a .ts file.": {
2053+
"category": "Error",
2054+
"code": 8009
2055+
},
2056+
"'types' can only be used in a .ts file.": {
2057+
"category": "Error",
2058+
"code": 8010
2059+
},
2060+
"'type arguments' can only be used in a .ts file.": {
2061+
"category": "Error",
2062+
"code": 8011
2063+
},
2064+
"'parameter modifiers' can only be used in a .ts file.": {
2065+
"category": "Error",
2066+
"code": 8012
2067+
},
2068+
"'?' can only be used in a .ts file.": {
2069+
"category": "Error",
2070+
"code": 8013
2071+
},
2072+
"'property declarations' can only be used in a .ts file.": {
2073+
"category": "Error",
2074+
"code": 8014
2075+
},
2076+
"'enum declarations' can only be used in a .ts file.": {
2077+
"category": "Error",
2078+
"code": 8015
2079+
},
2080+
"'type assertion expressions' can only be used in a .ts file.": {
2081+
"category": "Error",
2082+
"code": 8016
2083+
},
2084+
"'decorators' can only be used in a .ts file.": {
2085+
"category": "Error",
2086+
"code": 8017
2087+
},
2088+
20162089
"'yield' expressions are not currently supported.": {
20172090
"category": "Error",
20182091
"code": 9000

0 commit comments

Comments
 (0)