diff --git a/bin/tsc.js b/bin/tsc.js
index 7818785929..c1ce8cee83 100644
--- a/bin/tsc.js
+++ b/bin/tsc.js
@@ -418,6 +418,10 @@ var ts;
return normalizedPathComponents(path, rootLength);
}
ts.getNormalizedPathComponents = getNormalizedPathComponents;
+ function getNormalizedAbsolutePath(filename, currentDirectory) {
+ return getNormalizedPathFromPathComponents(getNormalizedPathComponents(filename, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
function getNormalizedPathFromPathComponents(pathComponents) {
if (pathComponents && pathComponents.length) {
return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator);
@@ -908,6 +912,7 @@ var ts;
Unterminated_template_literal: { code: 1160, category: 1 /* Error */, key: "Unterminated template literal." },
Unterminated_regular_expression_literal: { code: 1161, category: 1 /* Error */, key: "Unterminated regular expression literal." },
An_object_member_cannot_be_declared_optional: { code: 1162, category: 1 /* Error */, key: "An object member cannot be declared optional." },
+ yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1 /* Error */, key: "'yield' expression must be contained_within a generator declaration." },
Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." },
@@ -1058,27 +1063,16 @@ var ts;
Type_alias_name_cannot_be_0: { code: 2457, category: 1 /* Error */, key: "Type alias name cannot be '{0}'" },
An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1 /* Error */, key: "An AMD module cannot have multiple name assignments." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." },
- Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
- Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4003, category: 1 /* Error */, key: "Type parameter '{0}' of exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1 /* Error */, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4005, category: 1 /* Error */, key: "Type parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: 1 /* Error */, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4007, category: 1 /* Error */, key: "Type parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: 1 /* Error */, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4009, category: 1 /* Error */, key: "Type parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: 1 /* Error */, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." },
- Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4011, category: 1 /* Error */, key: "Type parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: 1 /* Error */, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." },
- Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4013, category: 1 /* Error */, key: "Type parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: 1 /* Error */, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4015, category: 1 /* Error */, key: "Type parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: 1 /* Error */, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." },
- Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2: { code: 4017, category: 1 /* Error */, key: "Implements clause of exported class '{0}' has or is using name '{1}' from private module '{2}'." },
- Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2: { code: 4018, category: 1 /* Error */, key: "Extends clause of exported class '{0}' has or is using name '{1}' from private module '{2}'." },
Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: 1 /* Error */, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." },
Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: 1 /* Error */, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." },
- Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2: { code: 4021, category: 1 /* Error */, key: "Extends clause of exported interface '{0}' has or is using name '{1}' from private module '{2}'." },
Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: 1 /* Error */, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." },
Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: 1 /* Error */, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." },
Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: 1 /* Error */, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." },
@@ -1136,8 +1130,6 @@ var ts;
Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." },
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using private name '{1}'." },
- Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4079, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from external module {2} but cannot be named." },
- Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." },
Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using private name '{1}'." },
Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: 1 /* Error */, key: "Enum declarations must all be const or non-const." },
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: 1 /* Error */, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true },
@@ -1208,7 +1200,9 @@ var ts;
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: 1 /* Error */, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
_0_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: 7023, category: 1 /* Error */, key: "'{0}' 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." },
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: 1 /* 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." },
- You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." }
+ You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." },
+ yield_expressions_are_not_currently_supported: { code: 9000, category: 1 /* Error */, key: "'yield' expressions are not currently supported." },
+ generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "'generators' are not currently supported." }
};
})(ts || (ts = {}));
var ts;
@@ -2206,7 +2200,7 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
- var nodeConstructors = new Array(199 /* Count */);
+ var nodeConstructors = new Array(200 /* Count */);
function getNodeConstructor(kind) {
return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind));
}
@@ -2219,7 +2213,7 @@ var ts;
return node;
}
function getSourceFileOfNode(node) {
- while (node && node.kind !== 196 /* SourceFile */)
+ while (node && node.kind !== 197 /* SourceFile */)
node = node.parent;
return node;
}
@@ -2241,13 +2235,17 @@ var ts;
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
}
ts.getTokenPosOfNode = getTokenPosOfNode;
+ function getSourceTextOfNodeFromSourceFile(sourceFile, node) {
+ var text = sourceFile.text;
+ return text.substring(ts.skipTrivia(text, node.pos), node.end);
+ }
+ ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
function getTextOfNodeFromSourceText(sourceText, node) {
return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end);
}
ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
function getTextOfNode(node) {
- var text = getSourceFileOfNode(node).text;
- return text.substring(ts.skipTrivia(text, node.pos), node.end);
+ return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node);
}
ts.getTextOfNode = getTextOfNode;
function escapeIdentifier(identifier) {
@@ -2281,12 +2279,12 @@ var ts;
function getErrorSpanForNode(node) {
var errorSpan;
switch (node.kind) {
- case 184 /* VariableDeclaration */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 190 /* EnumDeclaration */:
- case 195 /* EnumMember */:
+ case 185 /* VariableDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 196 /* EnumMember */:
errorSpan = node.name;
break;
}
@@ -2302,11 +2300,19 @@ var ts;
}
ts.isDeclarationFile = isDeclarationFile;
function isConstEnumDeclaration(node) {
- return (node.flags & 4096 /* Const */) !== 0;
+ return node.kind === 191 /* EnumDeclaration */ && isConst(node);
}
ts.isConstEnumDeclaration = isConstEnumDeclaration;
+ function isConst(node) {
+ return !!(node.flags & 4096 /* Const */);
+ }
+ ts.isConst = isConst;
+ function isLet(node) {
+ return !!(node.flags & 2048 /* Let */);
+ }
+ ts.isLet = isLet;
function isPrologueDirective(node) {
- return node.kind === 164 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */;
+ return node.kind === 165 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */;
}
ts.isPrologueDirective = isPrologueDirective;
function isEvalOrArgumentsIdentifier(node) {
@@ -2375,7 +2381,7 @@ var ts;
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body);
case 132 /* TypeReference */:
@@ -2416,64 +2422,64 @@ var ts;
return child(node.left) || child(node.right);
case 157 /* ConditionalExpression */:
return child(node.condition) || child(node.whenTrue) || child(node.whenFalse);
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 182 /* FinallyBlock */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
- case 196 /* SourceFile */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 183 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
+ case 197 /* SourceFile */:
return children(node.statements);
- case 162 /* VariableStatement */:
+ case 163 /* VariableStatement */:
return children(node.declarations);
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return child(node.expression);
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
return child(node.expression) || child(node.thenStatement) || child(node.elseStatement);
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
return child(node.statement) || child(node.expression);
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return child(node.expression) || child(node.statement);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement);
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement);
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
return child(node.label);
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return child(node.expression);
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
return child(node.expression) || child(node.statement);
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return child(node.expression) || children(node.clauses);
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
return child(node.expression) || children(node.statements);
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return child(node.label) || child(node.statement);
- case 178 /* ThrowStatement */:
+ case 179 /* ThrowStatement */:
return child(node.expression);
- case 179 /* TryStatement */:
+ case 180 /* TryStatement */:
return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock);
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
return child(node.variable) || children(node.statements);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return child(node.name) || child(node.type) || child(node.initializer);
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members);
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members);
- case 189 /* TypeAliasDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
return child(node.name) || child(node.type);
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
return child(node.name) || children(node.members);
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
return child(node.name) || child(node.initializer);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return child(node.name) || child(node.body);
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return child(node.name) || child(node.entityName) || child(node.externalModuleName);
- case 194 /* ExportAssignment */:
+ case 195 /* ExportAssignment */:
return child(node.exportName);
case 158 /* TemplateExpression */:
return child(node.head) || children(node.templateSpans);
@@ -2486,24 +2492,24 @@ var ts;
return traverse(body);
function traverse(node) {
switch (node.kind) {
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return visitor(node);
- case 161 /* Block */:
- case 186 /* FunctionBlock */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
- case 177 /* LabeledStatement */:
- case 179 /* TryStatement */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
+ case 162 /* Block */:
+ case 187 /* FunctionBlock */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
+ case 178 /* LabeledStatement */:
+ case 180 /* TryStatement */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
return forEachChild(node, traverse);
}
}
@@ -2513,7 +2519,7 @@ var ts;
if (node) {
switch (node.kind) {
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
case 125 /* Method */:
case 127 /* GetAccessor */:
@@ -2545,16 +2551,16 @@ var ts;
if (!includeArrowFunctions) {
continue;
}
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
case 124 /* Property */:
case 125 /* Method */:
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 190 /* EnumDeclaration */:
- case 196 /* SourceFile */:
+ case 191 /* EnumDeclaration */:
+ case 197 /* SourceFile */:
return node;
}
}
@@ -2577,6 +2583,13 @@ var ts;
}
}
ts.getSuperContainer = getSuperContainer;
+ function getInvokedExpression(node) {
+ if (node.kind === 149 /* TaggedTemplateExpression */) {
+ return node.tag;
+ }
+ return node.func;
+ }
+ ts.getInvokedExpression = getInvokedExpression;
function isExpression(node) {
switch (node.kind) {
case 91 /* ThisKeyword */:
@@ -2602,7 +2615,7 @@ var ts;
case 157 /* ConditionalExpression */:
case 158 /* TemplateExpression */:
case 9 /* NoSubstitutionTemplateLiteral */:
- case 160 /* OmittedExpression */:
+ case 161 /* OmittedExpression */:
return true;
case 121 /* QualifiedName */:
while (node.parent.kind === 121 /* QualifiedName */)
@@ -2616,26 +2629,26 @@ var ts;
case 7 /* StringLiteral */:
var parent = node.parent;
switch (parent.kind) {
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 123 /* Parameter */:
case 124 /* Property */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 143 /* PropertyAssignment */:
return parent.initializer === node;
- case 164 /* ExpressionStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 172 /* ReturnStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 178 /* ThrowStatement */:
- case 174 /* SwitchStatement */:
+ case 165 /* ExpressionStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 173 /* ReturnStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 179 /* ThrowStatement */:
+ case 175 /* SwitchStatement */:
return parent.expression === node;
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return parent.initializer === node || parent.condition === node || parent.iterator === node;
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return parent.variable === node || parent.expression === node;
case 150 /* TypeAssertion */:
return node === parent.operand;
@@ -2679,21 +2692,22 @@ var ts;
switch (node.kind) {
case 122 /* TypeParameter */:
case 123 /* Parameter */:
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 124 /* Property */:
case 143 /* PropertyAssignment */:
case 144 /* ShorthandPropertyAssignment */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 125 /* Method */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 190 /* EnumDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 126 /* Constructor */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 194 /* ImportDeclaration */:
return true;
}
return false;
@@ -2701,24 +2715,24 @@ var ts;
ts.isDeclaration = isDeclaration;
function isStatement(n) {
switch (n.kind) {
- case 171 /* BreakStatement */:
- case 170 /* ContinueStatement */:
- case 183 /* DebuggerStatement */:
- case 166 /* DoStatement */:
- case 164 /* ExpressionStatement */:
- case 163 /* EmptyStatement */:
- case 169 /* ForInStatement */:
- case 168 /* ForStatement */:
- case 165 /* IfStatement */:
- case 177 /* LabeledStatement */:
- case 172 /* ReturnStatement */:
- case 174 /* SwitchStatement */:
+ case 172 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 184 /* DebuggerStatement */:
+ case 167 /* DoStatement */:
+ case 165 /* ExpressionStatement */:
+ case 164 /* EmptyStatement */:
+ case 170 /* ForInStatement */:
+ case 169 /* ForStatement */:
+ case 166 /* IfStatement */:
+ case 178 /* LabeledStatement */:
+ case 173 /* ReturnStatement */:
+ case 175 /* SwitchStatement */:
case 92 /* ThrowKeyword */:
- case 179 /* TryStatement */:
- case 162 /* VariableStatement */:
- case 167 /* WhileStatement */:
- case 173 /* WithStatement */:
- case 194 /* ExportAssignment */:
+ case 180 /* TryStatement */:
+ case 163 /* VariableStatement */:
+ case 168 /* WhileStatement */:
+ case 174 /* WithStatement */:
+ case 195 /* ExportAssignment */:
return true;
default:
return false;
@@ -2733,24 +2747,32 @@ var ts;
if (isDeclaration(parent) || parent.kind === 152 /* FunctionExpression */) {
return parent.name === name;
}
- if (parent.kind === 181 /* CatchBlock */) {
+ if (parent.kind === 182 /* CatchBlock */) {
return parent.variable === name;
}
return false;
}
ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName;
+ function tryResolveScriptReference(program, sourceFile, reference) {
+ if (!program.getCompilerOptions().noResolve) {
+ var referenceFileName = ts.isRootedDiskPath(reference.filename) ? reference.filename : ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename);
+ referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, program.getCompilerHost().getCurrentDirectory());
+ return program.getSourceFile(referenceFileName);
+ }
+ }
+ ts.tryResolveScriptReference = tryResolveScriptReference;
function getAncestor(node, kind) {
switch (kind) {
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
while (node) {
switch (node.kind) {
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return node;
- case 190 /* EnumDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 194 /* ImportDeclaration */:
return undefined;
default:
node = node.parent;
@@ -2835,11 +2857,14 @@ var ts;
}
ts.isTrivia = isTrivia;
function isUnterminatedTemplateEnd(node) {
- ts.Debug.assert(node.kind === 9 /* NoSubstitutionTemplateLiteral */ || node.kind === 12 /* TemplateTail */);
+ ts.Debug.assert(isTemplateLiteralKind(node.kind));
var sourceText = getSourceFileOfNode(node).text;
if (node.end !== sourceText.length) {
return false;
}
+ if (node.kind !== 12 /* TemplateTail */ && node.kind !== 9 /* NoSubstitutionTemplateLiteral */) {
+ return false;
+ }
return sourceText.charCodeAt(node.end - 1) !== 96 /* backtick */ || node.text.length === 0;
}
ts.isUnterminatedTemplateEnd = isUnterminatedTemplateEnd;
@@ -2878,8 +2903,76 @@ var ts;
var identifierCount = 0;
var nodeCount = 0;
var lineStarts;
- var isInStrictMode = false;
var lookAheadMode = 0 /* NotLookingAhead */;
+ var contextFlags = 0;
+ function setContextFlag(val, flag) {
+ if (val) {
+ contextFlags |= flag;
+ }
+ else {
+ contextFlags &= ~flag;
+ }
+ }
+ function setStrictModeContext(val) {
+ setContextFlag(val, 1 /* StrictMode */);
+ }
+ function setDisallowInContext(val) {
+ setContextFlag(val, 2 /* DisallowIn */);
+ }
+ function setYieldContext(val) {
+ setContextFlag(val, 4 /* Yield */);
+ }
+ function setGeneratorParameterContext(val) {
+ setContextFlag(val, 8 /* GeneratorParameter */);
+ }
+ function allowInAnd(func) {
+ if (contextFlags & 2 /* DisallowIn */) {
+ setDisallowInContext(false);
+ var result = func();
+ setDisallowInContext(true);
+ return result;
+ }
+ return func();
+ }
+ function disallowInAnd(func) {
+ if (contextFlags & 2 /* DisallowIn */) {
+ return func();
+ }
+ setDisallowInContext(true);
+ var result = func();
+ setDisallowInContext(false);
+ return result;
+ }
+ function doInYieldContext(func) {
+ if (contextFlags & 4 /* Yield */) {
+ return func();
+ }
+ setYieldContext(true);
+ var result = func();
+ setYieldContext(false);
+ return result;
+ }
+ function doOutsideOfYieldContext(func) {
+ if (contextFlags & 4 /* Yield */) {
+ setYieldContext(false);
+ var result = func();
+ setYieldContext(true);
+ return result;
+ }
+ return func();
+ }
+ function inYieldContext() {
+ return (contextFlags & 4 /* Yield */) !== 0;
+ }
+ function inStrictModeContext() {
+ return (contextFlags & 1 /* StrictMode */) !== 0;
+ }
+ function inGeneratorParameterContext() {
+ return (contextFlags & 8 /* GeneratorParameter */) !== 0;
+ }
+ function inDisallowInContext() {
+ return (contextFlags & 2 /* DisallowIn */) !== 0;
+ }
function getLineStarts() {
return lineStarts || (lineStarts = ts.computeLineStarts(sourceText));
}
@@ -2963,7 +3056,13 @@ var ts;
return scanner.tryScan(function () { return lookAheadHelper(callback, false); });
}
function isIdentifier() {
- return token === 63 /* Identifier */ || (isInStrictMode ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */);
+ if (token === 63 /* Identifier */) {
+ return true;
+ }
+ if (token === 108 /* YieldKeyword */ && inYieldContext()) {
+ return false;
+ }
+ return inStrictModeContext() ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */;
}
function parseExpected(t) {
if (token === t) {
@@ -2980,6 +3079,14 @@ var ts;
}
return false;
}
+ function parseOptionalToken(t) {
+ if (token === t) {
+ var node = createNode(t);
+ nextToken();
+ return finishNode(node);
+ }
+ return undefined;
+ }
function canParseSemicolon() {
if (token === 21 /* SemicolonToken */) {
return true;
@@ -3008,8 +3115,8 @@ var ts;
}
function finishNode(node) {
node.end = scanner.getStartPos();
- if (isInStrictMode) {
- node.flags |= 8192 /* ParsedInStrictMode */;
+ if (contextFlags) {
+ node.parserContextFlags = contextFlags;
}
return node;
}
@@ -3057,7 +3164,7 @@ var ts;
function parseAnyContextualModifier() {
return isModifier(token) && tryParse(function () {
nextToken();
- return token === 17 /* OpenBracketToken */ || isPropertyName();
+ return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isPropertyName();
});
}
function isListElement(kind, inErrorRecovery) {
@@ -3075,8 +3182,9 @@ var ts;
case 6 /* ClassMembers */:
return lookAhead(isClassMemberStart);
case 7 /* EnumMembers */:
- case 11 /* ObjectLiteralMembers */:
return isPropertyName();
+ case 11 /* ObjectLiteralMembers */:
+ return token === 34 /* AsteriskToken */ || isPropertyName();
case 8 /* BaseTypeReferences */:
return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); }));
case 9 /* VariableDeclarations */:
@@ -3153,15 +3261,15 @@ var ts;
parsingContext |= 1 << kind;
var result = [];
result.pos = getNodePos();
- var saveIsInStrictMode = isInStrictMode;
+ var savedStrictModeContext = inStrictModeContext();
while (!isListTerminator(kind)) {
if (isListElement(kind, false)) {
var element = parseElement();
result.push(element);
- if (!isInStrictMode && checkForStrictMode) {
+ if (!inStrictModeContext() && checkForStrictMode) {
if (isPrologueDirective(element)) {
if (isUseStrictPrologueDirective(element)) {
- isInStrictMode = true;
+ setStrictModeContext(true);
checkForStrictMode = false;
}
}
@@ -3178,7 +3286,7 @@ var ts;
nextToken();
}
}
- isInStrictMode = saveIsInStrictMode;
+ setStrictModeContext(savedStrictModeContext);
result.end = getNodeEnd();
parsingContext = saveParsingContext;
return result;
@@ -3227,16 +3335,10 @@ var ts;
result.end = pos;
return result;
}
- function createNodeArray(node) {
- var result = [node];
- result.pos = node.pos;
- result.end = node.end;
- return result;
- }
- function parseBracketedList(kind, parseElement, startToken, endToken) {
- if (parseExpected(startToken)) {
+ function parseBracketedList(kind, parseElement, open, close) {
+ if (parseExpected(open)) {
var result = parseDelimitedList(kind, parseElement);
- parseExpected(endToken);
+ parseExpected(close);
return result;
}
return createMissingList();
@@ -3271,7 +3373,7 @@ var ts;
}
function parseTemplateSpan() {
var span = createNode(159 /* TemplateSpan */);
- span.expression = parseExpression(false);
+ span.expression = allowInAnd(parseExpression);
var literal;
if (token === 14 /* CloseBraceToken */) {
reScanTemplateToken();
@@ -3293,7 +3395,7 @@ var ts;
nextToken();
finishNode(node);
if (node.kind === 6 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) {
- node.flags |= 16384 /* OctalLiteral */;
+ node.flags |= 8192 /* OctalLiteral */;
}
return node;
}
@@ -3348,15 +3450,14 @@ var ts;
node.modifiers = modifiers;
}
}
- function parseParameter(flags) {
- if (flags === void 0) { flags = 0; }
+ function parseParameter() {
var node = createNode(123 /* Parameter */);
- var modifiers = parseModifiers(3 /* Parameters */);
+ var modifiers = parseModifiers();
setModifiers(node, modifiers);
if (parseOptional(20 /* DotDotDotToken */)) {
node.flags |= 8 /* Rest */;
}
- node.name = parseIdentifier();
+ node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifier) : parseIdentifier();
if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) {
nextToken();
}
@@ -3364,68 +3465,82 @@ var ts;
node.flags |= 4 /* QuestionMark */;
}
node.type = parseParameterType();
- node.initializer = parseInitializer(true);
+ node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer();
return finishNode(node);
}
- function parseSignature(kind, returnToken, returnTokenRequired) {
+ function parseParameterInitializer() {
+ return parseInitializer(true);
+ }
+ function parseSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext) {
+ var signature = {};
+ fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature);
+ return signature;
+ }
+ function fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature) {
if (kind === 130 /* ConstructSignature */) {
parseExpected(86 /* NewKeyword */);
}
- var typeParameters = parseTypeParameters();
- var parameters = parseParameterList(15 /* OpenParenToken */, 16 /* CloseParenToken */);
- var type;
+ signature.typeParameters = parseTypeParameters();
+ signature.parameters = parseParameterList(yieldAndGeneratorParameterContext);
if (returnTokenRequired) {
parseExpected(returnToken);
- type = parseType();
+ signature.type = parseType();
}
else if (parseOptional(returnToken)) {
- type = parseType();
+ signature.type = parseType();
}
- return {
- typeParameters: typeParameters,
- parameters: parameters,
- type: type
- };
}
- function parseParameterList(startDelimiter, endDelimiter) {
- return parseBracketedList(13 /* Parameters */, parseParameter, startDelimiter, endDelimiter);
+ function parseParameterList(yieldAndGeneratorParameterContext) {
+ if (parseExpected(15 /* OpenParenToken */)) {
+ var savedYieldContext = inYieldContext();
+ var savedGeneratorParameterContext = inGeneratorParameterContext();
+ setYieldContext(yieldAndGeneratorParameterContext);
+ setGeneratorParameterContext(yieldAndGeneratorParameterContext);
+ var result = parseDelimitedList(13 /* Parameters */, parseParameter);
+ parseExpected(16 /* CloseParenToken */);
+ setYieldContext(savedYieldContext);
+ setGeneratorParameterContext(savedGeneratorParameterContext);
+ return result;
+ }
+ return createMissingList();
}
function parseSignatureMember(kind, returnToken) {
var node = createNode(kind);
- var sig = parseSignature(kind, returnToken, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
+ fillSignature(kind, returnToken, false, false, node);
parseSemicolon();
return finishNode(node);
}
- function parseIndexSignatureMember(modifiers, pos) {
- var node = createNode(131 /* IndexSignature */, pos);
+ function parseIndexSignatureMember(fullStart, modifiers) {
+ var node = createNode(131 /* IndexSignature */, fullStart);
setModifiers(node, modifiers);
- node.parameters = parseParameterList(17 /* OpenBracketToken */, 18 /* CloseBracketToken */);
+ node.parameters = parseBracketedList(13 /* Parameters */, parseParameter, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */);
node.type = parseTypeAnnotation();
parseSemicolon();
return finishNode(node);
}
function parsePropertyOrMethod() {
- var node = createNode(0 /* Unknown */);
- node.name = parsePropertyName();
+ var fullStart = scanner.getStartPos();
+ var name = parsePropertyName();
+ var flags = 0;
if (parseOptional(49 /* QuestionToken */)) {
- node.flags |= 4 /* QuestionMark */;
+ flags = 4 /* QuestionMark */;
}
if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
- node.kind = 125 /* Method */;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
+ var method = createNode(125 /* Method */, fullStart);
+ method.name = name;
+ method.flags = flags;
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, method);
+ parseSemicolon();
+ return finishNode(method);
}
else {
- node.kind = 124 /* Property */;
- node.type = parseTypeAnnotation();
+ var property = createNode(124 /* Property */, fullStart);
+ property.name = name;
+ property.flags = flags;
+ property.type = parseTypeAnnotation();
+ parseSemicolon();
+ return finishNode(property);
}
- parseSemicolon();
- return finishNode(node);
}
function isStartOfTypeMember() {
switch (token) {
@@ -3443,7 +3558,7 @@ var ts;
case 23 /* LessThanToken */:
return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */);
case 17 /* OpenBracketToken */:
- return parseIndexSignatureMember(undefined);
+ return parseIndexSignatureMember(scanner.getStartPos(), undefined);
case 86 /* NewKeyword */:
if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) {
return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */);
@@ -3459,14 +3574,19 @@ var ts;
}
function parseTypeLiteral() {
var node = createNode(136 /* TypeLiteral */);
+ node.members = parseObjectType();
+ return finishNode(node);
+ }
+ function parseObjectType() {
+ var members;
if (parseExpected(13 /* OpenBraceToken */)) {
- node.members = parseList(5 /* TypeMembers */, false, parseTypeMember);
+ members = parseList(5 /* TypeMembers */, false, parseTypeMember);
parseExpected(14 /* CloseBraceToken */);
}
else {
- node.members = createMissingList();
+ members = createMissingList();
}
- return finishNode(node);
+ return members;
}
function parseTupleType() {
var node = createNode(138 /* TupleType */);
@@ -3481,13 +3601,9 @@ var ts;
return finishNode(node);
}
function parseFunctionType(typeKind) {
- var member = createNode(typeKind);
- var sig = parseSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true);
- member.typeParameters = sig.typeParameters;
- member.parameters = sig.parameters;
- member.type = sig.type;
- finishNode(member);
- return member;
+ var node = createNode(typeKind);
+ fillSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true, false, node);
+ return finishNode(node);
}
function parseKeywordAndNoDot() {
var node = parseTokenNode();
@@ -3587,6 +3703,16 @@ var ts;
});
}
function parseType() {
+ var savedYieldContext = inYieldContext();
+ var savedGeneratorParameterContext = inGeneratorParameterContext();
+ setYieldContext(false);
+ setGeneratorParameterContext(false);
+ var result = parseTypeWorker();
+ setYieldContext(savedYieldContext);
+ setGeneratorParameterContext(savedGeneratorParameterContext);
+ return result;
+ }
+ function parseTypeWorker() {
if (isStartOfFunctionType()) {
return parseFunctionType(133 /* FunctionType */);
}
@@ -3627,6 +3753,7 @@ var ts;
case 38 /* MinusMinusToken */:
case 23 /* LessThanToken */:
case 63 /* Identifier */:
+ case 108 /* YieldKeyword */:
return true;
default:
return isIdentifier();
@@ -3635,38 +3762,68 @@ var ts;
function isStartOfExpressionStatement() {
return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression();
}
- function parseExpression(noIn) {
- var expr = parseAssignmentExpression(noIn);
+ function parseExpression() {
+ var expr = parseAssignmentExpression();
while (parseOptional(22 /* CommaToken */)) {
- expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression(noIn));
+ expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression());
}
return expr;
}
- function parseInitializer(inParameter, noIn) {
+ function parseInitializer(inParameter) {
if (token !== 51 /* EqualsToken */) {
if (scanner.hasPrecedingLineBreak() || (inParameter && token === 13 /* OpenBraceToken */) || !isStartOfExpression()) {
return undefined;
}
}
parseExpected(51 /* EqualsToken */);
- return parseAssignmentExpression(noIn);
+ return parseAssignmentExpression();
}
- function parseAssignmentExpression(noIn) {
+ function parseAssignmentExpression() {
+ if (isYieldExpression()) {
+ return parseYieldExpression();
+ }
var arrowExpression = tryParseParenthesizedArrowFunctionExpression();
if (arrowExpression) {
return arrowExpression;
}
- var expr = parseConditionalExpression(noIn);
+ var expr = parseConditionalExpression();
if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) {
return parseSimpleArrowFunctionExpression(expr);
}
if (isLeftHandSideExpression(expr) && isAssignmentOperator(token)) {
var operator = token;
nextToken();
- return makeBinaryExpression(expr, operator, parseAssignmentExpression(noIn));
+ return makeBinaryExpression(expr, operator, parseAssignmentExpression());
}
return expr;
}
+ function isYieldExpression() {
+ if (token === 108 /* YieldKeyword */) {
+ if (inYieldContext()) {
+ return true;
+ }
+ if (inStrictModeContext()) {
+ return true;
+ }
+ return lookAhead(function () {
+ nextToken();
+ return !scanner.hasPrecedingLineBreak() && isIdentifier();
+ });
+ }
+ return false;
+ }
+ function parseYieldExpression() {
+ var node = createNode(160 /* YieldExpression */);
+ nextToken();
+ if (!scanner.hasPrecedingLineBreak() && (token === 34 /* AsteriskToken */ || isStartOfExpression())) {
+ node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
+ node.expression = parseAssignmentExpression();
+ return finishNode(node);
+ }
+ else {
+ return finishNode(node);
+ }
+ }
function parseSimpleArrowFunctionExpression(identifier) {
ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
parseExpected(31 /* EqualsGreaterThanToken */);
@@ -3678,7 +3835,7 @@ var ts;
parameters.pos = parameter.pos;
parameters.end = parameter.end;
var signature = { parameters: parameters };
- return parseArrowExpressionTail(identifier.pos, signature, false);
+ return parseArrowExpressionTail(identifier.pos, signature);
}
function tryParseParenthesizedArrowFunctionExpression() {
var triState = isParenthesizedArrowFunctionExpression();
@@ -3687,18 +3844,18 @@ var ts;
}
var pos = getNodePos();
if (triState === 1 /* True */) {
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false);
if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) {
- return parseArrowExpressionTail(pos, sig, false);
+ return parseArrowExpressionTail(pos, sig);
}
else {
- return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, sig, createMissingNode());
+ return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, createMissingNode());
}
}
var sig = tryParseSignatureIfArrowOrBraceFollows();
if (sig) {
parseExpected(31 /* EqualsGreaterThanToken */);
- return parseArrowExpressionTail(pos, sig, false);
+ return parseArrowExpressionTail(pos, sig);
}
else {
return undefined;
@@ -3748,49 +3905,46 @@ var ts;
}
function tryParseSignatureIfArrowOrBraceFollows() {
return tryParse(function () {
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false);
if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) {
return sig;
}
return undefined;
});
}
- function parseArrowExpressionTail(pos, sig, noIn) {
+ function parseArrowExpressionTail(pos, sig) {
var body;
if (token === 13 /* OpenBraceToken */) {
- body = parseFunctionBlock(false);
+ body = parseFunctionBlock(false, false);
}
else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) {
- body = parseFunctionBlock(true);
+ body = parseFunctionBlock(false, true);
}
else {
- body = parseAssignmentExpression(noIn);
+ body = parseAssignmentExpression();
}
- return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, sig, body);
+ return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, body);
}
- function parseConditionalExpression(noIn) {
- var expr = parseBinaryExpression(noIn);
+ function parseConditionalExpression() {
+ var expr = parseBinaryOperators(parseUnaryExpression(), 0);
while (parseOptional(49 /* QuestionToken */)) {
var node = createNode(157 /* ConditionalExpression */, expr.pos);
node.condition = expr;
- node.whenTrue = parseAssignmentExpression(false);
+ node.whenTrue = allowInAnd(parseAssignmentExpression);
parseExpected(50 /* ColonToken */);
- node.whenFalse = parseAssignmentExpression(noIn);
+ node.whenFalse = parseAssignmentExpression();
expr = finishNode(node);
}
return expr;
}
- function parseBinaryExpression(noIn) {
- return parseBinaryOperators(parseUnaryExpression(), 0, noIn);
- }
- function parseBinaryOperators(expr, minPrecedence, noIn) {
+ function parseBinaryOperators(expr, minPrecedence) {
while (true) {
reScanGreaterToken();
var precedence = getOperatorPrecedence();
- if (precedence && precedence > minPrecedence && (!noIn || token !== 84 /* InKeyword */)) {
+ if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== 84 /* InKeyword */)) {
var operator = token;
nextToken();
- expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence, noIn));
+ expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence));
continue;
}
return expr;
@@ -3915,7 +4069,7 @@ var ts;
indexedAccess.index = createMissingNode();
}
else {
- indexedAccess.index = parseExpression();
+ indexedAccess.index = allowInAnd(parseExpression);
if (indexedAccess.index.kind === 7 /* StringLiteral */ || indexedAccess.index.kind === 6 /* NumericLiteral */) {
var literal = indexedAccess.index;
literal.text = internIdentifier(literal.text);
@@ -4005,18 +4159,18 @@ var ts;
function parseParenExpression() {
var node = createNode(151 /* ParenExpression */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
return finishNode(node);
}
function parseAssignmentExpressionOrOmittedExpression() {
- return token === 22 /* CommaToken */ ? createNode(160 /* OmittedExpression */) : parseAssignmentExpression();
+ return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpression();
}
function parseArrayLiteralElement() {
return parseAssignmentExpressionOrOmittedExpression();
}
function parseArgumentExpression() {
- return parseAssignmentExpressionOrOmittedExpression();
+ return allowInAnd(parseAssignmentExpressionOrOmittedExpression);
}
function parseArrayLiteral() {
var node = createNode(141 /* ArrayLiteral */);
@@ -4029,16 +4183,17 @@ var ts;
}
function parsePropertyAssignment() {
var nodePos = scanner.getStartPos();
+ var asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
var tokenIsIdentifier = isIdentifier();
var nameToken = token;
var propertyName = parsePropertyName();
var node;
- if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
+ if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
node = createNode(143 /* PropertyAssignment */, nodePos);
node.name = propertyName;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- var body = parseFunctionBlock(false);
- node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, undefined, sig, body);
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken);
+ var body = parseFunctionBlock(!!asteriskToken, false);
+ node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, asteriskToken, undefined, sig, body);
return finishNode(node);
}
var flags = 0;
@@ -4054,7 +4209,7 @@ var ts;
node = createNode(143 /* PropertyAssignment */, nodePos);
node.name = propertyName;
parseExpected(50 /* ColonToken */);
- node.initializer = parseAssignmentExpression(false);
+ node.initializer = allowInAnd(parseAssignmentExpression);
}
node.flags = flags;
return finishNode(node);
@@ -4081,13 +4236,18 @@ var ts;
function parseFunctionExpression() {
var pos = getNodePos();
parseExpected(81 /* FunctionKeyword */);
- var name = isIdentifier() ? parseIdentifier() : undefined;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- var body = parseFunctionBlock(false);
- return makeFunctionExpression(152 /* FunctionExpression */, pos, name, sig, body);
+ var asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
+ var name = asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier();
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken);
+ var body = parseFunctionBlock(!!asteriskToken, false);
+ return makeFunctionExpression(152 /* FunctionExpression */, pos, asteriskToken, name, sig, body);
}
- function makeFunctionExpression(kind, pos, name, sig, body) {
+ function parseOptionalIdentifier() {
+ return isIdentifier() ? parseIdentifier() : undefined;
+ }
+ function makeFunctionExpression(kind, pos, asteriskToken, name, sig, body) {
var node = createNode(kind, pos);
+ node.asteriskToken = asteriskToken;
node.name = name;
node.typeParameters = sig.typeParameters;
node.parameters = sig.parameters;
@@ -4106,7 +4266,7 @@ var ts;
return finishNode(node);
}
function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) {
- var node = createNode(161 /* Block */);
+ var node = createNode(162 /* Block */);
if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) {
node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement);
parseExpected(14 /* CloseBraceToken */);
@@ -4116,42 +4276,45 @@ var ts;
}
return finishNode(node);
}
- function parseFunctionBlock(ignoreMissingOpenBrace) {
+ function parseFunctionBlock(allowYield, ignoreMissingOpenBrace) {
+ var savedYieldContext = inYieldContext();
+ setYieldContext(allowYield);
var block = parseBlock(ignoreMissingOpenBrace, true);
- block.kind = 186 /* FunctionBlock */;
+ block.kind = 187 /* FunctionBlock */;
+ setYieldContext(savedYieldContext);
return block;
}
function parseEmptyStatement() {
- var node = createNode(163 /* EmptyStatement */);
+ var node = createNode(164 /* EmptyStatement */);
parseExpected(21 /* SemicolonToken */);
return finishNode(node);
}
function parseIfStatement() {
- var node = createNode(165 /* IfStatement */);
+ var node = createNode(166 /* IfStatement */);
parseExpected(82 /* IfKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
node.thenStatement = parseStatement();
node.elseStatement = parseOptional(74 /* ElseKeyword */) ? parseStatement() : undefined;
return finishNode(node);
}
function parseDoStatement() {
- var node = createNode(166 /* DoStatement */);
+ var node = createNode(167 /* DoStatement */);
parseExpected(73 /* DoKeyword */);
node.statement = parseStatement();
parseExpected(98 /* WhileKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
parseOptional(21 /* SemicolonToken */);
return finishNode(node);
}
function parseWhileStatement() {
- var node = createNode(167 /* WhileStatement */);
+ var node = createNode(168 /* WhileStatement */);
parseExpected(98 /* WhileKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
node.statement = parseStatement();
return finishNode(node);
@@ -4162,33 +4325,33 @@ var ts;
parseExpected(15 /* OpenParenToken */);
if (token !== 21 /* SemicolonToken */) {
if (parseOptional(96 /* VarKeyword */)) {
- var declarations = parseVariableDeclarationList(0, true);
+ var declarations = disallowInAnd(parseVariableDeclarationList);
}
else if (parseOptional(102 /* LetKeyword */)) {
- var declarations = parseVariableDeclarationList(2048 /* Let */, true);
+ var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 2048 /* Let */);
}
else if (parseOptional(68 /* ConstKeyword */)) {
- var declarations = parseVariableDeclarationList(4096 /* Const */, true);
+ var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 4096 /* Const */);
}
else {
- var varOrInit = parseExpression(true);
+ var varOrInit = disallowInAnd(parseExpression);
}
}
var forOrForInStatement;
if (parseOptional(84 /* InKeyword */)) {
- var forInStatement = createNode(169 /* ForInStatement */, pos);
+ var forInStatement = createNode(170 /* ForInStatement */, pos);
if (declarations) {
forInStatement.declarations = declarations;
}
else {
forInStatement.variable = varOrInit;
}
- forInStatement.expression = parseExpression();
+ forInStatement.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
forOrForInStatement = forInStatement;
}
else {
- var forStatement = createNode(168 /* ForStatement */, pos);
+ var forStatement = createNode(169 /* ForStatement */, pos);
if (declarations) {
forStatement.declarations = declarations;
}
@@ -4197,11 +4360,11 @@ var ts;
}
parseExpected(21 /* SemicolonToken */);
if (token !== 21 /* SemicolonToken */ && token !== 16 /* CloseParenToken */) {
- forStatement.condition = parseExpression();
+ forStatement.condition = allowInAnd(parseExpression);
}
parseExpected(21 /* SemicolonToken */);
if (token !== 16 /* CloseParenToken */) {
- forStatement.iterator = parseExpression();
+ forStatement.iterator = allowInAnd(parseExpression);
}
parseExpected(16 /* CloseParenToken */);
forOrForInStatement = forStatement;
@@ -4211,7 +4374,7 @@ var ts;
}
function parseBreakOrContinueStatement(kind) {
var node = createNode(kind);
- parseExpected(kind === 171 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */);
+ parseExpected(kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */);
if (!canParseSemicolon()) {
node.label = parseIdentifier();
}
@@ -4219,35 +4382,33 @@ var ts;
return finishNode(node);
}
function parseReturnStatement() {
- var node = createNode(172 /* ReturnStatement */);
- var returnTokenStart = scanner.getTokenPos();
- var returnTokenLength = scanner.getTextPos() - returnTokenStart;
+ var node = createNode(173 /* ReturnStatement */);
parseExpected(88 /* ReturnKeyword */);
if (!canParseSemicolon()) {
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
}
parseSemicolon();
return finishNode(node);
}
function parseWithStatement() {
- var node = createNode(173 /* WithStatement */);
+ var node = createNode(174 /* WithStatement */);
parseExpected(99 /* WithKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
node.statement = parseStatement();
return finishNode(node);
}
function parseCaseClause() {
- var node = createNode(175 /* CaseClause */);
+ var node = createNode(176 /* CaseClause */);
parseExpected(65 /* CaseKeyword */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(50 /* ColonToken */);
node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement);
return finishNode(node);
}
function parseDefaultClause() {
- var node = createNode(176 /* DefaultClause */);
+ var node = createNode(177 /* DefaultClause */);
parseExpected(71 /* DefaultKeyword */);
parseExpected(50 /* ColonToken */);
node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement);
@@ -4257,10 +4418,10 @@ var ts;
return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
}
function parseSwitchStatement() {
- var node = createNode(174 /* SwitchStatement */);
+ var node = createNode(175 /* SwitchStatement */);
parseExpected(90 /* SwitchKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
parseExpected(13 /* OpenBraceToken */);
node.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause);
@@ -4268,23 +4429,23 @@ var ts;
return finishNode(node);
}
function parseThrowStatement() {
- var node = createNode(178 /* ThrowStatement */);
+ var node = createNode(179 /* ThrowStatement */);
parseExpected(92 /* ThrowKeyword */);
if (scanner.hasPrecedingLineBreak()) {
error(ts.Diagnostics.Line_break_not_permitted_here);
}
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseSemicolon();
return finishNode(node);
}
function parseTryStatement() {
- var node = createNode(179 /* TryStatement */);
- node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 180 /* TryBlock */);
+ var node = createNode(180 /* TryStatement */);
+ node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 181 /* TryBlock */);
if (token === 66 /* CatchKeyword */) {
node.catchBlock = parseCatchBlock();
}
if (token === 79 /* FinallyKeyword */) {
- node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 182 /* FinallyBlock */);
+ node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 183 /* FinallyBlock */);
}
if (!(node.catchBlock || node.finallyBlock)) {
error(ts.Diagnostics.catch_or_finally_expected);
@@ -4307,34 +4468,31 @@ var ts;
var typeAnnotation = parseTypeAnnotation();
parseExpected(16 /* CloseParenToken */);
var result = parseBlock(false, false);
- result.kind = 181 /* CatchBlock */;
+ result.kind = 182 /* CatchBlock */;
result.pos = pos;
result.variable = variable;
result.type = typeAnnotation;
return result;
}
function parseDebuggerStatement() {
- var node = createNode(183 /* DebuggerStatement */);
+ var node = createNode(184 /* DebuggerStatement */);
parseExpected(70 /* DebuggerKeyword */);
parseSemicolon();
return finishNode(node);
}
- function isIterationStatementStart() {
- return token === 98 /* WhileKeyword */ || token === 73 /* DoKeyword */ || token === 80 /* ForKeyword */;
- }
function isLabel() {
return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; });
}
function parseLabeledStatement() {
- var node = createNode(177 /* LabeledStatement */);
+ var node = createNode(178 /* LabeledStatement */);
node.label = parseIdentifier();
parseExpected(50 /* ColonToken */);
- node.statement = isLabel() ? parseLabeledStatement() : parseStatement();
+ node.statement = parseStatement();
return finishNode(node);
}
function parseExpressionStatement() {
- var node = createNode(164 /* ExpressionStatement */);
- node.expression = parseExpression();
+ var node = createNode(165 /* ExpressionStatement */);
+ node.expression = allowInAnd(parseExpression);
parseSemicolon();
return finishNode(node);
}
@@ -4390,9 +4548,9 @@ var ts;
case 96 /* VarKeyword */:
case 102 /* LetKeyword */:
case 68 /* ConstKeyword */:
- return parseVariableStatement();
+ return parseVariableStatement(scanner.getStartPos(), undefined);
case 81 /* FunctionKeyword */:
- return parseFunctionDeclaration();
+ return parseFunctionDeclaration(scanner.getStartPos(), undefined);
case 21 /* SemicolonToken */:
return parseEmptyStatement();
case 82 /* IfKeyword */:
@@ -4404,9 +4562,9 @@ var ts;
case 80 /* ForKeyword */:
return parseForOrForInStatement();
case 69 /* ContinueKeyword */:
- return parseBreakOrContinueStatement(170 /* ContinueStatement */);
+ return parseBreakOrContinueStatement(171 /* ContinueStatement */);
case 64 /* BreakKeyword */:
- return parseBreakOrContinueStatement(171 /* BreakStatement */);
+ return parseBreakOrContinueStatement(172 /* BreakStatement */);
case 88 /* ReturnKeyword */:
return parseReturnStatement();
case 99 /* WithKeyword */:
@@ -4425,9 +4583,9 @@ var ts;
return isLabel() ? parseLabeledStatement() : parseExpressionStatement();
}
}
- function parseFunctionBlockOrSemicolon() {
+ function parseFunctionBlockOrSemicolon(isGenerator) {
if (token === 13 /* OpenBraceToken */) {
- return parseFunctionBlock(false);
+ return parseFunctionBlock(isGenerator, false);
}
if (canParseSemicolon()) {
parseSemicolon();
@@ -4435,24 +4593,25 @@ var ts;
}
error(ts.Diagnostics.Block_or_expected);
}
- function parseVariableDeclaration(flags, noIn) {
- var node = createNode(184 /* VariableDeclaration */);
- node.flags = flags;
+ function parseVariableDeclaration() {
+ var node = createNode(185 /* VariableDeclaration */);
node.name = parseIdentifier();
node.type = parseTypeAnnotation();
- var initializerStart = scanner.getTokenPos();
- var initializerFirstTokenLength = scanner.getTextPos() - initializerStart;
- node.initializer = parseInitializer(false, noIn);
+ node.initializer = parseInitializer(false);
return finishNode(node);
}
- function parseVariableDeclarationList(flags, noIn) {
- return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); });
- }
- function parseVariableStatement(pos, flags) {
- var node = createNode(162 /* VariableStatement */, pos);
- if (flags) {
- node.flags = flags;
+ function setFlag(array, flag) {
+ for (var i = 0, n = array.length; i < n; i++) {
+ array[i].flags |= flag;
}
+ return array;
+ }
+ function parseVariableDeclarationList() {
+ return parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration);
+ }
+ function parseVariableStatement(fullStart, modifiers) {
+ var node = createNode(163 /* VariableStatement */, fullStart);
+ setModifiers(node, modifiers);
if (token === 102 /* LetKeyword */) {
node.flags |= 2048 /* Let */;
}
@@ -4463,79 +4622,67 @@ var ts;
ts.Debug.assert(token === 96 /* VarKeyword */);
}
nextToken();
- node.declarations = parseVariableDeclarationList(node.flags, false);
+ node.declarations = allowInAnd(parseVariableDeclarationList);
+ setFlag(node.declarations, node.flags);
parseSemicolon();
return finishNode(node);
}
- function parseFunctionDeclaration(pos, flags) {
- var node = createNode(185 /* FunctionDeclaration */, pos);
- if (flags)
- node.flags = flags;
+ function parseFunctionDeclaration(fullStart, modifiers) {
+ var node = createNode(186 /* FunctionDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(81 /* FunctionKeyword */);
+ node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
node.name = parseIdentifier();
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
- node.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!node.asteriskToken, node);
+ node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken);
return finishNode(node);
}
function parseConstructorDeclaration(pos, modifiers) {
var node = createNode(126 /* Constructor */, pos);
setModifiers(node, modifiers);
parseExpected(111 /* ConstructorKeyword */);
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
- node.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node);
+ node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
- function parsePropertyMemberDeclaration(pos, modifiers) {
- var name = parsePropertyName();
+ function parsePropertyMemberDeclaration(fullStart, modifiers) {
var flags = modifiers ? modifiers.flags : 0;
- var questionStart = scanner.getTokenPos();
+ var asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
+ var name = parsePropertyName();
if (parseOptional(49 /* QuestionToken */)) {
flags |= 4 /* QuestionMark */;
}
- if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
- var method = createNode(125 /* Method */, pos);
+ if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
+ var method = createNode(125 /* Method */, fullStart);
setModifiers(method, modifiers);
if (flags) {
method.flags = flags;
}
+ method.asteriskToken = asteriskToken;
method.name = name;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- method.typeParameters = sig.typeParameters;
- method.parameters = sig.parameters;
- method.type = sig.type;
- method.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken, method);
+ method.body = parseFunctionBlockOrSemicolon(!!asteriskToken);
return finishNode(method);
}
else {
- var property = createNode(124 /* Property */, pos);
+ var property = createNode(124 /* Property */, fullStart);
setModifiers(property, modifiers);
if (flags) {
property.flags = flags;
}
property.name = name;
property.type = parseTypeAnnotation();
- var initializerStart = scanner.getTokenPos();
- var initializerFirstTokenLength = scanner.getTextPos() - initializerStart;
- property.initializer = parseInitializer(false);
+ property.initializer = allowInAnd(function () { return parseInitializer(false); });
parseSemicolon();
return finishNode(property);
}
}
- function parseMemberAccessorDeclaration(kind, pos, modifiers) {
- var node = createNode(kind, pos);
+ function parseMemberAccessorDeclaration(kind, fullStart, modifiers) {
+ var node = createNode(kind, fullStart);
setModifiers(node, modifiers);
node.name = parsePropertyName();
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
- node.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node);
+ node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
function isClassMemberStart() {
@@ -4544,6 +4691,9 @@ var ts;
idToken = token;
nextToken();
}
+ if (token === 34 /* AsteriskToken */) {
+ return true;
+ }
if (isPropertyName()) {
idToken = token;
nextToken();
@@ -4568,19 +4718,20 @@ var ts;
}
return false;
}
- function parseModifiers(context) {
+ function parseModifiers() {
var flags = 0;
var modifiers;
while (true) {
var modifierStart = scanner.getTokenPos();
- var modifierToken = token;
- if (!parseAnyContextualModifier())
+ var modifierKind = token;
+ if (!parseAnyContextualModifier()) {
break;
+ }
if (!modifiers) {
modifiers = [];
}
- flags |= modifierToFlag(modifierToken);
- modifiers.push(finishNode(createNode(modifierToken, modifierStart)));
+ flags |= modifierToFlag(modifierKind);
+ modifiers.push(finishNode(createNode(modifierKind, modifierStart)));
}
if (modifiers) {
modifiers.flags = flags;
@@ -4588,37 +4739,37 @@ var ts;
return modifiers;
}
function parseClassMemberDeclaration() {
- var pos = getNodePos();
- var modifiers = parseModifiers(2 /* ClassMembers */);
+ var fullStart = getNodePos();
+ var modifiers = parseModifiers();
if (parseContextualModifier(113 /* GetKeyword */)) {
- return parseMemberAccessorDeclaration(127 /* GetAccessor */, pos, modifiers);
+ return parseMemberAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers);
}
if (parseContextualModifier(117 /* SetKeyword */)) {
- return parseMemberAccessorDeclaration(128 /* SetAccessor */, pos, modifiers);
+ return parseMemberAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers);
}
if (token === 111 /* ConstructorKeyword */) {
- return parseConstructorDeclaration(pos, modifiers);
+ return parseConstructorDeclaration(fullStart, modifiers);
}
- if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) {
- return parsePropertyMemberDeclaration(pos, modifiers);
+ if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */) {
+ return parsePropertyMemberDeclaration(fullStart, modifiers);
}
if (token === 17 /* OpenBracketToken */) {
- return parseIndexSignatureMember(modifiers, pos);
+ return parseIndexSignatureMember(fullStart, modifiers);
}
ts.Debug.fail("Should not have attempted to parse class member declaration.");
}
- function parseClassDeclaration(pos, flags) {
- var node = createNode(187 /* ClassDeclaration */, pos);
- node.flags = flags;
+ function parseClassDeclaration(fullStart, modifiers) {
+ var node = createNode(188 /* ClassDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(67 /* ClassKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
- node.baseType = parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined;
+ node.baseType = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassBaseType) : parseClassBaseType();
if (parseOptional(100 /* ImplementsKeyword */)) {
node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference);
}
if (parseExpected(13 /* OpenBraceToken */)) {
- node.members = parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration);
+ node.members = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassMembers) : parseClassMembers();
parseExpected(14 /* CloseBraceToken */);
}
else {
@@ -4626,21 +4777,27 @@ var ts;
}
return finishNode(node);
}
- function parseInterfaceDeclaration(pos, flags) {
- var node = createNode(188 /* InterfaceDeclaration */, pos);
- node.flags = flags;
+ function parseClassMembers() {
+ return parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration);
+ }
+ function parseClassBaseType() {
+ return parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined;
+ }
+ function parseInterfaceDeclaration(fullStart, modifiers) {
+ var node = createNode(189 /* InterfaceDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(101 /* InterfaceKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
if (parseOptional(77 /* ExtendsKeyword */)) {
node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference);
}
- node.members = parseTypeLiteral().members;
+ node.members = parseObjectType();
return finishNode(node);
}
- function parseTypeAliasDeclaration(pos, flags) {
- var node = createNode(189 /* TypeAliasDeclaration */, pos);
- node.flags = flags;
+ function parseTypeAliasDeclaration(fullStart, modifiers) {
+ var node = createNode(190 /* TypeAliasDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(119 /* TypeKeyword */);
node.name = parseIdentifier();
parseExpected(51 /* EqualsToken */);
@@ -4648,17 +4805,16 @@ var ts;
parseSemicolon();
return finishNode(node);
}
- function parseAndCheckEnumDeclaration(pos, flags) {
- var enumIsConst = flags & 4096 /* Const */;
- function parseEnumMember() {
- var node = createNode(195 /* EnumMember */);
- node.name = parsePropertyName();
- node.initializer = parseInitializer(false);
- return finishNode(node);
- }
- var node = createNode(190 /* EnumDeclaration */, pos);
+ function parseEnumMember() {
+ var node = createNode(196 /* EnumMember */, scanner.getStartPos());
+ node.name = parsePropertyName();
+ node.initializer = allowInAnd(function () { return parseInitializer(false); });
+ return finishNode(node);
+ }
+ function parseAndCheckEnumDeclaration(fullStart, flags) {
+ var node = createNode(191 /* EnumDeclaration */, fullStart);
node.flags = flags;
- if (enumIsConst) {
+ if (flags & 4096 /* Const */) {
parseExpected(68 /* ConstKeyword */);
}
parseExpected(75 /* EnumKeyword */);
@@ -4673,7 +4829,7 @@ var ts;
return finishNode(node);
}
function parseModuleBody() {
- var node = createNode(192 /* ModuleBlock */);
+ var node = createNode(193 /* ModuleBlock */, scanner.getStartPos());
if (parseExpected(13 /* OpenBraceToken */)) {
node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement);
parseExpected(14 /* CloseBraceToken */);
@@ -4683,32 +4839,27 @@ var ts;
}
return finishNode(node);
}
- function parseInternalModuleTail(pos, flags) {
- var node = createNode(191 /* ModuleDeclaration */, pos);
+ function parseInternalModuleTail(fullStart, flags) {
+ var node = createNode(192 /* ModuleDeclaration */, fullStart);
node.flags = flags;
node.name = parseIdentifier();
- if (parseOptional(19 /* DotToken */)) {
- node.body = parseInternalModuleTail(getNodePos(), 1 /* Export */);
- }
- else {
- node.body = parseModuleBody();
- }
+ node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), 1 /* Export */) : parseModuleBody();
return finishNode(node);
}
- function parseAmbientExternalModuleDeclaration(pos, flags) {
- var node = createNode(191 /* ModuleDeclaration */, pos);
+ function parseAmbientExternalModuleDeclaration(fullStart, flags) {
+ var node = createNode(192 /* ModuleDeclaration */, fullStart);
node.flags = flags;
node.name = parseStringLiteral();
node.body = parseModuleBody();
return finishNode(node);
}
- function parseModuleDeclaration(pos, flags) {
+ function parseModuleDeclaration(fullStart, flags) {
parseExpected(114 /* ModuleKeyword */);
- return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(pos, flags) : parseInternalModuleTail(pos, flags);
+ return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, flags) : parseInternalModuleTail(fullStart, flags);
}
- function parseImportDeclaration(pos, flags) {
- var node = createNode(193 /* ImportDeclaration */, pos);
- node.flags = flags;
+ function parseImportDeclaration(fullStart, modifiers) {
+ var node = createNode(194 /* ImportDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(83 /* ImportKeyword */);
node.name = parseIdentifier();
parseExpected(51 /* EqualsToken */);
@@ -4723,8 +4874,8 @@ var ts;
parseSemicolon();
return finishNode(node);
}
- function parseExportAssignmentTail(pos, modifiers) {
- var node = createNode(194 /* ExportAssignment */, pos);
+ function parseExportAssignmentTail(fullStart, modifiers) {
+ var node = createNode(195 /* ExportAssignment */, fullStart);
setModifiers(node, modifiers);
node.exportName = parseIdentifier();
parseSemicolon();
@@ -4758,14 +4909,13 @@ var ts;
});
}
}
- function parseDeclaration(modifierContext) {
- var pos = getNodePos();
- var modifiers = parseModifiers(modifierContext);
+ function parseDeclaration() {
+ var fullStart = getNodePos();
+ var modifiers = parseModifiers();
if (token === 76 /* ExportKeyword */) {
- var modifiersEnd = scanner.getStartPos();
nextToken();
if (parseOptional(51 /* EqualsToken */)) {
- return parseExportAssignmentTail(pos, modifiers);
+ return parseExportAssignmentTail(fullStart, modifiers);
}
}
var flags = modifiers ? modifiers.flags : 0;
@@ -4773,37 +4923,37 @@ var ts;
switch (token) {
case 96 /* VarKeyword */:
case 102 /* LetKeyword */:
- result = parseVariableStatement(pos, flags);
+ result = parseVariableStatement(fullStart, modifiers);
break;
case 68 /* ConstKeyword */:
var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; });
if (isConstEnum) {
- result = parseAndCheckEnumDeclaration(pos, flags | 4096 /* Const */);
+ result = parseAndCheckEnumDeclaration(fullStart, flags | 4096 /* Const */);
}
else {
- result = parseVariableStatement(pos, flags);
+ result = parseVariableStatement(fullStart, modifiers);
}
break;
case 81 /* FunctionKeyword */:
- result = parseFunctionDeclaration(pos, flags);
+ result = parseFunctionDeclaration(fullStart, modifiers);
break;
case 67 /* ClassKeyword */:
- result = parseClassDeclaration(pos, flags);
+ result = parseClassDeclaration(fullStart, modifiers);
break;
case 101 /* InterfaceKeyword */:
- result = parseInterfaceDeclaration(pos, flags);
+ result = parseInterfaceDeclaration(fullStart, modifiers);
break;
case 119 /* TypeKeyword */:
- result = parseTypeAliasDeclaration(pos, flags);
+ result = parseTypeAliasDeclaration(fullStart, modifiers);
break;
case 75 /* EnumKeyword */:
- result = parseAndCheckEnumDeclaration(pos, flags);
+ result = parseAndCheckEnumDeclaration(fullStart, flags);
break;
case 114 /* ModuleKeyword */:
- result = parseModuleDeclaration(pos, flags);
+ result = parseModuleDeclaration(fullStart, flags);
break;
case 83 /* ImportKeyword */:
- result = parseImportDeclaration(pos, flags);
+ result = parseImportDeclaration(fullStart, modifiers);
break;
default:
error(ts.Diagnostics.Declaration_expected);
@@ -4817,13 +4967,13 @@ var ts;
return isDeclarationStart() || isStatement(inErrorRecovery);
}
function parseSourceElement() {
- return parseSourceElementOrModuleElement(0 /* SourceElements */);
+ return parseSourceElementOrModuleElement();
}
function parseModuleElement() {
- return parseSourceElementOrModuleElement(1 /* ModuleElements */);
+ return parseSourceElementOrModuleElement();
}
- function parseSourceElementOrModuleElement(modifierContext) {
- return isDeclarationStart() ? parseDeclaration(modifierContext) : parseStatement();
+ function parseSourceElementOrModuleElement() {
+ return isDeclarationStart() ? parseDeclaration() : parseStatement();
}
function processReferenceComments() {
var referencedFiles = [];
@@ -4870,7 +5020,7 @@ var ts;
};
}
function getExternalModuleIndicator() {
- return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 193 /* ImportDeclaration */ && node.externalModuleName || node.kind === 194 /* ExportAssignment */ ? node : undefined; });
+ return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 194 /* ImportDeclaration */ && node.externalModuleName || node.kind === 195 /* ExportAssignment */ ? node : undefined; });
}
var syntacticDiagnostics;
function getSyntacticDiagnostics() {
@@ -4891,7 +5041,7 @@ var ts;
if (ts.fileExtensionIs(filename, ".d.ts")) {
rootNodeFlags = 1024 /* DeclarationFile */;
}
- file = createRootNode(196 /* SourceFile */, 0, sourceText.length, rootNodeFlags);
+ file = createRootNode(197 /* SourceFile */, 0, sourceText.length, rootNodeFlags);
file.filename = ts.normalizePath(filename);
file.text = sourceText;
file.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition;
@@ -4961,7 +5111,7 @@ var ts;
parent = node;
if (!checkModifiers(node)) {
var savedInFunctionBlock = inFunctionBlock;
- if (node.kind === 186 /* FunctionBlock */) {
+ if (node.kind === 187 /* FunctionBlock */) {
inFunctionBlock = true;
}
var savedInAmbientContext = inAmbientContext;
@@ -4992,48 +5142,49 @@ var ts;
case 130 /* ConstructSignature */:
case 133 /* FunctionType */:
return checkAnyParsedSignature(node);
- case 171 /* BreakStatement */:
- case 170 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
return checkBreakOrContinueStatement(node);
case 147 /* CallExpression */:
case 148 /* NewExpression */:
return checkCallOrNewExpression(node);
- case 190 /* EnumDeclaration */: return checkEnumDeclaration(node);
- case 123 /* Parameter */: return checkParameter(node);
+ case 191 /* EnumDeclaration */: return checkEnumDeclaration(node);
case 156 /* BinaryExpression */: return checkBinaryExpression(node);
- case 181 /* CatchBlock */: return checkCatchBlock(node);
- case 187 /* ClassDeclaration */: return checkClassDeclaration(node);
+ case 182 /* CatchBlock */: return checkCatchBlock(node);
+ case 188 /* ClassDeclaration */: return checkClassDeclaration(node);
case 126 /* Constructor */: return checkConstructor(node);
- case 194 /* ExportAssignment */: return checkExportAssignment(node);
- case 169 /* ForInStatement */: return checkForInStatement(node);
- case 168 /* ForStatement */: return checkForStatement(node);
- case 185 /* FunctionDeclaration */: return checkFunctionDeclaration(node);
+ case 195 /* ExportAssignment */: return checkExportAssignment(node);
+ case 170 /* ForInStatement */: return checkForInStatement(node);
+ case 169 /* ForStatement */: return checkForStatement(node);
+ case 186 /* FunctionDeclaration */: return checkFunctionDeclaration(node);
case 152 /* FunctionExpression */: return checkFunctionExpression(node);
case 127 /* GetAccessor */: return checkGetAccessor(node);
case 146 /* IndexedAccess */: return checkIndexedAccess(node);
case 131 /* IndexSignature */: return checkIndexSignature(node);
- case 188 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node);
- case 177 /* LabeledStatement */: return checkLabeledStatement(node);
+ case 189 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node);
+ case 178 /* LabeledStatement */: return checkLabeledStatement(node);
case 125 /* Method */: return checkMethod(node);
- case 191 /* ModuleDeclaration */: return checkModuleDeclaration(node);
+ case 192 /* ModuleDeclaration */: return checkModuleDeclaration(node);
case 142 /* ObjectLiteral */: return checkObjectLiteral(node);
case 6 /* NumericLiteral */: return checkNumericLiteral(node);
+ case 123 /* Parameter */: return checkParameter(node);
case 155 /* PostfixOperator */: return checkPostfixOperator(node);
case 154 /* PrefixOperator */: return checkPrefixOperator(node);
case 124 /* Property */: return checkProperty(node);
case 143 /* PropertyAssignment */: return checkPropertyAssignment(node);
- case 172 /* ReturnStatement */: return checkReturnStatement(node);
+ case 173 /* ReturnStatement */: return checkReturnStatement(node);
case 128 /* SetAccessor */: return checkSetAccessor(node);
- case 196 /* SourceFile */: return checkSourceFile(node);
+ case 197 /* SourceFile */: return checkSourceFile(node);
case 144 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node);
- case 174 /* SwitchStatement */: return checkSwitchStatement(node);
+ case 175 /* SwitchStatement */: return checkSwitchStatement(node);
case 149 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node);
case 138 /* TupleType */: return checkTupleType(node);
case 122 /* TypeParameter */: return checkTypeParameter(node);
case 132 /* TypeReference */: return checkTypeReference(node);
- case 184 /* VariableDeclaration */: return checkVariableDeclaration(node);
- case 162 /* VariableStatement */: return checkVariableStatement(node);
- case 173 /* WithStatement */: return checkWithStatement(node);
+ case 185 /* VariableDeclaration */: return checkVariableDeclaration(node);
+ case 163 /* VariableStatement */: return checkVariableStatement(node);
+ case 174 /* WithStatement */: return checkWithStatement(node);
+ case 160 /* YieldExpression */: return checkYieldExpression(node);
}
}
function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
@@ -5061,23 +5212,23 @@ var ts;
}
function checkForStatementInAmbientContext(node, kind) {
switch (kind) {
- case 161 /* Block */:
- case 163 /* EmptyStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
- case 172 /* ReturnStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 178 /* ThrowStatement */:
- case 179 /* TryStatement */:
- case 183 /* DebuggerStatement */:
- case 177 /* LabeledStatement */:
- case 164 /* ExpressionStatement */:
+ case 162 /* Block */:
+ case 164 /* EmptyStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
+ case 173 /* ReturnStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 179 /* ThrowStatement */:
+ case 180 /* TryStatement */:
+ case 184 /* DebuggerStatement */:
+ case 178 /* LabeledStatement */:
+ case 165 /* ExpressionStatement */:
return grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
}
}
@@ -5085,7 +5236,7 @@ var ts;
return checkTypeParameterList(node.typeParameters) || checkParameterList(node.parameters);
}
function checkBinaryExpression(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) {
if (isEvalOrArgumentsIdentifier(node.left)) {
return reportInvalidUseInStrictMode(node.left);
@@ -5095,12 +5246,12 @@ var ts;
}
function isIterationStatement(node, lookInLabeledStatements) {
switch (node.kind) {
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
return true;
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
}
return false;
@@ -5111,7 +5262,7 @@ var ts;
if (isAnyFunction(current)) {
break;
}
- if (current.kind === 177 /* LabeledStatement */ && current.label.text === node.label.text) {
+ if (current.kind === 178 /* LabeledStatement */ && current.label.text === node.label.text) {
return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label));
}
current = current.parent;
@@ -5124,17 +5275,17 @@ var ts;
return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
}
switch (current.kind) {
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
if (node.label && current.label.text === node.label.text) {
- var isMisplacedContinueLabel = node.kind === 170 /* ContinueStatement */ && !isIterationStatement(current.statement, true);
+ var isMisplacedContinueLabel = node.kind === 171 /* ContinueStatement */ && !isIterationStatement(current.statement, true);
if (isMisplacedContinueLabel) {
return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
}
return false;
}
break;
- case 174 /* SwitchStatement */:
- if (node.kind === 171 /* BreakStatement */ && !node.label) {
+ case 175 /* SwitchStatement */:
+ if (node.kind === 172 /* BreakStatement */ && !node.label) {
return false;
}
break;
@@ -5147,11 +5298,11 @@ var ts;
current = current.parent;
}
if (node.label) {
- var message = node.kind === 171 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
+ var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
}
else {
- var message = node.kind === 171 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
+ var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
}
}
@@ -5168,7 +5319,7 @@ var ts;
if (arguments) {
for (var i = 0, n = arguments.length; i < n; i++) {
var arg = arguments[i];
- if (arg.kind === 160 /* OmittedExpression */) {
+ if (arg.kind === 161 /* OmittedExpression */) {
return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
}
}
@@ -5203,7 +5354,7 @@ var ts;
var colonStart = ts.skipTrivia(sourceText, node.variable.end);
return grammarErrorAtPos(colonStart, ":".length, ts.Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation);
}
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) {
return reportInvalidUseInStrictMode(node.variable);
}
}
@@ -5282,13 +5433,18 @@ var ts;
}
}
function checkFunctionDeclaration(node) {
- return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false);
+ return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node);
+ }
+ function checkForGenerator(node) {
+ if (node.asteriskToken) {
+ return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.generators_are_not_currently_supported);
+ }
}
function checkFunctionExpression(node) {
- return checkAnyParsedSignature(node) || checkFunctionName(node.name);
+ return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForGenerator(node);
}
function checkFunctionName(name) {
- if (name && name.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(name)) {
+ if (name && name.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(name)) {
return reportInvalidUseInStrictMode(name);
}
}
@@ -5346,10 +5502,10 @@ var ts;
return checkForDisallowedTrailingComma(node.baseTypes) || checkForAtLeastOneHeritageClause(node.baseTypes, "extends");
}
function checkMethod(node) {
- return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 187 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional));
+ return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForGenerator(node);
}
function checkForBodyInAmbientContext(body, isConstructor) {
- if (inAmbientContext && body && body.kind === 186 /* FunctionBlock */) {
+ if (inAmbientContext && body && body.kind === 187 /* FunctionBlock */) {
var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context;
return grammarErrorOnFirstToken(body, diagnostic);
}
@@ -5363,14 +5519,14 @@ var ts;
}
}
function checkModuleDeclarationStatements(node) {
- if (node.name.kind === 63 /* Identifier */ && node.body.kind === 192 /* ModuleBlock */) {
+ if (node.name.kind === 63 /* Identifier */ && node.body.kind === 193 /* ModuleBlock */) {
var statements = node.body.statements;
for (var i = 0, n = statements.length; i < n; i++) {
var statement = statements[i];
- if (statement.kind === 194 /* ExportAssignment */) {
+ if (statement.kind === 195 /* ExportAssignment */) {
return grammarErrorOnNode(statement, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
}
- else if (statement.kind === 193 /* ImportDeclaration */ && statement.externalModuleName) {
+ else if (statement.kind === 194 /* ImportDeclaration */ && statement.externalModuleName) {
return grammarErrorOnNode(statement.externalModuleName, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
}
}
@@ -5382,10 +5538,10 @@ var ts;
var GetAccessor = 2;
var SetAccesor = 4;
var GetOrSetAccessor = GetAccessor | SetAccesor;
- var inStrictMode = (node.flags & 8192 /* ParsedInStrictMode */) !== 0;
+ var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0;
for (var i = 0, n = node.properties.length; i < n; i++) {
var prop = node.properties[i];
- if (prop.kind === 160 /* OmittedExpression */) {
+ if (prop.kind === 161 /* OmittedExpression */) {
continue;
}
var p = prop;
@@ -5431,8 +5587,8 @@ var ts;
}
}
function checkNumericLiteral(node) {
- if (node.flags & 16384 /* OctalLiteral */) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.flags & 8192 /* OctalLiteral */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
}
else if (languageVersion >= 1 /* ES5 */) {
@@ -5448,15 +5604,15 @@ var ts;
case 124 /* Property */:
case 125 /* Method */:
case 131 /* IndexSignature */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 190 /* EnumDeclaration */:
- case 194 /* ExportAssignment */:
- case 162 /* VariableStatement */:
- case 185 /* FunctionDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 195 /* ExportAssignment */:
+ case 163 /* VariableStatement */:
+ case 186 /* FunctionDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 194 /* ImportDeclaration */:
case 123 /* Parameter */:
break;
default:
@@ -5491,7 +5647,7 @@ var ts;
else if (flags & 128 /* Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
}
- else if (node.parent.kind === 192 /* ModuleBlock */ || node.parent.kind === 196 /* SourceFile */) {
+ else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text);
}
flags |= modifierToFlag(modifier.kind);
@@ -5500,7 +5656,7 @@ var ts;
if (flags & 128 /* Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
- else if (node.parent.kind === 192 /* ModuleBlock */ || node.parent.kind === 196 /* SourceFile */) {
+ else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static");
}
else if (node.kind === 123 /* Parameter */) {
@@ -5516,7 +5672,7 @@ var ts;
else if (flags & 2 /* Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
}
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
}
else if (node.kind === 123 /* Parameter */) {
@@ -5528,13 +5684,13 @@ var ts;
if (flags & 2 /* Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
}
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
}
else if (node.kind === 123 /* Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
}
- else if (inAmbientContext && node.parent.kind === 192 /* ModuleBlock */) {
+ else if (inAmbientContext && node.parent.kind === 193 /* ModuleBlock */) {
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
}
flags |= 2 /* Ambient */;
@@ -5553,15 +5709,15 @@ var ts;
return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private");
}
}
- else if (node.kind === 193 /* ImportDeclaration */ && flags & 2 /* Ambient */) {
+ else if (node.kind === 194 /* ImportDeclaration */ && flags & 2 /* Ambient */) {
return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare");
}
- else if (node.kind === 188 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) {
+ else if (node.kind === 189 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) {
return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare");
}
}
function checkParameter(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
return reportInvalidUseInStrictMode(node.name);
}
}
@@ -5608,12 +5764,12 @@ var ts;
}
}
function checkPostfixOperator(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) {
return reportInvalidUseInStrictMode(node.operand);
}
}
function checkPrefixOperator(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
if ((node.operator === 37 /* PlusPlusToken */ || node.operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) {
return reportInvalidUseInStrictMode(node.operand);
}
@@ -5623,7 +5779,7 @@ var ts;
}
}
function checkProperty(node) {
- return (node.parent.kind === 187 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node);
+ return (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node);
}
function checkForInitializerInAmbientContext(node) {
if (inAmbientContext && node.initializer) {
@@ -5694,7 +5850,7 @@ var ts;
function checkTopLevelElementsForRequiredDeclareModifier(file) {
for (var i = 0, n = file.statements.length; i < n; i++) {
var decl = file.statements[i];
- if (isDeclaration(decl) || decl.kind === 162 /* VariableStatement */) {
+ if (isDeclaration(decl) || decl.kind === 163 /* VariableStatement */) {
if (checkTopLevelElementForRequiredDeclareModifier(decl)) {
return true;
}
@@ -5702,7 +5858,7 @@ var ts;
}
}
function checkTopLevelElementForRequiredDeclareModifier(node) {
- if (node.kind === 188 /* InterfaceDeclaration */ || node.kind === 193 /* ImportDeclaration */ || node.kind === 194 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) {
+ if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 194 /* ImportDeclaration */ || node.kind === 195 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) {
return false;
}
return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file);
@@ -5714,7 +5870,7 @@ var ts;
var firstDefaultClause;
for (var i = 0, n = node.clauses.length; i < n; i++) {
var clause = node.clauses[i];
- if (clause.kind === 176 /* DefaultClause */) {
+ if (clause.kind === 177 /* DefaultClause */) {
if (firstDefaultClause === undefined) {
firstDefaultClause = clause;
}
@@ -5752,10 +5908,10 @@ var ts;
var equalsPos = node.type ? ts.skipTrivia(sourceText, node.type.end) : ts.skipTrivia(sourceText, node.name.end);
return grammarErrorAtPos(equalsPos, "=".length, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
}
- if (!inAmbientContext && !node.initializer && node.flags & 4096 /* Const */) {
+ if (!inAmbientContext && !node.initializer && isConst(node)) {
return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
}
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
return reportInvalidUseInStrictMode(node.name);
}
}
@@ -5769,10 +5925,10 @@ var ts;
}
var decl = declarations[0];
if (languageVersion < 2 /* ES6 */) {
- if (decl.flags & 2048 /* Let */) {
+ if (isLet(decl)) {
return grammarErrorOnFirstToken(decl, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
}
- else if (decl.flags & 4096 /* Const */) {
+ else if (isConst(decl)) {
return grammarErrorOnFirstToken(decl, ts.Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
}
}
@@ -5783,33 +5939,39 @@ var ts;
}
function checkForDisallowedLetOrConstStatement(node) {
if (!allowLetAndConstDeclarations(node.parent)) {
- if (node.flags & 2048 /* Let */) {
+ if (isLet(node)) {
return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
}
- else if (node.flags & 4096 /* Const */) {
+ else if (isConst(node)) {
return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
}
}
}
function allowLetAndConstDeclarations(parent) {
switch (parent.kind) {
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 173 /* WithStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 174 /* WithStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
return false;
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return allowLetAndConstDeclarations(parent.parent);
}
return true;
}
function checkWithStatement(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
}
}
+ function checkYieldExpression(node) {
+ if (!(node.parserContextFlags & 4 /* Yield */)) {
+ return grammarErrorOnFirstToken(node, ts.Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration);
+ }
+ return grammarErrorOnFirstToken(node, ts.Diagnostics.yield_expressions_are_not_currently_supported);
+ }
}
function createProgram(rootNames, options, host) {
var program;
@@ -5886,17 +6048,20 @@ var ts;
function findSourceFile(filename, isDefaultLib, refFile, refStart, refLength) {
var canonicalName = host.getCanonicalFileName(filename);
if (ts.hasProperty(filesByName, canonicalName)) {
- var file = filesByName[canonicalName];
- if (file && host.useCaseSensitiveFileNames() && canonicalName !== file.filename) {
- errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, file.filename));
- }
+ return getSourceFileFromCache(filename, canonicalName, false);
}
else {
+ var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(filename, host.getCurrentDirectory());
+ var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
+ if (ts.hasProperty(filesByName, canonicalAbsolutePath)) {
+ return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true);
+ }
var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, function (hostErrorMessage) {
errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
});
if (file) {
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
+ filesByName[canonicalAbsolutePath] = file;
if (!options.noResolve) {
var basePath = ts.getDirectoryPath(filename);
processReferencedFiles(file, basePath);
@@ -5914,6 +6079,16 @@ var ts;
}
}
return file;
+ function getSourceFileFromCache(filename, canonicalName, useAbsolutePath) {
+ var file = filesByName[canonicalName];
+ if (file && host.useCaseSensitiveFileNames()) {
+ var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.filename, host.getCurrentDirectory()) : file.filename;
+ if (canonicalName !== sourceFileName) {
+ errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, sourceFileName));
+ }
+ }
+ return file;
+ }
}
function processReferencedFiles(file, basePath) {
ts.forEach(file.referencedFiles, function (ref) {
@@ -5923,7 +6098,7 @@ var ts;
}
function processImportedModules(file, basePath) {
ts.forEach(file.statements, function (node) {
- if (node.kind === 193 /* ImportDeclaration */ && node.externalModuleName) {
+ if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) {
var nameLiteral = node.externalModuleName;
var moduleName = nameLiteral.text;
if (moduleName) {
@@ -5941,9 +6116,9 @@ var ts;
}
}
}
- else if (node.kind === 191 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) {
+ else if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) {
forEachChild(node.body, function (node) {
- if (node.kind === 193 /* ImportDeclaration */ && node.externalModuleName) {
+ if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) {
var nameLiteral = node.externalModuleName;
var moduleName = nameLiteral.text;
if (moduleName) {
@@ -6016,16 +6191,16 @@ var ts;
var ts;
(function (ts) {
function getModuleInstanceState(node) {
- if (node.kind === 188 /* InterfaceDeclaration */) {
+ if (node.kind === 189 /* InterfaceDeclaration */) {
return 0 /* NonInstantiated */;
}
- else if (node.kind === 190 /* EnumDeclaration */ && ts.isConstEnumDeclaration(node)) {
+ else if (ts.isConstEnumDeclaration(node)) {
return 2 /* ConstEnumOnly */;
}
- else if (node.kind === 193 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) {
+ else if (node.kind === 194 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) {
return 0 /* NonInstantiated */;
}
- else if (node.kind === 192 /* ModuleBlock */) {
+ else if (node.kind === 193 /* ModuleBlock */) {
var state = 0 /* NonInstantiated */;
ts.forEachChild(node, function (n) {
switch (getModuleInstanceState(n)) {
@@ -6041,7 +6216,7 @@ var ts;
});
return state;
}
- else if (node.kind === 191 /* ModuleDeclaration */) {
+ else if (node.kind === 192 /* ModuleDeclaration */) {
return getModuleInstanceState(node.body);
}
else {
@@ -6081,7 +6256,7 @@ var ts;
}
function getDeclarationName(node) {
if (node.name) {
- if (node.kind === 191 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) {
+ if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) {
return '"' + node.name.text + '"';
}
return node.name.text;
@@ -6123,7 +6298,7 @@ var ts;
}
addDeclarationToSymbol(symbol, node, includes);
symbol.parent = parent;
- if (node.kind === 187 /* ClassDeclaration */ && symbol.exports) {
+ if (node.kind === 188 /* ClassDeclaration */ && symbol.exports) {
var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype");
if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) {
if (node.name) {
@@ -6155,7 +6330,7 @@ var ts;
if (symbolKind & 1536 /* Namespace */) {
exportKind |= 16777216 /* ExportNamespace */;
}
- if (node.flags & 1 /* Export */ || (node.kind !== 193 /* ImportDeclaration */ && isAmbientContext(container))) {
+ if (node.flags & 1 /* Export */ || (node.kind !== 194 /* ImportDeclaration */ && isAmbientContext(container))) {
if (exportKind) {
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
@@ -6196,10 +6371,10 @@ var ts;
}
function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) {
switch (container.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
declareModuleMember(node, symbolKind, symbolExcludes);
break;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (ts.isExternalModule(container)) {
declareModuleMember(node, symbolKind, symbolExcludes);
break;
@@ -6213,22 +6388,22 @@ var ts;
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
break;
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
if (node.flags & 128 /* Static */) {
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
break;
}
case 136 /* TypeLiteral */:
case 142 /* ObjectLiteral */:
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes);
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
break;
}
@@ -6289,10 +6464,10 @@ var ts;
}
function bindBlockScopedVariableDeclaration(node) {
switch (blockScopeContainer.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */);
break;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (ts.isExternalModule(container)) {
declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */);
break;
@@ -6314,7 +6489,7 @@ var ts;
case 123 /* Parameter */:
bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false);
break;
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
if (node.flags & 6144 /* BlockScoped */) {
bindBlockScopedVariableDeclaration(node);
}
@@ -6327,7 +6502,7 @@ var ts;
case 144 /* ShorthandPropertyAssignment */:
bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false);
break;
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false);
break;
case 129 /* CallSignature */:
@@ -6342,7 +6517,7 @@ var ts;
case 131 /* IndexSignature */:
bindDeclaration(node, 524288 /* IndexSignature */, 0, false);
break;
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true);
break;
case 126 /* Constructor */:
@@ -6368,44 +6543,44 @@ var ts;
case 153 /* ArrowFunction */:
bindAnonymousDeclaration(node, 16 /* Function */, "__function", true);
break;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
bindCatchVariableDeclaration(node);
break;
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false);
break;
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false);
break;
- case 189 /* TypeAliasDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false);
break;
- case 190 /* EnumDeclaration */:
- if (ts.isConstEnumDeclaration(node)) {
+ case 191 /* EnumDeclaration */:
+ if (ts.isConst(node)) {
bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false);
}
else {
bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false);
}
break;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
bindModuleDeclaration(node);
break;
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false);
break;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (ts.isExternalModule(node)) {
bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true);
break;
}
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 174 /* SwitchStatement */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 175 /* SwitchStatement */:
bindChildren(node, 0, true);
break;
default:
@@ -6445,6 +6620,1057 @@ var ts;
return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile);
}
ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile;
+ function createTextWriter(newLine) {
+ var output = "";
+ var indent = 0;
+ var lineStart = true;
+ var lineCount = 0;
+ var linePos = 0;
+ function write(s) {
+ if (s && s.length) {
+ if (lineStart) {
+ output += getIndentString(indent);
+ lineStart = false;
+ }
+ output += s;
+ }
+ }
+ function rawWrite(s) {
+ if (s !== undefined) {
+ if (lineStart) {
+ lineStart = false;
+ }
+ output += s;
+ }
+ }
+ function writeLiteral(s) {
+ if (s && s.length) {
+ write(s);
+ var lineStartsOfS = ts.computeLineStarts(s);
+ if (lineStartsOfS.length > 1) {
+ lineCount = lineCount + lineStartsOfS.length - 1;
+ linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
+ }
+ }
+ }
+ function writeLine() {
+ if (!lineStart) {
+ output += newLine;
+ lineCount++;
+ linePos = output.length;
+ lineStart = true;
+ }
+ }
+ function writeTextOfNode(sourceFile, node) {
+ write(ts.getSourceTextOfNodeFromSourceFile(sourceFile, node));
+ }
+ return {
+ write: write,
+ rawWrite: rawWrite,
+ writeTextOfNode: writeTextOfNode,
+ writeLiteral: writeLiteral,
+ writeLine: writeLine,
+ increaseIndent: function () { return indent++; },
+ decreaseIndent: function () { return indent--; },
+ getIndent: function () { return indent; },
+ getTextPos: function () { return output.length; },
+ getLine: function () { return lineCount + 1; },
+ getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; },
+ getText: function () { return output; }
+ };
+ }
+ function getLineOfLocalPosition(currentSourceFile, pos) {
+ return currentSourceFile.getLineAndCharacterFromPosition(pos).line;
+ }
+ function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) {
+ if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) {
+ writer.writeLine();
+ }
+ }
+ function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) {
+ var emitLeadingSpace = !trailingSeparator;
+ ts.forEach(comments, function (comment) {
+ if (emitLeadingSpace) {
+ writer.write(" ");
+ emitLeadingSpace = false;
+ }
+ writeComment(currentSourceFile, writer, comment, newLine);
+ if (comment.hasTrailingNewLine) {
+ writer.writeLine();
+ }
+ else if (trailingSeparator) {
+ writer.write(" ");
+ }
+ else {
+ emitLeadingSpace = true;
+ }
+ });
+ }
+ function writeCommentRange(currentSourceFile, writer, comment, newLine) {
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
+ var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
+ var firstCommentLineIndent;
+ for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
+ var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1);
+ if (pos !== comment.pos) {
+ if (firstCommentLineIndent === undefined) {
+ firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos);
+ }
+ var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
+ var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart);
+ if (spacesToEmit > 0) {
+ var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
+ var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
+ writer.rawWrite(indentSizeSpaceString);
+ while (numberOfSingleSpacesToEmit) {
+ writer.rawWrite(" ");
+ numberOfSingleSpacesToEmit--;
+ }
+ }
+ else {
+ writer.rawWrite("");
+ }
+ }
+ writeTrimmedCurrentLine(pos, nextLineStart);
+ pos = nextLineStart;
+ }
+ }
+ else {
+ writer.write(currentSourceFile.text.substring(comment.pos, comment.end));
+ }
+ function writeTrimmedCurrentLine(pos, nextLineStart) {
+ var end = Math.min(comment.end, nextLineStart - 1);
+ var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, '');
+ if (currentLineText) {
+ writer.write(currentLineText);
+ if (end !== comment.end) {
+ writer.writeLine();
+ }
+ }
+ else {
+ writer.writeLiteral(newLine);
+ }
+ }
+ function calculateIndent(pos, end) {
+ var currentLineIndent = 0;
+ for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
+ if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) {
+ currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
+ }
+ else {
+ currentLineIndent++;
+ }
+ }
+ return currentLineIndent;
+ }
+ }
+ function getFirstConstructorWithBody(node) {
+ return ts.forEach(node.members, function (member) {
+ if (member.kind === 126 /* Constructor */ && member.body) {
+ return member;
+ }
+ });
+ }
+ function getAllAccessorDeclarations(node, accessor) {
+ var firstAccessor;
+ var getAccessor;
+ var setAccessor;
+ ts.forEach(node.members, function (member) {
+ if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) {
+ if (!firstAccessor) {
+ firstAccessor = member;
+ }
+ if (member.kind === 127 /* GetAccessor */ && !getAccessor) {
+ getAccessor = member;
+ }
+ if (member.kind === 128 /* SetAccessor */ && !setAccessor) {
+ setAccessor = member;
+ }
+ }
+ });
+ return {
+ firstAccessor: firstAccessor,
+ getAccessor: getAccessor,
+ setAccessor: setAccessor
+ };
+ }
+ function getSourceFilePathInNewDir(sourceFile, program, newDirPath) {
+ var compilerHost = program.getCompilerHost();
+ var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, compilerHost.getCurrentDirectory());
+ sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
+ return ts.combinePaths(newDirPath, sourceFilePath);
+ }
+ function getOwnEmitOutputFilePath(sourceFile, program, extension) {
+ var compilerOptions = program.getCompilerOptions();
+ if (compilerOptions.outDir) {
+ var emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, program, compilerOptions.outDir));
+ }
+ else {
+ var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename);
+ }
+ return emitOutputFilePathWithoutExtension + extension;
+ }
+ function writeFile(compilerHost, diagnostics, filename, data, writeByteOrderMark) {
+ compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) {
+ diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage));
+ });
+ }
+ function emitDeclarations(program, resolver, diagnostics, jsFilePath, root) {
+ var newLine = program.getCompilerHost().getNewLine();
+ var compilerOptions = program.getCompilerOptions();
+ var compilerHost = program.getCompilerHost();
+ var write;
+ var writeLine;
+ var increaseIndent;
+ var decreaseIndent;
+ var writeTextOfNode;
+ var writer = createAndSetNewTextWriterWithSymbolWriter();
+ var enclosingDeclaration;
+ var currentSourceFile;
+ var reportedDeclarationError = false;
+ var emitJsDocComments = compilerOptions.removeComments ? function (declaration) {
+ } : writeJsDocComments;
+ var aliasDeclarationEmitInfo = [];
+ function createAndSetNewTextWriterWithSymbolWriter() {
+ var writer = createTextWriter(newLine);
+ writer.trackSymbol = trackSymbol;
+ writer.writeKeyword = writer.write;
+ writer.writeOperator = writer.write;
+ writer.writePunctuation = writer.write;
+ writer.writeSpace = writer.write;
+ writer.writeStringLiteral = writer.writeLiteral;
+ writer.writeParameter = writer.write;
+ writer.writeSymbol = writer.write;
+ setWriter(writer);
+ return writer;
+ }
+ function setWriter(newWriter) {
+ writer = newWriter;
+ write = newWriter.write;
+ writeTextOfNode = newWriter.writeTextOfNode;
+ writeLine = newWriter.writeLine;
+ increaseIndent = newWriter.increaseIndent;
+ decreaseIndent = newWriter.decreaseIndent;
+ }
+ function writeAsychronousImportDeclarations(importDeclarations) {
+ var oldWriter = writer;
+ ts.forEach(importDeclarations, function (aliasToWrite) {
+ var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; });
+ if (aliasEmitInfo) {
+ createAndSetNewTextWriterWithSymbolWriter();
+ for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) {
+ increaseIndent();
+ }
+ writeImportDeclaration(aliasToWrite);
+ aliasEmitInfo.asynchronousOutput = writer.getText();
+ }
+ });
+ setWriter(oldWriter);
+ }
+ function handleSymbolAccessibilityError(symbolAccesibilityResult) {
+ if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) {
+ if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) {
+ writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
+ }
+ }
+ else {
+ reportedDeclarationError = true;
+ var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult);
+ if (errorInfo) {
+ if (errorInfo.typeName) {
+ diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
+ }
+ else {
+ diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
+ }
+ }
+ }
+ }
+ function trackSymbol(symbol, enclosingDeclaration, meaning) {
+ handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning));
+ }
+ function writeTypeAtLocation(location, type, getSymbolAccessibilityDiagnostic) {
+ writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
+ write(": ");
+ if (type) {
+ emitType(type);
+ }
+ else {
+ resolver.writeTypeAtLocation(location, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
+ }
+ }
+ function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) {
+ writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
+ write(": ");
+ if (signature.type) {
+ emitType(signature.type);
+ }
+ else {
+ resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
+ }
+ }
+ function emitLines(nodes) {
+ for (var i = 0, n = nodes.length; i < n; i++) {
+ emitNode(nodes[i]);
+ }
+ }
+ function emitSeparatedList(nodes, separator, eachNodeEmitFn) {
+ var currentWriterPos = writer.getTextPos();
+ for (var i = 0, n = nodes.length; i < n; i++) {
+ if (currentWriterPos !== writer.getTextPos()) {
+ write(separator);
+ }
+ currentWriterPos = writer.getTextPos();
+ eachNodeEmitFn(nodes[i]);
+ }
+ }
+ function emitCommaList(nodes, eachNodeEmitFn) {
+ emitSeparatedList(nodes, ", ", eachNodeEmitFn);
+ }
+ function writeJsDocComments(declaration) {
+ if (declaration) {
+ var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments);
+ emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange);
+ }
+ }
+ function emitTypeWithNewGetSymbolAccessibilityDiangostic(type, getSymbolAccessibilityDiagnostic) {
+ writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
+ emitType(type);
+ }
+ function emitType(type) {
+ switch (type.kind) {
+ case 109 /* AnyKeyword */:
+ case 118 /* StringKeyword */:
+ case 116 /* NumberKeyword */:
+ case 110 /* BooleanKeyword */:
+ case 97 /* VoidKeyword */:
+ case 7 /* StringLiteral */:
+ return writeTextOfNode(currentSourceFile, type);
+ case 132 /* TypeReference */:
+ return emitTypeReference(type);
+ case 135 /* TypeQuery */:
+ return emitTypeQuery(type);
+ case 137 /* ArrayType */:
+ return emitArrayType(type);
+ case 138 /* TupleType */:
+ return emitTupleType(type);
+ case 139 /* UnionType */:
+ return emitUnionType(type);
+ case 140 /* ParenType */:
+ return emitParenType(type);
+ case 133 /* FunctionType */:
+ case 134 /* ConstructorType */:
+ return emitSignatureDeclarationWithJsDocComments(type);
+ case 136 /* TypeLiteral */:
+ return emitTypeLiteral(type);
+ case 63 /* Identifier */:
+ return emitEntityName(type);
+ case 121 /* QualifiedName */:
+ return emitEntityName(type);
+ default:
+ ts.Debug.fail("Unknown type annotation: " + type.kind);
+ }
+ function emitEntityName(entityName) {
+ var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 194 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration);
+ handleSymbolAccessibilityError(visibilityResult);
+ writeEntityName(entityName);
+ function writeEntityName(entityName) {
+ if (entityName.kind === 63 /* Identifier */) {
+ writeTextOfNode(currentSourceFile, entityName);
+ }
+ else {
+ var qualifiedName = entityName;
+ writeEntityName(qualifiedName.left);
+ write(".");
+ writeTextOfNode(currentSourceFile, qualifiedName.right);
+ }
+ }
+ }
+ function emitTypeReference(type) {
+ emitEntityName(type.typeName);
+ if (type.typeArguments) {
+ write("<");
+ emitCommaList(type.typeArguments, emitType);
+ write(">");
+ }
+ }
+ function emitTypeQuery(type) {
+ write("typeof ");
+ emitEntityName(type.exprName);
+ }
+ function emitArrayType(type) {
+ emitType(type.elementType);
+ write("[]");
+ }
+ function emitTupleType(type) {
+ write("[");
+ emitCommaList(type.elementTypes, emitType);
+ write("]");
+ }
+ function emitUnionType(type) {
+ emitSeparatedList(type.types, " | ", emitType);
+ }
+ function emitParenType(type) {
+ write("(");
+ emitType(type.type);
+ write(")");
+ }
+ function emitTypeLiteral(type) {
+ write("{");
+ if (type.members.length) {
+ writeLine();
+ increaseIndent();
+ emitLines(type.members);
+ decreaseIndent();
+ }
+ write("}");
+ }
+ }
+ function emitSourceFile(node) {
+ currentSourceFile = node;
+ enclosingDeclaration = node;
+ emitLines(node.statements);
+ }
+ function emitExportAssignment(node) {
+ write("export = ");
+ writeTextOfNode(currentSourceFile, node.exportName);
+ write(";");
+ writeLine();
+ }
+ function emitModuleElementDeclarationFlags(node) {
+ if (node.parent === currentSourceFile) {
+ if (node.flags & 1 /* Export */) {
+ write("export ");
+ }
+ if (node.kind !== 189 /* InterfaceDeclaration */) {
+ write("declare ");
+ }
+ }
+ }
+ function emitClassMemberDeclarationFlags(node) {
+ if (node.flags & 32 /* Private */) {
+ write("private ");
+ }
+ else if (node.flags & 64 /* Protected */) {
+ write("protected ");
+ }
+ if (node.flags & 128 /* Static */) {
+ write("static ");
+ }
+ }
+ function emitImportDeclaration(node) {
+ var nodeEmitInfo = {
+ declaration: node,
+ outputPos: writer.getTextPos(),
+ indent: writer.getIndent(),
+ hasWritten: resolver.isDeclarationVisible(node)
+ };
+ aliasDeclarationEmitInfo.push(nodeEmitInfo);
+ if (nodeEmitInfo.hasWritten) {
+ writeImportDeclaration(node);
+ }
+ }
+ function writeImportDeclaration(node) {
+ emitJsDocComments(node);
+ if (node.flags & 1 /* Export */) {
+ write("export ");
+ }
+ write("import ");
+ writeTextOfNode(currentSourceFile, node.name);
+ write(" = ");
+ if (node.entityName) {
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node.entityName, getImportEntityNameVisibilityError);
+ write(";");
+ }
+ else {
+ write("require(");
+ writeTextOfNode(currentSourceFile, node.externalModuleName);
+ write(");");
+ }
+ writer.writeLine();
+ function getImportEntityNameVisibilityError(symbolAccesibilityResult) {
+ return {
+ diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
+ errorNode: node,
+ typeName: node.name
+ };
+ }
+ }
+ function emitModuleDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("module ");
+ writeTextOfNode(currentSourceFile, node.name);
+ while (node.body.kind !== 193 /* ModuleBlock */) {
+ node = node.body;
+ write(".");
+ writeTextOfNode(currentSourceFile, node.name);
+ }
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitLines(node.body.statements);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ enclosingDeclaration = prevEnclosingDeclaration;
+ }
+ }
+ function emitTypeAliasDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("type ");
+ writeTextOfNode(currentSourceFile, node.name);
+ write(" = ");
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node.type, getTypeAliasDeclarationVisibilityError);
+ write(";");
+ writeLine();
+ }
+ function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) {
+ return {
+ diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
+ errorNode: node.type,
+ typeName: node.name
+ };
+ }
+ }
+ function emitEnumDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ if (ts.isConst(node)) {
+ write("const ");
+ }
+ write("enum ");
+ writeTextOfNode(currentSourceFile, node.name);
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitLines(node.members);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ }
+ }
+ function emitEnumMemberDeclaration(node) {
+ emitJsDocComments(node);
+ writeTextOfNode(currentSourceFile, node.name);
+ var enumMemberValue = resolver.getEnumMemberValue(node);
+ if (enumMemberValue !== undefined) {
+ write(" = ");
+ write(enumMemberValue.toString());
+ }
+ write(",");
+ writeLine();
+ }
+ function emitTypeParameters(typeParameters) {
+ function emitTypeParameter(node) {
+ increaseIndent();
+ emitJsDocComments(node);
+ decreaseIndent();
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) {
+ write(" extends ");
+ if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || (node.parent.parent && node.parent.parent.kind === 136 /* TypeLiteral */)) {
+ ts.Debug.assert(node.parent.kind === 125 /* Method */ || node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.kind === 129 /* CallSignature */ || node.parent.kind === 130 /* ConstructSignature */);
+ emitType(node.constraint);
+ }
+ else {
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node.constraint, getTypeParameterConstraintVisibilityError);
+ }
+ }
+ function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ switch (node.parent.kind) {
+ case 188 /* ClassDeclaration */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
+ break;
+ case 189 /* InterfaceDeclaration */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 130 /* ConstructSignature */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 129 /* CallSignature */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 125 /* Method */:
+ if (node.parent.flags & 128 /* Static */) {
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else if (node.parent.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
+ }
+ break;
+ case 186 /* FunctionDeclaration */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
+ break;
+ default:
+ ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.name
+ };
+ }
+ }
+ if (typeParameters) {
+ write("<");
+ emitCommaList(typeParameters, emitTypeParameter);
+ write(">");
+ }
+ }
+ function emitHeritageClause(typeReferences, isImplementsList) {
+ if (typeReferences) {
+ write(isImplementsList ? " implements " : " extends ");
+ emitCommaList(typeReferences, emitTypeOfTypeReference);
+ }
+ function emitTypeOfTypeReference(node) {
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node, getHeritageClauseVisibilityError);
+ function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ if (node.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.parent.name
+ };
+ }
+ }
+ }
+ function emitClassDeclaration(node) {
+ function emitParameterProperties(constructorDeclaration) {
+ if (constructorDeclaration) {
+ ts.forEach(constructorDeclaration.parameters, function (param) {
+ if (param.flags & 112 /* AccessibilityModifier */) {
+ emitPropertyDeclaration(param);
+ }
+ });
+ }
+ }
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("class ");
+ writeTextOfNode(currentSourceFile, node.name);
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ emitTypeParameters(node.typeParameters);
+ if (node.baseType) {
+ emitHeritageClause([node.baseType], false);
+ }
+ emitHeritageClause(node.implementedTypes, true);
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitParameterProperties(getFirstConstructorWithBody(node));
+ emitLines(node.members);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ enclosingDeclaration = prevEnclosingDeclaration;
+ }
+ }
+ function emitInterfaceDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("interface ");
+ writeTextOfNode(currentSourceFile, node.name);
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ emitTypeParameters(node.typeParameters);
+ emitHeritageClause(node.baseTypes, false);
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitLines(node.members);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ enclosingDeclaration = prevEnclosingDeclaration;
+ }
+ }
+ function emitPropertyDeclaration(node) {
+ emitJsDocComments(node);
+ emitClassMemberDeclarationFlags(node);
+ emitVariableDeclaration(node);
+ write(";");
+ writeLine();
+ }
+ function emitVariableDeclaration(node) {
+ if (node.kind !== 185 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) {
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) {
+ write("?");
+ }
+ if (node.kind === 124 /* Property */ && node.parent.kind === 136 /* TypeLiteral */) {
+ emitTypeOfVariableDeclarationFromTypeLiteral(node);
+ }
+ else if (!(node.flags & 32 /* Private */)) {
+ writeTypeAtLocation(node, node.type, getVariableDeclarationTypeVisibilityError);
+ }
+ }
+ function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ if (node.kind === 185 /* VariableDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
+ }
+ else if (node.kind === 124 /* Property */) {
+ if (node.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
+ }
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
+ }
+ }
+ return diagnosticMessage !== undefined ? {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.name
+ } : undefined;
+ }
+ }
+ function emitTypeOfVariableDeclarationFromTypeLiteral(node) {
+ if (node.type) {
+ write(": ");
+ emitType(node.type);
+ }
+ }
+ function emitVariableStatement(node) {
+ var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); });
+ if (hasDeclarationWithEmit) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ if (ts.isLet(node)) {
+ write("let ");
+ }
+ else if (ts.isConst(node)) {
+ write("const ");
+ }
+ else {
+ write("var ");
+ }
+ emitCommaList(node.declarations, emitVariableDeclaration);
+ write(";");
+ writeLine();
+ }
+ }
+ function emitAccessorDeclaration(node) {
+ var accessors = getAllAccessorDeclarations(node.parent, node);
+ if (node === accessors.firstAccessor) {
+ emitJsDocComments(accessors.getAccessor);
+ emitJsDocComments(accessors.setAccessor);
+ emitClassMemberDeclarationFlags(node);
+ writeTextOfNode(currentSourceFile, node.name);
+ if (!(node.flags & 32 /* Private */)) {
+ var accessorWithTypeAnnotation = node;
+ var type = getTypeAnnotationFromAccessor(node);
+ if (!type) {
+ var anotherAccessor = node.kind === 127 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor;
+ type = getTypeAnnotationFromAccessor(anotherAccessor);
+ if (type) {
+ accessorWithTypeAnnotation = anotherAccessor;
+ }
+ }
+ writeTypeAtLocation(node, type, getAccessorDeclarationTypeVisibilityError);
+ }
+ write(";");
+ writeLine();
+ }
+ function getTypeAnnotationFromAccessor(accessor) {
+ if (accessor) {
+ return accessor.kind === 127 /* GetAccessor */ ? accessor.type : accessor.parameters[0].type;
+ }
+ }
+ function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ if (accessorWithTypeAnnotation.kind === 128 /* SetAccessor */) {
+ if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: accessorWithTypeAnnotation.parameters[0],
+ typeName: accessorWithTypeAnnotation.name
+ };
+ }
+ else {
+ if (accessorWithTypeAnnotation.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: accessorWithTypeAnnotation.name,
+ typeName: undefined
+ };
+ }
+ }
+ }
+ function emitFunctionDeclaration(node) {
+ if ((node.kind !== 186 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) {
+ emitJsDocComments(node);
+ if (node.kind === 186 /* FunctionDeclaration */) {
+ emitModuleElementDeclarationFlags(node);
+ }
+ else if (node.kind === 125 /* Method */) {
+ emitClassMemberDeclarationFlags(node);
+ }
+ if (node.kind === 186 /* FunctionDeclaration */) {
+ write("function ");
+ writeTextOfNode(currentSourceFile, node.name);
+ }
+ else if (node.kind === 126 /* Constructor */) {
+ write("constructor");
+ }
+ else {
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.flags & 4 /* QuestionMark */) {
+ write("?");
+ }
+ }
+ emitSignatureDeclaration(node);
+ }
+ }
+ function emitSignatureDeclarationWithJsDocComments(node) {
+ emitJsDocComments(node);
+ emitSignatureDeclaration(node);
+ }
+ function emitSignatureDeclaration(node) {
+ if (node.kind === 130 /* ConstructSignature */ || node.kind === 134 /* ConstructorType */) {
+ write("new ");
+ }
+ emitTypeParameters(node.typeParameters);
+ if (node.kind === 131 /* IndexSignature */) {
+ write("[");
+ }
+ else {
+ write("(");
+ }
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ emitCommaList(node.parameters, emitParameterDeclaration);
+ if (node.kind === 131 /* IndexSignature */) {
+ write("]");
+ }
+ else {
+ write(")");
+ }
+ var isFunctionTypeOrConstructorType = node.kind === 133 /* FunctionType */ || node.kind === 134 /* ConstructorType */;
+ if (isFunctionTypeOrConstructorType || node.parent.kind === 136 /* TypeLiteral */) {
+ if (node.type) {
+ write(isFunctionTypeOrConstructorType ? " => " : ": ");
+ emitType(node.type);
+ }
+ }
+ else if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) {
+ writeReturnTypeAtSignature(node, getReturnTypeVisibilityError);
+ }
+ enclosingDeclaration = prevEnclosingDeclaration;
+ if (!isFunctionTypeOrConstructorType) {
+ write(";");
+ writeLine();
+ }
+ function getReturnTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ switch (node.kind) {
+ case 130 /* ConstructSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
+ break;
+ case 129 /* CallSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
+ break;
+ case 131 /* IndexSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
+ break;
+ case 125 /* Method */:
+ if (node.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
+ }
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
+ }
+ break;
+ case 186 /* FunctionDeclaration */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
+ break;
+ default:
+ ts.Debug.fail("This is unknown kind for signature: " + node.kind);
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node.name || node
+ };
+ }
+ }
+ function emitParameterDeclaration(node) {
+ increaseIndent();
+ emitJsDocComments(node);
+ if (node.flags & 8 /* Rest */) {
+ write("...");
+ }
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.initializer || (node.flags & 4 /* QuestionMark */)) {
+ write("?");
+ }
+ decreaseIndent();
+ if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.parent.kind === 136 /* TypeLiteral */) {
+ emitTypeOfVariableDeclarationFromTypeLiteral(node);
+ }
+ else if (!(node.parent.flags & 32 /* Private */)) {
+ writeTypeAtLocation(node, node.type, getParameterDeclarationTypeVisibilityError);
+ }
+ function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ switch (node.parent.kind) {
+ case 126 /* Constructor */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
+ break;
+ case 130 /* ConstructSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 129 /* CallSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 125 /* Method */:
+ if (node.parent.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else if (node.parent.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
+ }
+ break;
+ case 186 /* FunctionDeclaration */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
+ break;
+ default:
+ ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind);
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.name
+ };
+ }
+ }
+ function emitNode(node) {
+ switch (node.kind) {
+ case 126 /* Constructor */:
+ case 186 /* FunctionDeclaration */:
+ case 125 /* Method */:
+ return emitFunctionDeclaration(node);
+ case 130 /* ConstructSignature */:
+ case 129 /* CallSignature */:
+ case 131 /* IndexSignature */:
+ return emitSignatureDeclarationWithJsDocComments(node);
+ case 127 /* GetAccessor */:
+ case 128 /* SetAccessor */:
+ return emitAccessorDeclaration(node);
+ case 163 /* VariableStatement */:
+ return emitVariableStatement(node);
+ case 124 /* Property */:
+ return emitPropertyDeclaration(node);
+ case 189 /* InterfaceDeclaration */:
+ return emitInterfaceDeclaration(node);
+ case 188 /* ClassDeclaration */:
+ return emitClassDeclaration(node);
+ case 190 /* TypeAliasDeclaration */:
+ return emitTypeAliasDeclaration(node);
+ case 196 /* EnumMember */:
+ return emitEnumMemberDeclaration(node);
+ case 191 /* EnumDeclaration */:
+ return emitEnumDeclaration(node);
+ case 192 /* ModuleDeclaration */:
+ return emitModuleDeclaration(node);
+ case 194 /* ImportDeclaration */:
+ return emitImportDeclaration(node);
+ case 195 /* ExportAssignment */:
+ return emitExportAssignment(node);
+ case 197 /* SourceFile */:
+ return emitSourceFile(node);
+ }
+ }
+ var referencePathsOutput = "";
+ function writeReferencePath(referencedFile) {
+ var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, program, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts";
+ declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, false);
+ referencePathsOutput += "/// " + newLine;
+ }
+ if (root) {
+ if (!compilerOptions.noResolve) {
+ var addedGlobalFileReference = false;
+ ts.forEach(root.referencedFiles, function (fileReference) {
+ var referencedFile = ts.tryResolveScriptReference(program, root, fileReference);
+ if (referencedFile && ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) {
+ writeReferencePath(referencedFile);
+ if (!isExternalModuleOrDeclarationFile(referencedFile)) {
+ addedGlobalFileReference = true;
+ }
+ }
+ });
+ }
+ emitNode(root);
+ }
+ else {
+ var emittedReferencedFiles = [];
+ ts.forEach(program.getSourceFiles(), function (sourceFile) {
+ if (!isExternalModuleOrDeclarationFile(sourceFile)) {
+ if (!compilerOptions.noResolve) {
+ ts.forEach(sourceFile.referencedFiles, function (fileReference) {
+ var referencedFile = ts.tryResolveScriptReference(program, sourceFile, fileReference);
+ if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) {
+ writeReferencePath(referencedFile);
+ emittedReferencedFiles.push(referencedFile);
+ }
+ });
+ }
+ emitNode(sourceFile);
+ }
+ });
+ }
+ return {
+ reportedDeclarationError: reportedDeclarationError,
+ aliasDeclarationEmitInfo: aliasDeclarationEmitInfo,
+ synchronousDeclarationOutput: writer.getText(),
+ referencePathsOutput: referencePathsOutput
+ };
+ }
+ function getDeclarationDiagnostics(program, resolver, targetSourceFile) {
+ var diagnostics = [];
+ var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js");
+ emitDeclarations(program, resolver, diagnostics, jsFilePath, targetSourceFile);
+ return diagnostics;
+ }
+ ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
function emitFiles(resolver, targetSourceFile) {
var program = resolver.getProgram();
var compilerHost = program.getCompilerHost();
@@ -6452,206 +7678,14 @@ var ts;
var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined;
var diagnostics = [];
var newLine = program.getCompilerHost().getNewLine();
- function getSourceFilePathInNewDir(newDirPath, sourceFile) {
- var sourceFilePath = ts.getNormalizedPathFromPathComponents(ts.getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
- sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
- return ts.combinePaths(newDirPath, sourceFilePath);
- }
- function getOwnEmitOutputFilePath(sourceFile, extension) {
- if (compilerOptions.outDir) {
- var emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
- }
- else {
- var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename);
- }
- return emitOutputFilePathWithoutExtension + extension;
- }
- function getFirstConstructorWithBody(node) {
- return ts.forEach(node.members, function (member) {
- if (member.kind === 126 /* Constructor */ && member.body) {
- return member;
- }
- });
- }
- function getAllAccessorDeclarations(node, accessor) {
- var firstAccessor;
- var getAccessor;
- var setAccessor;
- ts.forEach(node.members, function (member) {
- if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) {
- if (!firstAccessor) {
- firstAccessor = member;
- }
- if (member.kind === 127 /* GetAccessor */ && !getAccessor) {
- getAccessor = member;
- }
- if (member.kind === 128 /* SetAccessor */ && !setAccessor) {
- setAccessor = member;
- }
- }
- });
- return {
- firstAccessor: firstAccessor,
- getAccessor: getAccessor,
- setAccessor: setAccessor
- };
- }
- function createTextWriter() {
- var output = "";
- var indent = 0;
- var lineStart = true;
- var lineCount = 0;
- var linePos = 0;
- function write(s) {
- if (s && s.length) {
- if (lineStart) {
- output += getIndentString(indent);
- lineStart = false;
- }
- output += s;
- }
- }
- function rawWrite(s) {
- if (s !== undefined) {
- if (lineStart) {
- lineStart = false;
- }
- output += s;
- }
- }
- function writeLiteral(s) {
- if (s && s.length) {
- write(s);
- var lineStartsOfS = ts.computeLineStarts(s);
- if (lineStartsOfS.length > 1) {
- lineCount = lineCount + lineStartsOfS.length - 1;
- linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
- }
- }
- }
- function writeLine() {
- if (!lineStart) {
- output += newLine;
- lineCount++;
- linePos = output.length;
- lineStart = true;
- }
- }
- return {
- write: write,
- rawWrite: rawWrite,
- writeLiteral: writeLiteral,
- writeLine: writeLine,
- increaseIndent: function () { return indent++; },
- decreaseIndent: function () { return indent--; },
- getIndent: function () { return indent; },
- getTextPos: function () { return output.length; },
- getLine: function () { return lineCount + 1; },
- getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; },
- getText: function () { return output; }
- };
- }
- var currentSourceFile;
- function getSourceTextOfLocalNode(node) {
- var text = currentSourceFile.text;
- return text.substring(ts.skipTrivia(text, node.pos), node.end);
- }
- function getLineOfLocalPosition(pos) {
- return currentSourceFile.getLineAndCharacterFromPosition(pos).line;
- }
- function writeFile(filename, data, writeByteOrderMark) {
- compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) {
- diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage));
- });
- }
- function emitComments(comments, trailingSeparator, writer, writeComment) {
- var emitLeadingSpace = !trailingSeparator;
- ts.forEach(comments, function (comment) {
- if (emitLeadingSpace) {
- writer.write(" ");
- emitLeadingSpace = false;
- }
- writeComment(comment, writer);
- if (comment.hasTrailingNewLine) {
- writer.writeLine();
- }
- else if (trailingSeparator) {
- writer.write(" ");
- }
- else {
- emitLeadingSpace = true;
- }
- });
- }
- function emitNewLineBeforeLeadingComments(node, leadingComments, writer) {
- if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(node.pos) !== getLineOfLocalPosition(leadingComments[0].pos)) {
- writer.writeLine();
- }
- }
- function writeCommentRange(comment, writer) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
- var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
- var firstCommentLineIndent;
- for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
- var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1);
- if (pos !== comment.pos) {
- if (firstCommentLineIndent === undefined) {
- firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos);
- }
- var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
- var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart);
- if (spacesToEmit > 0) {
- var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
- var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
- writer.rawWrite(indentSizeSpaceString);
- while (numberOfSingleSpacesToEmit) {
- writer.rawWrite(" ");
- numberOfSingleSpacesToEmit--;
- }
- }
- else {
- writer.rawWrite("");
- }
- }
- writeTrimmedCurrentLine(pos, nextLineStart);
- pos = nextLineStart;
- }
- }
- else {
- writer.write(currentSourceFile.text.substring(comment.pos, comment.end));
- }
- function writeTrimmedCurrentLine(pos, nextLineStart) {
- var end = Math.min(comment.end, nextLineStart - 1);
- var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, '');
- if (currentLineText) {
- writer.write(currentLineText);
- if (end !== comment.end) {
- writer.writeLine();
- }
- }
- else {
- writer.writeLiteral(newLine);
- }
- }
- function calculateIndent(pos, end) {
- var currentLineIndent = 0;
- for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
- if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) {
- currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
- }
- else {
- currentLineIndent++;
- }
- }
- return currentLineIndent;
- }
- }
function emitJavaScript(jsFilePath, root) {
- var writer = createTextWriter();
+ var writer = createTextWriter(newLine);
var write = writer.write;
+ var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
+ var currentSourceFile;
var extendsEmitted = false;
var writeEmittedFiles = writeJavaScriptFile;
var emitLeadingComments = compilerOptions.removeComments ? function (node) {
@@ -6808,7 +7842,7 @@ var ts;
if (scopeName) {
recordScopeNameStart(scopeName);
}
- else if (node.kind === 185 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 191 /* ModuleDeclaration */ || node.kind === 187 /* ClassDeclaration */ || node.kind === 190 /* EnumDeclaration */) {
+ else if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */) {
if (node.name) {
scopeName = node.name.text;
}
@@ -6822,9 +7856,9 @@ var ts;
sourceMapNameIndices.pop();
}
;
- function writeCommentRangeWithMap(comment, writer) {
+ function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) {
recordSourceMapSpan(comment.pos);
- writeCommentRange(comment, writer);
+ writeCommentRange(currentSourceFile, writer, comment, newLine);
recordSourceMapSpan(comment.end);
}
function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) {
@@ -6852,7 +7886,7 @@ var ts;
}
function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) {
encodeLastRecordedSourceMapSpan();
- writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
+ writeFile(compilerHost, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
sourceMapDataList.push(sourceMapData);
writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark);
}
@@ -6875,7 +7909,7 @@ var ts;
if (compilerOptions.mapRoot) {
sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot);
if (root) {
- sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(sourceMapDir, root));
+ sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, program, sourceMapDir));
}
if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) {
sourceMapDir = ts.combinePaths(program.getCommonSourceDirectory(), sourceMapDir);
@@ -6890,7 +7924,7 @@ var ts;
}
function emitNodeWithMap(node) {
if (node) {
- if (node.kind != 196 /* SourceFile */) {
+ if (node.kind != 197 /* SourceFile */) {
recordEmitNodeStartSpan(node);
emitNode(node);
recordEmitNodeEndSpan(node);
@@ -6911,7 +7945,7 @@ var ts;
writeComment = writeCommentRangeWithMap;
}
function writeJavaScriptFile(emitOutput, writeByteOrderMark) {
- writeFile(jsFilePath, emitOutput, writeByteOrderMark);
+ writeFile(compilerHost, diagnostics, jsFilePath, emitOutput, writeByteOrderMark);
}
function emitTokenText(tokenKind, startPos, emitFn) {
var tokenString = ts.tokenToString(tokenKind);
@@ -6988,7 +8022,7 @@ var ts;
if (compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind)) {
return getTemplateLiteralAsStringLiteral(node);
}
- return getSourceTextOfLocalNode(node);
+ return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
}
}
function getTemplateLiteralAsStringLiteral(node) {
@@ -7071,7 +8105,7 @@ var ts;
write(node.text);
}
else {
- write(getSourceTextOfLocalNode(node));
+ writeTextOfNode(currentSourceFile, node);
}
write("\"");
}
@@ -7080,29 +8114,29 @@ var ts;
var parent = node.parent;
switch (parent.kind) {
case 123 /* Parameter */:
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 124 /* Property */:
case 143 /* PropertyAssignment */:
case 144 /* ShorthandPropertyAssignment */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 125 /* Method */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
case 152 /* FunctionExpression */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 194 /* ImportDeclaration */:
return parent.name === node;
- case 171 /* BreakStatement */:
- case 170 /* ContinueStatement */:
- case 194 /* ExportAssignment */:
+ case 172 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 195 /* ExportAssignment */:
return false;
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return node.parent.label === node;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
return node.parent.variable === node;
}
}
@@ -7112,14 +8146,14 @@ var ts;
write(prefix);
write(".");
}
- write(getSourceTextOfLocalNode(node));
+ writeTextOfNode(currentSourceFile, node);
}
function emitIdentifier(node) {
if (!isNotExpressionIdentifier(node)) {
emitExpressionIdentifier(node);
}
else {
- write(getSourceTextOfLocalNode(node));
+ writeTextOfNode(currentSourceFile, node);
}
}
function emitThis(node) {
@@ -7326,8 +8360,8 @@ var ts;
emitToken(13 /* OpenBraceToken */, node.pos);
increaseIndent();
scopeEmitStart(node.parent);
- if (node.kind === 192 /* ModuleBlock */) {
- ts.Debug.assert(node.parent.kind === 191 /* ModuleDeclaration */);
+ if (node.kind === 193 /* ModuleBlock */) {
+ ts.Debug.assert(node.parent.kind === 192 /* ModuleDeclaration */);
emitCaptureThisForNodeIfNecessary(node.parent);
}
emitLines(node.statements);
@@ -7337,7 +8371,7 @@ var ts;
scopeEmitEnd();
}
function emitEmbeddedStatement(node) {
- if (node.kind === 161 /* Block */) {
+ if (node.kind === 162 /* Block */) {
write(" ");
emit(node);
}
@@ -7370,7 +8404,7 @@ var ts;
if (node.elseStatement) {
writeLine();
emitToken(74 /* ElseKeyword */, node.thenStatement.end);
- if (node.elseStatement.kind === 165 /* IfStatement */) {
+ if (node.elseStatement.kind === 166 /* IfStatement */) {
write(" ");
emit(node.elseStatement);
}
@@ -7383,7 +8417,7 @@ var ts;
function emitDoStatement(node) {
write("do");
emitEmbeddedStatement(node.statement);
- if (node.statement.kind === 161 /* Block */) {
+ if (node.statement.kind === 162 /* Block */) {
write(" ");
}
else {
@@ -7404,10 +8438,10 @@ var ts;
write(" ");
endPos = emitToken(15 /* OpenParenToken */, endPos);
if (node.declarations) {
- if (node.declarations[0] && node.declarations[0].flags & 2048 /* Let */) {
+ if (node.declarations[0] && ts.isLet(node.declarations[0])) {
emitToken(102 /* LetKeyword */, endPos);
}
- else if (node.declarations[0] && node.declarations[0].flags & 4096 /* Const */) {
+ else if (node.declarations[0] && ts.isConst(node.declarations[0])) {
emitToken(68 /* ConstKeyword */, endPos);
}
else {
@@ -7433,7 +8467,7 @@ var ts;
if (node.declarations) {
if (node.declarations.length >= 1) {
var decl = node.declarations[0];
- if (decl.flags & 2048 /* Let */) {
+ if (ts.isLet(decl)) {
emitToken(102 /* LetKeyword */, endPos);
}
else {
@@ -7452,7 +8486,7 @@ var ts;
emitEmbeddedStatement(node.statement);
}
function emitBreakOrContinueStatement(node) {
- emitToken(node.kind === 171 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos);
+ emitToken(node.kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos);
emitOptional(" ", node.label);
write(";");
}
@@ -7484,10 +8518,10 @@ var ts;
emitToken(14 /* CloseBraceToken */, node.clauses.end);
}
function isOnSameLine(node1, node2) {
- return getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node2.pos));
+ return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos));
}
function emitCaseOrDefaultClause(node) {
- if (node.kind === 175 /* CaseClause */) {
+ if (node.kind === 176 /* CaseClause */) {
write("case ");
emit(node.expression);
write(":");
@@ -7542,7 +8576,7 @@ var ts;
function getContainingModule(node) {
do {
node = node.parent;
- } while (node && node.kind !== 191 /* ModuleDeclaration */);
+ } while (node && node.kind !== 192 /* ModuleDeclaration */);
return node;
}
function emitModuleMemberName(node) {
@@ -7564,10 +8598,10 @@ var ts;
function emitVariableStatement(node) {
emitLeadingComments(node);
if (!(node.flags & 1 /* Export */)) {
- if (node.flags & 2048 /* Let */) {
+ if (ts.isLet(node)) {
write("let ");
}
- else if (node.flags & 4096 /* Const */) {
+ else if (ts.isConst(node)) {
write("const ");
}
else {
@@ -7654,7 +8688,7 @@ var ts;
emitLeadingComments(node);
}
write("function ");
- if (node.kind === 185 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) {
+ if (node.kind === 186 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) {
emit(node.name);
}
emitSignatureAndBody(node);
@@ -7684,16 +8718,16 @@ var ts;
write(" {");
scopeEmitStart(node);
increaseIndent();
- emitDetachedComments(node.body.kind === 186 /* FunctionBlock */ ? node.body.statements : node.body);
+ emitDetachedComments(node.body.kind === 187 /* FunctionBlock */ ? node.body.statements : node.body);
var startIndex = 0;
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
startIndex = emitDirectivePrologues(node.body.statements, true);
}
var outPos = writer.getTextPos();
emitCaptureThisForNodeIfNecessary(node);
emitDefaultValueAssignments(node);
emitRestParameter(node);
- if (node.body.kind !== 186 /* FunctionBlock */ && outPos === writer.getTextPos()) {
+ if (node.body.kind !== 187 /* FunctionBlock */ && outPos === writer.getTextPos()) {
decreaseIndent();
write(" ");
emitStart(node.body);
@@ -7706,7 +8740,7 @@ var ts;
emitEnd(node.body);
}
else {
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
emitLinesStartingAt(node.body.statements, startIndex);
}
else {
@@ -7718,7 +8752,7 @@ var ts;
emitTrailingComments(node.body);
}
writeLine();
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
emitLeadingCommentsOfPosition(node.body.statements.end);
decreaseIndent();
emitToken(14 /* CloseBraceToken */, node.body.statements.end);
@@ -7744,7 +8778,7 @@ var ts;
function findInitialSuperCall(ctor) {
if (ctor.body) {
var statement = ctor.body.statements[0];
- if (statement && statement.kind === 164 /* ExpressionStatement */) {
+ if (statement && statement.kind === 165 /* ExpressionStatement */) {
var expr = statement.expression;
if (expr && expr.kind === 147 /* CallExpression */) {
var func = expr.func;
@@ -7995,7 +9029,7 @@ var ts;
emitPinnedOrTripleSlashComments(node);
}
function emitEnumDeclaration(node) {
- var isConstEnum = ts.isConstEnumDeclaration(node);
+ var isConstEnum = ts.isConst(node);
if (isConstEnum && !compilerOptions.preserveConstEnums) {
return;
}
@@ -8064,13 +9098,14 @@ var ts;
}
}
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
- if (moduleDeclaration.body.kind === 191 /* ModuleDeclaration */) {
+ if (moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) {
var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
return recursiveInnerModule || moduleDeclaration.body;
}
}
function emitModuleDeclaration(node) {
- if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ var shouldEmit = ts.getModuleInstanceState(node) === 1 /* Instantiated */ || (ts.getModuleInstanceState(node) === 2 /* ConstEnumOnly */ && compilerOptions.preserveConstEnums);
+ if (!shouldEmit) {
return emitPinnedOrTripleSlashComments(node);
}
emitLeadingComments(node);
@@ -8086,7 +9121,7 @@ var ts;
write(resolver.getLocalNameOfContainer(node));
emitEnd(node.name);
write(") ");
- if (node.body.kind === 192 /* ModuleBlock */) {
+ if (node.body.kind === 193 /* ModuleBlock */) {
emit(node.body);
}
else {
@@ -8120,7 +9155,7 @@ var ts;
emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node);
}
if (emitImportDeclaration) {
- if (node.externalModuleName && node.parent.kind === 196 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) {
+ if (node.externalModuleName && node.parent.kind === 197 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) {
if (node.flags & 1 /* Export */) {
writeLine();
emitLeadingComments(node);
@@ -8160,7 +9195,7 @@ var ts;
function getExternalImportDeclarations(node) {
var result = [];
ts.forEach(node.statements, function (stat) {
- if (stat.kind === 193 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) {
+ if (stat.kind === 194 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) {
result.push(stat);
}
});
@@ -8168,7 +9203,7 @@ var ts;
}
function getFirstExportAssignment(sourceFile) {
return ts.forEach(sourceFile.statements, function (node) {
- if (node.kind === 194 /* ExportAssignment */) {
+ if (node.kind === 195 /* ExportAssignment */) {
return node;
}
});
@@ -8341,7 +9376,7 @@ var ts;
return emit(node.operand);
case 151 /* ParenExpression */:
return emitParenExpression(node);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
return emitFunctionDeclaration(node);
@@ -8352,65 +9387,65 @@ var ts;
return emitBinaryExpression(node);
case 157 /* ConditionalExpression */:
return emitConditionalExpression(node);
- case 160 /* OmittedExpression */:
+ case 161 /* OmittedExpression */:
return;
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 182 /* FinallyBlock */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 183 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
return emitBlock(node);
- case 162 /* VariableStatement */:
+ case 163 /* VariableStatement */:
return emitVariableStatement(node);
- case 163 /* EmptyStatement */:
+ case 164 /* EmptyStatement */:
return write(";");
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return emitExpressionStatement(node);
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
return emitIfStatement(node);
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
return emitDoStatement(node);
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return emitWhileStatement(node);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return emitForStatement(node);
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return emitForInStatement(node);
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
return emitBreakOrContinueStatement(node);
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return emitReturnStatement(node);
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
return emitWithStatement(node);
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return emitSwitchStatement(node);
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
return emitCaseOrDefaultClause(node);
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return emitLabelledStatement(node);
- case 178 /* ThrowStatement */:
+ case 179 /* ThrowStatement */:
return emitThrowStatement(node);
- case 179 /* TryStatement */:
+ case 180 /* TryStatement */:
return emitTryStatement(node);
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
return emitCatchBlock(node);
- case 183 /* DebuggerStatement */:
+ case 184 /* DebuggerStatement */:
return emitDebuggerStatement(node);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return emitVariableDeclaration(node);
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return emitClassDeclaration(node);
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return emitInterfaceDeclaration(node);
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
return emitEnumDeclaration(node);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return emitModuleDeclaration(node);
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return emitImportDeclaration(node);
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
return emitSourceFile(node);
}
}
@@ -8428,7 +9463,7 @@ var ts;
return leadingComments;
}
function getLeadingCommentsToEmit(node) {
- if (node.parent.kind === 196 /* SourceFile */ || node.pos !== node.parent.pos) {
+ if (node.parent.kind === 197 /* SourceFile */ || node.pos !== node.parent.pos) {
var leadingComments;
if (hasDetachedComments(node.pos)) {
leadingComments = getLeadingCommentsWithoutDetachedComments();
@@ -8441,13 +9476,13 @@ var ts;
}
function emitLeadingDeclarationComments(node) {
var leadingComments = getLeadingCommentsToEmit(node);
- emitNewLineBeforeLeadingComments(node, leadingComments, writer);
- emitComments(leadingComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
+ emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitTrailingDeclarationComments(node) {
- if (node.parent.kind === 196 /* SourceFile */ || node.end !== node.parent.end) {
+ if (node.parent.kind === 197 /* SourceFile */ || node.end !== node.parent.end) {
var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end);
- emitComments(trailingComments, false, writer, writeComment);
+ emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment);
}
}
function emitLeadingCommentsOfLocalPosition(pos) {
@@ -8458,8 +9493,8 @@ var ts;
else {
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- emitNewLineBeforeLeadingComments({ pos: pos, end: pos }, leadingComments, writer);
- emitComments(leadingComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
+ emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitDetachedCommentsAtPosition(node) {
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
@@ -8468,8 +9503,8 @@ var ts;
var lastComment;
ts.forEach(leadingComments, function (comment) {
if (lastComment) {
- var lastCommentLine = getLineOfLocalPosition(lastComment.end);
- var commentLine = getLineOfLocalPosition(comment.pos);
+ var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end);
+ var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos);
if (commentLine >= lastCommentLine + 2) {
return detachedComments;
}
@@ -8478,11 +9513,11 @@ var ts;
lastComment = comment;
});
if (detachedComments.length) {
- var lastCommentLine = getLineOfLocalPosition(detachedComments[detachedComments.length - 1].end);
- var astLine = getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node.pos));
+ var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
+ var astLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
if (astLine >= lastCommentLine + 2) {
- emitNewLineBeforeLeadingComments(node, leadingComments, writer);
- emitComments(detachedComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
+ emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment);
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end };
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -8504,8 +9539,8 @@ var ts;
return true;
}
}
- emitNewLineBeforeLeadingComments(node, pinnedComments, writer);
- emitComments(pinnedComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments);
+ emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment);
}
if (compilerOptions.sourceMap) {
initializeEmitterWithSourceMaps();
@@ -8523,722 +9558,20 @@ var ts;
writeLine();
writeEmittedFiles(writer.getText(), compilerOptions.emitBOM);
}
- function emitDeclarations(jsFilePath, root) {
- var writer = createTextWriterWithSymbolWriter();
- var write = writer.write;
- var writeLine = writer.writeLine;
- var increaseIndent = writer.increaseIndent;
- var decreaseIndent = writer.decreaseIndent;
- var enclosingDeclaration;
- var reportedDeclarationError = false;
- var emitJsDocComments = compilerOptions.removeComments ? function (declaration) {
- } : writeJsDocComments;
- var aliasDeclarationEmitInfo = [];
- var getSymbolVisibilityDiagnosticMessage;
- function createTextWriterWithSymbolWriter() {
- var writer = createTextWriter();
- writer.trackSymbol = trackSymbol;
- writer.writeKeyword = writer.write;
- writer.writeOperator = writer.write;
- writer.writePunctuation = writer.write;
- writer.writeSpace = writer.write;
- writer.writeStringLiteral = writer.writeLiteral;
- writer.writeParameter = writer.write;
- writer.writeSymbol = writer.write;
- return writer;
- }
- function writeAsychronousImportDeclarations(importDeclarations) {
- var oldWriter = writer;
- ts.forEach(importDeclarations, function (aliasToWrite) {
- var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; });
- writer = createTextWriterWithSymbolWriter();
- for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) {
- writer.increaseIndent();
- }
- writeImportDeclaration(aliasToWrite);
- aliasEmitInfo.asynchronousOutput = writer.getText();
- });
- writer = oldWriter;
- }
- function trackSymbol(symbol, enclosingDeclaration, meaning) {
- var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning);
- if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) {
- if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) {
- writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
- }
- }
- else {
- reportedDeclarationError = true;
- var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult);
- if (errorInfo) {
- if (errorInfo.typeName) {
- diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, getSourceTextOfLocalNode(errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
- }
- else {
- diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
- }
- }
- }
- }
- function emitLines(nodes) {
- for (var i = 0, n = nodes.length; i < n; i++) {
- emitNode(nodes[i]);
- }
- }
- function emitCommaList(nodes, eachNodeEmitFn) {
- var currentWriterPos = writer.getTextPos();
- for (var i = 0, n = nodes.length; i < n; i++) {
- if (currentWriterPos !== writer.getTextPos()) {
- write(", ");
- }
- currentWriterPos = writer.getTextPos();
- eachNodeEmitFn(nodes[i]);
- }
- }
- function writeJsDocComments(declaration) {
- if (declaration) {
- var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile);
- emitNewLineBeforeLeadingComments(declaration, jsDocComments, writer);
- emitComments(jsDocComments, true, writer, writeCommentRange);
- }
- }
- function emitSourceTextOfNode(node) {
- write(getSourceTextOfLocalNode(node));
- }
- function emitSourceFile(node) {
- currentSourceFile = node;
- enclosingDeclaration = node;
- emitLines(node.statements);
- }
- function emitExportAssignment(node) {
- write("export = ");
- emitSourceTextOfNode(node.exportName);
- write(";");
- writeLine();
- }
- function emitDeclarationFlags(node) {
- if (node.flags & 128 /* Static */) {
- if (node.flags & 32 /* Private */) {
- write("private ");
- }
- else if (node.flags & 64 /* Protected */) {
- write("protected ");
- }
- write("static ");
- }
- else {
- if (node.flags & 32 /* Private */) {
- write("private ");
- }
- else if (node.flags & 64 /* Protected */) {
- write("protected ");
- }
- else if (node.parent === currentSourceFile) {
- if (node.flags & 1 /* Export */) {
- write("export ");
- }
- if (node.kind !== 188 /* InterfaceDeclaration */) {
- write("declare ");
- }
- }
- }
- }
- function emitImportDeclaration(node) {
- var nodeEmitInfo = {
- declaration: node,
- outputPos: writer.getTextPos(),
- indent: writer.getIndent(),
- hasWritten: resolver.isDeclarationVisible(node)
- };
- aliasDeclarationEmitInfo.push(nodeEmitInfo);
- if (nodeEmitInfo.hasWritten) {
- writeImportDeclaration(node);
- }
- }
- function writeImportDeclaration(node) {
- emitJsDocComments(node);
- if (node.flags & 1 /* Export */) {
- writer.write("export ");
- }
- writer.write("import ");
- writer.write(getSourceTextOfLocalNode(node.name));
- writer.write(" = ");
- if (node.entityName) {
- checkEntityNameAccessible();
- writer.write(getSourceTextOfLocalNode(node.entityName));
- writer.write(";");
- }
- else {
- writer.write("require(");
- writer.write(getSourceTextOfLocalNode(node.externalModuleName));
- writer.write(");");
- }
- writer.writeLine();
- function checkEntityNameAccessible() {
- var symbolAccesibilityResult = resolver.isImportDeclarationEntityNameReferenceDeclarationVisibile(node.entityName);
- if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) {
- if (symbolAccesibilityResult.aliasesToMakeVisible) {
- writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
- }
- }
- else {
- reportedDeclarationError = true;
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Import_declaration_0_is_using_private_name_1, getSourceTextOfLocalNode(node.name), symbolAccesibilityResult.errorSymbolName));
- }
- }
- }
- function emitModuleDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("module ");
- emitSourceTextOfNode(node.name);
- while (node.body.kind !== 192 /* ModuleBlock */) {
- node = node.body;
- write(".");
- emitSourceTextOfNode(node.name);
- }
- var prevEnclosingDeclaration = enclosingDeclaration;
- enclosingDeclaration = node;
- write(" {");
- writeLine();
- increaseIndent();
- emitLines(node.body.statements);
- decreaseIndent();
- write("}");
- writeLine();
- enclosingDeclaration = prevEnclosingDeclaration;
- }
- }
- function emitTypeAliasDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("type ");
- emitSourceTextOfNode(node.name);
- write(" = ");
- getSymbolVisibilityDiagnosticMessage = getTypeAliasDeclarationVisibilityError;
- resolver.writeTypeAtLocation(node.type, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- write(";");
- writeLine();
- }
- function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1;
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- };
- }
- }
- function emitEnumDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- if (ts.isConstEnumDeclaration(node)) {
- write("const ");
- }
- write("enum ");
- emitSourceTextOfNode(node.name);
- write(" {");
- writeLine();
- increaseIndent();
- emitLines(node.members);
- decreaseIndent();
- write("}");
- writeLine();
- }
- }
- function emitEnumMemberDeclaration(node) {
- emitJsDocComments(node);
- emitSourceTextOfNode(node.name);
- var enumMemberValue = resolver.getEnumMemberValue(node);
- if (enumMemberValue !== undefined) {
- write(" = ");
- write(enumMemberValue.toString());
- }
- write(",");
- writeLine();
- }
- function emitTypeParameters(typeParameters) {
- function emitTypeParameter(node) {
- function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- switch (node.parent.kind) {
- case 187 /* ClassDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
- break;
- case 188 /* InterfaceDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
- break;
- case 130 /* ConstructSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 129 /* CallSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 125 /* Method */:
- if (node.parent.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else if (node.parent.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
- }
- break;
- case 185 /* FunctionDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
- break;
- default:
- ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- };
- }
- increaseIndent();
- emitJsDocComments(node);
- decreaseIndent();
- emitSourceTextOfNode(node.name);
- if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) {
- write(" extends ");
- getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError;
- resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- }
- if (typeParameters) {
- write("<");
- emitCommaList(typeParameters, emitTypeParameter);
- write(">");
- }
- }
- function emitHeritageClause(typeReferences, isImplementsList) {
- if (typeReferences) {
- write(isImplementsList ? " implements " : " extends ");
- emitCommaList(typeReferences, emitTypeOfTypeReference);
- }
- function emitTypeOfTypeReference(node) {
- getSymbolVisibilityDiagnosticMessage = getHeritageClauseVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer);
- function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- if (node.parent.kind === 187 /* ClassDeclaration */) {
- if (symbolAccesibilityResult.errorModuleName) {
- diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2;
- }
- else {
- diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
- }
- }
- else {
- if (symbolAccesibilityResult.errorModuleName) {
- diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2;
- }
- else {
- diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
- }
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.parent.name
- };
- }
- }
- }
- function emitClassDeclaration(node) {
- function emitParameterProperties(constructorDeclaration) {
- if (constructorDeclaration) {
- ts.forEach(constructorDeclaration.parameters, function (param) {
- if (param.flags & 112 /* AccessibilityModifier */) {
- emitPropertyDeclaration(param);
- }
- });
- }
- }
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("class ");
- emitSourceTextOfNode(node.name);
- var prevEnclosingDeclaration = enclosingDeclaration;
- enclosingDeclaration = node;
- emitTypeParameters(node.typeParameters);
- if (node.baseType) {
- emitHeritageClause([node.baseType], false);
- }
- emitHeritageClause(node.implementedTypes, true);
- write(" {");
- writeLine();
- increaseIndent();
- emitParameterProperties(getFirstConstructorWithBody(node));
- emitLines(node.members);
- decreaseIndent();
- write("}");
- writeLine();
- enclosingDeclaration = prevEnclosingDeclaration;
- }
- }
- function emitInterfaceDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("interface ");
- emitSourceTextOfNode(node.name);
- var prevEnclosingDeclaration = enclosingDeclaration;
- enclosingDeclaration = node;
- emitTypeParameters(node.typeParameters);
- emitHeritageClause(node.baseTypes, false);
- write(" {");
- writeLine();
- increaseIndent();
- emitLines(node.members);
- decreaseIndent();
- write("}");
- writeLine();
- enclosingDeclaration = prevEnclosingDeclaration;
- }
- }
- function emitPropertyDeclaration(node) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- emitVariableDeclaration(node);
- write(";");
- writeLine();
- }
- function emitVariableDeclaration(node) {
- if (node.kind !== 184 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) {
- emitSourceTextOfNode(node.name);
- if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) {
- write("?");
- }
- if (!(node.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getVariableDeclarationTypeVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- }
- function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- if (node.kind === 184 /* VariableDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
- }
- else if (node.kind === 124 /* Property */) {
- if (node.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
- }
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
- }
- }
- return diagnosticMessage !== undefined ? {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- } : undefined;
- }
- }
- function emitVariableStatement(node) {
- var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); });
- if (hasDeclarationWithEmit) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- if (node.flags & 2048 /* Let */) {
- write("let ");
- }
- else if (node.flags & 4096 /* Const */) {
- write("const ");
- }
- else {
- write("var ");
- }
- emitCommaList(node.declarations, emitVariableDeclaration);
- write(";");
- writeLine();
- }
- }
- function emitAccessorDeclaration(node) {
- var accessors = getAllAccessorDeclarations(node.parent, node);
- if (node === accessors.firstAccessor) {
- emitJsDocComments(accessors.getAccessor);
- emitJsDocComments(accessors.setAccessor);
- emitDeclarationFlags(node);
- emitSourceTextOfNode(node.name);
- if (!(node.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getAccessorDeclarationTypeVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- write(";");
- writeLine();
- }
- function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- if (node.kind === 128 /* SetAccessor */) {
- if (node.parent.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node.parameters[0],
- typeName: node.name
- };
- }
- else {
- if (node.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node.name,
- typeName: undefined
- };
- }
- }
- }
- function emitFunctionDeclaration(node) {
- if ((node.kind !== 185 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- if (node.kind === 185 /* FunctionDeclaration */) {
- write("function ");
- emitSourceTextOfNode(node.name);
- }
- else if (node.kind === 126 /* Constructor */) {
- write("constructor");
- }
- else {
- emitSourceTextOfNode(node.name);
- if (node.flags & 4 /* QuestionMark */) {
- write("?");
- }
- }
- emitSignatureDeclaration(node);
- }
- }
- function emitConstructSignatureDeclaration(node) {
- emitJsDocComments(node);
- write("new ");
- emitSignatureDeclaration(node);
- }
- function emitSignatureDeclaration(node) {
- if (node.kind === 129 /* CallSignature */ || node.kind === 131 /* IndexSignature */) {
- emitJsDocComments(node);
- }
- emitTypeParameters(node.typeParameters);
- if (node.kind === 131 /* IndexSignature */) {
- write("[");
- }
- else {
- write("(");
- }
- emitCommaList(node.parameters, emitParameterDeclaration);
- if (node.kind === 131 /* IndexSignature */) {
- write("]");
- }
- else {
- write(")");
- }
- if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError;
- resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- write(";");
- writeLine();
- function getReturnTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- switch (node.kind) {
- case 130 /* ConstructSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
- break;
- case 129 /* CallSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
- break;
- case 131 /* IndexSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
- break;
- case 125 /* Method */:
- if (node.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
- }
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
- }
- break;
- case 185 /* FunctionDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
- break;
- default:
- ts.Debug.fail("This is unknown kind for signature: " + node.kind);
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node.name || node
- };
- }
- }
- function emitParameterDeclaration(node) {
- increaseIndent();
- emitJsDocComments(node);
- if (node.flags & 8 /* Rest */) {
- write("...");
- }
- emitSourceTextOfNode(node.name);
- if (node.initializer || (node.flags & 4 /* QuestionMark */)) {
- write("?");
- }
- decreaseIndent();
- if (!(node.parent.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getParameterDeclarationTypeVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- switch (node.parent.kind) {
- case 126 /* Constructor */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
- break;
- case 130 /* ConstructSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 129 /* CallSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 125 /* Method */:
- if (node.parent.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else if (node.parent.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
- }
- break;
- case 185 /* FunctionDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
- break;
- default:
- ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind);
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- };
- }
- }
- function emitNode(node) {
- switch (node.kind) {
- case 126 /* Constructor */:
- case 185 /* FunctionDeclaration */:
- case 125 /* Method */:
- return emitFunctionDeclaration(node);
- case 130 /* ConstructSignature */:
- return emitConstructSignatureDeclaration(node);
- case 129 /* CallSignature */:
- case 131 /* IndexSignature */:
- return emitSignatureDeclaration(node);
- case 127 /* GetAccessor */:
- case 128 /* SetAccessor */:
- return emitAccessorDeclaration(node);
- case 162 /* VariableStatement */:
- return emitVariableStatement(node);
- case 124 /* Property */:
- return emitPropertyDeclaration(node);
- case 188 /* InterfaceDeclaration */:
- return emitInterfaceDeclaration(node);
- case 187 /* ClassDeclaration */:
- return emitClassDeclaration(node);
- case 189 /* TypeAliasDeclaration */:
- return emitTypeAliasDeclaration(node);
- case 195 /* EnumMember */:
- return emitEnumMemberDeclaration(node);
- case 190 /* EnumDeclaration */:
- return emitEnumDeclaration(node);
- case 191 /* ModuleDeclaration */:
- return emitModuleDeclaration(node);
- case 193 /* ImportDeclaration */:
- return emitImportDeclaration(node);
- case 194 /* ExportAssignment */:
- return emitExportAssignment(node);
- case 196 /* SourceFile */:
- return emitSourceFile(node);
- }
- }
- function tryResolveScriptReference(sourceFile, reference) {
- var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename));
- return program.getSourceFile(referenceFileName);
- }
- var referencePathsOutput = "";
- function writeReferencePath(referencedFile) {
- var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts";
- declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, false);
- referencePathsOutput += "/// " + newLine;
- }
- if (root) {
- if (!compilerOptions.noResolve) {
- var addedGlobalFileReference = false;
- ts.forEach(root.referencedFiles, function (fileReference) {
- var referencedFile = tryResolveScriptReference(root, fileReference);
- if (referencedFile && ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) {
- writeReferencePath(referencedFile);
- if (!isExternalModuleOrDeclarationFile(referencedFile)) {
- addedGlobalFileReference = true;
- }
- }
- });
- }
- emitNode(root);
- }
- else {
- var emittedReferencedFiles = [];
- ts.forEach(program.getSourceFiles(), function (sourceFile) {
- if (!isExternalModuleOrDeclarationFile(sourceFile)) {
- if (!compilerOptions.noResolve) {
- ts.forEach(sourceFile.referencedFiles, function (fileReference) {
- var referencedFile = tryResolveScriptReference(sourceFile, fileReference);
- if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) {
- writeReferencePath(referencedFile);
- emittedReferencedFiles.push(referencedFile);
- }
- });
- }
- emitNode(sourceFile);
- }
- });
- }
- if (!reportedDeclarationError) {
- var declarationOutput = referencePathsOutput;
- var synchronousDeclarationOutput = writer.getText();
+ function writeDeclarationFile(jsFilePath, sourceFile) {
+ var emitDeclarationResult = emitDeclarations(program, resolver, diagnostics, jsFilePath, sourceFile);
+ if (!emitDeclarationResult.reportedDeclarationError) {
+ var declarationOutput = emitDeclarationResult.referencePathsOutput;
var appliedSyncOutputPos = 0;
- ts.forEach(aliasDeclarationEmitInfo, function (aliasEmitInfo) {
+ ts.forEach(emitDeclarationResult.aliasDeclarationEmitInfo, function (aliasEmitInfo) {
if (aliasEmitInfo.asynchronousOutput) {
- declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos);
+ declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos);
declarationOutput += aliasEmitInfo.asynchronousOutput;
appliedSyncOutputPos = aliasEmitInfo.outputPos;
}
});
- declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos);
- writeFile(ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
+ declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos);
+ writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
}
}
var hasSemanticErrors = resolver.hasSemanticErrors();
@@ -9247,14 +9580,14 @@ var ts;
if (!isEmitBlocked) {
emitJavaScript(jsFilePath, sourceFile);
if (!hasSemanticErrors && compilerOptions.declaration) {
- emitDeclarations(jsFilePath, sourceFile);
+ writeDeclarationFile(jsFilePath, sourceFile);
}
}
}
if (targetSourceFile === undefined) {
ts.forEach(program.getSourceFiles(), function (sourceFile) {
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
- var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js");
+ var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js");
emitFile(jsFilePath, sourceFile);
}
});
@@ -9264,7 +9597,7 @@ var ts;
}
else {
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
- var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js");
+ var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js");
emitFile(jsFilePath, targetSourceFile);
}
else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) {
@@ -9357,10 +9690,11 @@ var ts;
getTypeCount: function () { return typeCount; },
isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
+ emitFiles: invokeEmitter,
getDiagnostics: getDiagnostics,
+ getDeclarationDiagnostics: getDeclarationDiagnostics,
getGlobalDiagnostics: getGlobalDiagnostics,
checkProgram: checkProgram,
- invokeEmitter: invokeEmitter,
getParentOfSymbol: getParentOfSymbol,
getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol,
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
@@ -9566,10 +9900,10 @@ var ts;
return nodeLinks[node.id] || (nodeLinks[node.id] = {});
}
function getSourceFile(node) {
- return ts.getAncestor(node, 196 /* SourceFile */);
+ return ts.getAncestor(node, 197 /* SourceFile */);
}
function isGlobalSourceFile(node) {
- return node.kind === 196 /* SourceFile */ && !ts.isExternalModule(node);
+ return node.kind === 197 /* SourceFile */ && !ts.isExternalModule(node);
}
function getSymbol(symbols, name, meaning) {
if (meaning && ts.hasProperty(symbols, name)) {
@@ -9610,21 +9944,21 @@ var ts;
}
}
switch (location.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (!ts.isExternalModule(location))
break;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) {
break loop;
}
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) {
break loop;
}
break;
case 124 /* Property */:
- if (location.parent.kind === 187 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) {
+ if (location.parent.kind === 188 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) {
var ctor = findConstructorDeclaration(location.parent);
if (ctor && ctor.locals) {
if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) {
@@ -9633,8 +9967,8 @@ var ts;
}
}
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) {
if (lastLocation && lastLocation.flags & 128 /* Static */) {
error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
@@ -9647,7 +9981,7 @@ var ts;
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
if (name === "arguments") {
result = argumentsSymbol;
@@ -9665,7 +9999,7 @@ var ts;
break loop;
}
break;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
var id = location.variable;
if (name === id.text) {
result = location.symbol;
@@ -9706,7 +10040,7 @@ var ts;
var links = getSymbolLinks(symbol);
if (!links.target) {
links.target = resolvingSymbol;
- var node = getDeclarationOfKind(symbol, 193 /* ImportDeclaration */);
+ var node = getDeclarationOfKind(symbol, 194 /* ImportDeclaration */);
var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node);
if (links.target === resolvingSymbol) {
links.target = target || unknownSymbol;
@@ -9722,7 +10056,7 @@ var ts;
}
function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) {
if (!importDeclaration) {
- importDeclaration = ts.getAncestor(entityName, 193 /* ImportDeclaration */);
+ importDeclaration = ts.getAncestor(entityName, 194 /* ImportDeclaration */);
ts.Debug.assert(importDeclaration !== undefined);
}
if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
@@ -9732,7 +10066,7 @@ var ts;
return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */);
}
else {
- ts.Debug.assert(entityName.parent.kind === 193 /* ImportDeclaration */);
+ ts.Debug.assert(entityName.parent.kind === 194 /* ImportDeclaration */);
return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */);
}
}
@@ -9837,9 +10171,9 @@ var ts;
var seenExportedMember = false;
var result = [];
ts.forEach(symbol.declarations, function (declaration) {
- var block = (declaration.kind === 196 /* SourceFile */ ? declaration : declaration.body);
+ var block = (declaration.kind === 197 /* SourceFile */ ? declaration : declaration.body);
ts.forEach(block.statements, function (node) {
- if (node.kind === 194 /* ExportAssignment */) {
+ if (node.kind === 195 /* ExportAssignment */) {
result.push(node);
}
else {
@@ -9946,17 +10280,17 @@ var ts;
}
}
switch (location.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (!ts.isExternalModule(location)) {
break;
}
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (result = callback(getSymbolOfNode(location).exports)) {
return result;
}
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
if (result = callback(getSymbolOfNode(location).members)) {
return result;
}
@@ -9987,7 +10321,7 @@ var ts;
}
return ts.forEachValue(symbols, function (symbolFromSymbolTable) {
if (symbolFromSymbolTable.flags & 33554432 /* Import */) {
- if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 193 /* ImportDeclaration */ && declaration.externalModuleName; })) {
+ if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 194 /* ImportDeclaration */ && declaration.externalModuleName; })) {
var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable);
if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) {
return [symbolFromSymbolTable];
@@ -10038,7 +10372,7 @@ var ts;
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined
};
}
- return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasAccessibleDeclarations.aliasesToMakeVisible };
+ return hasAccessibleDeclarations;
}
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getParentOfSymbol(symbol);
@@ -10069,17 +10403,17 @@ var ts;
}
}
function hasExternalModuleSymbol(declaration) {
- return (declaration.kind === 191 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 196 /* SourceFile */ && ts.isExternalModule(declaration));
+ return (declaration.kind === 192 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 197 /* SourceFile */ && ts.isExternalModule(declaration));
}
function hasVisibleDeclarations(symbol) {
var aliasesToMakeVisible;
if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) {
return undefined;
}
- return { aliasesToMakeVisible: aliasesToMakeVisible };
+ return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible };
function getIsDeclarationVisible(declaration) {
if (!isDeclarationVisible(declaration)) {
- if (declaration.kind === 193 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) {
+ if (declaration.kind === 194 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) {
getNodeLinks(declaration).isVisible = true;
if (aliasesToMakeVisible) {
if (!ts.contains(aliasesToMakeVisible, declaration)) {
@@ -10096,11 +10430,24 @@ var ts;
return true;
}
}
- function isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName) {
+ function isEntityNameVisible(entityName, enclosingDeclaration) {
+ var meaning;
+ if (entityName.parent.kind === 135 /* TypeQuery */) {
+ meaning = 107455 /* Value */ | 4194304 /* ExportValue */;
+ }
+ else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 194 /* ImportDeclaration */) {
+ meaning = 1536 /* Namespace */;
+ }
+ else {
+ meaning = 3152352 /* Type */;
+ }
var firstIdentifier = getFirstIdentifier(entityName);
- var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier);
- var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace);
- return hasNamespaceDeclarationsVisibile ? { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } : { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.declarationNameToString(firstIdentifier) };
+ var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined);
+ return hasVisibleDeclarations(symbol) || {
+ accessibility: 1 /* NotAccessible */,
+ errorSymbolName: ts.getTextOfNode(firstIdentifier),
+ errorNode: firstIdentifier
+ };
}
function releaseStringWriter(writer) {
writer.clear();
@@ -10142,7 +10489,7 @@ var ts;
while (node.kind === 140 /* ParenType */) {
node = node.parent;
}
- if (node.kind === 189 /* TypeAliasDeclaration */) {
+ if (node.kind === 190 /* TypeAliasDeclaration */) {
return getSymbolOfNode(node);
}
}
@@ -10305,7 +10652,7 @@ var ts;
function shouldWriteTypeOfFunctionSymbol() {
if (type.symbol) {
var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; }));
- var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 196 /* SourceFile */ || declaration.parent.kind === 192 /* ModuleBlock */; }));
+ var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 197 /* SourceFile */ || declaration.parent.kind === 193 /* ModuleBlock */; }));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type));
}
@@ -10524,12 +10871,12 @@ var ts;
function isDeclarationVisible(node) {
function getContainingExternalModule(node) {
for (; node; node = node.parent) {
- if (node.kind === 191 /* ModuleDeclaration */) {
+ if (node.kind === 192 /* ModuleDeclaration */) {
if (node.name.kind === 7 /* StringLiteral */) {
return node;
}
}
- else if (node.kind === 196 /* SourceFile */) {
+ else if (node.kind === 197 /* SourceFile */) {
return ts.isExternalModule(node) ? node : undefined;
}
}
@@ -10571,16 +10918,16 @@ var ts;
}
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 184 /* VariableDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 185 /* FunctionDeclaration */:
- case 190 /* EnumDeclaration */:
- case 193 /* ImportDeclaration */:
- var parent = node.kind === 184 /* VariableDeclaration */ ? node.parent.parent : node.parent;
- if (!(node.flags & 1 /* Export */) && !(node.kind !== 193 /* ImportDeclaration */ && parent.kind !== 196 /* SourceFile */ && ts.isInAmbientContext(parent))) {
+ case 185 /* VariableDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 186 /* FunctionDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 194 /* ImportDeclaration */:
+ var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent;
+ if (!(node.flags & 1 /* Export */) && !(node.kind !== 194 /* ImportDeclaration */ && parent.kind !== 197 /* SourceFile */ && ts.isInAmbientContext(parent))) {
return isGlobalSourceFile(parent) || isUsedInExportAssignment(node);
}
return isDeclarationVisible(parent);
@@ -10594,9 +10941,10 @@ var ts;
case 129 /* CallSignature */:
case 131 /* IndexSignature */:
case 123 /* Parameter */:
- case 192 /* ModuleBlock */:
+ case 193 /* ModuleBlock */:
+ case 122 /* TypeParameter */:
return isDeclarationVisible(node.parent);
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
return true;
default:
ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
@@ -10615,7 +10963,7 @@ var ts;
return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
}
function getTypeOfVariableOrPropertyDeclaration(declaration) {
- if (declaration.parent.kind === 169 /* ForInStatement */) {
+ if (declaration.parent.kind === 170 /* ForInStatement */) {
return anyType;
}
if (declaration.type) {
@@ -10682,7 +11030,7 @@ var ts;
return links.type = getTypeOfPrototypeProperty(symbol);
}
var declaration = symbol.valueDeclaration;
- if (declaration.kind === 181 /* CatchBlock */) {
+ if (declaration.kind === 182 /* CatchBlock */) {
return links.type = anyType;
}
links.type = resolvingType;
@@ -10822,7 +11170,7 @@ var ts;
function getTypeParametersOfClassOrInterface(symbol) {
var result;
ts.forEach(symbol.declarations, function (node) {
- if (node.kind === 188 /* InterfaceDeclaration */ || node.kind === 187 /* ClassDeclaration */) {
+ if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 188 /* ClassDeclaration */) {
var declaration = node;
if (declaration.typeParameters && declaration.typeParameters.length) {
ts.forEach(declaration.typeParameters, function (node) {
@@ -10853,7 +11201,7 @@ var ts;
type.typeArguments = type.typeParameters;
}
type.baseTypes = [];
- var declaration = getDeclarationOfKind(symbol, 187 /* ClassDeclaration */);
+ var declaration = getDeclarationOfKind(symbol, 188 /* ClassDeclaration */);
if (declaration.baseType) {
var baseType = getTypeFromTypeReferenceNode(declaration.baseType);
if (baseType !== unknownType) {
@@ -10893,7 +11241,7 @@ var ts;
}
type.baseTypes = [];
ts.forEach(symbol.declarations, function (declaration) {
- if (declaration.kind === 188 /* InterfaceDeclaration */ && declaration.baseTypes) {
+ if (declaration.kind === 189 /* InterfaceDeclaration */ && declaration.baseTypes) {
ts.forEach(declaration.baseTypes, function (node) {
var baseType = getTypeFromTypeReferenceNode(node);
if (baseType !== unknownType) {
@@ -10924,7 +11272,7 @@ var ts;
var links = getSymbolLinks(symbol);
if (!links.declaredType) {
links.declaredType = resolvingType;
- var declaration = getDeclarationOfKind(symbol, 189 /* TypeAliasDeclaration */);
+ var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */);
var type = getTypeFromTypeNode(declaration.type);
if (links.declaredType === resolvingType) {
links.declaredType = type;
@@ -10932,7 +11280,7 @@ var ts;
}
else if (links.declaredType === resolvingType) {
links.declaredType = unknownType;
- var declaration = getDeclarationOfKind(symbol, 189 /* TypeAliasDeclaration */);
+ var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */);
error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
}
return links.declaredType;
@@ -11403,7 +11751,7 @@ var ts;
switch (node.kind) {
case 133 /* FunctionType */:
case 134 /* ConstructorType */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
case 126 /* Constructor */:
case 129 /* CallSignature */:
@@ -11633,9 +11981,9 @@ var ts;
for (var i = 0; i < declarations.length; i++) {
var declaration = declarations[i];
switch (declaration.kind) {
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
return declaration;
}
}
@@ -12944,7 +13292,7 @@ var ts;
switch (node.kind) {
case 156 /* BinaryExpression */:
return isAssignedInBinaryExpression(node);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return isAssignedInVariableDeclaration(node);
case 141 /* ArrayLiteral */:
case 142 /* ObjectLiteral */:
@@ -12957,25 +13305,25 @@ var ts;
case 154 /* PrefixOperator */:
case 155 /* PostfixOperator */:
case 157 /* ConditionalExpression */:
- case 161 /* Block */:
- case 162 /* VariableStatement */:
- case 164 /* ExpressionStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 172 /* ReturnStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
- case 177 /* LabeledStatement */:
- case 178 /* ThrowStatement */:
- case 179 /* TryStatement */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
+ case 162 /* Block */:
+ case 163 /* VariableStatement */:
+ case 165 /* ExpressionStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 173 /* ReturnStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
+ case 178 /* LabeledStatement */:
+ case 179 /* ThrowStatement */:
+ case 180 /* TryStatement */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
return ts.forEachChild(node, isAssignedIn);
}
return false;
@@ -12989,7 +13337,7 @@ var ts;
node = node.parent;
var narrowedType = type;
switch (node.kind) {
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
if (child !== node.expression) {
narrowedType = narrowType(type, node.expression, child === node.thenStatement);
}
@@ -13009,9 +13357,9 @@ var ts;
}
}
break;
- case 196 /* SourceFile */:
- case 191 /* ModuleDeclaration */:
- case 185 /* FunctionDeclaration */:
+ case 197 /* SourceFile */:
+ case 192 /* ModuleDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
@@ -13121,7 +13469,7 @@ var ts;
return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node);
}
function captureLexicalThis(node, container) {
- var classNode = container.parent && container.parent.kind === 187 /* ClassDeclaration */ ? container.parent : undefined;
+ var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined;
getNodeLinks(node).flags |= 2 /* LexicalThis */;
if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) {
getNodeLinks(classNode).flags |= 4 /* CaptureThis */;
@@ -13138,10 +13486,10 @@ var ts;
needToCaptureLexicalThis = true;
}
switch (container.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body);
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
break;
case 126 /* Constructor */:
@@ -13158,7 +13506,7 @@ var ts;
if (needToCaptureLexicalThis) {
captureLexicalThis(node, container);
}
- var classNode = container.parent && container.parent.kind === 187 /* ClassDeclaration */ ? container.parent : undefined;
+ var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined;
if (classNode) {
var symbol = getSymbolOfNode(classNode);
return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol);
@@ -13171,7 +13519,7 @@ var ts;
if (!node)
return node;
switch (node.kind) {
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
case 124 /* Property */:
@@ -13193,7 +13541,7 @@ var ts;
}
function checkSuperExpression(node) {
var isCallExpression = node.parent.kind === 147 /* CallExpression */ && node.parent.func === node;
- var enclosingClass = ts.getAncestor(node, 187 /* ClassDeclaration */);
+ var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */);
var baseClass;
if (enclosingClass && enclosingClass.baseType) {
var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass));
@@ -13215,7 +13563,7 @@ var ts;
container = getSuperContainer(container);
needToCaptureLexicalThis = true;
}
- if (container && container.parent && container.parent.kind === 187 /* ClassDeclaration */) {
+ if (container && container.parent && container.parent.kind === 188 /* ClassDeclaration */) {
if (container.flags & 128 /* Static */) {
canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */;
}
@@ -13393,12 +13741,12 @@ var ts;
}
var parent = node.parent;
switch (parent.kind) {
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 123 /* Parameter */:
case 124 /* Property */:
return getContextualTypeForInitializerExpression(node);
case 153 /* ArrowFunction */:
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return getContextualTypeForReturnExpression(node);
case 147 /* CallExpression */:
case 148 /* NewExpression */:
@@ -13549,7 +13897,7 @@ var ts;
if (!(flags & (32 /* Private */ | 64 /* Protected */))) {
return;
}
- var enclosingClassDeclaration = ts.getAncestor(node, 187 /* ClassDeclaration */);
+ var enclosingClassDeclaration = ts.getAncestor(node, 188 /* ClassDeclaration */);
var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined;
var declaringClass = getDeclaredTypeOfSymbol(prop.parent);
if (flags & 32 /* Private */) {
@@ -13734,7 +14082,7 @@ var ts;
var context = createInferenceContext(typeParameters, false);
var mapper = createInferenceMapper(context);
for (var i = 0; i < args.length; i++) {
- if (args[i].kind === 160 /* OmittedExpression */) {
+ if (args[i].kind === 161 /* OmittedExpression */) {
continue;
}
if (!excludeArgument || excludeArgument[i] === undefined) {
@@ -13748,7 +14096,7 @@ var ts;
}
if (excludeArgument) {
for (var i = 0; i < args.length; i++) {
- if (args[i].kind === 160 /* OmittedExpression */) {
+ if (args[i].kind === 161 /* OmittedExpression */) {
continue;
}
if (excludeArgument[i] === false) {
@@ -13786,7 +14134,7 @@ var ts;
for (var i = 0; i < args.length; i++) {
var arg = args[i];
var argType;
- if (arg.kind === 160 /* OmittedExpression */) {
+ if (arg.kind === 161 /* OmittedExpression */) {
continue;
}
var paramType = getTypeAtPosition(signature, i);
@@ -14109,7 +14457,7 @@ var ts;
}
function getReturnTypeFromBody(func, contextualMapper) {
var contextualSignature = getContextualSignature(func);
- if (func.body.kind !== 186 /* FunctionBlock */) {
+ if (func.body.kind !== 187 /* FunctionBlock */) {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
@@ -14157,7 +14505,7 @@ var ts;
});
}
function bodyContainsSingleThrowStatement(body) {
- return (body.statements.length === 1) && (body.statements[0].kind === 178 /* ThrowStatement */);
+ return (body.statements.length === 1) && (body.statements[0].kind === 179 /* ThrowStatement */);
}
function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) {
if (!fullTypeCheck) {
@@ -14166,7 +14514,7 @@ var ts;
if (returnType === voidType || returnType === anyType) {
return;
}
- if (!func.body || func.body.kind !== 186 /* FunctionBlock */) {
+ if (!func.body || func.body.kind !== 187 /* FunctionBlock */) {
return;
}
var bodyBlock = func.body;
@@ -14210,7 +14558,7 @@ var ts;
if (node.type) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
checkSourceElement(node.body);
}
else {
@@ -14558,7 +14906,7 @@ var ts;
return checkBinaryExpression(node, contextualMapper);
case 157 /* ConditionalExpression */:
return checkConditionalExpression(node, contextualMapper);
- case 160 /* OmittedExpression */:
+ case 161 /* OmittedExpression */:
return undefinedType;
}
return unknownType;
@@ -14638,7 +14986,7 @@ var ts;
checkSpecializedSignatureDeclaration(node);
}
function checkTypeForDuplicateIndexSignatures(node) {
- if (node.kind === 188 /* InterfaceDeclaration */) {
+ if (node.kind === 189 /* InterfaceDeclaration */) {
var nodeSymbol = getSymbolOfNode(node);
if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
return;
@@ -14702,7 +15050,7 @@ var ts;
}
switch (n.kind) {
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
case 142 /* ObjectLiteral */: return false;
default: return ts.forEachChild(n, containsSuperCall);
@@ -14712,7 +15060,7 @@ var ts;
if (n.kind === 91 /* ThisKeyword */) {
error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
}
- else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 185 /* FunctionDeclaration */) {
+ else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 186 /* FunctionDeclaration */) {
ts.forEachChild(n, markThisReferencesAsErrors);
}
}
@@ -14724,7 +15072,7 @@ var ts;
var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); });
if (superCallShouldBeFirst) {
var statements = node.body.statements;
- if (!statements.length || statements[0].kind !== 164 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) {
+ if (!statements.length || statements[0].kind !== 165 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) {
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties);
}
else {
@@ -14812,7 +15160,7 @@ var ts;
return;
}
var signaturesToCheck;
- if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 188 /* InterfaceDeclaration */) {
+ if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 189 /* InterfaceDeclaration */) {
ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */);
var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */;
var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent);
@@ -14832,7 +15180,7 @@ var ts;
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = n.flags;
- if (n.parent.kind !== 188 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
+ if (n.parent.kind !== 189 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
if (!(flags & 2 /* Ambient */)) {
flags |= 1 /* Export */;
}
@@ -14918,11 +15266,11 @@ var ts;
for (var i = 0; i < declarations.length; i++) {
var node = declarations[i];
var inAmbientContext = ts.isInAmbientContext(node);
- var inAmbientContextOrInterface = node.parent.kind === 188 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext;
+ var inAmbientContextOrInterface = node.parent.kind === 189 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext;
if (inAmbientContextOrInterface) {
previousDeclaration = undefined;
}
- if (node.kind === 185 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) {
+ if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) {
var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
someNodeFlags |= currentNodeFlags;
allNodeFlags &= currentNodeFlags;
@@ -15016,14 +15364,14 @@ var ts;
}
function getDeclarationSpaces(d) {
switch (d.kind) {
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return 8388608 /* ExportType */;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */;
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
return 8388608 /* ExportType */ | 4194304 /* ExportValue */;
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
var result = 0;
var target = resolveImport(getSymbolOfNode(d));
ts.forEach(target.declarations, function (d) {
@@ -15098,7 +15446,7 @@ var ts;
return;
}
switch (current.kind) {
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 125 /* Method */:
case 153 /* ArrowFunction */:
@@ -15153,7 +15501,7 @@ var ts;
if (!needCollisionCheckForIdentifier(node, name, "_super")) {
return;
}
- var enclosingClass = ts.getAncestor(node, 187 /* ClassDeclaration */);
+ var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */);
if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) {
return;
}
@@ -15171,11 +15519,11 @@ var ts;
if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
return;
}
- if (node.kind === 191 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ if (node.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
return;
}
- var parent = node.kind === 184 /* VariableDeclaration */ ? node.parent.parent : node.parent;
- if (parent.kind === 196 /* SourceFile */ && ts.isExternalModule(parent)) {
+ var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent;
+ if (parent.kind === 197 /* SourceFile */ && ts.isExternalModule(parent)) {
error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
}
}
@@ -15566,7 +15914,7 @@ var ts;
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
- var firstInterfaceDecl = getDeclarationOfKind(symbol, 188 /* InterfaceDeclaration */);
+ var firstInterfaceDecl = getDeclarationOfKind(symbol, 189 /* InterfaceDeclaration */);
if (symbol.declarations.length > 1) {
if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) {
error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters);
@@ -15599,7 +15947,7 @@ var ts;
var enumType = getDeclaredTypeOfSymbol(enumSymbol);
var autoValue = 0;
var ambient = ts.isInAmbientContext(node);
- var enumIsConst = ts.isConstEnumDeclaration(node);
+ var enumIsConst = ts.isConst(node);
ts.forEach(node.members, function (member) {
if (isNumericName(member.name.text)) {
error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
@@ -15740,7 +16088,7 @@ var ts;
var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind);
if (node === firstDeclaration) {
if (enumSymbol.declarations.length > 1) {
- var enumIsConst = ts.isConstEnumDeclaration(node);
+ var enumIsConst = ts.isConst(node);
ts.forEach(enumSymbol.declarations, function (decl) {
if (ts.isConstEnumDeclaration(decl) !== enumIsConst) {
error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
@@ -15749,7 +16097,7 @@ var ts;
}
var seenEnumMissingInitialInitializer = false;
ts.forEach(enumSymbol.declarations, function (declaration) {
- if (declaration.kind !== 190 /* EnumDeclaration */) {
+ if (declaration.kind !== 191 /* EnumDeclaration */) {
return false;
}
var enumDeclaration = declaration;
@@ -15772,7 +16120,7 @@ var ts;
var declarations = symbol.declarations;
for (var i = 0; i < declarations.length; i++) {
var declaration = declarations[i];
- if ((declaration.kind === 187 /* ClassDeclaration */ || (declaration.kind === 185 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) {
+ if ((declaration.kind === 188 /* ClassDeclaration */ || (declaration.kind === 186 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) {
return declaration;
}
}
@@ -15835,10 +16183,10 @@ var ts;
}
}
else {
- if (node.parent.kind === 196 /* SourceFile */) {
+ if (node.parent.kind === 197 /* SourceFile */) {
target = resolveImport(symbol);
}
- else if (node.parent.kind === 192 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) {
+ else if (node.parent.kind === 193 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) {
if (isExternalModuleNameRelative(node.externalModuleName.text)) {
error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name);
target = unknownSymbol;
@@ -15860,7 +16208,7 @@ var ts;
}
function checkExportAssignment(node) {
var container = node.parent;
- if (container.kind !== 196 /* SourceFile */) {
+ if (container.kind !== 197 /* SourceFile */) {
container = container.parent;
}
checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container));
@@ -15902,57 +16250,57 @@ var ts;
return checkUnionType(node);
case 140 /* ParenType */:
return checkSourceElement(node.type);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
return checkFunctionDeclaration(node);
- case 161 /* Block */:
+ case 162 /* Block */:
return checkBlock(node);
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
return checkBody(node);
- case 162 /* VariableStatement */:
+ case 163 /* VariableStatement */:
return checkVariableStatement(node);
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return checkExpressionStatement(node);
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
return checkIfStatement(node);
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
return checkDoStatement(node);
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return checkWhileStatement(node);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return checkForStatement(node);
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return checkForInStatement(node);
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
return checkBreakOrContinueStatement(node);
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return checkReturnStatement(node);
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
return checkWithStatement(node);
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return checkSwitchStatement(node);
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return checkLabeledStatement(node);
- case 178 /* ThrowStatement */:
+ case 179 /* ThrowStatement */:
return checkThrowStatement(node);
- case 179 /* TryStatement */:
+ case 180 /* TryStatement */:
return checkTryStatement(node);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return ts.Debug.fail("Checker encountered variable declaration");
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return checkClassDeclaration(node);
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return checkInterfaceDeclaration(node);
- case 189 /* TypeAliasDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
return checkTypeAliasDeclaration(node);
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
return checkEnumDeclaration(node);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return checkModuleDeclaration(node);
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return checkImportDeclaration(node);
- case 194 /* ExportAssignment */:
+ case 195 /* ExportAssignment */:
return checkExportAssignment(node);
}
}
@@ -15967,10 +16315,10 @@ var ts;
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
ts.forEach(node.parameters, checkFunctionExpressionBodies);
break;
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
checkFunctionExpressionBodies(node.expression);
break;
case 123 /* Parameter */:
@@ -15989,33 +16337,33 @@ var ts;
case 155 /* PostfixOperator */:
case 156 /* BinaryExpression */:
case 157 /* ConditionalExpression */:
- case 161 /* Block */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
- case 162 /* VariableStatement */:
- case 164 /* ExpressionStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
- case 172 /* ReturnStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
- case 177 /* LabeledStatement */:
- case 178 /* ThrowStatement */:
- case 179 /* TryStatement */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 184 /* VariableDeclaration */:
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
- case 195 /* EnumMember */:
- case 196 /* SourceFile */:
+ case 162 /* Block */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
+ case 163 /* VariableStatement */:
+ case 165 /* ExpressionStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
+ case 173 /* ReturnStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
+ case 178 /* LabeledStatement */:
+ case 179 /* ThrowStatement */:
+ case 180 /* TryStatement */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 185 /* VariableDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 196 /* EnumMember */:
+ case 197 /* SourceFile */:
ts.forEachChild(node, checkFunctionExpressionBodies);
break;
}
@@ -16065,6 +16413,11 @@ var ts;
checkProgram();
return getSortedDiagnostics();
}
+ function getDeclarationDiagnostics(targetSourceFile) {
+ var resolver = createResolver();
+ checkSourceFile(targetSourceFile);
+ return ts.getDeclarationDiagnostics(program, resolver, targetSourceFile);
+ }
function getGlobalDiagnostics() {
return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; });
}
@@ -16086,7 +16439,7 @@ var ts;
function isInsideWithStatementBody(node) {
if (node) {
while (node.parent) {
- if (node.parent.kind === 173 /* WithStatement */ && node.parent.statement === node) {
+ if (node.parent.kind === 174 /* WithStatement */ && node.parent.statement === node) {
return true;
}
node = node.parent;
@@ -16122,17 +16475,17 @@ var ts;
copySymbols(location.locals, meaning);
}
switch (location.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (!ts.isExternalModule(location))
break;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */);
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */);
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
if (!(memberFlags & 128 /* Static */)) {
copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */);
}
@@ -16142,7 +16495,7 @@ var ts;
copySymbol(location.symbol, meaning);
}
break;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
if (location.variable.text) {
copySymbol(location.symbol, meaning);
}
@@ -16160,10 +16513,10 @@ var ts;
function isTypeDeclaration(node) {
switch (node.kind) {
case 122 /* TypeParameter */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 191 /* EnumDeclaration */:
return true;
}
}
@@ -16205,9 +16558,9 @@ var ts;
return node === parent.constraint;
case 124 /* Property */:
case 123 /* Parameter */:
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return node === parent.type;
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
case 126 /* Constructor */:
@@ -16234,10 +16587,10 @@ var ts;
while (node.parent.kind === 121 /* QualifiedName */) {
node = node.parent;
}
- if (node.parent.kind === 193 /* ImportDeclaration */) {
+ if (node.parent.kind === 194 /* ImportDeclaration */) {
return node.parent.entityName === node;
}
- if (node.parent.kind === 194 /* ExportAssignment */) {
+ if (node.parent.kind === 195 /* ExportAssignment */) {
return node.parent.exportName === node;
}
return false;
@@ -16249,7 +16602,7 @@ var ts;
if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
return getSymbolOfNode(entityName.parent);
}
- if (entityName.parent.kind === 194 /* ExportAssignment */) {
+ if (entityName.parent.kind === 195 /* ExportAssignment */) {
return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */);
}
if (isInRightSideOfImportOrExportAssignment(entityName)) {
@@ -16289,7 +16642,7 @@ var ts;
return getSymbolOfNode(node.parent);
}
if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) {
- return node.parent.kind === 194 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node);
+ return node.parent.kind === 195 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node);
}
switch (node.kind) {
case 63 /* Identifier */:
@@ -16307,7 +16660,7 @@ var ts;
}
return undefined;
case 7 /* StringLiteral */:
- if (node.parent.kind === 193 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
+ if (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
var importSymbol = getSymbolOfNode(node.parent);
var moduleType = getTypeOfSymbol(importSymbol);
return moduleType ? moduleType.symbol : undefined;
@@ -16401,7 +16754,7 @@ var ts;
return [symbol];
}
function isExternalModuleSymbol(symbol) {
- return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 196 /* SourceFile */;
+ return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 197 /* SourceFile */;
}
function isNodeDescendentOf(node, ancestor) {
while (node) {
@@ -16434,7 +16787,7 @@ var ts;
function getLocalNameForSymbol(symbol, location) {
var node = location;
while (node) {
- if ((node.kind === 191 /* ModuleDeclaration */ || node.kind === 190 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) {
+ if ((node.kind === 192 /* ModuleDeclaration */ || node.kind === 191 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) {
return getLocalNameOfContainer(node);
}
node = node.parent;
@@ -16458,7 +16811,7 @@ var ts;
return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined;
}
function isTopLevelValueImportWithEntityName(node) {
- if (node.parent.kind !== 196 /* SourceFile */ || !node.entityName) {
+ if (node.parent.kind !== 197 /* SourceFile */ || !node.entityName) {
return false;
}
return isImportResolvedToValue(getSymbolOfNode(node));
@@ -16509,7 +16862,7 @@ var ts;
if (symbol && (symbol.flags & 8 /* EnumMember */)) {
var declaration = symbol.valueDeclaration;
var constantValue;
- if (declaration.kind === 195 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) {
+ if (declaration.kind === 196 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) {
return constantValue;
}
}
@@ -16524,8 +16877,8 @@ var ts;
var signature = getSignatureFromDeclaration(signatureDeclaration);
getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags);
}
- function invokeEmitter(targetSourceFile) {
- var resolver = {
+ function createResolver() {
+ return {
getProgram: function () { return program; },
getLocalNameOfContainer: getLocalNameOfContainer,
getExpressionNamePrefix: getExpressionNamePrefix,
@@ -16541,9 +16894,12 @@ var ts;
writeTypeAtLocation: writeTypeAtLocation,
writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration,
isSymbolAccessible: isSymbolAccessible,
- isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile,
+ isEntityNameVisible: isEntityNameVisible,
getConstantValue: getConstantValue
};
+ }
+ function invokeEmitter(targetSourceFile) {
+ var resolver = createResolver();
checkProgram();
return ts.emitFiles(resolver, targetSourceFile);
}
@@ -17078,7 +17434,7 @@ var ts;
}
else {
var emitStart = new Date().getTime();
- var emitOutput = checker.invokeEmitter();
+ var emitOutput = checker.emitFiles();
var emitErrors = emitOutput.diagnostics;
exitStatus = emitOutput.emitResultStatus;
var reportStart = new Date().getTime();
diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js
index 367a79bd47..8c36e0b88f 100644
--- a/bin/typescriptServices.js
+++ b/bin/typescriptServices.js
@@ -418,6 +418,10 @@ var ts;
return normalizedPathComponents(path, rootLength);
}
ts.getNormalizedPathComponents = getNormalizedPathComponents;
+ function getNormalizedAbsolutePath(filename, currentDirectory) {
+ return getNormalizedPathFromPathComponents(getNormalizedPathComponents(filename, currentDirectory));
+ }
+ ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
function getNormalizedPathFromPathComponents(pathComponents) {
if (pathComponents && pathComponents.length) {
return pathComponents[0] + pathComponents.slice(1).join(ts.directorySeparator);
@@ -713,6 +717,7 @@ var ts;
Unterminated_template_literal: { code: 1160, category: 1 /* Error */, key: "Unterminated template literal." },
Unterminated_regular_expression_literal: { code: 1161, category: 1 /* Error */, key: "Unterminated regular expression literal." },
An_object_member_cannot_be_declared_optional: { code: 1162, category: 1 /* Error */, key: "An object member cannot be declared optional." },
+ yield_expression_must_be_contained_within_a_generator_declaration: { code: 1163, category: 1 /* Error */, key: "'yield' expression must be contained_within a generator declaration." },
Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." },
@@ -863,27 +868,16 @@ var ts;
Type_alias_name_cannot_be_0: { code: 2457, category: 1 /* Error */, key: "Type alias name cannot be '{0}'" },
An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: 1 /* Error */, key: "An AMD module cannot have multiple name assignments." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." },
- Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
- Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4003, category: 1 /* Error */, key: "Type parameter '{0}' of exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: 1 /* Error */, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4005, category: 1 /* Error */, key: "Type parameter '{0}' of constructor signature from exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4006, category: 1 /* Error */, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4007, category: 1 /* Error */, key: "Type parameter '{0}' of call signature from exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4008, category: 1 /* Error */, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4009, category: 1 /* Error */, key: "Type parameter '{0}' of public static method from exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 4010, category: 1 /* Error */, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." },
- Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4011, category: 1 /* Error */, key: "Type parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1: { code: 4012, category: 1 /* Error */, key: "Type parameter '{0}' of public method from exported class has or is using private name '{1}'." },
- Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4013, category: 1 /* Error */, key: "Type parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1: { code: 4014, category: 1 /* Error */, key: "Type parameter '{0}' of method from exported interface has or is using private name '{1}'." },
- Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4015, category: 1 /* Error */, key: "Type parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
Type_parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4016, category: 1 /* Error */, key: "Type parameter '{0}' of exported function has or is using private name '{1}'." },
- Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2: { code: 4017, category: 1 /* Error */, key: "Implements clause of exported class '{0}' has or is using name '{1}' from private module '{2}'." },
- Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2: { code: 4018, category: 1 /* Error */, key: "Extends clause of exported class '{0}' has or is using name '{1}' from private module '{2}'." },
Implements_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4019, category: 1 /* Error */, key: "Implements clause of exported class '{0}' has or is using private name '{1}'." },
Extends_clause_of_exported_class_0_has_or_is_using_private_name_1: { code: 4020, category: 1 /* Error */, key: "Extends clause of exported class '{0}' has or is using private name '{1}'." },
- Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2: { code: 4021, category: 1 /* Error */, key: "Extends clause of exported interface '{0}' has or is using name '{1}' from private module '{2}'." },
Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1: { code: 4022, category: 1 /* Error */, key: "Extends clause of exported interface '{0}' has or is using private name '{1}'." },
Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4023, category: 1 /* Error */, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." },
Exported_variable_0_has_or_is_using_name_1_from_private_module_2: { code: 4024, category: 1 /* Error */, key: "Exported variable '{0}' has or is using name '{1}' from private module '{2}'." },
@@ -941,8 +935,6 @@ var ts;
Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4076, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." },
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: 1 /* Error */, key: "Parameter '{0}' of exported function has or is using private name '{1}'." },
- Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4079, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from external module {2} but cannot be named." },
- Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." },
Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using private name '{1}'." },
Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: 1 /* Error */, key: "Enum declarations must all be const or non-const." },
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: 1 /* Error */, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true },
@@ -1013,7 +1005,9 @@ var ts;
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: 1 /* Error */, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
_0_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: 7023, category: 1 /* Error */, key: "'{0}' 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." },
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: 1 /* 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." },
- You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." }
+ You_cannot_rename_this_element: { code: 8000, category: 1 /* Error */, key: "You cannot rename this element." },
+ yield_expressions_are_not_currently_supported: { code: 9000, category: 1 /* Error */, key: "'yield' expressions are not currently supported." },
+ generators_are_not_currently_supported: { code: 9001, category: 1 /* Error */, key: "'generators' are not currently supported." }
};
})(ts || (ts = {}));
var ts;
@@ -2011,7 +2005,7 @@ var ts;
})(ts || (ts = {}));
var ts;
(function (ts) {
- var nodeConstructors = new Array(199 /* Count */);
+ var nodeConstructors = new Array(200 /* Count */);
function getNodeConstructor(kind) {
return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind));
}
@@ -2024,7 +2018,7 @@ var ts;
return node;
}
function getSourceFileOfNode(node) {
- while (node && node.kind !== 196 /* SourceFile */)
+ while (node && node.kind !== 197 /* SourceFile */)
node = node.parent;
return node;
}
@@ -2046,13 +2040,17 @@ var ts;
return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
}
ts.getTokenPosOfNode = getTokenPosOfNode;
+ function getSourceTextOfNodeFromSourceFile(sourceFile, node) {
+ var text = sourceFile.text;
+ return text.substring(ts.skipTrivia(text, node.pos), node.end);
+ }
+ ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
function getTextOfNodeFromSourceText(sourceText, node) {
return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end);
}
ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
function getTextOfNode(node) {
- var text = getSourceFileOfNode(node).text;
- return text.substring(ts.skipTrivia(text, node.pos), node.end);
+ return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node);
}
ts.getTextOfNode = getTextOfNode;
function escapeIdentifier(identifier) {
@@ -2086,12 +2084,12 @@ var ts;
function getErrorSpanForNode(node) {
var errorSpan;
switch (node.kind) {
- case 184 /* VariableDeclaration */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 190 /* EnumDeclaration */:
- case 195 /* EnumMember */:
+ case 185 /* VariableDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 196 /* EnumMember */:
errorSpan = node.name;
break;
}
@@ -2107,11 +2105,19 @@ var ts;
}
ts.isDeclarationFile = isDeclarationFile;
function isConstEnumDeclaration(node) {
- return (node.flags & 4096 /* Const */) !== 0;
+ return node.kind === 191 /* EnumDeclaration */ && isConst(node);
}
ts.isConstEnumDeclaration = isConstEnumDeclaration;
+ function isConst(node) {
+ return !!(node.flags & 4096 /* Const */);
+ }
+ ts.isConst = isConst;
+ function isLet(node) {
+ return !!(node.flags & 2048 /* Let */);
+ }
+ ts.isLet = isLet;
function isPrologueDirective(node) {
- return node.kind === 164 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */;
+ return node.kind === 165 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */;
}
ts.isPrologueDirective = isPrologueDirective;
function isEvalOrArgumentsIdentifier(node) {
@@ -2180,7 +2186,7 @@ var ts;
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body);
case 132 /* TypeReference */:
@@ -2221,64 +2227,64 @@ var ts;
return child(node.left) || child(node.right);
case 157 /* ConditionalExpression */:
return child(node.condition) || child(node.whenTrue) || child(node.whenFalse);
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 182 /* FinallyBlock */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
- case 196 /* SourceFile */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 183 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
+ case 197 /* SourceFile */:
return children(node.statements);
- case 162 /* VariableStatement */:
+ case 163 /* VariableStatement */:
return children(node.declarations);
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return child(node.expression);
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
return child(node.expression) || child(node.thenStatement) || child(node.elseStatement);
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
return child(node.statement) || child(node.expression);
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return child(node.expression) || child(node.statement);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement);
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return children(node.declarations) || child(node.variable) || child(node.expression) || child(node.statement);
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
return child(node.label);
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return child(node.expression);
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
return child(node.expression) || child(node.statement);
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return child(node.expression) || children(node.clauses);
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
return child(node.expression) || children(node.statements);
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return child(node.label) || child(node.statement);
- case 178 /* ThrowStatement */:
+ case 179 /* ThrowStatement */:
return child(node.expression);
- case 179 /* TryStatement */:
+ case 180 /* TryStatement */:
return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock);
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
return child(node.variable) || children(node.statements);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return child(node.name) || child(node.type) || child(node.initializer);
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members);
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members);
- case 189 /* TypeAliasDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
return child(node.name) || child(node.type);
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
return child(node.name) || children(node.members);
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
return child(node.name) || child(node.initializer);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return child(node.name) || child(node.body);
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return child(node.name) || child(node.entityName) || child(node.externalModuleName);
- case 194 /* ExportAssignment */:
+ case 195 /* ExportAssignment */:
return child(node.exportName);
case 158 /* TemplateExpression */:
return child(node.head) || children(node.templateSpans);
@@ -2291,24 +2297,24 @@ var ts;
return traverse(body);
function traverse(node) {
switch (node.kind) {
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return visitor(node);
- case 161 /* Block */:
- case 186 /* FunctionBlock */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
- case 177 /* LabeledStatement */:
- case 179 /* TryStatement */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
+ case 162 /* Block */:
+ case 187 /* FunctionBlock */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
+ case 178 /* LabeledStatement */:
+ case 180 /* TryStatement */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
return forEachChild(node, traverse);
}
}
@@ -2318,7 +2324,7 @@ var ts;
if (node) {
switch (node.kind) {
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
case 125 /* Method */:
case 127 /* GetAccessor */:
@@ -2350,16 +2356,16 @@ var ts;
if (!includeArrowFunctions) {
continue;
}
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
case 124 /* Property */:
case 125 /* Method */:
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 190 /* EnumDeclaration */:
- case 196 /* SourceFile */:
+ case 191 /* EnumDeclaration */:
+ case 197 /* SourceFile */:
return node;
}
}
@@ -2382,6 +2388,13 @@ var ts;
}
}
ts.getSuperContainer = getSuperContainer;
+ function getInvokedExpression(node) {
+ if (node.kind === 149 /* TaggedTemplateExpression */) {
+ return node.tag;
+ }
+ return node.func;
+ }
+ ts.getInvokedExpression = getInvokedExpression;
function isExpression(node) {
switch (node.kind) {
case 91 /* ThisKeyword */:
@@ -2407,7 +2420,7 @@ var ts;
case 157 /* ConditionalExpression */:
case 158 /* TemplateExpression */:
case 9 /* NoSubstitutionTemplateLiteral */:
- case 160 /* OmittedExpression */:
+ case 161 /* OmittedExpression */:
return true;
case 121 /* QualifiedName */:
while (node.parent.kind === 121 /* QualifiedName */)
@@ -2421,26 +2434,26 @@ var ts;
case 7 /* StringLiteral */:
var parent = node.parent;
switch (parent.kind) {
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 123 /* Parameter */:
case 124 /* Property */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 143 /* PropertyAssignment */:
return parent.initializer === node;
- case 164 /* ExpressionStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 172 /* ReturnStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 178 /* ThrowStatement */:
- case 174 /* SwitchStatement */:
+ case 165 /* ExpressionStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 173 /* ReturnStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 179 /* ThrowStatement */:
+ case 175 /* SwitchStatement */:
return parent.expression === node;
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return parent.initializer === node || parent.condition === node || parent.iterator === node;
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return parent.variable === node || parent.expression === node;
case 150 /* TypeAssertion */:
return node === parent.operand;
@@ -2484,21 +2497,22 @@ var ts;
switch (node.kind) {
case 122 /* TypeParameter */:
case 123 /* Parameter */:
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 124 /* Property */:
case 143 /* PropertyAssignment */:
case 144 /* ShorthandPropertyAssignment */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 125 /* Method */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 190 /* EnumDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 126 /* Constructor */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 194 /* ImportDeclaration */:
return true;
}
return false;
@@ -2506,24 +2520,24 @@ var ts;
ts.isDeclaration = isDeclaration;
function isStatement(n) {
switch (n.kind) {
- case 171 /* BreakStatement */:
- case 170 /* ContinueStatement */:
- case 183 /* DebuggerStatement */:
- case 166 /* DoStatement */:
- case 164 /* ExpressionStatement */:
- case 163 /* EmptyStatement */:
- case 169 /* ForInStatement */:
- case 168 /* ForStatement */:
- case 165 /* IfStatement */:
- case 177 /* LabeledStatement */:
- case 172 /* ReturnStatement */:
- case 174 /* SwitchStatement */:
+ case 172 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 184 /* DebuggerStatement */:
+ case 167 /* DoStatement */:
+ case 165 /* ExpressionStatement */:
+ case 164 /* EmptyStatement */:
+ case 170 /* ForInStatement */:
+ case 169 /* ForStatement */:
+ case 166 /* IfStatement */:
+ case 178 /* LabeledStatement */:
+ case 173 /* ReturnStatement */:
+ case 175 /* SwitchStatement */:
case 92 /* ThrowKeyword */:
- case 179 /* TryStatement */:
- case 162 /* VariableStatement */:
- case 167 /* WhileStatement */:
- case 173 /* WithStatement */:
- case 194 /* ExportAssignment */:
+ case 180 /* TryStatement */:
+ case 163 /* VariableStatement */:
+ case 168 /* WhileStatement */:
+ case 174 /* WithStatement */:
+ case 195 /* ExportAssignment */:
return true;
default:
return false;
@@ -2538,24 +2552,32 @@ var ts;
if (isDeclaration(parent) || parent.kind === 152 /* FunctionExpression */) {
return parent.name === name;
}
- if (parent.kind === 181 /* CatchBlock */) {
+ if (parent.kind === 182 /* CatchBlock */) {
return parent.variable === name;
}
return false;
}
ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName;
+ function tryResolveScriptReference(program, sourceFile, reference) {
+ if (!program.getCompilerOptions().noResolve) {
+ var referenceFileName = ts.isRootedDiskPath(reference.filename) ? reference.filename : ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename);
+ referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, program.getCompilerHost().getCurrentDirectory());
+ return program.getSourceFile(referenceFileName);
+ }
+ }
+ ts.tryResolveScriptReference = tryResolveScriptReference;
function getAncestor(node, kind) {
switch (kind) {
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
while (node) {
switch (node.kind) {
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return node;
- case 190 /* EnumDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 194 /* ImportDeclaration */:
return undefined;
default:
node = node.parent;
@@ -2640,11 +2662,14 @@ var ts;
}
ts.isTrivia = isTrivia;
function isUnterminatedTemplateEnd(node) {
- ts.Debug.assert(node.kind === 9 /* NoSubstitutionTemplateLiteral */ || node.kind === 12 /* TemplateTail */);
+ ts.Debug.assert(isTemplateLiteralKind(node.kind));
var sourceText = getSourceFileOfNode(node).text;
if (node.end !== sourceText.length) {
return false;
}
+ if (node.kind !== 12 /* TemplateTail */ && node.kind !== 9 /* NoSubstitutionTemplateLiteral */) {
+ return false;
+ }
return sourceText.charCodeAt(node.end - 1) !== 96 /* backtick */ || node.text.length === 0;
}
ts.isUnterminatedTemplateEnd = isUnterminatedTemplateEnd;
@@ -2683,8 +2708,76 @@ var ts;
var identifierCount = 0;
var nodeCount = 0;
var lineStarts;
- var isInStrictMode = false;
var lookAheadMode = 0 /* NotLookingAhead */;
+ var contextFlags = 0;
+ function setContextFlag(val, flag) {
+ if (val) {
+ contextFlags |= flag;
+ }
+ else {
+ contextFlags &= ~flag;
+ }
+ }
+ function setStrictModeContext(val) {
+ setContextFlag(val, 1 /* StrictMode */);
+ }
+ function setDisallowInContext(val) {
+ setContextFlag(val, 2 /* DisallowIn */);
+ }
+ function setYieldContext(val) {
+ setContextFlag(val, 4 /* Yield */);
+ }
+ function setGeneratorParameterContext(val) {
+ setContextFlag(val, 8 /* GeneratorParameter */);
+ }
+ function allowInAnd(func) {
+ if (contextFlags & 2 /* DisallowIn */) {
+ setDisallowInContext(false);
+ var result = func();
+ setDisallowInContext(true);
+ return result;
+ }
+ return func();
+ }
+ function disallowInAnd(func) {
+ if (contextFlags & 2 /* DisallowIn */) {
+ return func();
+ }
+ setDisallowInContext(true);
+ var result = func();
+ setDisallowInContext(false);
+ return result;
+ }
+ function doInYieldContext(func) {
+ if (contextFlags & 4 /* Yield */) {
+ return func();
+ }
+ setYieldContext(true);
+ var result = func();
+ setYieldContext(false);
+ return result;
+ }
+ function doOutsideOfYieldContext(func) {
+ if (contextFlags & 4 /* Yield */) {
+ setYieldContext(false);
+ var result = func();
+ setYieldContext(true);
+ return result;
+ }
+ return func();
+ }
+ function inYieldContext() {
+ return (contextFlags & 4 /* Yield */) !== 0;
+ }
+ function inStrictModeContext() {
+ return (contextFlags & 1 /* StrictMode */) !== 0;
+ }
+ function inGeneratorParameterContext() {
+ return (contextFlags & 8 /* GeneratorParameter */) !== 0;
+ }
+ function inDisallowInContext() {
+ return (contextFlags & 2 /* DisallowIn */) !== 0;
+ }
function getLineStarts() {
return lineStarts || (lineStarts = ts.computeLineStarts(sourceText));
}
@@ -2768,7 +2861,13 @@ var ts;
return scanner.tryScan(function () { return lookAheadHelper(callback, false); });
}
function isIdentifier() {
- return token === 63 /* Identifier */ || (isInStrictMode ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */);
+ if (token === 63 /* Identifier */) {
+ return true;
+ }
+ if (token === 108 /* YieldKeyword */ && inYieldContext()) {
+ return false;
+ }
+ return inStrictModeContext() ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */;
}
function parseExpected(t) {
if (token === t) {
@@ -2785,6 +2884,14 @@ var ts;
}
return false;
}
+ function parseOptionalToken(t) {
+ if (token === t) {
+ var node = createNode(t);
+ nextToken();
+ return finishNode(node);
+ }
+ return undefined;
+ }
function canParseSemicolon() {
if (token === 21 /* SemicolonToken */) {
return true;
@@ -2813,8 +2920,8 @@ var ts;
}
function finishNode(node) {
node.end = scanner.getStartPos();
- if (isInStrictMode) {
- node.flags |= 8192 /* ParsedInStrictMode */;
+ if (contextFlags) {
+ node.parserContextFlags = contextFlags;
}
return node;
}
@@ -2862,7 +2969,7 @@ var ts;
function parseAnyContextualModifier() {
return isModifier(token) && tryParse(function () {
nextToken();
- return token === 17 /* OpenBracketToken */ || isPropertyName();
+ return token === 17 /* OpenBracketToken */ || token === 34 /* AsteriskToken */ || isPropertyName();
});
}
function isListElement(kind, inErrorRecovery) {
@@ -2880,8 +2987,9 @@ var ts;
case 6 /* ClassMembers */:
return lookAhead(isClassMemberStart);
case 7 /* EnumMembers */:
- case 11 /* ObjectLiteralMembers */:
return isPropertyName();
+ case 11 /* ObjectLiteralMembers */:
+ return token === 34 /* AsteriskToken */ || isPropertyName();
case 8 /* BaseTypeReferences */:
return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); }));
case 9 /* VariableDeclarations */:
@@ -2958,15 +3066,15 @@ var ts;
parsingContext |= 1 << kind;
var result = [];
result.pos = getNodePos();
- var saveIsInStrictMode = isInStrictMode;
+ var savedStrictModeContext = inStrictModeContext();
while (!isListTerminator(kind)) {
if (isListElement(kind, false)) {
var element = parseElement();
result.push(element);
- if (!isInStrictMode && checkForStrictMode) {
+ if (!inStrictModeContext() && checkForStrictMode) {
if (isPrologueDirective(element)) {
if (isUseStrictPrologueDirective(element)) {
- isInStrictMode = true;
+ setStrictModeContext(true);
checkForStrictMode = false;
}
}
@@ -2983,7 +3091,7 @@ var ts;
nextToken();
}
}
- isInStrictMode = saveIsInStrictMode;
+ setStrictModeContext(savedStrictModeContext);
result.end = getNodeEnd();
parsingContext = saveParsingContext;
return result;
@@ -3032,16 +3140,10 @@ var ts;
result.end = pos;
return result;
}
- function createNodeArray(node) {
- var result = [node];
- result.pos = node.pos;
- result.end = node.end;
- return result;
- }
- function parseBracketedList(kind, parseElement, startToken, endToken) {
- if (parseExpected(startToken)) {
+ function parseBracketedList(kind, parseElement, open, close) {
+ if (parseExpected(open)) {
var result = parseDelimitedList(kind, parseElement);
- parseExpected(endToken);
+ parseExpected(close);
return result;
}
return createMissingList();
@@ -3076,7 +3178,7 @@ var ts;
}
function parseTemplateSpan() {
var span = createNode(159 /* TemplateSpan */);
- span.expression = parseExpression(false);
+ span.expression = allowInAnd(parseExpression);
var literal;
if (token === 14 /* CloseBraceToken */) {
reScanTemplateToken();
@@ -3098,7 +3200,7 @@ var ts;
nextToken();
finishNode(node);
if (node.kind === 6 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) {
- node.flags |= 16384 /* OctalLiteral */;
+ node.flags |= 8192 /* OctalLiteral */;
}
return node;
}
@@ -3153,15 +3255,14 @@ var ts;
node.modifiers = modifiers;
}
}
- function parseParameter(flags) {
- if (flags === void 0) { flags = 0; }
+ function parseParameter() {
var node = createNode(123 /* Parameter */);
- var modifiers = parseModifiers(3 /* Parameters */);
+ var modifiers = parseModifiers();
setModifiers(node, modifiers);
if (parseOptional(20 /* DotDotDotToken */)) {
node.flags |= 8 /* Rest */;
}
- node.name = parseIdentifier();
+ node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifier) : parseIdentifier();
if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) {
nextToken();
}
@@ -3169,68 +3270,82 @@ var ts;
node.flags |= 4 /* QuestionMark */;
}
node.type = parseParameterType();
- node.initializer = parseInitializer(true);
+ node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer();
return finishNode(node);
}
- function parseSignature(kind, returnToken, returnTokenRequired) {
+ function parseParameterInitializer() {
+ return parseInitializer(true);
+ }
+ function parseSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext) {
+ var signature = {};
+ fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature);
+ return signature;
+ }
+ function fillSignature(kind, returnToken, returnTokenRequired, yieldAndGeneratorParameterContext, signature) {
if (kind === 130 /* ConstructSignature */) {
parseExpected(86 /* NewKeyword */);
}
- var typeParameters = parseTypeParameters();
- var parameters = parseParameterList(15 /* OpenParenToken */, 16 /* CloseParenToken */);
- var type;
+ signature.typeParameters = parseTypeParameters();
+ signature.parameters = parseParameterList(yieldAndGeneratorParameterContext);
if (returnTokenRequired) {
parseExpected(returnToken);
- type = parseType();
+ signature.type = parseType();
}
else if (parseOptional(returnToken)) {
- type = parseType();
+ signature.type = parseType();
}
- return {
- typeParameters: typeParameters,
- parameters: parameters,
- type: type
- };
}
- function parseParameterList(startDelimiter, endDelimiter) {
- return parseBracketedList(13 /* Parameters */, parseParameter, startDelimiter, endDelimiter);
+ function parseParameterList(yieldAndGeneratorParameterContext) {
+ if (parseExpected(15 /* OpenParenToken */)) {
+ var savedYieldContext = inYieldContext();
+ var savedGeneratorParameterContext = inGeneratorParameterContext();
+ setYieldContext(yieldAndGeneratorParameterContext);
+ setGeneratorParameterContext(yieldAndGeneratorParameterContext);
+ var result = parseDelimitedList(13 /* Parameters */, parseParameter);
+ parseExpected(16 /* CloseParenToken */);
+ setYieldContext(savedYieldContext);
+ setGeneratorParameterContext(savedGeneratorParameterContext);
+ return result;
+ }
+ return createMissingList();
}
function parseSignatureMember(kind, returnToken) {
var node = createNode(kind);
- var sig = parseSignature(kind, returnToken, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
+ fillSignature(kind, returnToken, false, false, node);
parseSemicolon();
return finishNode(node);
}
- function parseIndexSignatureMember(modifiers, pos) {
- var node = createNode(131 /* IndexSignature */, pos);
+ function parseIndexSignatureMember(fullStart, modifiers) {
+ var node = createNode(131 /* IndexSignature */, fullStart);
setModifiers(node, modifiers);
- node.parameters = parseParameterList(17 /* OpenBracketToken */, 18 /* CloseBracketToken */);
+ node.parameters = parseBracketedList(13 /* Parameters */, parseParameter, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */);
node.type = parseTypeAnnotation();
parseSemicolon();
return finishNode(node);
}
function parsePropertyOrMethod() {
- var node = createNode(0 /* Unknown */);
- node.name = parsePropertyName();
+ var fullStart = scanner.getStartPos();
+ var name = parsePropertyName();
+ var flags = 0;
if (parseOptional(49 /* QuestionToken */)) {
- node.flags |= 4 /* QuestionMark */;
+ flags = 4 /* QuestionMark */;
}
if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
- node.kind = 125 /* Method */;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
+ var method = createNode(125 /* Method */, fullStart);
+ method.name = name;
+ method.flags = flags;
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, method);
+ parseSemicolon();
+ return finishNode(method);
}
else {
- node.kind = 124 /* Property */;
- node.type = parseTypeAnnotation();
+ var property = createNode(124 /* Property */, fullStart);
+ property.name = name;
+ property.flags = flags;
+ property.type = parseTypeAnnotation();
+ parseSemicolon();
+ return finishNode(property);
}
- parseSemicolon();
- return finishNode(node);
}
function isStartOfTypeMember() {
switch (token) {
@@ -3248,7 +3363,7 @@ var ts;
case 23 /* LessThanToken */:
return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */);
case 17 /* OpenBracketToken */:
- return parseIndexSignatureMember(undefined);
+ return parseIndexSignatureMember(scanner.getStartPos(), undefined);
case 86 /* NewKeyword */:
if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) {
return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */);
@@ -3264,14 +3379,19 @@ var ts;
}
function parseTypeLiteral() {
var node = createNode(136 /* TypeLiteral */);
+ node.members = parseObjectType();
+ return finishNode(node);
+ }
+ function parseObjectType() {
+ var members;
if (parseExpected(13 /* OpenBraceToken */)) {
- node.members = parseList(5 /* TypeMembers */, false, parseTypeMember);
+ members = parseList(5 /* TypeMembers */, false, parseTypeMember);
parseExpected(14 /* CloseBraceToken */);
}
else {
- node.members = createMissingList();
+ members = createMissingList();
}
- return finishNode(node);
+ return members;
}
function parseTupleType() {
var node = createNode(138 /* TupleType */);
@@ -3286,13 +3406,9 @@ var ts;
return finishNode(node);
}
function parseFunctionType(typeKind) {
- var member = createNode(typeKind);
- var sig = parseSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true);
- member.typeParameters = sig.typeParameters;
- member.parameters = sig.parameters;
- member.type = sig.type;
- finishNode(member);
- return member;
+ var node = createNode(typeKind);
+ fillSignature(typeKind === 133 /* FunctionType */ ? 129 /* CallSignature */ : 130 /* ConstructSignature */, 31 /* EqualsGreaterThanToken */, true, false, node);
+ return finishNode(node);
}
function parseKeywordAndNoDot() {
var node = parseTokenNode();
@@ -3392,6 +3508,16 @@ var ts;
});
}
function parseType() {
+ var savedYieldContext = inYieldContext();
+ var savedGeneratorParameterContext = inGeneratorParameterContext();
+ setYieldContext(false);
+ setGeneratorParameterContext(false);
+ var result = parseTypeWorker();
+ setYieldContext(savedYieldContext);
+ setGeneratorParameterContext(savedGeneratorParameterContext);
+ return result;
+ }
+ function parseTypeWorker() {
if (isStartOfFunctionType()) {
return parseFunctionType(133 /* FunctionType */);
}
@@ -3432,6 +3558,7 @@ var ts;
case 38 /* MinusMinusToken */:
case 23 /* LessThanToken */:
case 63 /* Identifier */:
+ case 108 /* YieldKeyword */:
return true;
default:
return isIdentifier();
@@ -3440,38 +3567,68 @@ var ts;
function isStartOfExpressionStatement() {
return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression();
}
- function parseExpression(noIn) {
- var expr = parseAssignmentExpression(noIn);
+ function parseExpression() {
+ var expr = parseAssignmentExpression();
while (parseOptional(22 /* CommaToken */)) {
- expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression(noIn));
+ expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression());
}
return expr;
}
- function parseInitializer(inParameter, noIn) {
+ function parseInitializer(inParameter) {
if (token !== 51 /* EqualsToken */) {
if (scanner.hasPrecedingLineBreak() || (inParameter && token === 13 /* OpenBraceToken */) || !isStartOfExpression()) {
return undefined;
}
}
parseExpected(51 /* EqualsToken */);
- return parseAssignmentExpression(noIn);
+ return parseAssignmentExpression();
}
- function parseAssignmentExpression(noIn) {
+ function parseAssignmentExpression() {
+ if (isYieldExpression()) {
+ return parseYieldExpression();
+ }
var arrowExpression = tryParseParenthesizedArrowFunctionExpression();
if (arrowExpression) {
return arrowExpression;
}
- var expr = parseConditionalExpression(noIn);
+ var expr = parseConditionalExpression();
if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) {
return parseSimpleArrowFunctionExpression(expr);
}
if (isLeftHandSideExpression(expr) && isAssignmentOperator(token)) {
var operator = token;
nextToken();
- return makeBinaryExpression(expr, operator, parseAssignmentExpression(noIn));
+ return makeBinaryExpression(expr, operator, parseAssignmentExpression());
}
return expr;
}
+ function isYieldExpression() {
+ if (token === 108 /* YieldKeyword */) {
+ if (inYieldContext()) {
+ return true;
+ }
+ if (inStrictModeContext()) {
+ return true;
+ }
+ return lookAhead(function () {
+ nextToken();
+ return !scanner.hasPrecedingLineBreak() && isIdentifier();
+ });
+ }
+ return false;
+ }
+ function parseYieldExpression() {
+ var node = createNode(160 /* YieldExpression */);
+ nextToken();
+ if (!scanner.hasPrecedingLineBreak() && (token === 34 /* AsteriskToken */ || isStartOfExpression())) {
+ node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
+ node.expression = parseAssignmentExpression();
+ return finishNode(node);
+ }
+ else {
+ return finishNode(node);
+ }
+ }
function parseSimpleArrowFunctionExpression(identifier) {
ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
parseExpected(31 /* EqualsGreaterThanToken */);
@@ -3483,7 +3640,7 @@ var ts;
parameters.pos = parameter.pos;
parameters.end = parameter.end;
var signature = { parameters: parameters };
- return parseArrowExpressionTail(identifier.pos, signature, false);
+ return parseArrowExpressionTail(identifier.pos, signature);
}
function tryParseParenthesizedArrowFunctionExpression() {
var triState = isParenthesizedArrowFunctionExpression();
@@ -3492,18 +3649,18 @@ var ts;
}
var pos = getNodePos();
if (triState === 1 /* True */) {
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false);
if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) {
- return parseArrowExpressionTail(pos, sig, false);
+ return parseArrowExpressionTail(pos, sig);
}
else {
- return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, sig, createMissingNode());
+ return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, createMissingNode());
}
}
var sig = tryParseSignatureIfArrowOrBraceFollows();
if (sig) {
parseExpected(31 /* EqualsGreaterThanToken */);
- return parseArrowExpressionTail(pos, sig, false);
+ return parseArrowExpressionTail(pos, sig);
}
else {
return undefined;
@@ -3553,49 +3710,46 @@ var ts;
}
function tryParseSignatureIfArrowOrBraceFollows() {
return tryParse(function () {
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false);
if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) {
return sig;
}
return undefined;
});
}
- function parseArrowExpressionTail(pos, sig, noIn) {
+ function parseArrowExpressionTail(pos, sig) {
var body;
if (token === 13 /* OpenBraceToken */) {
- body = parseFunctionBlock(false);
+ body = parseFunctionBlock(false, false);
}
else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) {
- body = parseFunctionBlock(true);
+ body = parseFunctionBlock(false, true);
}
else {
- body = parseAssignmentExpression(noIn);
+ body = parseAssignmentExpression();
}
- return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, sig, body);
+ return makeFunctionExpression(153 /* ArrowFunction */, pos, undefined, undefined, sig, body);
}
- function parseConditionalExpression(noIn) {
- var expr = parseBinaryExpression(noIn);
+ function parseConditionalExpression() {
+ var expr = parseBinaryOperators(parseUnaryExpression(), 0);
while (parseOptional(49 /* QuestionToken */)) {
var node = createNode(157 /* ConditionalExpression */, expr.pos);
node.condition = expr;
- node.whenTrue = parseAssignmentExpression(false);
+ node.whenTrue = allowInAnd(parseAssignmentExpression);
parseExpected(50 /* ColonToken */);
- node.whenFalse = parseAssignmentExpression(noIn);
+ node.whenFalse = parseAssignmentExpression();
expr = finishNode(node);
}
return expr;
}
- function parseBinaryExpression(noIn) {
- return parseBinaryOperators(parseUnaryExpression(), 0, noIn);
- }
- function parseBinaryOperators(expr, minPrecedence, noIn) {
+ function parseBinaryOperators(expr, minPrecedence) {
while (true) {
reScanGreaterToken();
var precedence = getOperatorPrecedence();
- if (precedence && precedence > minPrecedence && (!noIn || token !== 84 /* InKeyword */)) {
+ if (precedence && precedence > minPrecedence && (!inDisallowInContext() || token !== 84 /* InKeyword */)) {
var operator = token;
nextToken();
- expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence, noIn));
+ expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence));
continue;
}
return expr;
@@ -3720,7 +3874,7 @@ var ts;
indexedAccess.index = createMissingNode();
}
else {
- indexedAccess.index = parseExpression();
+ indexedAccess.index = allowInAnd(parseExpression);
if (indexedAccess.index.kind === 7 /* StringLiteral */ || indexedAccess.index.kind === 6 /* NumericLiteral */) {
var literal = indexedAccess.index;
literal.text = internIdentifier(literal.text);
@@ -3810,18 +3964,18 @@ var ts;
function parseParenExpression() {
var node = createNode(151 /* ParenExpression */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
return finishNode(node);
}
function parseAssignmentExpressionOrOmittedExpression() {
- return token === 22 /* CommaToken */ ? createNode(160 /* OmittedExpression */) : parseAssignmentExpression();
+ return token === 22 /* CommaToken */ ? createNode(161 /* OmittedExpression */) : parseAssignmentExpression();
}
function parseArrayLiteralElement() {
return parseAssignmentExpressionOrOmittedExpression();
}
function parseArgumentExpression() {
- return parseAssignmentExpressionOrOmittedExpression();
+ return allowInAnd(parseAssignmentExpressionOrOmittedExpression);
}
function parseArrayLiteral() {
var node = createNode(141 /* ArrayLiteral */);
@@ -3834,16 +3988,17 @@ var ts;
}
function parsePropertyAssignment() {
var nodePos = scanner.getStartPos();
+ var asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
var tokenIsIdentifier = isIdentifier();
var nameToken = token;
var propertyName = parsePropertyName();
var node;
- if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
+ if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
node = createNode(143 /* PropertyAssignment */, nodePos);
node.name = propertyName;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- var body = parseFunctionBlock(false);
- node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, undefined, sig, body);
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken);
+ var body = parseFunctionBlock(!!asteriskToken, false);
+ node.initializer = makeFunctionExpression(152 /* FunctionExpression */, node.pos, asteriskToken, undefined, sig, body);
return finishNode(node);
}
var flags = 0;
@@ -3859,7 +4014,7 @@ var ts;
node = createNode(143 /* PropertyAssignment */, nodePos);
node.name = propertyName;
parseExpected(50 /* ColonToken */);
- node.initializer = parseAssignmentExpression(false);
+ node.initializer = allowInAnd(parseAssignmentExpression);
}
node.flags = flags;
return finishNode(node);
@@ -3886,13 +4041,18 @@ var ts;
function parseFunctionExpression() {
var pos = getNodePos();
parseExpected(81 /* FunctionKeyword */);
- var name = isIdentifier() ? parseIdentifier() : undefined;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- var body = parseFunctionBlock(false);
- return makeFunctionExpression(152 /* FunctionExpression */, pos, name, sig, body);
+ var asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
+ var name = asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier();
+ var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken);
+ var body = parseFunctionBlock(!!asteriskToken, false);
+ return makeFunctionExpression(152 /* FunctionExpression */, pos, asteriskToken, name, sig, body);
}
- function makeFunctionExpression(kind, pos, name, sig, body) {
+ function parseOptionalIdentifier() {
+ return isIdentifier() ? parseIdentifier() : undefined;
+ }
+ function makeFunctionExpression(kind, pos, asteriskToken, name, sig, body) {
var node = createNode(kind, pos);
+ node.asteriskToken = asteriskToken;
node.name = name;
node.typeParameters = sig.typeParameters;
node.parameters = sig.parameters;
@@ -3911,7 +4071,7 @@ var ts;
return finishNode(node);
}
function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) {
- var node = createNode(161 /* Block */);
+ var node = createNode(162 /* Block */);
if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) {
node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatement);
parseExpected(14 /* CloseBraceToken */);
@@ -3921,42 +4081,45 @@ var ts;
}
return finishNode(node);
}
- function parseFunctionBlock(ignoreMissingOpenBrace) {
+ function parseFunctionBlock(allowYield, ignoreMissingOpenBrace) {
+ var savedYieldContext = inYieldContext();
+ setYieldContext(allowYield);
var block = parseBlock(ignoreMissingOpenBrace, true);
- block.kind = 186 /* FunctionBlock */;
+ block.kind = 187 /* FunctionBlock */;
+ setYieldContext(savedYieldContext);
return block;
}
function parseEmptyStatement() {
- var node = createNode(163 /* EmptyStatement */);
+ var node = createNode(164 /* EmptyStatement */);
parseExpected(21 /* SemicolonToken */);
return finishNode(node);
}
function parseIfStatement() {
- var node = createNode(165 /* IfStatement */);
+ var node = createNode(166 /* IfStatement */);
parseExpected(82 /* IfKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
node.thenStatement = parseStatement();
node.elseStatement = parseOptional(74 /* ElseKeyword */) ? parseStatement() : undefined;
return finishNode(node);
}
function parseDoStatement() {
- var node = createNode(166 /* DoStatement */);
+ var node = createNode(167 /* DoStatement */);
parseExpected(73 /* DoKeyword */);
node.statement = parseStatement();
parseExpected(98 /* WhileKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
parseOptional(21 /* SemicolonToken */);
return finishNode(node);
}
function parseWhileStatement() {
- var node = createNode(167 /* WhileStatement */);
+ var node = createNode(168 /* WhileStatement */);
parseExpected(98 /* WhileKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
node.statement = parseStatement();
return finishNode(node);
@@ -3967,33 +4130,33 @@ var ts;
parseExpected(15 /* OpenParenToken */);
if (token !== 21 /* SemicolonToken */) {
if (parseOptional(96 /* VarKeyword */)) {
- var declarations = parseVariableDeclarationList(0, true);
+ var declarations = disallowInAnd(parseVariableDeclarationList);
}
else if (parseOptional(102 /* LetKeyword */)) {
- var declarations = parseVariableDeclarationList(2048 /* Let */, true);
+ var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 2048 /* Let */);
}
else if (parseOptional(68 /* ConstKeyword */)) {
- var declarations = parseVariableDeclarationList(4096 /* Const */, true);
+ var declarations = setFlag(disallowInAnd(parseVariableDeclarationList), 4096 /* Const */);
}
else {
- var varOrInit = parseExpression(true);
+ var varOrInit = disallowInAnd(parseExpression);
}
}
var forOrForInStatement;
if (parseOptional(84 /* InKeyword */)) {
- var forInStatement = createNode(169 /* ForInStatement */, pos);
+ var forInStatement = createNode(170 /* ForInStatement */, pos);
if (declarations) {
forInStatement.declarations = declarations;
}
else {
forInStatement.variable = varOrInit;
}
- forInStatement.expression = parseExpression();
+ forInStatement.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
forOrForInStatement = forInStatement;
}
else {
- var forStatement = createNode(168 /* ForStatement */, pos);
+ var forStatement = createNode(169 /* ForStatement */, pos);
if (declarations) {
forStatement.declarations = declarations;
}
@@ -4002,11 +4165,11 @@ var ts;
}
parseExpected(21 /* SemicolonToken */);
if (token !== 21 /* SemicolonToken */ && token !== 16 /* CloseParenToken */) {
- forStatement.condition = parseExpression();
+ forStatement.condition = allowInAnd(parseExpression);
}
parseExpected(21 /* SemicolonToken */);
if (token !== 16 /* CloseParenToken */) {
- forStatement.iterator = parseExpression();
+ forStatement.iterator = allowInAnd(parseExpression);
}
parseExpected(16 /* CloseParenToken */);
forOrForInStatement = forStatement;
@@ -4016,7 +4179,7 @@ var ts;
}
function parseBreakOrContinueStatement(kind) {
var node = createNode(kind);
- parseExpected(kind === 171 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */);
+ parseExpected(kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */);
if (!canParseSemicolon()) {
node.label = parseIdentifier();
}
@@ -4024,35 +4187,33 @@ var ts;
return finishNode(node);
}
function parseReturnStatement() {
- var node = createNode(172 /* ReturnStatement */);
- var returnTokenStart = scanner.getTokenPos();
- var returnTokenLength = scanner.getTextPos() - returnTokenStart;
+ var node = createNode(173 /* ReturnStatement */);
parseExpected(88 /* ReturnKeyword */);
if (!canParseSemicolon()) {
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
}
parseSemicolon();
return finishNode(node);
}
function parseWithStatement() {
- var node = createNode(173 /* WithStatement */);
+ var node = createNode(174 /* WithStatement */);
parseExpected(99 /* WithKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
node.statement = parseStatement();
return finishNode(node);
}
function parseCaseClause() {
- var node = createNode(175 /* CaseClause */);
+ var node = createNode(176 /* CaseClause */);
parseExpected(65 /* CaseKeyword */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(50 /* ColonToken */);
node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement);
return finishNode(node);
}
function parseDefaultClause() {
- var node = createNode(176 /* DefaultClause */);
+ var node = createNode(177 /* DefaultClause */);
parseExpected(71 /* DefaultKeyword */);
parseExpected(50 /* ColonToken */);
node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatement);
@@ -4062,10 +4223,10 @@ var ts;
return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause();
}
function parseSwitchStatement() {
- var node = createNode(174 /* SwitchStatement */);
+ var node = createNode(175 /* SwitchStatement */);
parseExpected(90 /* SwitchKeyword */);
parseExpected(15 /* OpenParenToken */);
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseExpected(16 /* CloseParenToken */);
parseExpected(13 /* OpenBraceToken */);
node.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause);
@@ -4073,23 +4234,23 @@ var ts;
return finishNode(node);
}
function parseThrowStatement() {
- var node = createNode(178 /* ThrowStatement */);
+ var node = createNode(179 /* ThrowStatement */);
parseExpected(92 /* ThrowKeyword */);
if (scanner.hasPrecedingLineBreak()) {
error(ts.Diagnostics.Line_break_not_permitted_here);
}
- node.expression = parseExpression();
+ node.expression = allowInAnd(parseExpression);
parseSemicolon();
return finishNode(node);
}
function parseTryStatement() {
- var node = createNode(179 /* TryStatement */);
- node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 180 /* TryBlock */);
+ var node = createNode(180 /* TryStatement */);
+ node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 181 /* TryBlock */);
if (token === 66 /* CatchKeyword */) {
node.catchBlock = parseCatchBlock();
}
if (token === 79 /* FinallyKeyword */) {
- node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 182 /* FinallyBlock */);
+ node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 183 /* FinallyBlock */);
}
if (!(node.catchBlock || node.finallyBlock)) {
error(ts.Diagnostics.catch_or_finally_expected);
@@ -4112,34 +4273,31 @@ var ts;
var typeAnnotation = parseTypeAnnotation();
parseExpected(16 /* CloseParenToken */);
var result = parseBlock(false, false);
- result.kind = 181 /* CatchBlock */;
+ result.kind = 182 /* CatchBlock */;
result.pos = pos;
result.variable = variable;
result.type = typeAnnotation;
return result;
}
function parseDebuggerStatement() {
- var node = createNode(183 /* DebuggerStatement */);
+ var node = createNode(184 /* DebuggerStatement */);
parseExpected(70 /* DebuggerKeyword */);
parseSemicolon();
return finishNode(node);
}
- function isIterationStatementStart() {
- return token === 98 /* WhileKeyword */ || token === 73 /* DoKeyword */ || token === 80 /* ForKeyword */;
- }
function isLabel() {
return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; });
}
function parseLabeledStatement() {
- var node = createNode(177 /* LabeledStatement */);
+ var node = createNode(178 /* LabeledStatement */);
node.label = parseIdentifier();
parseExpected(50 /* ColonToken */);
- node.statement = isLabel() ? parseLabeledStatement() : parseStatement();
+ node.statement = parseStatement();
return finishNode(node);
}
function parseExpressionStatement() {
- var node = createNode(164 /* ExpressionStatement */);
- node.expression = parseExpression();
+ var node = createNode(165 /* ExpressionStatement */);
+ node.expression = allowInAnd(parseExpression);
parseSemicolon();
return finishNode(node);
}
@@ -4195,9 +4353,9 @@ var ts;
case 96 /* VarKeyword */:
case 102 /* LetKeyword */:
case 68 /* ConstKeyword */:
- return parseVariableStatement();
+ return parseVariableStatement(scanner.getStartPos(), undefined);
case 81 /* FunctionKeyword */:
- return parseFunctionDeclaration();
+ return parseFunctionDeclaration(scanner.getStartPos(), undefined);
case 21 /* SemicolonToken */:
return parseEmptyStatement();
case 82 /* IfKeyword */:
@@ -4209,9 +4367,9 @@ var ts;
case 80 /* ForKeyword */:
return parseForOrForInStatement();
case 69 /* ContinueKeyword */:
- return parseBreakOrContinueStatement(170 /* ContinueStatement */);
+ return parseBreakOrContinueStatement(171 /* ContinueStatement */);
case 64 /* BreakKeyword */:
- return parseBreakOrContinueStatement(171 /* BreakStatement */);
+ return parseBreakOrContinueStatement(172 /* BreakStatement */);
case 88 /* ReturnKeyword */:
return parseReturnStatement();
case 99 /* WithKeyword */:
@@ -4230,9 +4388,9 @@ var ts;
return isLabel() ? parseLabeledStatement() : parseExpressionStatement();
}
}
- function parseFunctionBlockOrSemicolon() {
+ function parseFunctionBlockOrSemicolon(isGenerator) {
if (token === 13 /* OpenBraceToken */) {
- return parseFunctionBlock(false);
+ return parseFunctionBlock(isGenerator, false);
}
if (canParseSemicolon()) {
parseSemicolon();
@@ -4240,24 +4398,25 @@ var ts;
}
error(ts.Diagnostics.Block_or_expected);
}
- function parseVariableDeclaration(flags, noIn) {
- var node = createNode(184 /* VariableDeclaration */);
- node.flags = flags;
+ function parseVariableDeclaration() {
+ var node = createNode(185 /* VariableDeclaration */);
node.name = parseIdentifier();
node.type = parseTypeAnnotation();
- var initializerStart = scanner.getTokenPos();
- var initializerFirstTokenLength = scanner.getTextPos() - initializerStart;
- node.initializer = parseInitializer(false, noIn);
+ node.initializer = parseInitializer(false);
return finishNode(node);
}
- function parseVariableDeclarationList(flags, noIn) {
- return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); });
- }
- function parseVariableStatement(pos, flags) {
- var node = createNode(162 /* VariableStatement */, pos);
- if (flags) {
- node.flags = flags;
+ function setFlag(array, flag) {
+ for (var i = 0, n = array.length; i < n; i++) {
+ array[i].flags |= flag;
}
+ return array;
+ }
+ function parseVariableDeclarationList() {
+ return parseDelimitedList(9 /* VariableDeclarations */, parseVariableDeclaration);
+ }
+ function parseVariableStatement(fullStart, modifiers) {
+ var node = createNode(163 /* VariableStatement */, fullStart);
+ setModifiers(node, modifiers);
if (token === 102 /* LetKeyword */) {
node.flags |= 2048 /* Let */;
}
@@ -4268,79 +4427,67 @@ var ts;
ts.Debug.assert(token === 96 /* VarKeyword */);
}
nextToken();
- node.declarations = parseVariableDeclarationList(node.flags, false);
+ node.declarations = allowInAnd(parseVariableDeclarationList);
+ setFlag(node.declarations, node.flags);
parseSemicolon();
return finishNode(node);
}
- function parseFunctionDeclaration(pos, flags) {
- var node = createNode(185 /* FunctionDeclaration */, pos);
- if (flags)
- node.flags = flags;
+ function parseFunctionDeclaration(fullStart, modifiers) {
+ var node = createNode(186 /* FunctionDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(81 /* FunctionKeyword */);
+ node.asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
node.name = parseIdentifier();
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
- node.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!node.asteriskToken, node);
+ node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken);
return finishNode(node);
}
function parseConstructorDeclaration(pos, modifiers) {
var node = createNode(126 /* Constructor */, pos);
setModifiers(node, modifiers);
parseExpected(111 /* ConstructorKeyword */);
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
- node.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node);
+ node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
- function parsePropertyMemberDeclaration(pos, modifiers) {
- var name = parsePropertyName();
+ function parsePropertyMemberDeclaration(fullStart, modifiers) {
var flags = modifiers ? modifiers.flags : 0;
- var questionStart = scanner.getTokenPos();
+ var asteriskToken = parseOptionalToken(34 /* AsteriskToken */);
+ var name = parsePropertyName();
if (parseOptional(49 /* QuestionToken */)) {
flags |= 4 /* QuestionMark */;
}
- if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
- var method = createNode(125 /* Method */, pos);
+ if (asteriskToken || token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) {
+ var method = createNode(125 /* Method */, fullStart);
setModifiers(method, modifiers);
if (flags) {
method.flags = flags;
}
+ method.asteriskToken = asteriskToken;
method.name = name;
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- method.typeParameters = sig.typeParameters;
- method.parameters = sig.parameters;
- method.type = sig.type;
- method.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, !!asteriskToken, method);
+ method.body = parseFunctionBlockOrSemicolon(!!asteriskToken);
return finishNode(method);
}
else {
- var property = createNode(124 /* Property */, pos);
+ var property = createNode(124 /* Property */, fullStart);
setModifiers(property, modifiers);
if (flags) {
property.flags = flags;
}
property.name = name;
property.type = parseTypeAnnotation();
- var initializerStart = scanner.getTokenPos();
- var initializerFirstTokenLength = scanner.getTextPos() - initializerStart;
- property.initializer = parseInitializer(false);
+ property.initializer = allowInAnd(function () { return parseInitializer(false); });
parseSemicolon();
return finishNode(property);
}
}
- function parseMemberAccessorDeclaration(kind, pos, modifiers) {
- var node = createNode(kind, pos);
+ function parseMemberAccessorDeclaration(kind, fullStart, modifiers) {
+ var node = createNode(kind, fullStart);
setModifiers(node, modifiers);
node.name = parsePropertyName();
- var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false);
- node.typeParameters = sig.typeParameters;
- node.parameters = sig.parameters;
- node.type = sig.type;
- node.body = parseFunctionBlockOrSemicolon();
+ fillSignature(129 /* CallSignature */, 50 /* ColonToken */, false, false, node);
+ node.body = parseFunctionBlockOrSemicolon(false);
return finishNode(node);
}
function isClassMemberStart() {
@@ -4349,6 +4496,9 @@ var ts;
idToken = token;
nextToken();
}
+ if (token === 34 /* AsteriskToken */) {
+ return true;
+ }
if (isPropertyName()) {
idToken = token;
nextToken();
@@ -4373,19 +4523,20 @@ var ts;
}
return false;
}
- function parseModifiers(context) {
+ function parseModifiers() {
var flags = 0;
var modifiers;
while (true) {
var modifierStart = scanner.getTokenPos();
- var modifierToken = token;
- if (!parseAnyContextualModifier())
+ var modifierKind = token;
+ if (!parseAnyContextualModifier()) {
break;
+ }
if (!modifiers) {
modifiers = [];
}
- flags |= modifierToFlag(modifierToken);
- modifiers.push(finishNode(createNode(modifierToken, modifierStart)));
+ flags |= modifierToFlag(modifierKind);
+ modifiers.push(finishNode(createNode(modifierKind, modifierStart)));
}
if (modifiers) {
modifiers.flags = flags;
@@ -4393,37 +4544,37 @@ var ts;
return modifiers;
}
function parseClassMemberDeclaration() {
- var pos = getNodePos();
- var modifiers = parseModifiers(2 /* ClassMembers */);
+ var fullStart = getNodePos();
+ var modifiers = parseModifiers();
if (parseContextualModifier(113 /* GetKeyword */)) {
- return parseMemberAccessorDeclaration(127 /* GetAccessor */, pos, modifiers);
+ return parseMemberAccessorDeclaration(127 /* GetAccessor */, fullStart, modifiers);
}
if (parseContextualModifier(117 /* SetKeyword */)) {
- return parseMemberAccessorDeclaration(128 /* SetAccessor */, pos, modifiers);
+ return parseMemberAccessorDeclaration(128 /* SetAccessor */, fullStart, modifiers);
}
if (token === 111 /* ConstructorKeyword */) {
- return parseConstructorDeclaration(pos, modifiers);
+ return parseConstructorDeclaration(fullStart, modifiers);
}
- if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) {
- return parsePropertyMemberDeclaration(pos, modifiers);
+ if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */ || token === 34 /* AsteriskToken */) {
+ return parsePropertyMemberDeclaration(fullStart, modifiers);
}
if (token === 17 /* OpenBracketToken */) {
- return parseIndexSignatureMember(modifiers, pos);
+ return parseIndexSignatureMember(fullStart, modifiers);
}
ts.Debug.fail("Should not have attempted to parse class member declaration.");
}
- function parseClassDeclaration(pos, flags) {
- var node = createNode(187 /* ClassDeclaration */, pos);
- node.flags = flags;
+ function parseClassDeclaration(fullStart, modifiers) {
+ var node = createNode(188 /* ClassDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(67 /* ClassKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
- node.baseType = parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined;
+ node.baseType = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassBaseType) : parseClassBaseType();
if (parseOptional(100 /* ImplementsKeyword */)) {
node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference);
}
if (parseExpected(13 /* OpenBraceToken */)) {
- node.members = parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration);
+ node.members = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseClassMembers) : parseClassMembers();
parseExpected(14 /* CloseBraceToken */);
}
else {
@@ -4431,21 +4582,27 @@ var ts;
}
return finishNode(node);
}
- function parseInterfaceDeclaration(pos, flags) {
- var node = createNode(188 /* InterfaceDeclaration */, pos);
- node.flags = flags;
+ function parseClassMembers() {
+ return parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration);
+ }
+ function parseClassBaseType() {
+ return parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined;
+ }
+ function parseInterfaceDeclaration(fullStart, modifiers) {
+ var node = createNode(189 /* InterfaceDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(101 /* InterfaceKeyword */);
node.name = parseIdentifier();
node.typeParameters = parseTypeParameters();
if (parseOptional(77 /* ExtendsKeyword */)) {
node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference);
}
- node.members = parseTypeLiteral().members;
+ node.members = parseObjectType();
return finishNode(node);
}
- function parseTypeAliasDeclaration(pos, flags) {
- var node = createNode(189 /* TypeAliasDeclaration */, pos);
- node.flags = flags;
+ function parseTypeAliasDeclaration(fullStart, modifiers) {
+ var node = createNode(190 /* TypeAliasDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(119 /* TypeKeyword */);
node.name = parseIdentifier();
parseExpected(51 /* EqualsToken */);
@@ -4453,17 +4610,16 @@ var ts;
parseSemicolon();
return finishNode(node);
}
- function parseAndCheckEnumDeclaration(pos, flags) {
- var enumIsConst = flags & 4096 /* Const */;
- function parseEnumMember() {
- var node = createNode(195 /* EnumMember */);
- node.name = parsePropertyName();
- node.initializer = parseInitializer(false);
- return finishNode(node);
- }
- var node = createNode(190 /* EnumDeclaration */, pos);
+ function parseEnumMember() {
+ var node = createNode(196 /* EnumMember */, scanner.getStartPos());
+ node.name = parsePropertyName();
+ node.initializer = allowInAnd(function () { return parseInitializer(false); });
+ return finishNode(node);
+ }
+ function parseAndCheckEnumDeclaration(fullStart, flags) {
+ var node = createNode(191 /* EnumDeclaration */, fullStart);
node.flags = flags;
- if (enumIsConst) {
+ if (flags & 4096 /* Const */) {
parseExpected(68 /* ConstKeyword */);
}
parseExpected(75 /* EnumKeyword */);
@@ -4478,7 +4634,7 @@ var ts;
return finishNode(node);
}
function parseModuleBody() {
- var node = createNode(192 /* ModuleBlock */);
+ var node = createNode(193 /* ModuleBlock */, scanner.getStartPos());
if (parseExpected(13 /* OpenBraceToken */)) {
node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement);
parseExpected(14 /* CloseBraceToken */);
@@ -4488,32 +4644,27 @@ var ts;
}
return finishNode(node);
}
- function parseInternalModuleTail(pos, flags) {
- var node = createNode(191 /* ModuleDeclaration */, pos);
+ function parseInternalModuleTail(fullStart, flags) {
+ var node = createNode(192 /* ModuleDeclaration */, fullStart);
node.flags = flags;
node.name = parseIdentifier();
- if (parseOptional(19 /* DotToken */)) {
- node.body = parseInternalModuleTail(getNodePos(), 1 /* Export */);
- }
- else {
- node.body = parseModuleBody();
- }
+ node.body = parseOptional(19 /* DotToken */) ? parseInternalModuleTail(getNodePos(), 1 /* Export */) : parseModuleBody();
return finishNode(node);
}
- function parseAmbientExternalModuleDeclaration(pos, flags) {
- var node = createNode(191 /* ModuleDeclaration */, pos);
+ function parseAmbientExternalModuleDeclaration(fullStart, flags) {
+ var node = createNode(192 /* ModuleDeclaration */, fullStart);
node.flags = flags;
node.name = parseStringLiteral();
node.body = parseModuleBody();
return finishNode(node);
}
- function parseModuleDeclaration(pos, flags) {
+ function parseModuleDeclaration(fullStart, flags) {
parseExpected(114 /* ModuleKeyword */);
- return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(pos, flags) : parseInternalModuleTail(pos, flags);
+ return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(fullStart, flags) : parseInternalModuleTail(fullStart, flags);
}
- function parseImportDeclaration(pos, flags) {
- var node = createNode(193 /* ImportDeclaration */, pos);
- node.flags = flags;
+ function parseImportDeclaration(fullStart, modifiers) {
+ var node = createNode(194 /* ImportDeclaration */, fullStart);
+ setModifiers(node, modifiers);
parseExpected(83 /* ImportKeyword */);
node.name = parseIdentifier();
parseExpected(51 /* EqualsToken */);
@@ -4528,8 +4679,8 @@ var ts;
parseSemicolon();
return finishNode(node);
}
- function parseExportAssignmentTail(pos, modifiers) {
- var node = createNode(194 /* ExportAssignment */, pos);
+ function parseExportAssignmentTail(fullStart, modifiers) {
+ var node = createNode(195 /* ExportAssignment */, fullStart);
setModifiers(node, modifiers);
node.exportName = parseIdentifier();
parseSemicolon();
@@ -4563,14 +4714,13 @@ var ts;
});
}
}
- function parseDeclaration(modifierContext) {
- var pos = getNodePos();
- var modifiers = parseModifiers(modifierContext);
+ function parseDeclaration() {
+ var fullStart = getNodePos();
+ var modifiers = parseModifiers();
if (token === 76 /* ExportKeyword */) {
- var modifiersEnd = scanner.getStartPos();
nextToken();
if (parseOptional(51 /* EqualsToken */)) {
- return parseExportAssignmentTail(pos, modifiers);
+ return parseExportAssignmentTail(fullStart, modifiers);
}
}
var flags = modifiers ? modifiers.flags : 0;
@@ -4578,37 +4728,37 @@ var ts;
switch (token) {
case 96 /* VarKeyword */:
case 102 /* LetKeyword */:
- result = parseVariableStatement(pos, flags);
+ result = parseVariableStatement(fullStart, modifiers);
break;
case 68 /* ConstKeyword */:
var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; });
if (isConstEnum) {
- result = parseAndCheckEnumDeclaration(pos, flags | 4096 /* Const */);
+ result = parseAndCheckEnumDeclaration(fullStart, flags | 4096 /* Const */);
}
else {
- result = parseVariableStatement(pos, flags);
+ result = parseVariableStatement(fullStart, modifiers);
}
break;
case 81 /* FunctionKeyword */:
- result = parseFunctionDeclaration(pos, flags);
+ result = parseFunctionDeclaration(fullStart, modifiers);
break;
case 67 /* ClassKeyword */:
- result = parseClassDeclaration(pos, flags);
+ result = parseClassDeclaration(fullStart, modifiers);
break;
case 101 /* InterfaceKeyword */:
- result = parseInterfaceDeclaration(pos, flags);
+ result = parseInterfaceDeclaration(fullStart, modifiers);
break;
case 119 /* TypeKeyword */:
- result = parseTypeAliasDeclaration(pos, flags);
+ result = parseTypeAliasDeclaration(fullStart, modifiers);
break;
case 75 /* EnumKeyword */:
- result = parseAndCheckEnumDeclaration(pos, flags);
+ result = parseAndCheckEnumDeclaration(fullStart, flags);
break;
case 114 /* ModuleKeyword */:
- result = parseModuleDeclaration(pos, flags);
+ result = parseModuleDeclaration(fullStart, flags);
break;
case 83 /* ImportKeyword */:
- result = parseImportDeclaration(pos, flags);
+ result = parseImportDeclaration(fullStart, modifiers);
break;
default:
error(ts.Diagnostics.Declaration_expected);
@@ -4622,13 +4772,13 @@ var ts;
return isDeclarationStart() || isStatement(inErrorRecovery);
}
function parseSourceElement() {
- return parseSourceElementOrModuleElement(0 /* SourceElements */);
+ return parseSourceElementOrModuleElement();
}
function parseModuleElement() {
- return parseSourceElementOrModuleElement(1 /* ModuleElements */);
+ return parseSourceElementOrModuleElement();
}
- function parseSourceElementOrModuleElement(modifierContext) {
- return isDeclarationStart() ? parseDeclaration(modifierContext) : parseStatement();
+ function parseSourceElementOrModuleElement() {
+ return isDeclarationStart() ? parseDeclaration() : parseStatement();
}
function processReferenceComments() {
var referencedFiles = [];
@@ -4675,7 +4825,7 @@ var ts;
};
}
function getExternalModuleIndicator() {
- return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 193 /* ImportDeclaration */ && node.externalModuleName || node.kind === 194 /* ExportAssignment */ ? node : undefined; });
+ return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 194 /* ImportDeclaration */ && node.externalModuleName || node.kind === 195 /* ExportAssignment */ ? node : undefined; });
}
var syntacticDiagnostics;
function getSyntacticDiagnostics() {
@@ -4696,7 +4846,7 @@ var ts;
if (ts.fileExtensionIs(filename, ".d.ts")) {
rootNodeFlags = 1024 /* DeclarationFile */;
}
- file = createRootNode(196 /* SourceFile */, 0, sourceText.length, rootNodeFlags);
+ file = createRootNode(197 /* SourceFile */, 0, sourceText.length, rootNodeFlags);
file.filename = ts.normalizePath(filename);
file.text = sourceText;
file.getLineAndCharacterFromPosition = getLineAndCharacterFromSourcePosition;
@@ -4766,7 +4916,7 @@ var ts;
parent = node;
if (!checkModifiers(node)) {
var savedInFunctionBlock = inFunctionBlock;
- if (node.kind === 186 /* FunctionBlock */) {
+ if (node.kind === 187 /* FunctionBlock */) {
inFunctionBlock = true;
}
var savedInAmbientContext = inAmbientContext;
@@ -4797,48 +4947,49 @@ var ts;
case 130 /* ConstructSignature */:
case 133 /* FunctionType */:
return checkAnyParsedSignature(node);
- case 171 /* BreakStatement */:
- case 170 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
return checkBreakOrContinueStatement(node);
case 147 /* CallExpression */:
case 148 /* NewExpression */:
return checkCallOrNewExpression(node);
- case 190 /* EnumDeclaration */: return checkEnumDeclaration(node);
- case 123 /* Parameter */: return checkParameter(node);
+ case 191 /* EnumDeclaration */: return checkEnumDeclaration(node);
case 156 /* BinaryExpression */: return checkBinaryExpression(node);
- case 181 /* CatchBlock */: return checkCatchBlock(node);
- case 187 /* ClassDeclaration */: return checkClassDeclaration(node);
+ case 182 /* CatchBlock */: return checkCatchBlock(node);
+ case 188 /* ClassDeclaration */: return checkClassDeclaration(node);
case 126 /* Constructor */: return checkConstructor(node);
- case 194 /* ExportAssignment */: return checkExportAssignment(node);
- case 169 /* ForInStatement */: return checkForInStatement(node);
- case 168 /* ForStatement */: return checkForStatement(node);
- case 185 /* FunctionDeclaration */: return checkFunctionDeclaration(node);
+ case 195 /* ExportAssignment */: return checkExportAssignment(node);
+ case 170 /* ForInStatement */: return checkForInStatement(node);
+ case 169 /* ForStatement */: return checkForStatement(node);
+ case 186 /* FunctionDeclaration */: return checkFunctionDeclaration(node);
case 152 /* FunctionExpression */: return checkFunctionExpression(node);
case 127 /* GetAccessor */: return checkGetAccessor(node);
case 146 /* IndexedAccess */: return checkIndexedAccess(node);
case 131 /* IndexSignature */: return checkIndexSignature(node);
- case 188 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node);
- case 177 /* LabeledStatement */: return checkLabeledStatement(node);
+ case 189 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node);
+ case 178 /* LabeledStatement */: return checkLabeledStatement(node);
case 125 /* Method */: return checkMethod(node);
- case 191 /* ModuleDeclaration */: return checkModuleDeclaration(node);
+ case 192 /* ModuleDeclaration */: return checkModuleDeclaration(node);
case 142 /* ObjectLiteral */: return checkObjectLiteral(node);
case 6 /* NumericLiteral */: return checkNumericLiteral(node);
+ case 123 /* Parameter */: return checkParameter(node);
case 155 /* PostfixOperator */: return checkPostfixOperator(node);
case 154 /* PrefixOperator */: return checkPrefixOperator(node);
case 124 /* Property */: return checkProperty(node);
case 143 /* PropertyAssignment */: return checkPropertyAssignment(node);
- case 172 /* ReturnStatement */: return checkReturnStatement(node);
+ case 173 /* ReturnStatement */: return checkReturnStatement(node);
case 128 /* SetAccessor */: return checkSetAccessor(node);
- case 196 /* SourceFile */: return checkSourceFile(node);
+ case 197 /* SourceFile */: return checkSourceFile(node);
case 144 /* ShorthandPropertyAssignment */: return checkShorthandPropertyAssignment(node);
- case 174 /* SwitchStatement */: return checkSwitchStatement(node);
+ case 175 /* SwitchStatement */: return checkSwitchStatement(node);
case 149 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node);
case 138 /* TupleType */: return checkTupleType(node);
case 122 /* TypeParameter */: return checkTypeParameter(node);
case 132 /* TypeReference */: return checkTypeReference(node);
- case 184 /* VariableDeclaration */: return checkVariableDeclaration(node);
- case 162 /* VariableStatement */: return checkVariableStatement(node);
- case 173 /* WithStatement */: return checkWithStatement(node);
+ case 185 /* VariableDeclaration */: return checkVariableDeclaration(node);
+ case 163 /* VariableStatement */: return checkVariableStatement(node);
+ case 174 /* WithStatement */: return checkWithStatement(node);
+ case 160 /* YieldExpression */: return checkYieldExpression(node);
}
}
function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
@@ -4866,23 +5017,23 @@ var ts;
}
function checkForStatementInAmbientContext(node, kind) {
switch (kind) {
- case 161 /* Block */:
- case 163 /* EmptyStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
- case 172 /* ReturnStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 178 /* ThrowStatement */:
- case 179 /* TryStatement */:
- case 183 /* DebuggerStatement */:
- case 177 /* LabeledStatement */:
- case 164 /* ExpressionStatement */:
+ case 162 /* Block */:
+ case 164 /* EmptyStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
+ case 173 /* ReturnStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 179 /* ThrowStatement */:
+ case 180 /* TryStatement */:
+ case 184 /* DebuggerStatement */:
+ case 178 /* LabeledStatement */:
+ case 165 /* ExpressionStatement */:
return grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
}
}
@@ -4890,7 +5041,7 @@ var ts;
return checkTypeParameterList(node.typeParameters) || checkParameterList(node.parameters);
}
function checkBinaryExpression(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
if (isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operator)) {
if (isEvalOrArgumentsIdentifier(node.left)) {
return reportInvalidUseInStrictMode(node.left);
@@ -4900,12 +5051,12 @@ var ts;
}
function isIterationStatement(node, lookInLabeledStatements) {
switch (node.kind) {
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
return true;
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
}
return false;
@@ -4916,7 +5067,7 @@ var ts;
if (isAnyFunction(current)) {
break;
}
- if (current.kind === 177 /* LabeledStatement */ && current.label.text === node.label.text) {
+ if (current.kind === 178 /* LabeledStatement */ && current.label.text === node.label.text) {
return grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label));
}
current = current.parent;
@@ -4929,17 +5080,17 @@ var ts;
return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
}
switch (current.kind) {
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
if (node.label && current.label.text === node.label.text) {
- var isMisplacedContinueLabel = node.kind === 170 /* ContinueStatement */ && !isIterationStatement(current.statement, true);
+ var isMisplacedContinueLabel = node.kind === 171 /* ContinueStatement */ && !isIterationStatement(current.statement, true);
if (isMisplacedContinueLabel) {
return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
}
return false;
}
break;
- case 174 /* SwitchStatement */:
- if (node.kind === 171 /* BreakStatement */ && !node.label) {
+ case 175 /* SwitchStatement */:
+ if (node.kind === 172 /* BreakStatement */ && !node.label) {
return false;
}
break;
@@ -4952,11 +5103,11 @@ var ts;
current = current.parent;
}
if (node.label) {
- var message = node.kind === 171 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
+ var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
}
else {
- var message = node.kind === 171 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
+ var message = node.kind === 172 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
return grammarErrorOnNode(node, message);
}
}
@@ -4973,7 +5124,7 @@ var ts;
if (arguments) {
for (var i = 0, n = arguments.length; i < n; i++) {
var arg = arguments[i];
- if (arg.kind === 160 /* OmittedExpression */) {
+ if (arg.kind === 161 /* OmittedExpression */) {
return grammarErrorAtPos(arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
}
}
@@ -5008,7 +5159,7 @@ var ts;
var colonStart = ts.skipTrivia(sourceText, node.variable.end);
return grammarErrorAtPos(colonStart, ":".length, ts.Diagnostics.Catch_clause_parameter_cannot_have_a_type_annotation);
}
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.variable)) {
return reportInvalidUseInStrictMode(node.variable);
}
}
@@ -5087,13 +5238,18 @@ var ts;
}
}
function checkFunctionDeclaration(node) {
- return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false);
+ return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForBodyInAmbientContext(node.body, false) || checkForGenerator(node);
+ }
+ function checkForGenerator(node) {
+ if (node.asteriskToken) {
+ return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.generators_are_not_currently_supported);
+ }
}
function checkFunctionExpression(node) {
- return checkAnyParsedSignature(node) || checkFunctionName(node.name);
+ return checkAnyParsedSignature(node) || checkFunctionName(node.name) || checkForGenerator(node);
}
function checkFunctionName(name) {
- if (name && name.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(name)) {
+ if (name && name.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(name)) {
return reportInvalidUseInStrictMode(name);
}
}
@@ -5151,10 +5307,10 @@ var ts;
return checkForDisallowedTrailingComma(node.baseTypes) || checkForAtLeastOneHeritageClause(node.baseTypes, "extends");
}
function checkMethod(node) {
- return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 187 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional));
+ return checkAnyParsedSignature(node) || checkForBodyInAmbientContext(node.body, false) || (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForGenerator(node);
}
function checkForBodyInAmbientContext(body, isConstructor) {
- if (inAmbientContext && body && body.kind === 186 /* FunctionBlock */) {
+ if (inAmbientContext && body && body.kind === 187 /* FunctionBlock */) {
var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context;
return grammarErrorOnFirstToken(body, diagnostic);
}
@@ -5168,14 +5324,14 @@ var ts;
}
}
function checkModuleDeclarationStatements(node) {
- if (node.name.kind === 63 /* Identifier */ && node.body.kind === 192 /* ModuleBlock */) {
+ if (node.name.kind === 63 /* Identifier */ && node.body.kind === 193 /* ModuleBlock */) {
var statements = node.body.statements;
for (var i = 0, n = statements.length; i < n; i++) {
var statement = statements[i];
- if (statement.kind === 194 /* ExportAssignment */) {
+ if (statement.kind === 195 /* ExportAssignment */) {
return grammarErrorOnNode(statement, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module);
}
- else if (statement.kind === 193 /* ImportDeclaration */ && statement.externalModuleName) {
+ else if (statement.kind === 194 /* ImportDeclaration */ && statement.externalModuleName) {
return grammarErrorOnNode(statement.externalModuleName, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
}
}
@@ -5187,10 +5343,10 @@ var ts;
var GetAccessor = 2;
var SetAccesor = 4;
var GetOrSetAccessor = GetAccessor | SetAccesor;
- var inStrictMode = (node.flags & 8192 /* ParsedInStrictMode */) !== 0;
+ var inStrictMode = (node.parserContextFlags & 1 /* StrictMode */) !== 0;
for (var i = 0, n = node.properties.length; i < n; i++) {
var prop = node.properties[i];
- if (prop.kind === 160 /* OmittedExpression */) {
+ if (prop.kind === 161 /* OmittedExpression */) {
continue;
}
var p = prop;
@@ -5236,8 +5392,8 @@ var ts;
}
}
function checkNumericLiteral(node) {
- if (node.flags & 16384 /* OctalLiteral */) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.flags & 8192 /* OctalLiteral */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode);
}
else if (languageVersion >= 1 /* ES5 */) {
@@ -5253,15 +5409,15 @@ var ts;
case 124 /* Property */:
case 125 /* Method */:
case 131 /* IndexSignature */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 190 /* EnumDeclaration */:
- case 194 /* ExportAssignment */:
- case 162 /* VariableStatement */:
- case 185 /* FunctionDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 195 /* ExportAssignment */:
+ case 163 /* VariableStatement */:
+ case 186 /* FunctionDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 194 /* ImportDeclaration */:
case 123 /* Parameter */:
break;
default:
@@ -5296,7 +5452,7 @@ var ts;
else if (flags & 128 /* Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
}
- else if (node.parent.kind === 192 /* ModuleBlock */ || node.parent.kind === 196 /* SourceFile */) {
+ else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text);
}
flags |= modifierToFlag(modifier.kind);
@@ -5305,7 +5461,7 @@ var ts;
if (flags & 128 /* Static */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
}
- else if (node.parent.kind === 192 /* ModuleBlock */ || node.parent.kind === 196 /* SourceFile */) {
+ else if (node.parent.kind === 193 /* ModuleBlock */ || node.parent.kind === 197 /* SourceFile */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static");
}
else if (node.kind === 123 /* Parameter */) {
@@ -5321,7 +5477,7 @@ var ts;
else if (flags & 2 /* Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
}
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export");
}
else if (node.kind === 123 /* Parameter */) {
@@ -5333,13 +5489,13 @@ var ts;
if (flags & 2 /* Ambient */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
}
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
}
else if (node.kind === 123 /* Parameter */) {
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
}
- else if (inAmbientContext && node.parent.kind === 192 /* ModuleBlock */) {
+ else if (inAmbientContext && node.parent.kind === 193 /* ModuleBlock */) {
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
}
flags |= 2 /* Ambient */;
@@ -5358,15 +5514,15 @@ var ts;
return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private");
}
}
- else if (node.kind === 193 /* ImportDeclaration */ && flags & 2 /* Ambient */) {
+ else if (node.kind === 194 /* ImportDeclaration */ && flags & 2 /* Ambient */) {
return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare");
}
- else if (node.kind === 188 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) {
+ else if (node.kind === 189 /* InterfaceDeclaration */ && flags & 2 /* Ambient */) {
return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare");
}
}
function checkParameter(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
return reportInvalidUseInStrictMode(node.name);
}
}
@@ -5413,12 +5569,12 @@ var ts;
}
}
function checkPostfixOperator(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.operand)) {
return reportInvalidUseInStrictMode(node.operand);
}
}
function checkPrefixOperator(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
if ((node.operator === 37 /* PlusPlusToken */ || node.operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(node.operand)) {
return reportInvalidUseInStrictMode(node.operand);
}
@@ -5428,7 +5584,7 @@ var ts;
}
}
function checkProperty(node) {
- return (node.parent.kind === 187 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node);
+ return (node.parent.kind === 188 /* ClassDeclaration */ && checkForInvalidQuestionMark(node, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) || checkForInitializerInAmbientContext(node);
}
function checkForInitializerInAmbientContext(node) {
if (inAmbientContext && node.initializer) {
@@ -5499,7 +5655,7 @@ var ts;
function checkTopLevelElementsForRequiredDeclareModifier(file) {
for (var i = 0, n = file.statements.length; i < n; i++) {
var decl = file.statements[i];
- if (isDeclaration(decl) || decl.kind === 162 /* VariableStatement */) {
+ if (isDeclaration(decl) || decl.kind === 163 /* VariableStatement */) {
if (checkTopLevelElementForRequiredDeclareModifier(decl)) {
return true;
}
@@ -5507,7 +5663,7 @@ var ts;
}
}
function checkTopLevelElementForRequiredDeclareModifier(node) {
- if (node.kind === 188 /* InterfaceDeclaration */ || node.kind === 193 /* ImportDeclaration */ || node.kind === 194 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) {
+ if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 194 /* ImportDeclaration */ || node.kind === 195 /* ExportAssignment */ || (node.flags & 2 /* Ambient */)) {
return false;
}
return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file);
@@ -5519,7 +5675,7 @@ var ts;
var firstDefaultClause;
for (var i = 0, n = node.clauses.length; i < n; i++) {
var clause = node.clauses[i];
- if (clause.kind === 176 /* DefaultClause */) {
+ if (clause.kind === 177 /* DefaultClause */) {
if (firstDefaultClause === undefined) {
firstDefaultClause = clause;
}
@@ -5557,10 +5713,10 @@ var ts;
var equalsPos = node.type ? ts.skipTrivia(sourceText, node.type.end) : ts.skipTrivia(sourceText, node.name.end);
return grammarErrorAtPos(equalsPos, "=".length, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
}
- if (!inAmbientContext && !node.initializer && node.flags & 4096 /* Const */) {
+ if (!inAmbientContext && !node.initializer && isConst(node)) {
return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
}
- if (node.flags & 8192 /* ParsedInStrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
+ if (node.parserContextFlags & 1 /* StrictMode */ && isEvalOrArgumentsIdentifier(node.name)) {
return reportInvalidUseInStrictMode(node.name);
}
}
@@ -5574,10 +5730,10 @@ var ts;
}
var decl = declarations[0];
if (languageVersion < 2 /* ES6 */) {
- if (decl.flags & 2048 /* Let */) {
+ if (isLet(decl)) {
return grammarErrorOnFirstToken(decl, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
}
- else if (decl.flags & 4096 /* Const */) {
+ else if (isConst(decl)) {
return grammarErrorOnFirstToken(decl, ts.Diagnostics.const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher);
}
}
@@ -5588,33 +5744,39 @@ var ts;
}
function checkForDisallowedLetOrConstStatement(node) {
if (!allowLetAndConstDeclarations(node.parent)) {
- if (node.flags & 2048 /* Let */) {
+ if (isLet(node)) {
return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
}
- else if (node.flags & 4096 /* Const */) {
+ else if (isConst(node)) {
return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
}
}
}
function allowLetAndConstDeclarations(parent) {
switch (parent.kind) {
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 173 /* WithStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 174 /* WithStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
return false;
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return allowLetAndConstDeclarations(parent.parent);
}
return true;
}
function checkWithStatement(node) {
- if (node.flags & 8192 /* ParsedInStrictMode */) {
+ if (node.parserContextFlags & 1 /* StrictMode */) {
return grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
}
}
+ function checkYieldExpression(node) {
+ if (!(node.parserContextFlags & 4 /* Yield */)) {
+ return grammarErrorOnFirstToken(node, ts.Diagnostics.yield_expression_must_be_contained_within_a_generator_declaration);
+ }
+ return grammarErrorOnFirstToken(node, ts.Diagnostics.yield_expressions_are_not_currently_supported);
+ }
}
function createProgram(rootNames, options, host) {
var program;
@@ -5691,17 +5853,20 @@ var ts;
function findSourceFile(filename, isDefaultLib, refFile, refStart, refLength) {
var canonicalName = host.getCanonicalFileName(filename);
if (ts.hasProperty(filesByName, canonicalName)) {
- var file = filesByName[canonicalName];
- if (file && host.useCaseSensitiveFileNames() && canonicalName !== file.filename) {
- errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, file.filename));
- }
+ return getSourceFileFromCache(filename, canonicalName, false);
}
else {
+ var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(filename, host.getCurrentDirectory());
+ var canonicalAbsolutePath = host.getCanonicalFileName(normalizedAbsolutePath);
+ if (ts.hasProperty(filesByName, canonicalAbsolutePath)) {
+ return getSourceFileFromCache(normalizedAbsolutePath, canonicalAbsolutePath, true);
+ }
var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, function (hostErrorMessage) {
errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage));
});
if (file) {
seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;
+ filesByName[canonicalAbsolutePath] = file;
if (!options.noResolve) {
var basePath = ts.getDirectoryPath(filename);
processReferencedFiles(file, basePath);
@@ -5719,6 +5884,16 @@ var ts;
}
}
return file;
+ function getSourceFileFromCache(filename, canonicalName, useAbsolutePath) {
+ var file = filesByName[canonicalName];
+ if (file && host.useCaseSensitiveFileNames()) {
+ var sourceFileName = useAbsolutePath ? ts.getNormalizedAbsolutePath(file.filename, host.getCurrentDirectory()) : file.filename;
+ if (canonicalName !== sourceFileName) {
+ errors.push(ts.createFileDiagnostic(refFile, refStart, refLength, ts.Diagnostics.Filename_0_differs_from_already_included_filename_1_only_in_casing, filename, sourceFileName));
+ }
+ }
+ return file;
+ }
}
function processReferencedFiles(file, basePath) {
ts.forEach(file.referencedFiles, function (ref) {
@@ -5728,7 +5903,7 @@ var ts;
}
function processImportedModules(file, basePath) {
ts.forEach(file.statements, function (node) {
- if (node.kind === 193 /* ImportDeclaration */ && node.externalModuleName) {
+ if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) {
var nameLiteral = node.externalModuleName;
var moduleName = nameLiteral.text;
if (moduleName) {
@@ -5746,9 +5921,9 @@ var ts;
}
}
}
- else if (node.kind === 191 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) {
+ else if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) {
forEachChild(node.body, function (node) {
- if (node.kind === 193 /* ImportDeclaration */ && node.externalModuleName) {
+ if (node.kind === 194 /* ImportDeclaration */ && node.externalModuleName) {
var nameLiteral = node.externalModuleName;
var moduleName = nameLiteral.text;
if (moduleName) {
@@ -5821,16 +5996,16 @@ var ts;
var ts;
(function (ts) {
function getModuleInstanceState(node) {
- if (node.kind === 188 /* InterfaceDeclaration */) {
+ if (node.kind === 189 /* InterfaceDeclaration */) {
return 0 /* NonInstantiated */;
}
- else if (node.kind === 190 /* EnumDeclaration */ && ts.isConstEnumDeclaration(node)) {
+ else if (ts.isConstEnumDeclaration(node)) {
return 2 /* ConstEnumOnly */;
}
- else if (node.kind === 193 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) {
+ else if (node.kind === 194 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) {
return 0 /* NonInstantiated */;
}
- else if (node.kind === 192 /* ModuleBlock */) {
+ else if (node.kind === 193 /* ModuleBlock */) {
var state = 0 /* NonInstantiated */;
ts.forEachChild(node, function (n) {
switch (getModuleInstanceState(n)) {
@@ -5846,7 +6021,7 @@ var ts;
});
return state;
}
- else if (node.kind === 191 /* ModuleDeclaration */) {
+ else if (node.kind === 192 /* ModuleDeclaration */) {
return getModuleInstanceState(node.body);
}
else {
@@ -5886,7 +6061,7 @@ var ts;
}
function getDeclarationName(node) {
if (node.name) {
- if (node.kind === 191 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) {
+ if (node.kind === 192 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) {
return '"' + node.name.text + '"';
}
return node.name.text;
@@ -5928,7 +6103,7 @@ var ts;
}
addDeclarationToSymbol(symbol, node, includes);
symbol.parent = parent;
- if (node.kind === 187 /* ClassDeclaration */ && symbol.exports) {
+ if (node.kind === 188 /* ClassDeclaration */ && symbol.exports) {
var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype");
if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) {
if (node.name) {
@@ -5960,7 +6135,7 @@ var ts;
if (symbolKind & 1536 /* Namespace */) {
exportKind |= 16777216 /* ExportNamespace */;
}
- if (node.flags & 1 /* Export */ || (node.kind !== 193 /* ImportDeclaration */ && isAmbientContext(container))) {
+ if (node.flags & 1 /* Export */ || (node.kind !== 194 /* ImportDeclaration */ && isAmbientContext(container))) {
if (exportKind) {
var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
@@ -6001,10 +6176,10 @@ var ts;
}
function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) {
switch (container.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
declareModuleMember(node, symbolKind, symbolExcludes);
break;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (ts.isExternalModule(container)) {
declareModuleMember(node, symbolKind, symbolExcludes);
break;
@@ -6018,22 +6193,22 @@ var ts;
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes);
break;
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
if (node.flags & 128 /* Static */) {
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
break;
}
case 136 /* TypeLiteral */:
case 142 /* ObjectLiteral */:
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes);
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes);
break;
}
@@ -6094,10 +6269,10 @@ var ts;
}
function bindBlockScopedVariableDeclaration(node) {
switch (blockScopeContainer.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */);
break;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (ts.isExternalModule(container)) {
declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */);
break;
@@ -6119,7 +6294,7 @@ var ts;
case 123 /* Parameter */:
bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false);
break;
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
if (node.flags & 6144 /* BlockScoped */) {
bindBlockScopedVariableDeclaration(node);
}
@@ -6132,7 +6307,7 @@ var ts;
case 144 /* ShorthandPropertyAssignment */:
bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false);
break;
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false);
break;
case 129 /* CallSignature */:
@@ -6147,7 +6322,7 @@ var ts;
case 131 /* IndexSignature */:
bindDeclaration(node, 524288 /* IndexSignature */, 0, false);
break;
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true);
break;
case 126 /* Constructor */:
@@ -6173,44 +6348,44 @@ var ts;
case 153 /* ArrowFunction */:
bindAnonymousDeclaration(node, 16 /* Function */, "__function", true);
break;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
bindCatchVariableDeclaration(node);
break;
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false);
break;
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false);
break;
- case 189 /* TypeAliasDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false);
break;
- case 190 /* EnumDeclaration */:
- if (ts.isConstEnumDeclaration(node)) {
+ case 191 /* EnumDeclaration */:
+ if (ts.isConst(node)) {
bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false);
}
else {
bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false);
}
break;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
bindModuleDeclaration(node);
break;
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false);
break;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (ts.isExternalModule(node)) {
bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true);
break;
}
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 174 /* SwitchStatement */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 175 /* SwitchStatement */:
bindChildren(node, 0, true);
break;
default:
@@ -6250,6 +6425,1057 @@ var ts;
return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile);
}
ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile;
+ function createTextWriter(newLine) {
+ var output = "";
+ var indent = 0;
+ var lineStart = true;
+ var lineCount = 0;
+ var linePos = 0;
+ function write(s) {
+ if (s && s.length) {
+ if (lineStart) {
+ output += getIndentString(indent);
+ lineStart = false;
+ }
+ output += s;
+ }
+ }
+ function rawWrite(s) {
+ if (s !== undefined) {
+ if (lineStart) {
+ lineStart = false;
+ }
+ output += s;
+ }
+ }
+ function writeLiteral(s) {
+ if (s && s.length) {
+ write(s);
+ var lineStartsOfS = ts.computeLineStarts(s);
+ if (lineStartsOfS.length > 1) {
+ lineCount = lineCount + lineStartsOfS.length - 1;
+ linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
+ }
+ }
+ }
+ function writeLine() {
+ if (!lineStart) {
+ output += newLine;
+ lineCount++;
+ linePos = output.length;
+ lineStart = true;
+ }
+ }
+ function writeTextOfNode(sourceFile, node) {
+ write(ts.getSourceTextOfNodeFromSourceFile(sourceFile, node));
+ }
+ return {
+ write: write,
+ rawWrite: rawWrite,
+ writeTextOfNode: writeTextOfNode,
+ writeLiteral: writeLiteral,
+ writeLine: writeLine,
+ increaseIndent: function () { return indent++; },
+ decreaseIndent: function () { return indent--; },
+ getIndent: function () { return indent; },
+ getTextPos: function () { return output.length; },
+ getLine: function () { return lineCount + 1; },
+ getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; },
+ getText: function () { return output; }
+ };
+ }
+ function getLineOfLocalPosition(currentSourceFile, pos) {
+ return currentSourceFile.getLineAndCharacterFromPosition(pos).line;
+ }
+ function emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments) {
+ if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(currentSourceFile, node.pos) !== getLineOfLocalPosition(currentSourceFile, leadingComments[0].pos)) {
+ writer.writeLine();
+ }
+ }
+ function emitComments(currentSourceFile, writer, comments, trailingSeparator, newLine, writeComment) {
+ var emitLeadingSpace = !trailingSeparator;
+ ts.forEach(comments, function (comment) {
+ if (emitLeadingSpace) {
+ writer.write(" ");
+ emitLeadingSpace = false;
+ }
+ writeComment(currentSourceFile, writer, comment, newLine);
+ if (comment.hasTrailingNewLine) {
+ writer.writeLine();
+ }
+ else if (trailingSeparator) {
+ writer.write(" ");
+ }
+ else {
+ emitLeadingSpace = true;
+ }
+ });
+ }
+ function writeCommentRange(currentSourceFile, writer, comment, newLine) {
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
+ var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
+ var firstCommentLineIndent;
+ for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
+ var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1);
+ if (pos !== comment.pos) {
+ if (firstCommentLineIndent === undefined) {
+ firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos);
+ }
+ var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
+ var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart);
+ if (spacesToEmit > 0) {
+ var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
+ var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
+ writer.rawWrite(indentSizeSpaceString);
+ while (numberOfSingleSpacesToEmit) {
+ writer.rawWrite(" ");
+ numberOfSingleSpacesToEmit--;
+ }
+ }
+ else {
+ writer.rawWrite("");
+ }
+ }
+ writeTrimmedCurrentLine(pos, nextLineStart);
+ pos = nextLineStart;
+ }
+ }
+ else {
+ writer.write(currentSourceFile.text.substring(comment.pos, comment.end));
+ }
+ function writeTrimmedCurrentLine(pos, nextLineStart) {
+ var end = Math.min(comment.end, nextLineStart - 1);
+ var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, '');
+ if (currentLineText) {
+ writer.write(currentLineText);
+ if (end !== comment.end) {
+ writer.writeLine();
+ }
+ }
+ else {
+ writer.writeLiteral(newLine);
+ }
+ }
+ function calculateIndent(pos, end) {
+ var currentLineIndent = 0;
+ for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
+ if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) {
+ currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
+ }
+ else {
+ currentLineIndent++;
+ }
+ }
+ return currentLineIndent;
+ }
+ }
+ function getFirstConstructorWithBody(node) {
+ return ts.forEach(node.members, function (member) {
+ if (member.kind === 126 /* Constructor */ && member.body) {
+ return member;
+ }
+ });
+ }
+ function getAllAccessorDeclarations(node, accessor) {
+ var firstAccessor;
+ var getAccessor;
+ var setAccessor;
+ ts.forEach(node.members, function (member) {
+ if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) {
+ if (!firstAccessor) {
+ firstAccessor = member;
+ }
+ if (member.kind === 127 /* GetAccessor */ && !getAccessor) {
+ getAccessor = member;
+ }
+ if (member.kind === 128 /* SetAccessor */ && !setAccessor) {
+ setAccessor = member;
+ }
+ }
+ });
+ return {
+ firstAccessor: firstAccessor,
+ getAccessor: getAccessor,
+ setAccessor: setAccessor
+ };
+ }
+ function getSourceFilePathInNewDir(sourceFile, program, newDirPath) {
+ var compilerHost = program.getCompilerHost();
+ var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.filename, compilerHost.getCurrentDirectory());
+ sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
+ return ts.combinePaths(newDirPath, sourceFilePath);
+ }
+ function getOwnEmitOutputFilePath(sourceFile, program, extension) {
+ var compilerOptions = program.getCompilerOptions();
+ if (compilerOptions.outDir) {
+ var emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(sourceFile, program, compilerOptions.outDir));
+ }
+ else {
+ var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename);
+ }
+ return emitOutputFilePathWithoutExtension + extension;
+ }
+ function writeFile(compilerHost, diagnostics, filename, data, writeByteOrderMark) {
+ compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) {
+ diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage));
+ });
+ }
+ function emitDeclarations(program, resolver, diagnostics, jsFilePath, root) {
+ var newLine = program.getCompilerHost().getNewLine();
+ var compilerOptions = program.getCompilerOptions();
+ var compilerHost = program.getCompilerHost();
+ var write;
+ var writeLine;
+ var increaseIndent;
+ var decreaseIndent;
+ var writeTextOfNode;
+ var writer = createAndSetNewTextWriterWithSymbolWriter();
+ var enclosingDeclaration;
+ var currentSourceFile;
+ var reportedDeclarationError = false;
+ var emitJsDocComments = compilerOptions.removeComments ? function (declaration) {
+ } : writeJsDocComments;
+ var aliasDeclarationEmitInfo = [];
+ function createAndSetNewTextWriterWithSymbolWriter() {
+ var writer = createTextWriter(newLine);
+ writer.trackSymbol = trackSymbol;
+ writer.writeKeyword = writer.write;
+ writer.writeOperator = writer.write;
+ writer.writePunctuation = writer.write;
+ writer.writeSpace = writer.write;
+ writer.writeStringLiteral = writer.writeLiteral;
+ writer.writeParameter = writer.write;
+ writer.writeSymbol = writer.write;
+ setWriter(writer);
+ return writer;
+ }
+ function setWriter(newWriter) {
+ writer = newWriter;
+ write = newWriter.write;
+ writeTextOfNode = newWriter.writeTextOfNode;
+ writeLine = newWriter.writeLine;
+ increaseIndent = newWriter.increaseIndent;
+ decreaseIndent = newWriter.decreaseIndent;
+ }
+ function writeAsychronousImportDeclarations(importDeclarations) {
+ var oldWriter = writer;
+ ts.forEach(importDeclarations, function (aliasToWrite) {
+ var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; });
+ if (aliasEmitInfo) {
+ createAndSetNewTextWriterWithSymbolWriter();
+ for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) {
+ increaseIndent();
+ }
+ writeImportDeclaration(aliasToWrite);
+ aliasEmitInfo.asynchronousOutput = writer.getText();
+ }
+ });
+ setWriter(oldWriter);
+ }
+ function handleSymbolAccessibilityError(symbolAccesibilityResult) {
+ if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) {
+ if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) {
+ writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
+ }
+ }
+ else {
+ reportedDeclarationError = true;
+ var errorInfo = writer.getSymbolAccessibilityDiagnostic(symbolAccesibilityResult);
+ if (errorInfo) {
+ if (errorInfo.typeName) {
+ diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
+ }
+ else {
+ diagnostics.push(ts.createDiagnosticForNode(symbolAccesibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
+ }
+ }
+ }
+ }
+ function trackSymbol(symbol, enclosingDeclaration, meaning) {
+ handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning));
+ }
+ function writeTypeAtLocation(location, type, getSymbolAccessibilityDiagnostic) {
+ writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
+ write(": ");
+ if (type) {
+ emitType(type);
+ }
+ else {
+ resolver.writeTypeAtLocation(location, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
+ }
+ }
+ function writeReturnTypeAtSignature(signature, getSymbolAccessibilityDiagnostic) {
+ writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
+ write(": ");
+ if (signature.type) {
+ emitType(signature.type);
+ }
+ else {
+ resolver.writeReturnTypeOfSignatureDeclaration(signature, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
+ }
+ }
+ function emitLines(nodes) {
+ for (var i = 0, n = nodes.length; i < n; i++) {
+ emitNode(nodes[i]);
+ }
+ }
+ function emitSeparatedList(nodes, separator, eachNodeEmitFn) {
+ var currentWriterPos = writer.getTextPos();
+ for (var i = 0, n = nodes.length; i < n; i++) {
+ if (currentWriterPos !== writer.getTextPos()) {
+ write(separator);
+ }
+ currentWriterPos = writer.getTextPos();
+ eachNodeEmitFn(nodes[i]);
+ }
+ }
+ function emitCommaList(nodes, eachNodeEmitFn) {
+ emitSeparatedList(nodes, ", ", eachNodeEmitFn);
+ }
+ function writeJsDocComments(declaration) {
+ if (declaration) {
+ var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, declaration, jsDocComments);
+ emitComments(currentSourceFile, writer, jsDocComments, true, newLine, writeCommentRange);
+ }
+ }
+ function emitTypeWithNewGetSymbolAccessibilityDiangostic(type, getSymbolAccessibilityDiagnostic) {
+ writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic;
+ emitType(type);
+ }
+ function emitType(type) {
+ switch (type.kind) {
+ case 109 /* AnyKeyword */:
+ case 118 /* StringKeyword */:
+ case 116 /* NumberKeyword */:
+ case 110 /* BooleanKeyword */:
+ case 97 /* VoidKeyword */:
+ case 7 /* StringLiteral */:
+ return writeTextOfNode(currentSourceFile, type);
+ case 132 /* TypeReference */:
+ return emitTypeReference(type);
+ case 135 /* TypeQuery */:
+ return emitTypeQuery(type);
+ case 137 /* ArrayType */:
+ return emitArrayType(type);
+ case 138 /* TupleType */:
+ return emitTupleType(type);
+ case 139 /* UnionType */:
+ return emitUnionType(type);
+ case 140 /* ParenType */:
+ return emitParenType(type);
+ case 133 /* FunctionType */:
+ case 134 /* ConstructorType */:
+ return emitSignatureDeclarationWithJsDocComments(type);
+ case 136 /* TypeLiteral */:
+ return emitTypeLiteral(type);
+ case 63 /* Identifier */:
+ return emitEntityName(type);
+ case 121 /* QualifiedName */:
+ return emitEntityName(type);
+ default:
+ ts.Debug.fail("Unknown type annotation: " + type.kind);
+ }
+ function emitEntityName(entityName) {
+ var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 194 /* ImportDeclaration */ ? entityName.parent : enclosingDeclaration);
+ handleSymbolAccessibilityError(visibilityResult);
+ writeEntityName(entityName);
+ function writeEntityName(entityName) {
+ if (entityName.kind === 63 /* Identifier */) {
+ writeTextOfNode(currentSourceFile, entityName);
+ }
+ else {
+ var qualifiedName = entityName;
+ writeEntityName(qualifiedName.left);
+ write(".");
+ writeTextOfNode(currentSourceFile, qualifiedName.right);
+ }
+ }
+ }
+ function emitTypeReference(type) {
+ emitEntityName(type.typeName);
+ if (type.typeArguments) {
+ write("<");
+ emitCommaList(type.typeArguments, emitType);
+ write(">");
+ }
+ }
+ function emitTypeQuery(type) {
+ write("typeof ");
+ emitEntityName(type.exprName);
+ }
+ function emitArrayType(type) {
+ emitType(type.elementType);
+ write("[]");
+ }
+ function emitTupleType(type) {
+ write("[");
+ emitCommaList(type.elementTypes, emitType);
+ write("]");
+ }
+ function emitUnionType(type) {
+ emitSeparatedList(type.types, " | ", emitType);
+ }
+ function emitParenType(type) {
+ write("(");
+ emitType(type.type);
+ write(")");
+ }
+ function emitTypeLiteral(type) {
+ write("{");
+ if (type.members.length) {
+ writeLine();
+ increaseIndent();
+ emitLines(type.members);
+ decreaseIndent();
+ }
+ write("}");
+ }
+ }
+ function emitSourceFile(node) {
+ currentSourceFile = node;
+ enclosingDeclaration = node;
+ emitLines(node.statements);
+ }
+ function emitExportAssignment(node) {
+ write("export = ");
+ writeTextOfNode(currentSourceFile, node.exportName);
+ write(";");
+ writeLine();
+ }
+ function emitModuleElementDeclarationFlags(node) {
+ if (node.parent === currentSourceFile) {
+ if (node.flags & 1 /* Export */) {
+ write("export ");
+ }
+ if (node.kind !== 189 /* InterfaceDeclaration */) {
+ write("declare ");
+ }
+ }
+ }
+ function emitClassMemberDeclarationFlags(node) {
+ if (node.flags & 32 /* Private */) {
+ write("private ");
+ }
+ else if (node.flags & 64 /* Protected */) {
+ write("protected ");
+ }
+ if (node.flags & 128 /* Static */) {
+ write("static ");
+ }
+ }
+ function emitImportDeclaration(node) {
+ var nodeEmitInfo = {
+ declaration: node,
+ outputPos: writer.getTextPos(),
+ indent: writer.getIndent(),
+ hasWritten: resolver.isDeclarationVisible(node)
+ };
+ aliasDeclarationEmitInfo.push(nodeEmitInfo);
+ if (nodeEmitInfo.hasWritten) {
+ writeImportDeclaration(node);
+ }
+ }
+ function writeImportDeclaration(node) {
+ emitJsDocComments(node);
+ if (node.flags & 1 /* Export */) {
+ write("export ");
+ }
+ write("import ");
+ writeTextOfNode(currentSourceFile, node.name);
+ write(" = ");
+ if (node.entityName) {
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node.entityName, getImportEntityNameVisibilityError);
+ write(";");
+ }
+ else {
+ write("require(");
+ writeTextOfNode(currentSourceFile, node.externalModuleName);
+ write(");");
+ }
+ writer.writeLine();
+ function getImportEntityNameVisibilityError(symbolAccesibilityResult) {
+ return {
+ diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
+ errorNode: node,
+ typeName: node.name
+ };
+ }
+ }
+ function emitModuleDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("module ");
+ writeTextOfNode(currentSourceFile, node.name);
+ while (node.body.kind !== 193 /* ModuleBlock */) {
+ node = node.body;
+ write(".");
+ writeTextOfNode(currentSourceFile, node.name);
+ }
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitLines(node.body.statements);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ enclosingDeclaration = prevEnclosingDeclaration;
+ }
+ }
+ function emitTypeAliasDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("type ");
+ writeTextOfNode(currentSourceFile, node.name);
+ write(" = ");
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node.type, getTypeAliasDeclarationVisibilityError);
+ write(";");
+ writeLine();
+ }
+ function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) {
+ return {
+ diagnosticMessage: ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
+ errorNode: node.type,
+ typeName: node.name
+ };
+ }
+ }
+ function emitEnumDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ if (ts.isConst(node)) {
+ write("const ");
+ }
+ write("enum ");
+ writeTextOfNode(currentSourceFile, node.name);
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitLines(node.members);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ }
+ }
+ function emitEnumMemberDeclaration(node) {
+ emitJsDocComments(node);
+ writeTextOfNode(currentSourceFile, node.name);
+ var enumMemberValue = resolver.getEnumMemberValue(node);
+ if (enumMemberValue !== undefined) {
+ write(" = ");
+ write(enumMemberValue.toString());
+ }
+ write(",");
+ writeLine();
+ }
+ function emitTypeParameters(typeParameters) {
+ function emitTypeParameter(node) {
+ increaseIndent();
+ emitJsDocComments(node);
+ decreaseIndent();
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) {
+ write(" extends ");
+ if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || (node.parent.parent && node.parent.parent.kind === 136 /* TypeLiteral */)) {
+ ts.Debug.assert(node.parent.kind === 125 /* Method */ || node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.kind === 129 /* CallSignature */ || node.parent.kind === 130 /* ConstructSignature */);
+ emitType(node.constraint);
+ }
+ else {
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node.constraint, getTypeParameterConstraintVisibilityError);
+ }
+ }
+ function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ switch (node.parent.kind) {
+ case 188 /* ClassDeclaration */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
+ break;
+ case 189 /* InterfaceDeclaration */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 130 /* ConstructSignature */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 129 /* CallSignature */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 125 /* Method */:
+ if (node.parent.flags & 128 /* Static */) {
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else if (node.parent.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
+ }
+ break;
+ case 186 /* FunctionDeclaration */:
+ diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
+ break;
+ default:
+ ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.name
+ };
+ }
+ }
+ if (typeParameters) {
+ write("<");
+ emitCommaList(typeParameters, emitTypeParameter);
+ write(">");
+ }
+ }
+ function emitHeritageClause(typeReferences, isImplementsList) {
+ if (typeReferences) {
+ write(isImplementsList ? " implements " : " extends ");
+ emitCommaList(typeReferences, emitTypeOfTypeReference);
+ }
+ function emitTypeOfTypeReference(node) {
+ emitTypeWithNewGetSymbolAccessibilityDiangostic(node, getHeritageClauseVisibilityError);
+ function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ if (node.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.parent.name
+ };
+ }
+ }
+ }
+ function emitClassDeclaration(node) {
+ function emitParameterProperties(constructorDeclaration) {
+ if (constructorDeclaration) {
+ ts.forEach(constructorDeclaration.parameters, function (param) {
+ if (param.flags & 112 /* AccessibilityModifier */) {
+ emitPropertyDeclaration(param);
+ }
+ });
+ }
+ }
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("class ");
+ writeTextOfNode(currentSourceFile, node.name);
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ emitTypeParameters(node.typeParameters);
+ if (node.baseType) {
+ emitHeritageClause([node.baseType], false);
+ }
+ emitHeritageClause(node.implementedTypes, true);
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitParameterProperties(getFirstConstructorWithBody(node));
+ emitLines(node.members);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ enclosingDeclaration = prevEnclosingDeclaration;
+ }
+ }
+ function emitInterfaceDeclaration(node) {
+ if (resolver.isDeclarationVisible(node)) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ write("interface ");
+ writeTextOfNode(currentSourceFile, node.name);
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ emitTypeParameters(node.typeParameters);
+ emitHeritageClause(node.baseTypes, false);
+ write(" {");
+ writeLine();
+ increaseIndent();
+ emitLines(node.members);
+ decreaseIndent();
+ write("}");
+ writeLine();
+ enclosingDeclaration = prevEnclosingDeclaration;
+ }
+ }
+ function emitPropertyDeclaration(node) {
+ emitJsDocComments(node);
+ emitClassMemberDeclarationFlags(node);
+ emitVariableDeclaration(node);
+ write(";");
+ writeLine();
+ }
+ function emitVariableDeclaration(node) {
+ if (node.kind !== 185 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) {
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) {
+ write("?");
+ }
+ if (node.kind === 124 /* Property */ && node.parent.kind === 136 /* TypeLiteral */) {
+ emitTypeOfVariableDeclarationFromTypeLiteral(node);
+ }
+ else if (!(node.flags & 32 /* Private */)) {
+ writeTypeAtLocation(node, node.type, getVariableDeclarationTypeVisibilityError);
+ }
+ }
+ function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ if (node.kind === 185 /* VariableDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
+ }
+ else if (node.kind === 124 /* Property */) {
+ if (node.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
+ }
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
+ }
+ }
+ return diagnosticMessage !== undefined ? {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.name
+ } : undefined;
+ }
+ }
+ function emitTypeOfVariableDeclarationFromTypeLiteral(node) {
+ if (node.type) {
+ write(": ");
+ emitType(node.type);
+ }
+ }
+ function emitVariableStatement(node) {
+ var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); });
+ if (hasDeclarationWithEmit) {
+ emitJsDocComments(node);
+ emitModuleElementDeclarationFlags(node);
+ if (ts.isLet(node)) {
+ write("let ");
+ }
+ else if (ts.isConst(node)) {
+ write("const ");
+ }
+ else {
+ write("var ");
+ }
+ emitCommaList(node.declarations, emitVariableDeclaration);
+ write(";");
+ writeLine();
+ }
+ }
+ function emitAccessorDeclaration(node) {
+ var accessors = getAllAccessorDeclarations(node.parent, node);
+ if (node === accessors.firstAccessor) {
+ emitJsDocComments(accessors.getAccessor);
+ emitJsDocComments(accessors.setAccessor);
+ emitClassMemberDeclarationFlags(node);
+ writeTextOfNode(currentSourceFile, node.name);
+ if (!(node.flags & 32 /* Private */)) {
+ var accessorWithTypeAnnotation = node;
+ var type = getTypeAnnotationFromAccessor(node);
+ if (!type) {
+ var anotherAccessor = node.kind === 127 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor;
+ type = getTypeAnnotationFromAccessor(anotherAccessor);
+ if (type) {
+ accessorWithTypeAnnotation = anotherAccessor;
+ }
+ }
+ writeTypeAtLocation(node, type, getAccessorDeclarationTypeVisibilityError);
+ }
+ write(";");
+ writeLine();
+ }
+ function getTypeAnnotationFromAccessor(accessor) {
+ if (accessor) {
+ return accessor.kind === 127 /* GetAccessor */ ? accessor.type : accessor.parameters[0].type;
+ }
+ }
+ function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ if (accessorWithTypeAnnotation.kind === 128 /* SetAccessor */) {
+ if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: accessorWithTypeAnnotation.parameters[0],
+ typeName: accessorWithTypeAnnotation.name
+ };
+ }
+ else {
+ if (accessorWithTypeAnnotation.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: accessorWithTypeAnnotation.name,
+ typeName: undefined
+ };
+ }
+ }
+ }
+ function emitFunctionDeclaration(node) {
+ if ((node.kind !== 186 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) {
+ emitJsDocComments(node);
+ if (node.kind === 186 /* FunctionDeclaration */) {
+ emitModuleElementDeclarationFlags(node);
+ }
+ else if (node.kind === 125 /* Method */) {
+ emitClassMemberDeclarationFlags(node);
+ }
+ if (node.kind === 186 /* FunctionDeclaration */) {
+ write("function ");
+ writeTextOfNode(currentSourceFile, node.name);
+ }
+ else if (node.kind === 126 /* Constructor */) {
+ write("constructor");
+ }
+ else {
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.flags & 4 /* QuestionMark */) {
+ write("?");
+ }
+ }
+ emitSignatureDeclaration(node);
+ }
+ }
+ function emitSignatureDeclarationWithJsDocComments(node) {
+ emitJsDocComments(node);
+ emitSignatureDeclaration(node);
+ }
+ function emitSignatureDeclaration(node) {
+ if (node.kind === 130 /* ConstructSignature */ || node.kind === 134 /* ConstructorType */) {
+ write("new ");
+ }
+ emitTypeParameters(node.typeParameters);
+ if (node.kind === 131 /* IndexSignature */) {
+ write("[");
+ }
+ else {
+ write("(");
+ }
+ var prevEnclosingDeclaration = enclosingDeclaration;
+ enclosingDeclaration = node;
+ emitCommaList(node.parameters, emitParameterDeclaration);
+ if (node.kind === 131 /* IndexSignature */) {
+ write("]");
+ }
+ else {
+ write(")");
+ }
+ var isFunctionTypeOrConstructorType = node.kind === 133 /* FunctionType */ || node.kind === 134 /* ConstructorType */;
+ if (isFunctionTypeOrConstructorType || node.parent.kind === 136 /* TypeLiteral */) {
+ if (node.type) {
+ write(isFunctionTypeOrConstructorType ? " => " : ": ");
+ emitType(node.type);
+ }
+ }
+ else if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) {
+ writeReturnTypeAtSignature(node, getReturnTypeVisibilityError);
+ }
+ enclosingDeclaration = prevEnclosingDeclaration;
+ if (!isFunctionTypeOrConstructorType) {
+ write(";");
+ writeLine();
+ }
+ function getReturnTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ switch (node.kind) {
+ case 130 /* ConstructSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
+ break;
+ case 129 /* CallSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
+ break;
+ case 131 /* IndexSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
+ break;
+ case 125 /* Method */:
+ if (node.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
+ }
+ else if (node.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
+ }
+ break;
+ case 186 /* FunctionDeclaration */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
+ break;
+ default:
+ ts.Debug.fail("This is unknown kind for signature: " + node.kind);
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node.name || node
+ };
+ }
+ }
+ function emitParameterDeclaration(node) {
+ increaseIndent();
+ emitJsDocComments(node);
+ if (node.flags & 8 /* Rest */) {
+ write("...");
+ }
+ writeTextOfNode(currentSourceFile, node.name);
+ if (node.initializer || (node.flags & 4 /* QuestionMark */)) {
+ write("?");
+ }
+ decreaseIndent();
+ if (node.parent.kind === 133 /* FunctionType */ || node.parent.kind === 134 /* ConstructorType */ || node.parent.parent.kind === 136 /* TypeLiteral */) {
+ emitTypeOfVariableDeclarationFromTypeLiteral(node);
+ }
+ else if (!(node.parent.flags & 32 /* Private */)) {
+ writeTypeAtLocation(node, node.type, getParameterDeclarationTypeVisibilityError);
+ }
+ function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) {
+ var diagnosticMessage;
+ switch (node.parent.kind) {
+ case 126 /* Constructor */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
+ break;
+ case 130 /* ConstructSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 129 /* CallSignature */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
+ break;
+ case 125 /* Method */:
+ if (node.parent.flags & 128 /* Static */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else if (node.parent.parent.kind === 188 /* ClassDeclaration */) {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
+ }
+ else {
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
+ }
+ break;
+ case 186 /* FunctionDeclaration */:
+ diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
+ break;
+ default:
+ ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind);
+ }
+ return {
+ diagnosticMessage: diagnosticMessage,
+ errorNode: node,
+ typeName: node.name
+ };
+ }
+ }
+ function emitNode(node) {
+ switch (node.kind) {
+ case 126 /* Constructor */:
+ case 186 /* FunctionDeclaration */:
+ case 125 /* Method */:
+ return emitFunctionDeclaration(node);
+ case 130 /* ConstructSignature */:
+ case 129 /* CallSignature */:
+ case 131 /* IndexSignature */:
+ return emitSignatureDeclarationWithJsDocComments(node);
+ case 127 /* GetAccessor */:
+ case 128 /* SetAccessor */:
+ return emitAccessorDeclaration(node);
+ case 163 /* VariableStatement */:
+ return emitVariableStatement(node);
+ case 124 /* Property */:
+ return emitPropertyDeclaration(node);
+ case 189 /* InterfaceDeclaration */:
+ return emitInterfaceDeclaration(node);
+ case 188 /* ClassDeclaration */:
+ return emitClassDeclaration(node);
+ case 190 /* TypeAliasDeclaration */:
+ return emitTypeAliasDeclaration(node);
+ case 196 /* EnumMember */:
+ return emitEnumMemberDeclaration(node);
+ case 191 /* EnumDeclaration */:
+ return emitEnumDeclaration(node);
+ case 192 /* ModuleDeclaration */:
+ return emitModuleDeclaration(node);
+ case 194 /* ImportDeclaration */:
+ return emitImportDeclaration(node);
+ case 195 /* ExportAssignment */:
+ return emitExportAssignment(node);
+ case 197 /* SourceFile */:
+ return emitSourceFile(node);
+ }
+ }
+ var referencePathsOutput = "";
+ function writeReferencePath(referencedFile) {
+ var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, program, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts";
+ declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, false);
+ referencePathsOutput += "/// " + newLine;
+ }
+ if (root) {
+ if (!compilerOptions.noResolve) {
+ var addedGlobalFileReference = false;
+ ts.forEach(root.referencedFiles, function (fileReference) {
+ var referencedFile = ts.tryResolveScriptReference(program, root, fileReference);
+ if (referencedFile && ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) {
+ writeReferencePath(referencedFile);
+ if (!isExternalModuleOrDeclarationFile(referencedFile)) {
+ addedGlobalFileReference = true;
+ }
+ }
+ });
+ }
+ emitNode(root);
+ }
+ else {
+ var emittedReferencedFiles = [];
+ ts.forEach(program.getSourceFiles(), function (sourceFile) {
+ if (!isExternalModuleOrDeclarationFile(sourceFile)) {
+ if (!compilerOptions.noResolve) {
+ ts.forEach(sourceFile.referencedFiles, function (fileReference) {
+ var referencedFile = ts.tryResolveScriptReference(program, sourceFile, fileReference);
+ if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) {
+ writeReferencePath(referencedFile);
+ emittedReferencedFiles.push(referencedFile);
+ }
+ });
+ }
+ emitNode(sourceFile);
+ }
+ });
+ }
+ return {
+ reportedDeclarationError: reportedDeclarationError,
+ aliasDeclarationEmitInfo: aliasDeclarationEmitInfo,
+ synchronousDeclarationOutput: writer.getText(),
+ referencePathsOutput: referencePathsOutput
+ };
+ }
+ function getDeclarationDiagnostics(program, resolver, targetSourceFile) {
+ var diagnostics = [];
+ var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js");
+ emitDeclarations(program, resolver, diagnostics, jsFilePath, targetSourceFile);
+ return diagnostics;
+ }
+ ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
function emitFiles(resolver, targetSourceFile) {
var program = resolver.getProgram();
var compilerHost = program.getCompilerHost();
@@ -6257,206 +7483,14 @@ var ts;
var sourceMapDataList = compilerOptions.sourceMap ? [] : undefined;
var diagnostics = [];
var newLine = program.getCompilerHost().getNewLine();
- function getSourceFilePathInNewDir(newDirPath, sourceFile) {
- var sourceFilePath = ts.getNormalizedPathFromPathComponents(ts.getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
- sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
- return ts.combinePaths(newDirPath, sourceFilePath);
- }
- function getOwnEmitOutputFilePath(sourceFile, extension) {
- if (compilerOptions.outDir) {
- var emitOutputFilePathWithoutExtension = ts.removeFileExtension(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
- }
- else {
- var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.filename);
- }
- return emitOutputFilePathWithoutExtension + extension;
- }
- function getFirstConstructorWithBody(node) {
- return ts.forEach(node.members, function (member) {
- if (member.kind === 126 /* Constructor */ && member.body) {
- return member;
- }
- });
- }
- function getAllAccessorDeclarations(node, accessor) {
- var firstAccessor;
- var getAccessor;
- var setAccessor;
- ts.forEach(node.members, function (member) {
- if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) {
- if (!firstAccessor) {
- firstAccessor = member;
- }
- if (member.kind === 127 /* GetAccessor */ && !getAccessor) {
- getAccessor = member;
- }
- if (member.kind === 128 /* SetAccessor */ && !setAccessor) {
- setAccessor = member;
- }
- }
- });
- return {
- firstAccessor: firstAccessor,
- getAccessor: getAccessor,
- setAccessor: setAccessor
- };
- }
- function createTextWriter() {
- var output = "";
- var indent = 0;
- var lineStart = true;
- var lineCount = 0;
- var linePos = 0;
- function write(s) {
- if (s && s.length) {
- if (lineStart) {
- output += getIndentString(indent);
- lineStart = false;
- }
- output += s;
- }
- }
- function rawWrite(s) {
- if (s !== undefined) {
- if (lineStart) {
- lineStart = false;
- }
- output += s;
- }
- }
- function writeLiteral(s) {
- if (s && s.length) {
- write(s);
- var lineStartsOfS = ts.computeLineStarts(s);
- if (lineStartsOfS.length > 1) {
- lineCount = lineCount + lineStartsOfS.length - 1;
- linePos = output.length - s.length + lineStartsOfS[lineStartsOfS.length - 1];
- }
- }
- }
- function writeLine() {
- if (!lineStart) {
- output += newLine;
- lineCount++;
- linePos = output.length;
- lineStart = true;
- }
- }
- return {
- write: write,
- rawWrite: rawWrite,
- writeLiteral: writeLiteral,
- writeLine: writeLine,
- increaseIndent: function () { return indent++; },
- decreaseIndent: function () { return indent--; },
- getIndent: function () { return indent; },
- getTextPos: function () { return output.length; },
- getLine: function () { return lineCount + 1; },
- getColumn: function () { return lineStart ? indent * getIndentSize() + 1 : output.length - linePos + 1; },
- getText: function () { return output; }
- };
- }
- var currentSourceFile;
- function getSourceTextOfLocalNode(node) {
- var text = currentSourceFile.text;
- return text.substring(ts.skipTrivia(text, node.pos), node.end);
- }
- function getLineOfLocalPosition(pos) {
- return currentSourceFile.getLineAndCharacterFromPosition(pos).line;
- }
- function writeFile(filename, data, writeByteOrderMark) {
- compilerHost.writeFile(filename, data, writeByteOrderMark, function (hostErrorMessage) {
- diagnostics.push(ts.createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, filename, hostErrorMessage));
- });
- }
- function emitComments(comments, trailingSeparator, writer, writeComment) {
- var emitLeadingSpace = !trailingSeparator;
- ts.forEach(comments, function (comment) {
- if (emitLeadingSpace) {
- writer.write(" ");
- emitLeadingSpace = false;
- }
- writeComment(comment, writer);
- if (comment.hasTrailingNewLine) {
- writer.writeLine();
- }
- else if (trailingSeparator) {
- writer.write(" ");
- }
- else {
- emitLeadingSpace = true;
- }
- });
- }
- function emitNewLineBeforeLeadingComments(node, leadingComments, writer) {
- if (leadingComments && leadingComments.length && node.pos !== leadingComments[0].pos && getLineOfLocalPosition(node.pos) !== getLineOfLocalPosition(leadingComments[0].pos)) {
- writer.writeLine();
- }
- }
- function writeCommentRange(comment, writer) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
- var firstCommentLineAndCharacter = currentSourceFile.getLineAndCharacterFromPosition(comment.pos);
- var firstCommentLineIndent;
- for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
- var nextLineStart = currentSourceFile.getPositionFromLineAndCharacter(currentLine + 1, 1);
- if (pos !== comment.pos) {
- if (firstCommentLineIndent === undefined) {
- firstCommentLineIndent = calculateIndent(currentSourceFile.getPositionFromLineAndCharacter(firstCommentLineAndCharacter.line, 1), comment.pos);
- }
- var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
- var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(pos, nextLineStart);
- if (spacesToEmit > 0) {
- var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
- var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
- writer.rawWrite(indentSizeSpaceString);
- while (numberOfSingleSpacesToEmit) {
- writer.rawWrite(" ");
- numberOfSingleSpacesToEmit--;
- }
- }
- else {
- writer.rawWrite("");
- }
- }
- writeTrimmedCurrentLine(pos, nextLineStart);
- pos = nextLineStart;
- }
- }
- else {
- writer.write(currentSourceFile.text.substring(comment.pos, comment.end));
- }
- function writeTrimmedCurrentLine(pos, nextLineStart) {
- var end = Math.min(comment.end, nextLineStart - 1);
- var currentLineText = currentSourceFile.text.substring(pos, end).replace(/^\s+|\s+$/g, '');
- if (currentLineText) {
- writer.write(currentLineText);
- if (end !== comment.end) {
- writer.writeLine();
- }
- }
- else {
- writer.writeLiteral(newLine);
- }
- }
- function calculateIndent(pos, end) {
- var currentLineIndent = 0;
- for (; pos < end && ts.isWhiteSpace(currentSourceFile.text.charCodeAt(pos)); pos++) {
- if (currentSourceFile.text.charCodeAt(pos) === 9 /* tab */) {
- currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
- }
- else {
- currentLineIndent++;
- }
- }
- return currentLineIndent;
- }
- }
function emitJavaScript(jsFilePath, root) {
- var writer = createTextWriter();
+ var writer = createTextWriter(newLine);
var write = writer.write;
+ var writeTextOfNode = writer.writeTextOfNode;
var writeLine = writer.writeLine;
var increaseIndent = writer.increaseIndent;
var decreaseIndent = writer.decreaseIndent;
+ var currentSourceFile;
var extendsEmitted = false;
var writeEmittedFiles = writeJavaScriptFile;
var emitLeadingComments = compilerOptions.removeComments ? function (node) {
@@ -6613,7 +7647,7 @@ var ts;
if (scopeName) {
recordScopeNameStart(scopeName);
}
- else if (node.kind === 185 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 191 /* ModuleDeclaration */ || node.kind === 187 /* ClassDeclaration */ || node.kind === 190 /* EnumDeclaration */) {
+ else if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 152 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */) {
if (node.name) {
scopeName = node.name.text;
}
@@ -6627,9 +7661,9 @@ var ts;
sourceMapNameIndices.pop();
}
;
- function writeCommentRangeWithMap(comment, writer) {
+ function writeCommentRangeWithMap(curentSourceFile, writer, comment, newLine) {
recordSourceMapSpan(comment.pos);
- writeCommentRange(comment, writer);
+ writeCommentRange(currentSourceFile, writer, comment, newLine);
recordSourceMapSpan(comment.end);
}
function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings) {
@@ -6657,7 +7691,7 @@ var ts;
}
function writeJavaScriptAndSourceMapFile(emitOutput, writeByteOrderMark) {
encodeLastRecordedSourceMapSpan();
- writeFile(sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
+ writeFile(compilerHost, diagnostics, sourceMapData.sourceMapFilePath, serializeSourceMapContents(3, sourceMapData.sourceMapFile, sourceMapData.sourceMapSourceRoot, sourceMapData.sourceMapSources, sourceMapData.sourceMapNames, sourceMapData.sourceMapMappings), false);
sourceMapDataList.push(sourceMapData);
writeJavaScriptFile(emitOutput + "//# sourceMappingURL=" + sourceMapData.jsSourceMappingURL, writeByteOrderMark);
}
@@ -6680,7 +7714,7 @@ var ts;
if (compilerOptions.mapRoot) {
sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot);
if (root) {
- sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(sourceMapDir, root));
+ sourceMapDir = ts.getDirectoryPath(getSourceFilePathInNewDir(root, program, sourceMapDir));
}
if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) {
sourceMapDir = ts.combinePaths(program.getCommonSourceDirectory(), sourceMapDir);
@@ -6695,7 +7729,7 @@ var ts;
}
function emitNodeWithMap(node) {
if (node) {
- if (node.kind != 196 /* SourceFile */) {
+ if (node.kind != 197 /* SourceFile */) {
recordEmitNodeStartSpan(node);
emitNode(node);
recordEmitNodeEndSpan(node);
@@ -6716,7 +7750,7 @@ var ts;
writeComment = writeCommentRangeWithMap;
}
function writeJavaScriptFile(emitOutput, writeByteOrderMark) {
- writeFile(jsFilePath, emitOutput, writeByteOrderMark);
+ writeFile(compilerHost, diagnostics, jsFilePath, emitOutput, writeByteOrderMark);
}
function emitTokenText(tokenKind, startPos, emitFn) {
var tokenString = ts.tokenToString(tokenKind);
@@ -6793,7 +7827,7 @@ var ts;
if (compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind)) {
return getTemplateLiteralAsStringLiteral(node);
}
- return getSourceTextOfLocalNode(node);
+ return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
}
}
function getTemplateLiteralAsStringLiteral(node) {
@@ -6876,7 +7910,7 @@ var ts;
write(node.text);
}
else {
- write(getSourceTextOfLocalNode(node));
+ writeTextOfNode(currentSourceFile, node);
}
write("\"");
}
@@ -6885,29 +7919,29 @@ var ts;
var parent = node.parent;
switch (parent.kind) {
case 123 /* Parameter */:
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 124 /* Property */:
case 143 /* PropertyAssignment */:
case 144 /* ShorthandPropertyAssignment */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 125 /* Method */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
case 152 /* FunctionExpression */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 194 /* ImportDeclaration */:
return parent.name === node;
- case 171 /* BreakStatement */:
- case 170 /* ContinueStatement */:
- case 194 /* ExportAssignment */:
+ case 172 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 195 /* ExportAssignment */:
return false;
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return node.parent.label === node;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
return node.parent.variable === node;
}
}
@@ -6917,14 +7951,14 @@ var ts;
write(prefix);
write(".");
}
- write(getSourceTextOfLocalNode(node));
+ writeTextOfNode(currentSourceFile, node);
}
function emitIdentifier(node) {
if (!isNotExpressionIdentifier(node)) {
emitExpressionIdentifier(node);
}
else {
- write(getSourceTextOfLocalNode(node));
+ writeTextOfNode(currentSourceFile, node);
}
}
function emitThis(node) {
@@ -7131,8 +8165,8 @@ var ts;
emitToken(13 /* OpenBraceToken */, node.pos);
increaseIndent();
scopeEmitStart(node.parent);
- if (node.kind === 192 /* ModuleBlock */) {
- ts.Debug.assert(node.parent.kind === 191 /* ModuleDeclaration */);
+ if (node.kind === 193 /* ModuleBlock */) {
+ ts.Debug.assert(node.parent.kind === 192 /* ModuleDeclaration */);
emitCaptureThisForNodeIfNecessary(node.parent);
}
emitLines(node.statements);
@@ -7142,7 +8176,7 @@ var ts;
scopeEmitEnd();
}
function emitEmbeddedStatement(node) {
- if (node.kind === 161 /* Block */) {
+ if (node.kind === 162 /* Block */) {
write(" ");
emit(node);
}
@@ -7175,7 +8209,7 @@ var ts;
if (node.elseStatement) {
writeLine();
emitToken(74 /* ElseKeyword */, node.thenStatement.end);
- if (node.elseStatement.kind === 165 /* IfStatement */) {
+ if (node.elseStatement.kind === 166 /* IfStatement */) {
write(" ");
emit(node.elseStatement);
}
@@ -7188,7 +8222,7 @@ var ts;
function emitDoStatement(node) {
write("do");
emitEmbeddedStatement(node.statement);
- if (node.statement.kind === 161 /* Block */) {
+ if (node.statement.kind === 162 /* Block */) {
write(" ");
}
else {
@@ -7209,10 +8243,10 @@ var ts;
write(" ");
endPos = emitToken(15 /* OpenParenToken */, endPos);
if (node.declarations) {
- if (node.declarations[0] && node.declarations[0].flags & 2048 /* Let */) {
+ if (node.declarations[0] && ts.isLet(node.declarations[0])) {
emitToken(102 /* LetKeyword */, endPos);
}
- else if (node.declarations[0] && node.declarations[0].flags & 4096 /* Const */) {
+ else if (node.declarations[0] && ts.isConst(node.declarations[0])) {
emitToken(68 /* ConstKeyword */, endPos);
}
else {
@@ -7238,7 +8272,7 @@ var ts;
if (node.declarations) {
if (node.declarations.length >= 1) {
var decl = node.declarations[0];
- if (decl.flags & 2048 /* Let */) {
+ if (ts.isLet(decl)) {
emitToken(102 /* LetKeyword */, endPos);
}
else {
@@ -7257,7 +8291,7 @@ var ts;
emitEmbeddedStatement(node.statement);
}
function emitBreakOrContinueStatement(node) {
- emitToken(node.kind === 171 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos);
+ emitToken(node.kind === 172 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos);
emitOptional(" ", node.label);
write(";");
}
@@ -7289,10 +8323,10 @@ var ts;
emitToken(14 /* CloseBraceToken */, node.clauses.end);
}
function isOnSameLine(node1, node2) {
- return getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node2.pos));
+ return getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos));
}
function emitCaseOrDefaultClause(node) {
- if (node.kind === 175 /* CaseClause */) {
+ if (node.kind === 176 /* CaseClause */) {
write("case ");
emit(node.expression);
write(":");
@@ -7347,7 +8381,7 @@ var ts;
function getContainingModule(node) {
do {
node = node.parent;
- } while (node && node.kind !== 191 /* ModuleDeclaration */);
+ } while (node && node.kind !== 192 /* ModuleDeclaration */);
return node;
}
function emitModuleMemberName(node) {
@@ -7369,10 +8403,10 @@ var ts;
function emitVariableStatement(node) {
emitLeadingComments(node);
if (!(node.flags & 1 /* Export */)) {
- if (node.flags & 2048 /* Let */) {
+ if (ts.isLet(node)) {
write("let ");
}
- else if (node.flags & 4096 /* Const */) {
+ else if (ts.isConst(node)) {
write("const ");
}
else {
@@ -7459,7 +8493,7 @@ var ts;
emitLeadingComments(node);
}
write("function ");
- if (node.kind === 185 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) {
+ if (node.kind === 186 /* FunctionDeclaration */ || (node.kind === 152 /* FunctionExpression */ && node.name)) {
emit(node.name);
}
emitSignatureAndBody(node);
@@ -7489,16 +8523,16 @@ var ts;
write(" {");
scopeEmitStart(node);
increaseIndent();
- emitDetachedComments(node.body.kind === 186 /* FunctionBlock */ ? node.body.statements : node.body);
+ emitDetachedComments(node.body.kind === 187 /* FunctionBlock */ ? node.body.statements : node.body);
var startIndex = 0;
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
startIndex = emitDirectivePrologues(node.body.statements, true);
}
var outPos = writer.getTextPos();
emitCaptureThisForNodeIfNecessary(node);
emitDefaultValueAssignments(node);
emitRestParameter(node);
- if (node.body.kind !== 186 /* FunctionBlock */ && outPos === writer.getTextPos()) {
+ if (node.body.kind !== 187 /* FunctionBlock */ && outPos === writer.getTextPos()) {
decreaseIndent();
write(" ");
emitStart(node.body);
@@ -7511,7 +8545,7 @@ var ts;
emitEnd(node.body);
}
else {
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
emitLinesStartingAt(node.body.statements, startIndex);
}
else {
@@ -7523,7 +8557,7 @@ var ts;
emitTrailingComments(node.body);
}
writeLine();
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
emitLeadingCommentsOfPosition(node.body.statements.end);
decreaseIndent();
emitToken(14 /* CloseBraceToken */, node.body.statements.end);
@@ -7549,7 +8583,7 @@ var ts;
function findInitialSuperCall(ctor) {
if (ctor.body) {
var statement = ctor.body.statements[0];
- if (statement && statement.kind === 164 /* ExpressionStatement */) {
+ if (statement && statement.kind === 165 /* ExpressionStatement */) {
var expr = statement.expression;
if (expr && expr.kind === 147 /* CallExpression */) {
var func = expr.func;
@@ -7800,7 +8834,7 @@ var ts;
emitPinnedOrTripleSlashComments(node);
}
function emitEnumDeclaration(node) {
- var isConstEnum = ts.isConstEnumDeclaration(node);
+ var isConstEnum = ts.isConst(node);
if (isConstEnum && !compilerOptions.preserveConstEnums) {
return;
}
@@ -7869,13 +8903,14 @@ var ts;
}
}
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
- if (moduleDeclaration.body.kind === 191 /* ModuleDeclaration */) {
+ if (moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) {
var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
return recursiveInnerModule || moduleDeclaration.body;
}
}
function emitModuleDeclaration(node) {
- if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ var shouldEmit = ts.getModuleInstanceState(node) === 1 /* Instantiated */ || (ts.getModuleInstanceState(node) === 2 /* ConstEnumOnly */ && compilerOptions.preserveConstEnums);
+ if (!shouldEmit) {
return emitPinnedOrTripleSlashComments(node);
}
emitLeadingComments(node);
@@ -7891,7 +8926,7 @@ var ts;
write(resolver.getLocalNameOfContainer(node));
emitEnd(node.name);
write(") ");
- if (node.body.kind === 192 /* ModuleBlock */) {
+ if (node.body.kind === 193 /* ModuleBlock */) {
emit(node.body);
}
else {
@@ -7925,7 +8960,7 @@ var ts;
emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node);
}
if (emitImportDeclaration) {
- if (node.externalModuleName && node.parent.kind === 196 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) {
+ if (node.externalModuleName && node.parent.kind === 197 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) {
if (node.flags & 1 /* Export */) {
writeLine();
emitLeadingComments(node);
@@ -7965,7 +9000,7 @@ var ts;
function getExternalImportDeclarations(node) {
var result = [];
ts.forEach(node.statements, function (stat) {
- if (stat.kind === 193 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) {
+ if (stat.kind === 194 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) {
result.push(stat);
}
});
@@ -7973,7 +9008,7 @@ var ts;
}
function getFirstExportAssignment(sourceFile) {
return ts.forEach(sourceFile.statements, function (node) {
- if (node.kind === 194 /* ExportAssignment */) {
+ if (node.kind === 195 /* ExportAssignment */) {
return node;
}
});
@@ -8146,7 +9181,7 @@ var ts;
return emit(node.operand);
case 151 /* ParenExpression */:
return emitParenExpression(node);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
return emitFunctionDeclaration(node);
@@ -8157,65 +9192,65 @@ var ts;
return emitBinaryExpression(node);
case 157 /* ConditionalExpression */:
return emitConditionalExpression(node);
- case 160 /* OmittedExpression */:
+ case 161 /* OmittedExpression */:
return;
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 182 /* FinallyBlock */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 183 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
return emitBlock(node);
- case 162 /* VariableStatement */:
+ case 163 /* VariableStatement */:
return emitVariableStatement(node);
- case 163 /* EmptyStatement */:
+ case 164 /* EmptyStatement */:
return write(";");
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return emitExpressionStatement(node);
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
return emitIfStatement(node);
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
return emitDoStatement(node);
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return emitWhileStatement(node);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return emitForStatement(node);
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return emitForInStatement(node);
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
return emitBreakOrContinueStatement(node);
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return emitReturnStatement(node);
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
return emitWithStatement(node);
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return emitSwitchStatement(node);
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
return emitCaseOrDefaultClause(node);
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return emitLabelledStatement(node);
- case 178 /* ThrowStatement */:
+ case 179 /* ThrowStatement */:
return emitThrowStatement(node);
- case 179 /* TryStatement */:
+ case 180 /* TryStatement */:
return emitTryStatement(node);
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
return emitCatchBlock(node);
- case 183 /* DebuggerStatement */:
+ case 184 /* DebuggerStatement */:
return emitDebuggerStatement(node);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return emitVariableDeclaration(node);
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return emitClassDeclaration(node);
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return emitInterfaceDeclaration(node);
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
return emitEnumDeclaration(node);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return emitModuleDeclaration(node);
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return emitImportDeclaration(node);
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
return emitSourceFile(node);
}
}
@@ -8233,7 +9268,7 @@ var ts;
return leadingComments;
}
function getLeadingCommentsToEmit(node) {
- if (node.parent.kind === 196 /* SourceFile */ || node.pos !== node.parent.pos) {
+ if (node.parent.kind === 197 /* SourceFile */ || node.pos !== node.parent.pos) {
var leadingComments;
if (hasDetachedComments(node.pos)) {
leadingComments = getLeadingCommentsWithoutDetachedComments();
@@ -8246,13 +9281,13 @@ var ts;
}
function emitLeadingDeclarationComments(node) {
var leadingComments = getLeadingCommentsToEmit(node);
- emitNewLineBeforeLeadingComments(node, leadingComments, writer);
- emitComments(leadingComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
+ emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitTrailingDeclarationComments(node) {
- if (node.parent.kind === 196 /* SourceFile */ || node.end !== node.parent.end) {
+ if (node.parent.kind === 197 /* SourceFile */ || node.end !== node.parent.end) {
var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end);
- emitComments(trailingComments, false, writer, writeComment);
+ emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment);
}
}
function emitLeadingCommentsOfLocalPosition(pos) {
@@ -8263,8 +9298,8 @@ var ts;
else {
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- emitNewLineBeforeLeadingComments({ pos: pos, end: pos }, leadingComments, writer);
- emitComments(leadingComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
+ emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitDetachedCommentsAtPosition(node) {
var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
@@ -8273,8 +9308,8 @@ var ts;
var lastComment;
ts.forEach(leadingComments, function (comment) {
if (lastComment) {
- var lastCommentLine = getLineOfLocalPosition(lastComment.end);
- var commentLine = getLineOfLocalPosition(comment.pos);
+ var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end);
+ var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos);
if (commentLine >= lastCommentLine + 2) {
return detachedComments;
}
@@ -8283,11 +9318,11 @@ var ts;
lastComment = comment;
});
if (detachedComments.length) {
- var lastCommentLine = getLineOfLocalPosition(detachedComments[detachedComments.length - 1].end);
- var astLine = getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node.pos));
+ var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
+ var astLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos));
if (astLine >= lastCommentLine + 2) {
- emitNewLineBeforeLeadingComments(node, leadingComments, writer);
- emitComments(detachedComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
+ emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment);
var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: detachedComments[detachedComments.length - 1].end };
if (detachedCommentsInfo) {
detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -8309,8 +9344,8 @@ var ts;
return true;
}
}
- emitNewLineBeforeLeadingComments(node, pinnedComments, writer);
- emitComments(pinnedComments, true, writer, writeComment);
+ emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, pinnedComments);
+ emitComments(currentSourceFile, writer, pinnedComments, true, newLine, writeComment);
}
if (compilerOptions.sourceMap) {
initializeEmitterWithSourceMaps();
@@ -8328,722 +9363,20 @@ var ts;
writeLine();
writeEmittedFiles(writer.getText(), compilerOptions.emitBOM);
}
- function emitDeclarations(jsFilePath, root) {
- var writer = createTextWriterWithSymbolWriter();
- var write = writer.write;
- var writeLine = writer.writeLine;
- var increaseIndent = writer.increaseIndent;
- var decreaseIndent = writer.decreaseIndent;
- var enclosingDeclaration;
- var reportedDeclarationError = false;
- var emitJsDocComments = compilerOptions.removeComments ? function (declaration) {
- } : writeJsDocComments;
- var aliasDeclarationEmitInfo = [];
- var getSymbolVisibilityDiagnosticMessage;
- function createTextWriterWithSymbolWriter() {
- var writer = createTextWriter();
- writer.trackSymbol = trackSymbol;
- writer.writeKeyword = writer.write;
- writer.writeOperator = writer.write;
- writer.writePunctuation = writer.write;
- writer.writeSpace = writer.write;
- writer.writeStringLiteral = writer.writeLiteral;
- writer.writeParameter = writer.write;
- writer.writeSymbol = writer.write;
- return writer;
- }
- function writeAsychronousImportDeclarations(importDeclarations) {
- var oldWriter = writer;
- ts.forEach(importDeclarations, function (aliasToWrite) {
- var aliasEmitInfo = ts.forEach(aliasDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.declaration === aliasToWrite ? declEmitInfo : undefined; });
- writer = createTextWriterWithSymbolWriter();
- for (var declarationIndent = aliasEmitInfo.indent; declarationIndent; declarationIndent--) {
- writer.increaseIndent();
- }
- writeImportDeclaration(aliasToWrite);
- aliasEmitInfo.asynchronousOutput = writer.getText();
- });
- writer = oldWriter;
- }
- function trackSymbol(symbol, enclosingDeclaration, meaning) {
- var symbolAccesibilityResult = resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning);
- if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) {
- if (symbolAccesibilityResult && symbolAccesibilityResult.aliasesToMakeVisible) {
- writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
- }
- }
- else {
- reportedDeclarationError = true;
- var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult);
- if (errorInfo) {
- if (errorInfo.typeName) {
- diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, getSourceTextOfLocalNode(errorInfo.typeName), symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
- }
- else {
- diagnostics.push(ts.createDiagnosticForNode(errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccesibilityResult.errorSymbolName, symbolAccesibilityResult.errorModuleName));
- }
- }
- }
- }
- function emitLines(nodes) {
- for (var i = 0, n = nodes.length; i < n; i++) {
- emitNode(nodes[i]);
- }
- }
- function emitCommaList(nodes, eachNodeEmitFn) {
- var currentWriterPos = writer.getTextPos();
- for (var i = 0, n = nodes.length; i < n; i++) {
- if (currentWriterPos !== writer.getTextPos()) {
- write(", ");
- }
- currentWriterPos = writer.getTextPos();
- eachNodeEmitFn(nodes[i]);
- }
- }
- function writeJsDocComments(declaration) {
- if (declaration) {
- var jsDocComments = ts.getJsDocComments(declaration, currentSourceFile);
- emitNewLineBeforeLeadingComments(declaration, jsDocComments, writer);
- emitComments(jsDocComments, true, writer, writeCommentRange);
- }
- }
- function emitSourceTextOfNode(node) {
- write(getSourceTextOfLocalNode(node));
- }
- function emitSourceFile(node) {
- currentSourceFile = node;
- enclosingDeclaration = node;
- emitLines(node.statements);
- }
- function emitExportAssignment(node) {
- write("export = ");
- emitSourceTextOfNode(node.exportName);
- write(";");
- writeLine();
- }
- function emitDeclarationFlags(node) {
- if (node.flags & 128 /* Static */) {
- if (node.flags & 32 /* Private */) {
- write("private ");
- }
- else if (node.flags & 64 /* Protected */) {
- write("protected ");
- }
- write("static ");
- }
- else {
- if (node.flags & 32 /* Private */) {
- write("private ");
- }
- else if (node.flags & 64 /* Protected */) {
- write("protected ");
- }
- else if (node.parent === currentSourceFile) {
- if (node.flags & 1 /* Export */) {
- write("export ");
- }
- if (node.kind !== 188 /* InterfaceDeclaration */) {
- write("declare ");
- }
- }
- }
- }
- function emitImportDeclaration(node) {
- var nodeEmitInfo = {
- declaration: node,
- outputPos: writer.getTextPos(),
- indent: writer.getIndent(),
- hasWritten: resolver.isDeclarationVisible(node)
- };
- aliasDeclarationEmitInfo.push(nodeEmitInfo);
- if (nodeEmitInfo.hasWritten) {
- writeImportDeclaration(node);
- }
- }
- function writeImportDeclaration(node) {
- emitJsDocComments(node);
- if (node.flags & 1 /* Export */) {
- writer.write("export ");
- }
- writer.write("import ");
- writer.write(getSourceTextOfLocalNode(node.name));
- writer.write(" = ");
- if (node.entityName) {
- checkEntityNameAccessible();
- writer.write(getSourceTextOfLocalNode(node.entityName));
- writer.write(";");
- }
- else {
- writer.write("require(");
- writer.write(getSourceTextOfLocalNode(node.externalModuleName));
- writer.write(");");
- }
- writer.writeLine();
- function checkEntityNameAccessible() {
- var symbolAccesibilityResult = resolver.isImportDeclarationEntityNameReferenceDeclarationVisibile(node.entityName);
- if (symbolAccesibilityResult.accessibility === 0 /* Accessible */) {
- if (symbolAccesibilityResult.aliasesToMakeVisible) {
- writeAsychronousImportDeclarations(symbolAccesibilityResult.aliasesToMakeVisible);
- }
- }
- else {
- reportedDeclarationError = true;
- diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Import_declaration_0_is_using_private_name_1, getSourceTextOfLocalNode(node.name), symbolAccesibilityResult.errorSymbolName));
- }
- }
- }
- function emitModuleDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("module ");
- emitSourceTextOfNode(node.name);
- while (node.body.kind !== 192 /* ModuleBlock */) {
- node = node.body;
- write(".");
- emitSourceTextOfNode(node.name);
- }
- var prevEnclosingDeclaration = enclosingDeclaration;
- enclosingDeclaration = node;
- write(" {");
- writeLine();
- increaseIndent();
- emitLines(node.body.statements);
- decreaseIndent();
- write("}");
- writeLine();
- enclosingDeclaration = prevEnclosingDeclaration;
- }
- }
- function emitTypeAliasDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("type ");
- emitSourceTextOfNode(node.name);
- write(" = ");
- getSymbolVisibilityDiagnosticMessage = getTypeAliasDeclarationVisibilityError;
- resolver.writeTypeAtLocation(node.type, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- write(";");
- writeLine();
- }
- function getTypeAliasDeclarationVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1;
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- };
- }
- }
- function emitEnumDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- if (ts.isConstEnumDeclaration(node)) {
- write("const ");
- }
- write("enum ");
- emitSourceTextOfNode(node.name);
- write(" {");
- writeLine();
- increaseIndent();
- emitLines(node.members);
- decreaseIndent();
- write("}");
- writeLine();
- }
- }
- function emitEnumMemberDeclaration(node) {
- emitJsDocComments(node);
- emitSourceTextOfNode(node.name);
- var enumMemberValue = resolver.getEnumMemberValue(node);
- if (enumMemberValue !== undefined) {
- write(" = ");
- write(enumMemberValue.toString());
- }
- write(",");
- writeLine();
- }
- function emitTypeParameters(typeParameters) {
- function emitTypeParameter(node) {
- function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- switch (node.parent.kind) {
- case 187 /* ClassDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
- break;
- case 188 /* InterfaceDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
- break;
- case 130 /* ConstructSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 129 /* CallSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 125 /* Method */:
- if (node.parent.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else if (node.parent.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
- }
- break;
- case 185 /* FunctionDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
- break;
- default:
- ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- };
- }
- increaseIndent();
- emitJsDocComments(node);
- decreaseIndent();
- emitSourceTextOfNode(node.name);
- if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) {
- write(" extends ");
- getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError;
- resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- }
- if (typeParameters) {
- write("<");
- emitCommaList(typeParameters, emitTypeParameter);
- write(">");
- }
- }
- function emitHeritageClause(typeReferences, isImplementsList) {
- if (typeReferences) {
- write(isImplementsList ? " implements " : " extends ");
- emitCommaList(typeReferences, emitTypeOfTypeReference);
- }
- function emitTypeOfTypeReference(node) {
- getSymbolVisibilityDiagnosticMessage = getHeritageClauseVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer);
- function getHeritageClauseVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- if (node.parent.kind === 187 /* ClassDeclaration */) {
- if (symbolAccesibilityResult.errorModuleName) {
- diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2;
- }
- else {
- diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1;
- }
- }
- else {
- if (symbolAccesibilityResult.errorModuleName) {
- diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2;
- }
- else {
- diagnosticMessage = ts.Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
- }
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.parent.name
- };
- }
- }
- }
- function emitClassDeclaration(node) {
- function emitParameterProperties(constructorDeclaration) {
- if (constructorDeclaration) {
- ts.forEach(constructorDeclaration.parameters, function (param) {
- if (param.flags & 112 /* AccessibilityModifier */) {
- emitPropertyDeclaration(param);
- }
- });
- }
- }
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("class ");
- emitSourceTextOfNode(node.name);
- var prevEnclosingDeclaration = enclosingDeclaration;
- enclosingDeclaration = node;
- emitTypeParameters(node.typeParameters);
- if (node.baseType) {
- emitHeritageClause([node.baseType], false);
- }
- emitHeritageClause(node.implementedTypes, true);
- write(" {");
- writeLine();
- increaseIndent();
- emitParameterProperties(getFirstConstructorWithBody(node));
- emitLines(node.members);
- decreaseIndent();
- write("}");
- writeLine();
- enclosingDeclaration = prevEnclosingDeclaration;
- }
- }
- function emitInterfaceDeclaration(node) {
- if (resolver.isDeclarationVisible(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- write("interface ");
- emitSourceTextOfNode(node.name);
- var prevEnclosingDeclaration = enclosingDeclaration;
- enclosingDeclaration = node;
- emitTypeParameters(node.typeParameters);
- emitHeritageClause(node.baseTypes, false);
- write(" {");
- writeLine();
- increaseIndent();
- emitLines(node.members);
- decreaseIndent();
- write("}");
- writeLine();
- enclosingDeclaration = prevEnclosingDeclaration;
- }
- }
- function emitPropertyDeclaration(node) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- emitVariableDeclaration(node);
- write(";");
- writeLine();
- }
- function emitVariableDeclaration(node) {
- if (node.kind !== 184 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) {
- emitSourceTextOfNode(node.name);
- if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) {
- write("?");
- }
- if (!(node.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getVariableDeclarationTypeVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- }
- function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- if (node.kind === 184 /* VariableDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
- }
- else if (node.kind === 124 /* Property */) {
- if (node.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
- }
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
- }
- }
- return diagnosticMessage !== undefined ? {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- } : undefined;
- }
- }
- function emitVariableStatement(node) {
- var hasDeclarationWithEmit = ts.forEach(node.declarations, function (varDeclaration) { return resolver.isDeclarationVisible(varDeclaration); });
- if (hasDeclarationWithEmit) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- if (node.flags & 2048 /* Let */) {
- write("let ");
- }
- else if (node.flags & 4096 /* Const */) {
- write("const ");
- }
- else {
- write("var ");
- }
- emitCommaList(node.declarations, emitVariableDeclaration);
- write(";");
- writeLine();
- }
- }
- function emitAccessorDeclaration(node) {
- var accessors = getAllAccessorDeclarations(node.parent, node);
- if (node === accessors.firstAccessor) {
- emitJsDocComments(accessors.getAccessor);
- emitJsDocComments(accessors.setAccessor);
- emitDeclarationFlags(node);
- emitSourceTextOfNode(node.name);
- if (!(node.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getAccessorDeclarationTypeVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- write(";");
- writeLine();
- }
- function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- if (node.kind === 128 /* SetAccessor */) {
- if (node.parent.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_property_setter_from_exported_class_has_or_is_using_private_name_1;
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node.parameters[0],
- typeName: node.name
- };
- }
- else {
- if (node.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0;
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node.name,
- typeName: undefined
- };
- }
- }
- }
- function emitFunctionDeclaration(node) {
- if ((node.kind !== 185 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) {
- emitJsDocComments(node);
- emitDeclarationFlags(node);
- if (node.kind === 185 /* FunctionDeclaration */) {
- write("function ");
- emitSourceTextOfNode(node.name);
- }
- else if (node.kind === 126 /* Constructor */) {
- write("constructor");
- }
- else {
- emitSourceTextOfNode(node.name);
- if (node.flags & 4 /* QuestionMark */) {
- write("?");
- }
- }
- emitSignatureDeclaration(node);
- }
- }
- function emitConstructSignatureDeclaration(node) {
- emitJsDocComments(node);
- write("new ");
- emitSignatureDeclaration(node);
- }
- function emitSignatureDeclaration(node) {
- if (node.kind === 129 /* CallSignature */ || node.kind === 131 /* IndexSignature */) {
- emitJsDocComments(node);
- }
- emitTypeParameters(node.typeParameters);
- if (node.kind === 131 /* IndexSignature */) {
- write("[");
- }
- else {
- write("(");
- }
- emitCommaList(node.parameters, emitParameterDeclaration);
- if (node.kind === 131 /* IndexSignature */) {
- write("]");
- }
- else {
- write(")");
- }
- if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError;
- resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- write(";");
- writeLine();
- function getReturnTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- switch (node.kind) {
- case 130 /* ConstructSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
- break;
- case 129 /* CallSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
- break;
- case 131 /* IndexSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
- break;
- case 125 /* Method */:
- if (node.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
- }
- else if (node.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
- }
- break;
- case 185 /* FunctionDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
- break;
- default:
- ts.Debug.fail("This is unknown kind for signature: " + node.kind);
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node.name || node
- };
- }
- }
- function emitParameterDeclaration(node) {
- increaseIndent();
- emitJsDocComments(node);
- if (node.flags & 8 /* Rest */) {
- write("...");
- }
- emitSourceTextOfNode(node.name);
- if (node.initializer || (node.flags & 4 /* QuestionMark */)) {
- write("?");
- }
- decreaseIndent();
- if (!(node.parent.flags & 32 /* Private */)) {
- write(": ");
- getSymbolVisibilityDiagnosticMessage = getParameterDeclarationTypeVisibilityError;
- resolver.writeTypeAtLocation(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer);
- }
- function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) {
- var diagnosticMessage;
- switch (node.parent.kind) {
- case 126 /* Constructor */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
- break;
- case 130 /* ConstructSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 129 /* CallSignature */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
- break;
- case 125 /* Method */:
- if (node.parent.flags & 128 /* Static */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else if (node.parent.parent.kind === 187 /* ClassDeclaration */) {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
- }
- else {
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
- }
- break;
- case 185 /* FunctionDeclaration */:
- diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
- break;
- default:
- ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind);
- }
- return {
- diagnosticMessage: diagnosticMessage,
- errorNode: node,
- typeName: node.name
- };
- }
- }
- function emitNode(node) {
- switch (node.kind) {
- case 126 /* Constructor */:
- case 185 /* FunctionDeclaration */:
- case 125 /* Method */:
- return emitFunctionDeclaration(node);
- case 130 /* ConstructSignature */:
- return emitConstructSignatureDeclaration(node);
- case 129 /* CallSignature */:
- case 131 /* IndexSignature */:
- return emitSignatureDeclaration(node);
- case 127 /* GetAccessor */:
- case 128 /* SetAccessor */:
- return emitAccessorDeclaration(node);
- case 162 /* VariableStatement */:
- return emitVariableStatement(node);
- case 124 /* Property */:
- return emitPropertyDeclaration(node);
- case 188 /* InterfaceDeclaration */:
- return emitInterfaceDeclaration(node);
- case 187 /* ClassDeclaration */:
- return emitClassDeclaration(node);
- case 189 /* TypeAliasDeclaration */:
- return emitTypeAliasDeclaration(node);
- case 195 /* EnumMember */:
- return emitEnumMemberDeclaration(node);
- case 190 /* EnumDeclaration */:
- return emitEnumDeclaration(node);
- case 191 /* ModuleDeclaration */:
- return emitModuleDeclaration(node);
- case 193 /* ImportDeclaration */:
- return emitImportDeclaration(node);
- case 194 /* ExportAssignment */:
- return emitExportAssignment(node);
- case 196 /* SourceFile */:
- return emitSourceFile(node);
- }
- }
- function tryResolveScriptReference(sourceFile, reference) {
- var referenceFileName = ts.normalizePath(ts.combinePaths(ts.getDirectoryPath(sourceFile.filename), reference.filename));
- return program.getSourceFile(referenceFileName);
- }
- var referencePathsOutput = "";
- function writeReferencePath(referencedFile) {
- var declFileName = referencedFile.flags & 1024 /* DeclarationFile */ ? referencedFile.filename : shouldEmitToOwnFile(referencedFile, compilerOptions) ? getOwnEmitOutputFilePath(referencedFile, ".d.ts") : ts.removeFileExtension(compilerOptions.out) + ".d.ts";
- declFileName = ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizeSlashes(jsFilePath)), declFileName, compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName, false);
- referencePathsOutput += "/// " + newLine;
- }
- if (root) {
- if (!compilerOptions.noResolve) {
- var addedGlobalFileReference = false;
- ts.forEach(root.referencedFiles, function (fileReference) {
- var referencedFile = tryResolveScriptReference(root, fileReference);
- if (referencedFile && ((referencedFile.flags & 1024 /* DeclarationFile */) || shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) {
- writeReferencePath(referencedFile);
- if (!isExternalModuleOrDeclarationFile(referencedFile)) {
- addedGlobalFileReference = true;
- }
- }
- });
- }
- emitNode(root);
- }
- else {
- var emittedReferencedFiles = [];
- ts.forEach(program.getSourceFiles(), function (sourceFile) {
- if (!isExternalModuleOrDeclarationFile(sourceFile)) {
- if (!compilerOptions.noResolve) {
- ts.forEach(sourceFile.referencedFiles, function (fileReference) {
- var referencedFile = tryResolveScriptReference(sourceFile, fileReference);
- if (referencedFile && (isExternalModuleOrDeclarationFile(referencedFile) && !ts.contains(emittedReferencedFiles, referencedFile))) {
- writeReferencePath(referencedFile);
- emittedReferencedFiles.push(referencedFile);
- }
- });
- }
- emitNode(sourceFile);
- }
- });
- }
- if (!reportedDeclarationError) {
- var declarationOutput = referencePathsOutput;
- var synchronousDeclarationOutput = writer.getText();
+ function writeDeclarationFile(jsFilePath, sourceFile) {
+ var emitDeclarationResult = emitDeclarations(program, resolver, diagnostics, jsFilePath, sourceFile);
+ if (!emitDeclarationResult.reportedDeclarationError) {
+ var declarationOutput = emitDeclarationResult.referencePathsOutput;
var appliedSyncOutputPos = 0;
- ts.forEach(aliasDeclarationEmitInfo, function (aliasEmitInfo) {
+ ts.forEach(emitDeclarationResult.aliasDeclarationEmitInfo, function (aliasEmitInfo) {
if (aliasEmitInfo.asynchronousOutput) {
- declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos);
+ declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos, aliasEmitInfo.outputPos);
declarationOutput += aliasEmitInfo.asynchronousOutput;
appliedSyncOutputPos = aliasEmitInfo.outputPos;
}
});
- declarationOutput += synchronousDeclarationOutput.substring(appliedSyncOutputPos);
- writeFile(ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
+ declarationOutput += emitDeclarationResult.synchronousDeclarationOutput.substring(appliedSyncOutputPos);
+ writeFile(compilerHost, diagnostics, ts.removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
}
}
var hasSemanticErrors = resolver.hasSemanticErrors();
@@ -9052,14 +9385,14 @@ var ts;
if (!isEmitBlocked) {
emitJavaScript(jsFilePath, sourceFile);
if (!hasSemanticErrors && compilerOptions.declaration) {
- emitDeclarations(jsFilePath, sourceFile);
+ writeDeclarationFile(jsFilePath, sourceFile);
}
}
}
if (targetSourceFile === undefined) {
ts.forEach(program.getSourceFiles(), function (sourceFile) {
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
- var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js");
+ var jsFilePath = getOwnEmitOutputFilePath(sourceFile, program, ".js");
emitFile(jsFilePath, sourceFile);
}
});
@@ -9069,7 +9402,7 @@ var ts;
}
else {
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
- var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js");
+ var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, program, ".js");
emitFile(jsFilePath, targetSourceFile);
}
else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) {
@@ -9162,10 +9495,11 @@ var ts;
getTypeCount: function () { return typeCount; },
isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
+ emitFiles: invokeEmitter,
getDiagnostics: getDiagnostics,
+ getDeclarationDiagnostics: getDeclarationDiagnostics,
getGlobalDiagnostics: getGlobalDiagnostics,
checkProgram: checkProgram,
- invokeEmitter: invokeEmitter,
getParentOfSymbol: getParentOfSymbol,
getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol,
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
@@ -9371,10 +9705,10 @@ var ts;
return nodeLinks[node.id] || (nodeLinks[node.id] = {});
}
function getSourceFile(node) {
- return ts.getAncestor(node, 196 /* SourceFile */);
+ return ts.getAncestor(node, 197 /* SourceFile */);
}
function isGlobalSourceFile(node) {
- return node.kind === 196 /* SourceFile */ && !ts.isExternalModule(node);
+ return node.kind === 197 /* SourceFile */ && !ts.isExternalModule(node);
}
function getSymbol(symbols, name, meaning) {
if (meaning && ts.hasProperty(symbols, name)) {
@@ -9415,21 +9749,21 @@ var ts;
}
}
switch (location.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (!ts.isExternalModule(location))
break;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) {
break loop;
}
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) {
break loop;
}
break;
case 124 /* Property */:
- if (location.parent.kind === 187 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) {
+ if (location.parent.kind === 188 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) {
var ctor = findConstructorDeclaration(location.parent);
if (ctor && ctor.locals) {
if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) {
@@ -9438,8 +9772,8 @@ var ts;
}
}
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) {
if (lastLocation && lastLocation.flags & 128 /* Static */) {
error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
@@ -9452,7 +9786,7 @@ var ts;
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
if (name === "arguments") {
result = argumentsSymbol;
@@ -9470,7 +9804,7 @@ var ts;
break loop;
}
break;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
var id = location.variable;
if (name === id.text) {
result = location.symbol;
@@ -9511,7 +9845,7 @@ var ts;
var links = getSymbolLinks(symbol);
if (!links.target) {
links.target = resolvingSymbol;
- var node = getDeclarationOfKind(symbol, 193 /* ImportDeclaration */);
+ var node = getDeclarationOfKind(symbol, 194 /* ImportDeclaration */);
var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node);
if (links.target === resolvingSymbol) {
links.target = target || unknownSymbol;
@@ -9527,7 +9861,7 @@ var ts;
}
function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) {
if (!importDeclaration) {
- importDeclaration = ts.getAncestor(entityName, 193 /* ImportDeclaration */);
+ importDeclaration = ts.getAncestor(entityName, 194 /* ImportDeclaration */);
ts.Debug.assert(importDeclaration !== undefined);
}
if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
@@ -9537,7 +9871,7 @@ var ts;
return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */);
}
else {
- ts.Debug.assert(entityName.parent.kind === 193 /* ImportDeclaration */);
+ ts.Debug.assert(entityName.parent.kind === 194 /* ImportDeclaration */);
return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */);
}
}
@@ -9642,9 +9976,9 @@ var ts;
var seenExportedMember = false;
var result = [];
ts.forEach(symbol.declarations, function (declaration) {
- var block = (declaration.kind === 196 /* SourceFile */ ? declaration : declaration.body);
+ var block = (declaration.kind === 197 /* SourceFile */ ? declaration : declaration.body);
ts.forEach(block.statements, function (node) {
- if (node.kind === 194 /* ExportAssignment */) {
+ if (node.kind === 195 /* ExportAssignment */) {
result.push(node);
}
else {
@@ -9751,17 +10085,17 @@ var ts;
}
}
switch (location.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (!ts.isExternalModule(location)) {
break;
}
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (result = callback(getSymbolOfNode(location).exports)) {
return result;
}
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
if (result = callback(getSymbolOfNode(location).members)) {
return result;
}
@@ -9792,7 +10126,7 @@ var ts;
}
return ts.forEachValue(symbols, function (symbolFromSymbolTable) {
if (symbolFromSymbolTable.flags & 33554432 /* Import */) {
- if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 193 /* ImportDeclaration */ && declaration.externalModuleName; })) {
+ if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 194 /* ImportDeclaration */ && declaration.externalModuleName; })) {
var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable);
if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) {
return [symbolFromSymbolTable];
@@ -9843,7 +10177,7 @@ var ts;
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined
};
}
- return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasAccessibleDeclarations.aliasesToMakeVisible };
+ return hasAccessibleDeclarations;
}
meaningToLook = getQualifiedLeftMeaning(meaning);
symbol = getParentOfSymbol(symbol);
@@ -9874,17 +10208,17 @@ var ts;
}
}
function hasExternalModuleSymbol(declaration) {
- return (declaration.kind === 191 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 196 /* SourceFile */ && ts.isExternalModule(declaration));
+ return (declaration.kind === 192 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 197 /* SourceFile */ && ts.isExternalModule(declaration));
}
function hasVisibleDeclarations(symbol) {
var aliasesToMakeVisible;
if (ts.forEach(symbol.declarations, function (declaration) { return !getIsDeclarationVisible(declaration); })) {
return undefined;
}
- return { aliasesToMakeVisible: aliasesToMakeVisible };
+ return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible };
function getIsDeclarationVisible(declaration) {
if (!isDeclarationVisible(declaration)) {
- if (declaration.kind === 193 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) {
+ if (declaration.kind === 194 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) {
getNodeLinks(declaration).isVisible = true;
if (aliasesToMakeVisible) {
if (!ts.contains(aliasesToMakeVisible, declaration)) {
@@ -9901,11 +10235,24 @@ var ts;
return true;
}
}
- function isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName) {
+ function isEntityNameVisible(entityName, enclosingDeclaration) {
+ var meaning;
+ if (entityName.parent.kind === 135 /* TypeQuery */) {
+ meaning = 107455 /* Value */ | 4194304 /* ExportValue */;
+ }
+ else if (entityName.kind === 121 /* QualifiedName */ || entityName.parent.kind === 194 /* ImportDeclaration */) {
+ meaning = 1536 /* Namespace */;
+ }
+ else {
+ meaning = 3152352 /* Type */;
+ }
var firstIdentifier = getFirstIdentifier(entityName);
- var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier);
- var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace);
- return hasNamespaceDeclarationsVisibile ? { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } : { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.declarationNameToString(firstIdentifier) };
+ var symbol = resolveName(enclosingDeclaration, firstIdentifier.text, meaning, undefined, undefined);
+ return hasVisibleDeclarations(symbol) || {
+ accessibility: 1 /* NotAccessible */,
+ errorSymbolName: ts.getTextOfNode(firstIdentifier),
+ errorNode: firstIdentifier
+ };
}
function releaseStringWriter(writer) {
writer.clear();
@@ -9947,7 +10294,7 @@ var ts;
while (node.kind === 140 /* ParenType */) {
node = node.parent;
}
- if (node.kind === 189 /* TypeAliasDeclaration */) {
+ if (node.kind === 190 /* TypeAliasDeclaration */) {
return getSymbolOfNode(node);
}
}
@@ -10110,7 +10457,7 @@ var ts;
function shouldWriteTypeOfFunctionSymbol() {
if (type.symbol) {
var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; }));
- var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 196 /* SourceFile */ || declaration.parent.kind === 192 /* ModuleBlock */; }));
+ var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 197 /* SourceFile */ || declaration.parent.kind === 193 /* ModuleBlock */; }));
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type));
}
@@ -10329,12 +10676,12 @@ var ts;
function isDeclarationVisible(node) {
function getContainingExternalModule(node) {
for (; node; node = node.parent) {
- if (node.kind === 191 /* ModuleDeclaration */) {
+ if (node.kind === 192 /* ModuleDeclaration */) {
if (node.name.kind === 7 /* StringLiteral */) {
return node;
}
}
- else if (node.kind === 196 /* SourceFile */) {
+ else if (node.kind === 197 /* SourceFile */) {
return ts.isExternalModule(node) ? node : undefined;
}
}
@@ -10376,16 +10723,16 @@ var ts;
}
function determineIfDeclarationIsVisible() {
switch (node.kind) {
- case 184 /* VariableDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 185 /* FunctionDeclaration */:
- case 190 /* EnumDeclaration */:
- case 193 /* ImportDeclaration */:
- var parent = node.kind === 184 /* VariableDeclaration */ ? node.parent.parent : node.parent;
- if (!(node.flags & 1 /* Export */) && !(node.kind !== 193 /* ImportDeclaration */ && parent.kind !== 196 /* SourceFile */ && ts.isInAmbientContext(parent))) {
+ case 185 /* VariableDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 186 /* FunctionDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 194 /* ImportDeclaration */:
+ var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent;
+ if (!(node.flags & 1 /* Export */) && !(node.kind !== 194 /* ImportDeclaration */ && parent.kind !== 197 /* SourceFile */ && ts.isInAmbientContext(parent))) {
return isGlobalSourceFile(parent) || isUsedInExportAssignment(node);
}
return isDeclarationVisible(parent);
@@ -10399,9 +10746,10 @@ var ts;
case 129 /* CallSignature */:
case 131 /* IndexSignature */:
case 123 /* Parameter */:
- case 192 /* ModuleBlock */:
+ case 193 /* ModuleBlock */:
+ case 122 /* TypeParameter */:
return isDeclarationVisible(node.parent);
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
return true;
default:
ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
@@ -10420,7 +10768,7 @@ var ts;
return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
}
function getTypeOfVariableOrPropertyDeclaration(declaration) {
- if (declaration.parent.kind === 169 /* ForInStatement */) {
+ if (declaration.parent.kind === 170 /* ForInStatement */) {
return anyType;
}
if (declaration.type) {
@@ -10487,7 +10835,7 @@ var ts;
return links.type = getTypeOfPrototypeProperty(symbol);
}
var declaration = symbol.valueDeclaration;
- if (declaration.kind === 181 /* CatchBlock */) {
+ if (declaration.kind === 182 /* CatchBlock */) {
return links.type = anyType;
}
links.type = resolvingType;
@@ -10627,7 +10975,7 @@ var ts;
function getTypeParametersOfClassOrInterface(symbol) {
var result;
ts.forEach(symbol.declarations, function (node) {
- if (node.kind === 188 /* InterfaceDeclaration */ || node.kind === 187 /* ClassDeclaration */) {
+ if (node.kind === 189 /* InterfaceDeclaration */ || node.kind === 188 /* ClassDeclaration */) {
var declaration = node;
if (declaration.typeParameters && declaration.typeParameters.length) {
ts.forEach(declaration.typeParameters, function (node) {
@@ -10658,7 +11006,7 @@ var ts;
type.typeArguments = type.typeParameters;
}
type.baseTypes = [];
- var declaration = getDeclarationOfKind(symbol, 187 /* ClassDeclaration */);
+ var declaration = getDeclarationOfKind(symbol, 188 /* ClassDeclaration */);
if (declaration.baseType) {
var baseType = getTypeFromTypeReferenceNode(declaration.baseType);
if (baseType !== unknownType) {
@@ -10698,7 +11046,7 @@ var ts;
}
type.baseTypes = [];
ts.forEach(symbol.declarations, function (declaration) {
- if (declaration.kind === 188 /* InterfaceDeclaration */ && declaration.baseTypes) {
+ if (declaration.kind === 189 /* InterfaceDeclaration */ && declaration.baseTypes) {
ts.forEach(declaration.baseTypes, function (node) {
var baseType = getTypeFromTypeReferenceNode(node);
if (baseType !== unknownType) {
@@ -10729,7 +11077,7 @@ var ts;
var links = getSymbolLinks(symbol);
if (!links.declaredType) {
links.declaredType = resolvingType;
- var declaration = getDeclarationOfKind(symbol, 189 /* TypeAliasDeclaration */);
+ var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */);
var type = getTypeFromTypeNode(declaration.type);
if (links.declaredType === resolvingType) {
links.declaredType = type;
@@ -10737,7 +11085,7 @@ var ts;
}
else if (links.declaredType === resolvingType) {
links.declaredType = unknownType;
- var declaration = getDeclarationOfKind(symbol, 189 /* TypeAliasDeclaration */);
+ var declaration = getDeclarationOfKind(symbol, 190 /* TypeAliasDeclaration */);
error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
}
return links.declaredType;
@@ -11208,7 +11556,7 @@ var ts;
switch (node.kind) {
case 133 /* FunctionType */:
case 134 /* ConstructorType */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
case 126 /* Constructor */:
case 129 /* CallSignature */:
@@ -11438,9 +11786,9 @@ var ts;
for (var i = 0; i < declarations.length; i++) {
var declaration = declarations[i];
switch (declaration.kind) {
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
return declaration;
}
}
@@ -12749,7 +13097,7 @@ var ts;
switch (node.kind) {
case 156 /* BinaryExpression */:
return isAssignedInBinaryExpression(node);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return isAssignedInVariableDeclaration(node);
case 141 /* ArrayLiteral */:
case 142 /* ObjectLiteral */:
@@ -12762,25 +13110,25 @@ var ts;
case 154 /* PrefixOperator */:
case 155 /* PostfixOperator */:
case 157 /* ConditionalExpression */:
- case 161 /* Block */:
- case 162 /* VariableStatement */:
- case 164 /* ExpressionStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 172 /* ReturnStatement */:
- case 173 /* WithStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
- case 177 /* LabeledStatement */:
- case 178 /* ThrowStatement */:
- case 179 /* TryStatement */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
+ case 162 /* Block */:
+ case 163 /* VariableStatement */:
+ case 165 /* ExpressionStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 173 /* ReturnStatement */:
+ case 174 /* WithStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
+ case 178 /* LabeledStatement */:
+ case 179 /* ThrowStatement */:
+ case 180 /* TryStatement */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
return ts.forEachChild(node, isAssignedIn);
}
return false;
@@ -12794,7 +13142,7 @@ var ts;
node = node.parent;
var narrowedType = type;
switch (node.kind) {
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
if (child !== node.expression) {
narrowedType = narrowType(type, node.expression, child === node.thenStatement);
}
@@ -12814,9 +13162,9 @@ var ts;
}
}
break;
- case 196 /* SourceFile */:
- case 191 /* ModuleDeclaration */:
- case 185 /* FunctionDeclaration */:
+ case 197 /* SourceFile */:
+ case 192 /* ModuleDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
@@ -12926,7 +13274,7 @@ var ts;
return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node);
}
function captureLexicalThis(node, container) {
- var classNode = container.parent && container.parent.kind === 187 /* ClassDeclaration */ ? container.parent : undefined;
+ var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined;
getNodeLinks(node).flags |= 2 /* LexicalThis */;
if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) {
getNodeLinks(classNode).flags |= 4 /* CaptureThis */;
@@ -12943,10 +13291,10 @@ var ts;
needToCaptureLexicalThis = true;
}
switch (container.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body);
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
break;
case 126 /* Constructor */:
@@ -12963,7 +13311,7 @@ var ts;
if (needToCaptureLexicalThis) {
captureLexicalThis(node, container);
}
- var classNode = container.parent && container.parent.kind === 187 /* ClassDeclaration */ ? container.parent : undefined;
+ var classNode = container.parent && container.parent.kind === 188 /* ClassDeclaration */ ? container.parent : undefined;
if (classNode) {
var symbol = getSymbolOfNode(classNode);
return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol);
@@ -12976,7 +13324,7 @@ var ts;
if (!node)
return node;
switch (node.kind) {
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
case 124 /* Property */:
@@ -12998,7 +13346,7 @@ var ts;
}
function checkSuperExpression(node) {
var isCallExpression = node.parent.kind === 147 /* CallExpression */ && node.parent.func === node;
- var enclosingClass = ts.getAncestor(node, 187 /* ClassDeclaration */);
+ var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */);
var baseClass;
if (enclosingClass && enclosingClass.baseType) {
var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass));
@@ -13020,7 +13368,7 @@ var ts;
container = getSuperContainer(container);
needToCaptureLexicalThis = true;
}
- if (container && container.parent && container.parent.kind === 187 /* ClassDeclaration */) {
+ if (container && container.parent && container.parent.kind === 188 /* ClassDeclaration */) {
if (container.flags & 128 /* Static */) {
canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */;
}
@@ -13198,12 +13546,12 @@ var ts;
}
var parent = node.parent;
switch (parent.kind) {
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 123 /* Parameter */:
case 124 /* Property */:
return getContextualTypeForInitializerExpression(node);
case 153 /* ArrowFunction */:
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return getContextualTypeForReturnExpression(node);
case 147 /* CallExpression */:
case 148 /* NewExpression */:
@@ -13354,7 +13702,7 @@ var ts;
if (!(flags & (32 /* Private */ | 64 /* Protected */))) {
return;
}
- var enclosingClassDeclaration = ts.getAncestor(node, 187 /* ClassDeclaration */);
+ var enclosingClassDeclaration = ts.getAncestor(node, 188 /* ClassDeclaration */);
var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined;
var declaringClass = getDeclaredTypeOfSymbol(prop.parent);
if (flags & 32 /* Private */) {
@@ -13539,7 +13887,7 @@ var ts;
var context = createInferenceContext(typeParameters, false);
var mapper = createInferenceMapper(context);
for (var i = 0; i < args.length; i++) {
- if (args[i].kind === 160 /* OmittedExpression */) {
+ if (args[i].kind === 161 /* OmittedExpression */) {
continue;
}
if (!excludeArgument || excludeArgument[i] === undefined) {
@@ -13553,7 +13901,7 @@ var ts;
}
if (excludeArgument) {
for (var i = 0; i < args.length; i++) {
- if (args[i].kind === 160 /* OmittedExpression */) {
+ if (args[i].kind === 161 /* OmittedExpression */) {
continue;
}
if (excludeArgument[i] === false) {
@@ -13591,7 +13939,7 @@ var ts;
for (var i = 0; i < args.length; i++) {
var arg = args[i];
var argType;
- if (arg.kind === 160 /* OmittedExpression */) {
+ if (arg.kind === 161 /* OmittedExpression */) {
continue;
}
var paramType = getTypeAtPosition(signature, i);
@@ -13914,7 +14262,7 @@ var ts;
}
function getReturnTypeFromBody(func, contextualMapper) {
var contextualSignature = getContextualSignature(func);
- if (func.body.kind !== 186 /* FunctionBlock */) {
+ if (func.body.kind !== 187 /* FunctionBlock */) {
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
var widenedType = getWidenedType(unwidenedType);
if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) {
@@ -13962,7 +14310,7 @@ var ts;
});
}
function bodyContainsSingleThrowStatement(body) {
- return (body.statements.length === 1) && (body.statements[0].kind === 178 /* ThrowStatement */);
+ return (body.statements.length === 1) && (body.statements[0].kind === 179 /* ThrowStatement */);
}
function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) {
if (!fullTypeCheck) {
@@ -13971,7 +14319,7 @@ var ts;
if (returnType === voidType || returnType === anyType) {
return;
}
- if (!func.body || func.body.kind !== 186 /* FunctionBlock */) {
+ if (!func.body || func.body.kind !== 187 /* FunctionBlock */) {
return;
}
var bodyBlock = func.body;
@@ -14015,7 +14363,7 @@ var ts;
if (node.type) {
checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type));
}
- if (node.body.kind === 186 /* FunctionBlock */) {
+ if (node.body.kind === 187 /* FunctionBlock */) {
checkSourceElement(node.body);
}
else {
@@ -14363,7 +14711,7 @@ var ts;
return checkBinaryExpression(node, contextualMapper);
case 157 /* ConditionalExpression */:
return checkConditionalExpression(node, contextualMapper);
- case 160 /* OmittedExpression */:
+ case 161 /* OmittedExpression */:
return undefinedType;
}
return unknownType;
@@ -14443,7 +14791,7 @@ var ts;
checkSpecializedSignatureDeclaration(node);
}
function checkTypeForDuplicateIndexSignatures(node) {
- if (node.kind === 188 /* InterfaceDeclaration */) {
+ if (node.kind === 189 /* InterfaceDeclaration */) {
var nodeSymbol = getSymbolOfNode(node);
if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
return;
@@ -14507,7 +14855,7 @@ var ts;
}
switch (n.kind) {
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
case 142 /* ObjectLiteral */: return false;
default: return ts.forEachChild(n, containsSuperCall);
@@ -14517,7 +14865,7 @@ var ts;
if (n.kind === 91 /* ThisKeyword */) {
error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
}
- else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 185 /* FunctionDeclaration */) {
+ else if (n.kind !== 152 /* FunctionExpression */ && n.kind !== 186 /* FunctionDeclaration */) {
ts.forEachChild(n, markThisReferencesAsErrors);
}
}
@@ -14529,7 +14877,7 @@ var ts;
var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); });
if (superCallShouldBeFirst) {
var statements = node.body.statements;
- if (!statements.length || statements[0].kind !== 164 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) {
+ if (!statements.length || statements[0].kind !== 165 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) {
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties);
}
else {
@@ -14617,7 +14965,7 @@ var ts;
return;
}
var signaturesToCheck;
- if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 188 /* InterfaceDeclaration */) {
+ if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 189 /* InterfaceDeclaration */) {
ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */);
var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */;
var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent);
@@ -14637,7 +14985,7 @@ var ts;
}
function getEffectiveDeclarationFlags(n, flagsToCheck) {
var flags = n.flags;
- if (n.parent.kind !== 188 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
+ if (n.parent.kind !== 189 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) {
if (!(flags & 2 /* Ambient */)) {
flags |= 1 /* Export */;
}
@@ -14723,11 +15071,11 @@ var ts;
for (var i = 0; i < declarations.length; i++) {
var node = declarations[i];
var inAmbientContext = ts.isInAmbientContext(node);
- var inAmbientContextOrInterface = node.parent.kind === 188 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext;
+ var inAmbientContextOrInterface = node.parent.kind === 189 /* InterfaceDeclaration */ || node.parent.kind === 136 /* TypeLiteral */ || inAmbientContext;
if (inAmbientContextOrInterface) {
previousDeclaration = undefined;
}
- if (node.kind === 185 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) {
+ if (node.kind === 186 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) {
var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
someNodeFlags |= currentNodeFlags;
allNodeFlags &= currentNodeFlags;
@@ -14821,14 +15169,14 @@ var ts;
}
function getDeclarationSpaces(d) {
switch (d.kind) {
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return 8388608 /* ExportType */;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */;
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
return 8388608 /* ExportType */ | 4194304 /* ExportValue */;
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
var result = 0;
var target = resolveImport(getSymbolOfNode(d));
ts.forEach(target.declarations, function (d) {
@@ -14903,7 +15251,7 @@ var ts;
return;
}
switch (current.kind) {
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 125 /* Method */:
case 153 /* ArrowFunction */:
@@ -14958,7 +15306,7 @@ var ts;
if (!needCollisionCheckForIdentifier(node, name, "_super")) {
return;
}
- var enclosingClass = ts.getAncestor(node, 187 /* ClassDeclaration */);
+ var enclosingClass = ts.getAncestor(node, 188 /* ClassDeclaration */);
if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) {
return;
}
@@ -14976,11 +15324,11 @@ var ts;
if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
return;
}
- if (node.kind === 191 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
+ if (node.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
return;
}
- var parent = node.kind === 184 /* VariableDeclaration */ ? node.parent.parent : node.parent;
- if (parent.kind === 196 /* SourceFile */ && ts.isExternalModule(parent)) {
+ var parent = node.kind === 185 /* VariableDeclaration */ ? node.parent.parent : node.parent;
+ if (parent.kind === 197 /* SourceFile */ && ts.isExternalModule(parent)) {
error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, ts.declarationNameToString(name), ts.declarationNameToString(name));
}
}
@@ -15371,7 +15719,7 @@ var ts;
checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
checkExportsOnMergedDeclarations(node);
var symbol = getSymbolOfNode(node);
- var firstInterfaceDecl = getDeclarationOfKind(symbol, 188 /* InterfaceDeclaration */);
+ var firstInterfaceDecl = getDeclarationOfKind(symbol, 189 /* InterfaceDeclaration */);
if (symbol.declarations.length > 1) {
if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) {
error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters);
@@ -15404,7 +15752,7 @@ var ts;
var enumType = getDeclaredTypeOfSymbol(enumSymbol);
var autoValue = 0;
var ambient = ts.isInAmbientContext(node);
- var enumIsConst = ts.isConstEnumDeclaration(node);
+ var enumIsConst = ts.isConst(node);
ts.forEach(node.members, function (member) {
if (isNumericName(member.name.text)) {
error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
@@ -15545,7 +15893,7 @@ var ts;
var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind);
if (node === firstDeclaration) {
if (enumSymbol.declarations.length > 1) {
- var enumIsConst = ts.isConstEnumDeclaration(node);
+ var enumIsConst = ts.isConst(node);
ts.forEach(enumSymbol.declarations, function (decl) {
if (ts.isConstEnumDeclaration(decl) !== enumIsConst) {
error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
@@ -15554,7 +15902,7 @@ var ts;
}
var seenEnumMissingInitialInitializer = false;
ts.forEach(enumSymbol.declarations, function (declaration) {
- if (declaration.kind !== 190 /* EnumDeclaration */) {
+ if (declaration.kind !== 191 /* EnumDeclaration */) {
return false;
}
var enumDeclaration = declaration;
@@ -15577,7 +15925,7 @@ var ts;
var declarations = symbol.declarations;
for (var i = 0; i < declarations.length; i++) {
var declaration = declarations[i];
- if ((declaration.kind === 187 /* ClassDeclaration */ || (declaration.kind === 185 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) {
+ if ((declaration.kind === 188 /* ClassDeclaration */ || (declaration.kind === 186 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) {
return declaration;
}
}
@@ -15640,10 +15988,10 @@ var ts;
}
}
else {
- if (node.parent.kind === 196 /* SourceFile */) {
+ if (node.parent.kind === 197 /* SourceFile */) {
target = resolveImport(symbol);
}
- else if (node.parent.kind === 192 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) {
+ else if (node.parent.kind === 193 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) {
if (isExternalModuleNameRelative(node.externalModuleName.text)) {
error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name);
target = unknownSymbol;
@@ -15665,7 +16013,7 @@ var ts;
}
function checkExportAssignment(node) {
var container = node.parent;
- if (container.kind !== 196 /* SourceFile */) {
+ if (container.kind !== 197 /* SourceFile */) {
container = container.parent;
}
checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container));
@@ -15707,57 +16055,57 @@ var ts;
return checkUnionType(node);
case 140 /* ParenType */:
return checkSourceElement(node.type);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
return checkFunctionDeclaration(node);
- case 161 /* Block */:
+ case 162 /* Block */:
return checkBlock(node);
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
return checkBody(node);
- case 162 /* VariableStatement */:
+ case 163 /* VariableStatement */:
return checkVariableStatement(node);
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return checkExpressionStatement(node);
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
return checkIfStatement(node);
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
return checkDoStatement(node);
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return checkWhileStatement(node);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return checkForStatement(node);
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return checkForInStatement(node);
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
return checkBreakOrContinueStatement(node);
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return checkReturnStatement(node);
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
return checkWithStatement(node);
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return checkSwitchStatement(node);
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return checkLabeledStatement(node);
- case 178 /* ThrowStatement */:
+ case 179 /* ThrowStatement */:
return checkThrowStatement(node);
- case 179 /* TryStatement */:
+ case 180 /* TryStatement */:
return checkTryStatement(node);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return ts.Debug.fail("Checker encountered variable declaration");
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return checkClassDeclaration(node);
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return checkInterfaceDeclaration(node);
- case 189 /* TypeAliasDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
return checkTypeAliasDeclaration(node);
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
return checkEnumDeclaration(node);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return checkModuleDeclaration(node);
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return checkImportDeclaration(node);
- case 194 /* ExportAssignment */:
+ case 195 /* ExportAssignment */:
return checkExportAssignment(node);
}
}
@@ -15772,10 +16120,10 @@ var ts;
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
ts.forEach(node.parameters, checkFunctionExpressionBodies);
break;
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
checkFunctionExpressionBodies(node.expression);
break;
case 123 /* Parameter */:
@@ -15794,33 +16142,33 @@ var ts;
case 155 /* PostfixOperator */:
case 156 /* BinaryExpression */:
case 157 /* ConditionalExpression */:
- case 161 /* Block */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
- case 162 /* VariableStatement */:
- case 164 /* ExpressionStatement */:
- case 165 /* IfStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 170 /* ContinueStatement */:
- case 171 /* BreakStatement */:
- case 172 /* ReturnStatement */:
- case 174 /* SwitchStatement */:
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
- case 177 /* LabeledStatement */:
- case 178 /* ThrowStatement */:
- case 179 /* TryStatement */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 184 /* VariableDeclaration */:
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
- case 195 /* EnumMember */:
- case 196 /* SourceFile */:
+ case 162 /* Block */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
+ case 163 /* VariableStatement */:
+ case 165 /* ExpressionStatement */:
+ case 166 /* IfStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 171 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
+ case 173 /* ReturnStatement */:
+ case 175 /* SwitchStatement */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
+ case 178 /* LabeledStatement */:
+ case 179 /* ThrowStatement */:
+ case 180 /* TryStatement */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 185 /* VariableDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 196 /* EnumMember */:
+ case 197 /* SourceFile */:
ts.forEachChild(node, checkFunctionExpressionBodies);
break;
}
@@ -15870,6 +16218,11 @@ var ts;
checkProgram();
return getSortedDiagnostics();
}
+ function getDeclarationDiagnostics(targetSourceFile) {
+ var resolver = createResolver();
+ checkSourceFile(targetSourceFile);
+ return ts.getDeclarationDiagnostics(program, resolver, targetSourceFile);
+ }
function getGlobalDiagnostics() {
return ts.filter(getSortedDiagnostics(), function (d) { return !d.file; });
}
@@ -15891,7 +16244,7 @@ var ts;
function isInsideWithStatementBody(node) {
if (node) {
while (node.parent) {
- if (node.parent.kind === 173 /* WithStatement */ && node.parent.statement === node) {
+ if (node.parent.kind === 174 /* WithStatement */ && node.parent.statement === node) {
return true;
}
node = node.parent;
@@ -15927,17 +16280,17 @@ var ts;
copySymbols(location.locals, meaning);
}
switch (location.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (!ts.isExternalModule(location))
break;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */);
break;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */);
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
if (!(memberFlags & 128 /* Static */)) {
copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */);
}
@@ -15947,7 +16300,7 @@ var ts;
copySymbol(location.symbol, meaning);
}
break;
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
if (location.variable.text) {
copySymbol(location.symbol, meaning);
}
@@ -15965,10 +16318,10 @@ var ts;
function isTypeDeclaration(node) {
switch (node.kind) {
case 122 /* TypeParameter */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 191 /* EnumDeclaration */:
return true;
}
}
@@ -16010,9 +16363,9 @@ var ts;
return node === parent.constraint;
case 124 /* Property */:
case 123 /* Parameter */:
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
return node === parent.type;
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
case 126 /* Constructor */:
@@ -16039,10 +16392,10 @@ var ts;
while (node.parent.kind === 121 /* QualifiedName */) {
node = node.parent;
}
- if (node.parent.kind === 193 /* ImportDeclaration */) {
+ if (node.parent.kind === 194 /* ImportDeclaration */) {
return node.parent.entityName === node;
}
- if (node.parent.kind === 194 /* ExportAssignment */) {
+ if (node.parent.kind === 195 /* ExportAssignment */) {
return node.parent.exportName === node;
}
return false;
@@ -16054,7 +16407,7 @@ var ts;
if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) {
return getSymbolOfNode(entityName.parent);
}
- if (entityName.parent.kind === 194 /* ExportAssignment */) {
+ if (entityName.parent.kind === 195 /* ExportAssignment */) {
return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */);
}
if (isInRightSideOfImportOrExportAssignment(entityName)) {
@@ -16094,7 +16447,7 @@ var ts;
return getSymbolOfNode(node.parent);
}
if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) {
- return node.parent.kind === 194 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node);
+ return node.parent.kind === 195 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node);
}
switch (node.kind) {
case 63 /* Identifier */:
@@ -16112,7 +16465,7 @@ var ts;
}
return undefined;
case 7 /* StringLiteral */:
- if (node.parent.kind === 193 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
+ if (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node) {
var importSymbol = getSymbolOfNode(node.parent);
var moduleType = getTypeOfSymbol(importSymbol);
return moduleType ? moduleType.symbol : undefined;
@@ -16206,7 +16559,7 @@ var ts;
return [symbol];
}
function isExternalModuleSymbol(symbol) {
- return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 196 /* SourceFile */;
+ return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 197 /* SourceFile */;
}
function isNodeDescendentOf(node, ancestor) {
while (node) {
@@ -16239,7 +16592,7 @@ var ts;
function getLocalNameForSymbol(symbol, location) {
var node = location;
while (node) {
- if ((node.kind === 191 /* ModuleDeclaration */ || node.kind === 190 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) {
+ if ((node.kind === 192 /* ModuleDeclaration */ || node.kind === 191 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) {
return getLocalNameOfContainer(node);
}
node = node.parent;
@@ -16263,7 +16616,7 @@ var ts;
return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined;
}
function isTopLevelValueImportWithEntityName(node) {
- if (node.parent.kind !== 196 /* SourceFile */ || !node.entityName) {
+ if (node.parent.kind !== 197 /* SourceFile */ || !node.entityName) {
return false;
}
return isImportResolvedToValue(getSymbolOfNode(node));
@@ -16314,7 +16667,7 @@ var ts;
if (symbol && (symbol.flags & 8 /* EnumMember */)) {
var declaration = symbol.valueDeclaration;
var constantValue;
- if (declaration.kind === 195 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) {
+ if (declaration.kind === 196 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) {
return constantValue;
}
}
@@ -16329,8 +16682,8 @@ var ts;
var signature = getSignatureFromDeclaration(signatureDeclaration);
getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags);
}
- function invokeEmitter(targetSourceFile) {
- var resolver = {
+ function createResolver() {
+ return {
getProgram: function () { return program; },
getLocalNameOfContainer: getLocalNameOfContainer,
getExpressionNamePrefix: getExpressionNamePrefix,
@@ -16346,9 +16699,12 @@ var ts;
writeTypeAtLocation: writeTypeAtLocation,
writeReturnTypeOfSignatureDeclaration: writeReturnTypeOfSignatureDeclaration,
isSymbolAccessible: isSymbolAccessible,
- isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile,
+ isEntityNameVisible: isEntityNameVisible,
getConstantValue: getConstantValue
};
+ }
+ function invokeEmitter(targetSourceFile) {
+ var resolver = createResolver();
checkProgram();
return ts.emitFiles(resolver, targetSourceFile);
}
@@ -16518,10 +16874,10 @@ var ts;
}
function autoCollapse(node) {
switch (node.kind) {
- case 192 /* ModuleBlock */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 193 /* ModuleBlock */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
return false;
}
return true;
@@ -16533,11 +16889,11 @@ var ts;
return;
}
switch (n.kind) {
- case 161 /* Block */:
+ case 162 /* Block */:
var parent = n.parent;
var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile);
var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile);
- if (parent.kind === 166 /* DoStatement */ || parent.kind === 169 /* ForInStatement */ || parent.kind === 168 /* ForStatement */ || parent.kind === 165 /* IfStatement */ || parent.kind === 167 /* WhileStatement */ || parent.kind === 173 /* WithStatement */) {
+ if (parent.kind === 167 /* DoStatement */ || parent.kind === 170 /* ForInStatement */ || parent.kind === 169 /* ForStatement */ || parent.kind === 166 /* IfStatement */ || parent.kind === 168 /* WhileStatement */ || parent.kind === 174 /* WithStatement */) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
}
else {
@@ -16550,20 +16906,20 @@ var ts;
});
}
break;
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile);
var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile);
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
case 142 /* ObjectLiteral */:
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile);
var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile);
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
@@ -16596,14 +16952,14 @@ var ts;
var current = node.parent;
while (current) {
switch (current.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
do {
current = current.parent;
- } while (current.kind === 191 /* ModuleDeclaration */);
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 185 /* FunctionDeclaration */:
+ } while (current.kind === 192 /* ModuleDeclaration */);
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 186 /* FunctionDeclaration */:
indent++;
}
current = current.parent;
@@ -16614,10 +16970,10 @@ var ts;
var childNodes = [];
for (var i = 0, n = nodes.length; i < n; i++) {
var node = nodes[i];
- if (node.kind === 187 /* ClassDeclaration */ || node.kind === 190 /* EnumDeclaration */ || node.kind === 188 /* InterfaceDeclaration */ || node.kind === 191 /* ModuleDeclaration */ || node.kind === 185 /* FunctionDeclaration */) {
+ if (node.kind === 188 /* ClassDeclaration */ || node.kind === 191 /* EnumDeclaration */ || node.kind === 189 /* InterfaceDeclaration */ || node.kind === 192 /* ModuleDeclaration */ || node.kind === 186 /* FunctionDeclaration */) {
childNodes.push(node);
}
- else if (node.kind === 162 /* VariableStatement */) {
+ else if (node.kind === 163 /* VariableStatement */) {
childNodes.push.apply(childNodes, node.declarations);
}
}
@@ -16650,17 +17006,17 @@ var ts;
for (var i = 0, n = nodes.length; i < n; i++) {
var node = nodes[i];
switch (node.kind) {
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 189 /* InterfaceDeclaration */:
topLevelNodes.push(node);
break;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
var moduleDeclaration = node;
topLevelNodes.push(node);
addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes);
break;
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
var functionDeclaration = node;
if (isTopLevelFunctionDeclaration(functionDeclaration)) {
topLevelNodes.push(node);
@@ -16671,12 +17027,12 @@ var ts;
}
}
function isTopLevelFunctionDeclaration(functionDeclaration) {
- if (functionDeclaration.kind === 185 /* FunctionDeclaration */) {
- if (functionDeclaration.body && functionDeclaration.body.kind === 186 /* FunctionBlock */) {
- if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 185 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) {
+ if (functionDeclaration.kind === 186 /* FunctionDeclaration */) {
+ if (functionDeclaration.body && functionDeclaration.body.kind === 187 /* FunctionBlock */) {
+ if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 186 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) {
return true;
}
- if (functionDeclaration.parent.kind !== 186 /* FunctionBlock */) {
+ if (functionDeclaration.parent.kind !== 187 /* FunctionBlock */) {
return true;
}
}
@@ -16739,7 +17095,7 @@ var ts;
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement);
case 131 /* IndexSignature */:
return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement);
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement);
case 129 /* CallSignature */:
return createItem(node, "()", ts.ScriptElementKind.callSignatureElement);
@@ -16747,11 +17103,14 @@ var ts;
return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement);
case 124 /* Property */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement);
- case 184 /* VariableDeclaration */:
- if (node.flags & 4096 /* Const */) {
- return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.constantElement);
+ case 185 /* VariableDeclaration */:
+ if (ts.isConst(node)) {
+ return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.constElement);
+ }
+ else if (ts.isLet(node)) {
+ return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.letElement);
}
else {
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.variableElement);
@@ -16786,17 +17145,17 @@ var ts;
}
function createTopLevelItem(node) {
switch (node.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
return createSourceFileItem(node);
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
return createClassItem(node);
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
return createEnumItem(node);
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return createIterfaceItem(node);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return createModuleItem(node);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
return createFunctionItem(node);
}
return undefined;
@@ -16806,7 +17165,7 @@ var ts;
}
var result = [];
result.push(moduleDeclaration.name.text);
- while (moduleDeclaration.body && moduleDeclaration.body.kind === 191 /* ModuleDeclaration */) {
+ while (moduleDeclaration.body && moduleDeclaration.body.kind === 192 /* ModuleDeclaration */) {
moduleDeclaration = moduleDeclaration.body;
result.push(moduleDeclaration.name.text);
}
@@ -16818,7 +17177,7 @@ var ts;
return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node));
}
function createFunctionItem(node) {
- if (node.name && node.body && node.body.kind === 186 /* FunctionBlock */) {
+ if (node.name && node.body && node.body.kind === 187 /* FunctionBlock */) {
var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem);
return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node));
}
@@ -16854,13 +17213,13 @@ var ts;
}
}
function getInnermostModule(node) {
- while (node.body.kind === 191 /* ModuleDeclaration */) {
+ while (node.body.kind === 192 /* ModuleDeclaration */) {
node = node.body;
}
return node;
}
function getNodeSpan(node) {
- return node.kind === 196 /* SourceFile */ ? ts.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : ts.TextSpan.fromBounds(node.getStart(), node.getEnd());
+ return node.kind === 197 /* SourceFile */ ? ts.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : ts.TextSpan.fromBounds(node.getStart(), node.getEnd());
}
function getTextOfNode(node) {
return ts.getTextOfNodeFromSourceText(sourceFile.text, node);
@@ -16884,7 +17243,7 @@ var ts;
if (!argumentInfo) {
return undefined;
}
- var call = argumentInfo.list.parent;
+ var call = argumentInfo.invocation;
var candidates = [];
var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates);
cancellationToken.throwIfCancellationRequested();
@@ -16893,23 +17252,103 @@ var ts;
}
return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo);
function getImmediatelyContainingArgumentInfo(node) {
- if (node.parent.kind !== 147 /* CallExpression */ && node.parent.kind !== 148 /* NewExpression */) {
- return undefined;
+ if (node.parent.kind === 147 /* CallExpression */ || node.parent.kind === 148 /* NewExpression */) {
+ var callExpression = node.parent;
+ if (node.kind === 23 /* LessThanToken */ || node.kind === 15 /* OpenParenToken */) {
+ var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile);
+ var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
+ ts.Debug.assert(list !== undefined);
+ return {
+ kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */,
+ invocation: callExpression,
+ argumentsSpan: getApplicableSpanForArguments(list),
+ argumentIndex: 0,
+ argumentCount: getCommaBasedArgCount(list)
+ };
+ }
+ var listItemInfo = ts.findListItemInfo(node);
+ if (listItemInfo) {
+ var list = listItemInfo.list;
+ var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
+ var argumentIndex = (listItemInfo.listItemIndex + 1) >> 1;
+ return {
+ kind: isTypeArgList ? 0 /* TypeArguments */ : 1 /* CallArguments */,
+ invocation: callExpression,
+ argumentsSpan: getApplicableSpanForArguments(list),
+ argumentIndex: argumentIndex,
+ argumentCount: getCommaBasedArgCount(list)
+ };
+ }
}
- var parent = node.parent;
- if (node.kind === 23 /* LessThanToken */ || node.kind === 15 /* OpenParenToken */) {
- var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile);
- ts.Debug.assert(list !== undefined);
- return {
- list: list,
- listItemIndex: 0
- };
+ else if (node.kind === 9 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 149 /* TaggedTemplateExpression */) {
+ if (ts.isInsideTemplateLiteral(node, position)) {
+ return getArgumentListInfoForTemplate(node.parent, 0);
+ }
}
- return ts.findListItemInfo(node);
+ else if (node.kind === 10 /* TemplateHead */ && node.parent.parent.kind === 149 /* TaggedTemplateExpression */) {
+ var templateExpression = node.parent;
+ var tagExpression = templateExpression.parent;
+ ts.Debug.assert(templateExpression.kind === 158 /* TemplateExpression */);
+ var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1;
+ return getArgumentListInfoForTemplate(tagExpression, argumentIndex);
+ }
+ else if (node.parent.kind === 159 /* TemplateSpan */ && node.parent.parent.parent.kind === 149 /* TaggedTemplateExpression */) {
+ var templateSpan = node.parent;
+ var templateExpression = templateSpan.parent;
+ var tagExpression = templateExpression.parent;
+ ts.Debug.assert(templateExpression.kind === 158 /* TemplateExpression */);
+ if (node.kind === 12 /* TemplateTail */ && position >= node.getEnd() && !ts.isUnterminatedTemplateEnd(node)) {
+ return undefined;
+ }
+ var spanIndex = templateExpression.templateSpans.indexOf(templateSpan);
+ var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node);
+ return getArgumentListInfoForTemplate(tagExpression, argumentIndex);
+ }
+ return undefined;
+ }
+ function getCommaBasedArgCount(argumentsList) {
+ return argumentsList.getChildCount() === 0 ? 0 : 1 + ts.countWhere(argumentsList.getChildren(), function (arg) { return arg.kind === 22 /* CommaToken */; });
+ }
+ function getArgumentIndexForTemplatePiece(spanIndex, node) {
+ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");
+ if (ts.isTemplateLiteralKind(node.kind)) {
+ if (ts.isInsideTemplateLiteral(node, position)) {
+ return 0;
+ }
+ return spanIndex + 2;
+ }
+ return spanIndex + 1;
+ }
+ function getArgumentListInfoForTemplate(tagExpression, argumentIndex) {
+ var argumentCount = tagExpression.template.kind === 9 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1;
+ return {
+ kind: 2 /* TaggedTemplateArguments */,
+ invocation: tagExpression,
+ argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression),
+ argumentIndex: argumentIndex,
+ argumentCount: argumentCount
+ };
+ }
+ function getApplicableSpanForArguments(argumentsList) {
+ var applicableSpanStart = argumentsList.getFullStart();
+ var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentsList.getEnd(), false);
+ return new ts.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
+ }
+ function getApplicableSpanForTaggedTemplate(taggedTemplate) {
+ var template = taggedTemplate.template;
+ var applicableSpanStart = template.getStart();
+ var applicableSpanEnd = template.getEnd();
+ if (template.kind === 158 /* TemplateExpression */) {
+ var lastSpan = ts.lastOrUndefined(template.templateSpans);
+ if (lastSpan.literal.kind === 120 /* Missing */) {
+ applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false);
+ }
+ }
+ return new ts.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
}
function getContainingArgumentInfo(node) {
- for (var n = node; n.kind !== 196 /* SourceFile */; n = n.parent) {
- if (n.kind === 186 /* FunctionBlock */) {
+ for (var n = node; n.kind !== 197 /* SourceFile */; n = n.parent) {
+ if (n.kind === 187 /* FunctionBlock */) {
return undefined;
}
if (n.pos < n.parent.pos || n.end > n.parent.end) {
@@ -16943,13 +17382,12 @@ var ts;
}
return maxParamsSignatureIndex;
}
- function createSignatureHelpItems(candidates, bestSignature, argumentInfoOrTypeArgumentInfo) {
- var argumentListOrTypeArgumentList = argumentInfoOrTypeArgumentInfo.list;
- var parent = argumentListOrTypeArgumentList.parent;
- var isTypeParameterHelp = parent.typeArguments && parent.typeArguments.pos === argumentListOrTypeArgumentList.pos;
- ts.Debug.assert(isTypeParameterHelp || parent.arguments.pos === argumentListOrTypeArgumentList.pos);
- var callTargetNode = argumentListOrTypeArgumentList.parent.func;
- var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTargetNode);
+ function createSignatureHelpItems(candidates, bestSignature, argumentListInfo) {
+ var applicableSpan = argumentListInfo.argumentsSpan;
+ var isTypeParameterList = argumentListInfo.kind === 0 /* TypeArguments */;
+ var invocation = argumentListInfo.invocation;
+ var callTarget = ts.getInvokedExpression(invocation);
+ var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTarget);
var callTargetDisplayParts = callTargetSymbol && ts.symbolToDisplayParts(typeInfoResolver, callTargetSymbol, undefined, undefined);
var items = ts.map(candidates, function (candidateSignature) {
var signatureHelpParameters;
@@ -16958,23 +17396,23 @@ var ts;
if (callTargetDisplayParts) {
prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts);
}
- if (isTypeParameterHelp) {
+ if (isTypeParameterList) {
prefixDisplayParts.push(ts.punctuationPart(23 /* LessThanToken */));
var typeParameters = candidateSignature.typeParameters;
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
suffixDisplayParts.push(ts.punctuationPart(24 /* GreaterThanToken */));
- var parameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, argumentListOrTypeArgumentList); });
+ var parameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); });
suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts);
}
else {
- var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, argumentListOrTypeArgumentList); });
+ var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); });
prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts);
prefixDisplayParts.push(ts.punctuationPart(15 /* OpenParenToken */));
var parameters = candidateSignature.parameters;
signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray;
suffixDisplayParts.push(ts.punctuationPart(16 /* CloseParenToken */));
}
- var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, argumentListOrTypeArgumentList); });
+ var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); });
suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts);
return {
isVariadic: candidateSignature.hasRestParameter,
@@ -16985,11 +17423,8 @@ var ts;
documentation: candidateSignature.getDocumentationComment()
};
});
- var applicableSpanStart = argumentListOrTypeArgumentList.getFullStart();
- var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentListOrTypeArgumentList.end, false);
- var applicableSpan = new ts.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
- var argumentIndex = (argumentInfoOrTypeArgumentInfo.listItemIndex + 1) >> 1;
- var argumentCount = argumentListOrTypeArgumentList.getChildCount() === 0 ? 0 : 1 + ts.countWhere(argumentListOrTypeArgumentList.getChildren(), function (arg) { return arg.kind === 22 /* CommaToken */; });
+ var argumentIndex = argumentListInfo.argumentIndex;
+ var argumentCount = argumentListInfo.argumentCount;
var selectedItemIndex = candidates.indexOf(bestSignature);
if (selectedItemIndex < 0) {
selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount);
@@ -17002,7 +17437,7 @@ var ts;
argumentCount: argumentCount
};
function createSignatureHelpParameterForParameter(parameter) {
- var displayParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, argumentListOrTypeArgumentList); });
+ var displayParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation); });
var isOptional = !!(parameter.valueDeclaration.flags & 4 /* QuestionMark */);
return {
name: parameter.name,
@@ -17012,7 +17447,7 @@ var ts;
};
}
function createSignatureHelpParameterForTypeParameter(typeParameter) {
- var displayParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, argumentListOrTypeArgumentList); });
+ var displayParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation); });
return {
name: typeParameter.symbol.name,
documentation: emptyArray,
@@ -17097,7 +17532,7 @@ var ts;
ts.findChildOfKind = findChildOfKind;
function findContainingList(node) {
var syntaxList = ts.forEach(node.parent.getChildren(), function (c) {
- if (c.kind === 198 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) {
+ if (c.kind === 199 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) {
return c;
}
});
@@ -17105,7 +17540,7 @@ var ts;
}
ts.findContainingList = findContainingList;
function findListItemIndexContainingPosition(list, position) {
- ts.Debug.assert(list.kind === 198 /* SyntaxList */);
+ ts.Debug.assert(list.kind === 199 /* SyntaxList */);
var children = list.getChildren();
for (var i = 0; i < children.length; i++) {
if (children[i].pos <= position && children[i].end > position) {
@@ -17212,7 +17647,7 @@ var ts;
}
}
}
- ts.Debug.assert(startNode !== undefined || n.kind === 196 /* SourceFile */);
+ ts.Debug.assert(startNode !== undefined || n.kind === 197 /* SourceFile */);
if (children.length) {
var candidate = findRightmostChildNodeWithTokens(children, children.length);
return candidate && findRightmostToken(candidate);
@@ -17237,7 +17672,7 @@ var ts;
if (node.kind === 132 /* TypeReference */ || node.kind === 147 /* CallExpression */) {
return node.typeArguments;
}
- if (ts.isAnyFunction(node) || node.kind === 187 /* ClassDeclaration */ || node.kind === 188 /* InterfaceDeclaration */) {
+ if (ts.isAnyFunction(node) || node.kind === 188 /* ClassDeclaration */ || node.kind === 189 /* InterfaceDeclaration */) {
return node.typeParameters;
}
return undefined;
@@ -17261,6 +17696,10 @@ var ts;
return 13 /* FirstPunctuation */ <= kind && kind <= 62 /* LastPunctuation */;
}
ts.isPunctuation = isPunctuation;
+ function isInsideTemplateLiteral(node, position) {
+ return (node.getStart() < position && position < node.getEnd()) || (ts.isUnterminatedTemplateEnd(node) && position === node.getEnd());
+ }
+ ts.isInsideTemplateLiteral = isInsideTemplateLiteral;
})(ts || (ts = {}));
var ts;
(function (ts) {
@@ -17364,7 +17803,7 @@ var ts;
return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options);
}
function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) {
- var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 196 /* SourceFile */ || !parentAndChildShareLine);
+ var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 197 /* SourceFile */ || !parentAndChildShareLine);
if (!useActualIndentation) {
return -1;
}
@@ -17391,7 +17830,7 @@ var ts;
return candidate.end > position || !isCompletedNode(candidate, sourceFile);
}
function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) {
- if (parent.kind === 165 /* IfStatement */ && parent.elseStatement === child) {
+ if (parent.kind === 166 /* IfStatement */ && parent.elseStatement === child) {
var elseKeyword = ts.findChildOfKind(parent, 74 /* ElseKeyword */, sourceFile);
ts.Debug.assert(elseKeyword !== undefined);
var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
@@ -17412,7 +17851,7 @@ var ts;
return node.parent.properties;
case 141 /* ArrayLiteral */:
return node.parent.elements;
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
case 125 /* Method */:
@@ -17487,28 +17926,28 @@ var ts;
SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn;
function nodeContentIsAlwaysIndented(kind) {
switch (kind) {
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
case 141 /* ArrayLiteral */:
- case 161 /* Block */:
- case 186 /* FunctionBlock */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 192 /* ModuleBlock */:
+ case 162 /* Block */:
+ case 187 /* FunctionBlock */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 193 /* ModuleBlock */:
case 142 /* ObjectLiteral */:
case 136 /* TypeLiteral */:
- case 174 /* SwitchStatement */:
- case 176 /* DefaultClause */:
- case 175 /* CaseClause */:
+ case 175 /* SwitchStatement */:
+ case 177 /* DefaultClause */:
+ case 176 /* CaseClause */:
case 151 /* ParenExpression */:
case 147 /* CallExpression */:
case 148 /* NewExpression */:
- case 162 /* VariableStatement */:
- case 184 /* VariableDeclaration */:
- case 194 /* ExportAssignment */:
- case 172 /* ReturnStatement */:
+ case 163 /* VariableStatement */:
+ case 185 /* VariableDeclaration */:
+ case 195 /* ExportAssignment */:
+ case 173 /* ReturnStatement */:
return true;
}
return false;
@@ -17518,20 +17957,20 @@ var ts;
return true;
}
switch (parent) {
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
- case 169 /* ForInStatement */:
- case 168 /* ForStatement */:
- case 165 /* IfStatement */:
- return child !== 161 /* Block */;
- case 185 /* FunctionDeclaration */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
+ case 170 /* ForInStatement */:
+ case 169 /* ForStatement */:
+ case 166 /* IfStatement */:
+ return child !== 162 /* Block */;
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 125 /* Method */:
case 153 /* ArrowFunction */:
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- return child !== 186 /* FunctionBlock */;
+ return child !== 187 /* FunctionBlock */;
default:
return false;
}
@@ -17552,46 +17991,46 @@ var ts;
}
function isCompletedNode(n, sourceFile) {
switch (n.kind) {
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
case 142 /* ObjectLiteral */:
- case 161 /* Block */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
- case 174 /* SwitchStatement */:
+ case 162 /* Block */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
+ case 175 /* SwitchStatement */:
return nodeEndsWith(n, 14 /* CloseBraceToken */, sourceFile);
case 151 /* ParenExpression */:
case 129 /* CallSignature */:
case 147 /* CallExpression */:
case 130 /* ConstructSignature */:
return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 125 /* Method */:
case 153 /* ArrowFunction */:
return !n.body || isCompletedNode(n.body, sourceFile);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return n.body && isCompletedNode(n.body, sourceFile);
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
if (n.elseStatement) {
return isCompletedNode(n.elseStatement, sourceFile);
}
return isCompletedNode(n.thenStatement, sourceFile);
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return isCompletedNode(n.expression, sourceFile);
case 141 /* ArrayLiteral */:
return nodeEndsWith(n, 18 /* CloseBracketToken */, sourceFile);
case 120 /* Missing */:
return false;
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
return false;
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return isCompletedNode(n.statement, sourceFile);
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
var hasWhileKeyword = ts.findChildOfKind(n, 98 /* WhileKeyword */, sourceFile);
if (hasWhileKeyword) {
return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile);
@@ -18166,7 +18605,7 @@ var ts;
throw new Error("Unknown rule");
};
Rules.IsForContext = function (context) {
- return context.contextNode.kind === 168 /* ForStatement */;
+ return context.contextNode.kind === 169 /* ForStatement */;
};
Rules.IsNotForContext = function (context) {
return !Rules.IsForContext(context);
@@ -18176,13 +18615,13 @@ var ts;
case 156 /* BinaryExpression */:
case 157 /* ConditionalExpression */:
return true;
- case 193 /* ImportDeclaration */:
- case 184 /* VariableDeclaration */:
+ case 194 /* ImportDeclaration */:
+ case 185 /* VariableDeclaration */:
case 123 /* Parameter */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 124 /* Property */:
return context.currentTokenSpan.kind === 51 /* EqualsToken */ || context.nextTokenSpan.kind === 51 /* EqualsToken */;
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return context.currentTokenSpan.kind === 84 /* InKeyword */ || context.nextTokenSpan.kind === 84 /* InKeyword */;
}
return false;
@@ -18213,21 +18652,21 @@ var ts;
return true;
}
switch (node.kind) {
- case 161 /* Block */:
- case 174 /* SwitchStatement */:
+ case 162 /* Block */:
+ case 175 /* SwitchStatement */:
case 142 /* ObjectLiteral */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
return true;
}
return false;
};
Rules.IsFunctionDeclContext = function (context) {
switch (context.contextNode.kind) {
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
@@ -18235,7 +18674,7 @@ var ts;
case 152 /* FunctionExpression */:
case 126 /* Constructor */:
case 153 /* ArrowFunction */:
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return true;
}
return false;
@@ -18245,43 +18684,43 @@ var ts;
};
Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) {
switch (node.kind) {
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
case 136 /* TypeLiteral */:
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return true;
}
return false;
};
Rules.IsAfterCodeBlockContext = function (context) {
switch (context.currentTokenParent.kind) {
- case 187 /* ClassDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 190 /* EnumDeclaration */:
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 186 /* FunctionBlock */:
- case 192 /* ModuleBlock */:
- case 174 /* SwitchStatement */:
+ case 188 /* ClassDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 187 /* FunctionBlock */:
+ case 193 /* ModuleBlock */:
+ case 175 /* SwitchStatement */:
return true;
}
return false;
};
Rules.IsControlDeclContext = function (context) {
switch (context.contextNode.kind) {
- case 165 /* IfStatement */:
- case 174 /* SwitchStatement */:
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 167 /* WhileStatement */:
- case 179 /* TryStatement */:
- case 166 /* DoStatement */:
- case 173 /* WithStatement */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
+ case 166 /* IfStatement */:
+ case 175 /* SwitchStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 168 /* WhileStatement */:
+ case 180 /* TryStatement */:
+ case 167 /* DoStatement */:
+ case 174 /* WithStatement */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
return true;
default:
return false;
@@ -18306,7 +18745,7 @@ var ts;
return context.formattingRequestKind != 2 /* FormatOnEnter */;
};
Rules.IsModuleDeclContext = function (context) {
- return context.contextNode.kind === 191 /* ModuleDeclaration */;
+ return context.contextNode.kind === 192 /* ModuleDeclaration */;
};
Rules.IsObjectTypeContext = function (context) {
return context.contextNode.kind === 136 /* TypeLiteral */;
@@ -18317,9 +18756,9 @@ var ts;
}
switch (parent.kind) {
case 132 /* TypeReference */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 185 /* FunctionDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
case 125 /* Method */:
@@ -18756,18 +19195,18 @@ var ts;
}
function isListElement(parent, node) {
switch (parent.kind) {
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
return ts.rangeContainsRange(parent.members, node);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
var body = parent.body;
- return body && body.kind === 161 /* Block */ && ts.rangeContainsRange(body.statements, node);
- case 196 /* SourceFile */:
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 192 /* ModuleBlock */:
+ return body && body.kind === 162 /* Block */ && ts.rangeContainsRange(body.statements, node);
+ case 197 /* SourceFile */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 193 /* ModuleBlock */:
return ts.rangeContainsRange(parent.statements, node);
}
return false;
@@ -18860,7 +19299,7 @@ var ts;
var indentation = inheritedIndentation;
if (indentation === -1 /* Unknown */) {
if (isSomeBlock(node.kind)) {
- if (isSomeBlock(parent.kind) || parent.kind === 196 /* SourceFile */ || parent.kind === 175 /* CaseClause */ || parent.kind === 176 /* DefaultClause */) {
+ if (isSomeBlock(parent.kind) || parent.kind === 197 /* SourceFile */ || parent.kind === 176 /* CaseClause */ || parent.kind === 177 /* DefaultClause */) {
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta();
}
else {
@@ -19255,12 +19694,12 @@ var ts;
}
function isSomeBlock(kind) {
switch (kind) {
- case 161 /* Block */:
- case 186 /* FunctionBlock */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 192 /* ModuleBlock */:
+ case 162 /* Block */:
+ case 187 /* FunctionBlock */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 193 /* ModuleBlock */:
return true;
}
return false;
@@ -19268,7 +19707,7 @@ var ts;
function getOpenTokenForList(node, list) {
switch (node.kind) {
case 126 /* Constructor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 125 /* Method */:
case 153 /* ArrowFunction */:
@@ -19388,7 +19827,7 @@ var ts;
return pos;
};
NodeObject.prototype.createSyntaxList = function (nodes) {
- var list = createNode(198 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this);
+ var list = createNode(199 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this);
list._children = [];
var pos = nodes.pos;
for (var i = 0, len = nodes.length; i < len; i++) {
@@ -19514,13 +19953,13 @@ var ts;
}
});
}
- if (declaration.kind === 191 /* ModuleDeclaration */ && declaration.body.kind === 191 /* ModuleDeclaration */) {
+ if (declaration.kind === 192 /* ModuleDeclaration */ && declaration.body.kind === 192 /* ModuleDeclaration */) {
return;
}
- while (declaration.kind === 191 /* ModuleDeclaration */ && declaration.parent.kind === 191 /* ModuleDeclaration */) {
+ while (declaration.kind === 192 /* ModuleDeclaration */ && declaration.parent.kind === 192 /* ModuleDeclaration */) {
declaration = declaration.parent;
}
- ts.forEach(getJsDocCommentTextRange(declaration.kind === 184 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) {
+ ts.forEach(getJsDocCommentTextRange(declaration.kind === 185 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) {
var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration);
if (cleanedJsDocComment) {
jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment);
@@ -19782,18 +20221,6 @@ var ts;
function SourceFileObject() {
_super.apply(this, arguments);
}
- SourceFileObject.prototype.getLineAndCharacterFromPosition = function (position) {
- return null;
- };
- SourceFileObject.prototype.getPositionFromLineAndCharacter = function (line, character) {
- return -1;
- };
- SourceFileObject.prototype.getLineStarts = function () {
- return undefined;
- };
- SourceFileObject.prototype.getSyntacticDiagnostics = function () {
- return undefined;
- };
SourceFileObject.prototype.getScriptSnapshot = function () {
return this.scriptSnapshot;
};
@@ -19803,7 +20230,7 @@ var ts;
var namedDeclarations = [];
ts.forEachChild(sourceFile, function visit(node) {
switch (node.kind) {
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
var functionDeclaration = node;
if (functionDeclaration.name && functionDeclaration.name.kind !== 120 /* Missing */) {
@@ -19819,12 +20246,12 @@ var ts;
ts.forEachChild(node, visit);
}
break;
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
- case 190 /* EnumDeclaration */:
- case 191 /* ModuleDeclaration */:
- case 193 /* ImportDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 192 /* ModuleDeclaration */:
+ case 194 /* ImportDeclaration */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
case 136 /* TypeLiteral */:
@@ -19832,17 +20259,17 @@ var ts;
namedDeclarations.push(node);
}
case 126 /* Constructor */:
- case 162 /* VariableStatement */:
- case 192 /* ModuleBlock */:
- case 186 /* FunctionBlock */:
+ case 163 /* VariableStatement */:
+ case 193 /* ModuleBlock */:
+ case 187 /* FunctionBlock */:
ts.forEachChild(node, visit);
break;
case 123 /* Parameter */:
if (!(node.flags & 112 /* AccessibilityModifier */)) {
break;
}
- case 184 /* VariableDeclaration */:
- case 195 /* EnumMember */:
+ case 185 /* VariableDeclaration */:
+ case 196 /* EnumMember */:
case 124 /* Property */:
namedDeclarations.push(node);
break;
@@ -19946,7 +20373,8 @@ var ts;
ScriptElementKind.primitiveType = "primitive type";
ScriptElementKind.label = "label";
ScriptElementKind.alias = "alias";
- ScriptElementKind.constantElement = "constant";
+ ScriptElementKind.constElement = "const";
+ ScriptElementKind.letElement = "let";
return ScriptElementKind;
})();
ts.ScriptElementKind = ScriptElementKind;
@@ -20088,11 +20516,11 @@ var ts;
if (declaration.kind === 152 /* FunctionExpression */) {
return true;
}
- if (declaration.kind !== 184 /* VariableDeclaration */ && declaration.kind !== 185 /* FunctionDeclaration */) {
+ if (declaration.kind !== 185 /* VariableDeclaration */ && declaration.kind !== 186 /* FunctionDeclaration */) {
return false;
}
- for (var parent = declaration.parent; parent.kind !== 186 /* FunctionBlock */; parent = parent.parent) {
- if (parent.kind === 196 /* SourceFile */ || parent.kind === 192 /* ModuleBlock */) {
+ for (var parent = declaration.parent; parent.kind !== 187 /* FunctionBlock */; parent = parent.parent) {
+ if (parent.kind === 197 /* SourceFile */ || parent.kind === 193 /* ModuleBlock */) {
return false;
}
}
@@ -20484,7 +20912,7 @@ var ts;
ts.getNodeModifiers = getNodeModifiers;
function getTargetLabel(referenceNode, labelName) {
while (referenceNode) {
- if (referenceNode.kind === 177 /* LabeledStatement */ && referenceNode.label.text === labelName) {
+ if (referenceNode.kind === 178 /* LabeledStatement */ && referenceNode.label.text === labelName) {
return referenceNode.label;
}
referenceNode = referenceNode.parent;
@@ -20492,13 +20920,13 @@ var ts;
return undefined;
}
function isJumpStatementTarget(node) {
- return node.kind === 63 /* Identifier */ && (node.parent.kind === 171 /* BreakStatement */ || node.parent.kind === 170 /* ContinueStatement */) && node.parent.label === node;
+ return node.kind === 63 /* Identifier */ && (node.parent.kind === 172 /* BreakStatement */ || node.parent.kind === 171 /* ContinueStatement */) && node.parent.label === node;
}
function isLabelOfLabeledStatement(node) {
- return node.kind === 63 /* Identifier */ && node.parent.kind === 177 /* LabeledStatement */ && node.parent.label === node;
+ return node.kind === 63 /* Identifier */ && node.parent.kind === 178 /* LabeledStatement */ && node.parent.label === node;
}
function isLabeledBy(node, labelName) {
- for (var owner = node.parent; owner.kind === 177 /* LabeledStatement */; owner = owner.parent) {
+ for (var owner = node.parent; owner.kind === 178 /* LabeledStatement */; owner = owner.parent) {
if (owner.label.text === labelName) {
return true;
}
@@ -20527,7 +20955,7 @@ var ts;
return node && node.parent && node.parent.kind === 148 /* NewExpression */ && node.parent.func === node;
}
function isNameOfModuleDeclaration(node) {
- return node.parent.kind === 191 /* ModuleDeclaration */ && node.parent.name === node;
+ return node.parent.kind === 192 /* ModuleDeclaration */ && node.parent.name === node;
}
function isNameOfFunctionDeclaration(node) {
return node.kind === 63 /* Identifier */ && ts.isAnyFunction(node.parent) && node.parent.name === node;
@@ -20540,11 +20968,11 @@ var ts;
switch (node.parent.kind) {
case 124 /* Property */:
case 143 /* PropertyAssignment */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 125 /* Method */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
return node.parent.name === node;
case 146 /* IndexedAccess */:
return node.parent.index === node;
@@ -20553,7 +20981,7 @@ var ts;
return false;
}
function isNameOfExternalModuleImportOrDeclaration(node) {
- return node.kind === 7 /* StringLiteral */ && (isNameOfModuleDeclaration(node) || (node.parent.kind === 193 /* ImportDeclaration */ && node.parent.externalModuleName === node));
+ return node.kind === 7 /* StringLiteral */ && (isNameOfModuleDeclaration(node) || (node.parent.kind === 194 /* ImportDeclaration */ && node.parent.externalModuleName === node));
}
function isInsideComment(sourceFile, token, position) {
return position <= token.getStart(sourceFile) && (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart())));
@@ -20600,8 +21028,11 @@ var ts;
if (!ts.localizedDiagnosticMessages) {
ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages();
}
+ function getCanonicalFileName(filename) {
+ return useCaseSensitivefilenames ? filename : filename.toLowerCase();
+ }
function getSourceFile(filename) {
- return ts.lookUp(sourceFilesByName, filename);
+ return ts.lookUp(sourceFilesByName, getCanonicalFileName(filename));
}
function getFullTypeCheckChecker() {
return fullTypeCheckChecker_doNotAccessDirectly || (fullTypeCheckChecker_doNotAccessDirectly = program.getTypeChecker(true));
@@ -20669,7 +21100,7 @@ var ts;
var filename = oldSourceFiles[i].filename;
if (!hostCache.contains(filename) || changesInCompilationSettingsAffectSyntax) {
documentRegistry.releaseDocument(filename, oldSettings);
- delete sourceFilesByName[filename];
+ delete sourceFilesByName[getCanonicalFileName(filename)];
}
}
}
@@ -20693,7 +21124,7 @@ var ts;
else {
sourceFile = documentRegistry.acquireDocument(filename, compilationSettings, scriptSnapshot, version, isOpen);
}
- sourceFilesByName[filename] = sourceFile;
+ sourceFilesByName[getCanonicalFileName(filename)] = sourceFile;
}
program = ts.createProgram(hostfilenames, compilationSettings, createCompilerHost());
typeInfoResolver = program.getTypeChecker(false);
@@ -20725,11 +21156,7 @@ var ts;
var targetSourceFile = getSourceFile(filename);
var allDiagnostics = checker.getDiagnostics(targetSourceFile);
if (compilerOptions.declaration) {
- var savedWriter = writer;
- writer = function (filename, data, writeByteOrderMark) {
- };
- allDiagnostics = allDiagnostics.concat(checker.invokeEmitter(targetSourceFile).diagnostics);
- writer = savedWriter;
+ allDiagnostics = allDiagnostics.concat(checker.getDeclarationDiagnostics(targetSourceFile));
}
return allDiagnostics;
}
@@ -20939,7 +21366,7 @@ var ts;
switch (kind) {
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
case 126 /* Constructor */:
case 127 /* GetAccessor */:
@@ -20956,13 +21383,13 @@ var ts;
var containingNodeKind = previousToken.parent.kind;
switch (previousToken.kind) {
case 22 /* CommaToken */:
- return containingNodeKind === 184 /* VariableDeclaration */ || containingNodeKind === 162 /* VariableStatement */ || containingNodeKind === 190 /* EnumDeclaration */ || isFunction(containingNodeKind);
+ return containingNodeKind === 185 /* VariableDeclaration */ || containingNodeKind === 163 /* VariableStatement */ || containingNodeKind === 191 /* EnumDeclaration */ || isFunction(containingNodeKind);
case 15 /* OpenParenToken */:
- return containingNodeKind === 181 /* CatchBlock */ || isFunction(containingNodeKind);
+ return containingNodeKind === 182 /* CatchBlock */ || isFunction(containingNodeKind);
case 13 /* OpenBraceToken */:
- return containingNodeKind === 190 /* EnumDeclaration */ || containingNodeKind === 188 /* InterfaceDeclaration */;
+ return containingNodeKind === 191 /* EnumDeclaration */ || containingNodeKind === 189 /* InterfaceDeclaration */;
case 21 /* SemicolonToken */:
- return containingNodeKind === 124 /* Property */ && previousToken.parent.parent.kind === 188 /* InterfaceDeclaration */;
+ return containingNodeKind === 124 /* Property */ && previousToken.parent.parent.kind === 189 /* InterfaceDeclaration */;
case 106 /* PublicKeyword */:
case 104 /* PrivateKeyword */:
case 107 /* StaticKeyword */:
@@ -21059,16 +21486,16 @@ var ts;
return undefined;
}
switch (node.kind) {
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
case 125 /* Method */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 187 /* ClassDeclaration */:
- case 188 /* InterfaceDeclaration */:
- case 190 /* EnumDeclaration */:
- case 191 /* ModuleDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 192 /* ModuleDeclaration */:
return node;
}
}
@@ -21107,8 +21534,11 @@ var ts;
if (isFirstDeclarationOfSymbolParameter(symbol)) {
return ScriptElementKind.parameterElement;
}
- else if (symbol.valueDeclaration && symbol.valueDeclaration.flags & 4096 /* Const */) {
- return ScriptElementKind.constantElement;
+ else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) {
+ return ScriptElementKind.constElement;
+ }
+ else if (ts.forEach(symbol.declarations, function (declaration) { return ts.isLet(declaration); })) {
+ return ScriptElementKind.letElement;
}
return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localVariableElement : ScriptElementKind.variableElement;
}
@@ -21162,13 +21592,13 @@ var ts;
}
function getNodeKind(node) {
switch (node.kind) {
- case 191 /* ModuleDeclaration */: return ScriptElementKind.moduleElement;
- case 187 /* ClassDeclaration */: return ScriptElementKind.classElement;
- case 188 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement;
- case 189 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement;
- case 190 /* EnumDeclaration */: return ScriptElementKind.enumElement;
- case 184 /* VariableDeclaration */: return node.flags & 4096 /* Const */ ? ScriptElementKind.constantElement : ScriptElementKind.variableElement;
- case 185 /* FunctionDeclaration */: return ScriptElementKind.functionElement;
+ case 192 /* ModuleDeclaration */: return ScriptElementKind.moduleElement;
+ case 188 /* ClassDeclaration */: return ScriptElementKind.classElement;
+ case 189 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement;
+ case 190 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement;
+ case 191 /* EnumDeclaration */: return ScriptElementKind.enumElement;
+ case 185 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : node.flags & 2048 /* Let */ ? ScriptElementKind.letElement : ScriptElementKind.variableElement;
+ case 186 /* FunctionDeclaration */: return ScriptElementKind.functionElement;
case 127 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement;
case 128 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement;
case 125 /* Method */: return ScriptElementKind.memberFunctionElement;
@@ -21178,7 +21608,7 @@ var ts;
case 129 /* CallSignature */: return ScriptElementKind.callSignatureElement;
case 126 /* Constructor */: return ScriptElementKind.constructorImplementationElement;
case 122 /* TypeParameter */: return ScriptElementKind.typeParameterElement;
- case 195 /* EnumMember */: return ScriptElementKind.variableElement;
+ case 196 /* EnumMember */: return ScriptElementKind.variableElement;
case 123 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement;
}
return ScriptElementKind.unknown;
@@ -21246,7 +21676,7 @@ var ts;
switch (symbolKind) {
case ScriptElementKind.memberVariableElement:
case ScriptElementKind.variableElement:
- case ScriptElementKind.constantElement:
+ case ScriptElementKind.constElement:
case ScriptElementKind.parameterElement:
case ScriptElementKind.localVariableElement:
displayParts.push(punctuationPart(50 /* ColonToken */));
@@ -21312,6 +21742,10 @@ var ts;
}
if (symbolFlags & 384 /* Enum */) {
addNewLineIfDisplayPartsExist();
+ if (ts.forEach(symbol.declarations, function (declaration) { return ts.isConstEnumDeclaration(declaration); })) {
+ displayParts.push(keywordPart(68 /* ConstKeyword */));
+ displayParts.push(spacePart());
+ }
displayParts.push(keywordPart(75 /* EnumKeyword */));
displayParts.push(spacePart());
addFullSymbolName(symbol);
@@ -21352,7 +21786,7 @@ var ts;
if (symbolFlags & 8 /* EnumMember */) {
addPrefixForAnyFunctionOrVar(symbol, "enum member");
var declaration = symbol.declarations[0];
- if (declaration.kind === 195 /* EnumMember */) {
+ if (declaration.kind === 196 /* EnumMember */) {
var constantValue = typeResolver.getEnumMemberValue(declaration);
if (constantValue !== undefined) {
displayParts.push(spacePart());
@@ -21368,7 +21802,7 @@ var ts;
displayParts.push(spacePart());
addFullSymbolName(symbol);
ts.forEach(symbol.declarations, function (declaration) {
- if (declaration.kind === 193 /* ImportDeclaration */) {
+ if (declaration.kind === 194 /* ImportDeclaration */) {
var importDeclaration = declaration;
if (importDeclaration.externalModuleName) {
displayParts.push(spacePart());
@@ -21515,7 +21949,7 @@ var ts;
var declarations = [];
var definition;
ts.forEach(signatureDeclarations, function (d) {
- if ((selectConstructors && d.kind === 126 /* Constructor */) || (!selectConstructors && (d.kind === 185 /* FunctionDeclaration */ || d.kind === 125 /* Method */))) {
+ if ((selectConstructors && d.kind === 126 /* Constructor */) || (!selectConstructors && (d.kind === 186 /* FunctionDeclaration */ || d.kind === 125 /* Method */))) {
declarations.push(d);
if (d.body)
definition = d;
@@ -21535,7 +21969,7 @@ var ts;
if (isNewExpressionTarget(location) || location.kind === 111 /* ConstructorKeyword */) {
if (symbol.flags & 32 /* Class */) {
var classDeclaration = symbol.getDeclarations()[0];
- ts.Debug.assert(classDeclaration && classDeclaration.kind === 187 /* ClassDeclaration */);
+ ts.Debug.assert(classDeclaration && classDeclaration.kind === 188 /* ClassDeclaration */);
return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result);
}
}
@@ -21561,11 +21995,10 @@ var ts;
}
var comment = ts.forEach(sourceFile.referencedFiles, function (r) { return (r.pos <= position && position < r.end) ? r : undefined; });
if (comment) {
- var targetFilename = ts.isRootedDiskPath(comment.filename) ? comment.filename : ts.combinePaths(ts.getDirectoryPath(filename), comment.filename);
- targetFilename = ts.normalizePath(targetFilename);
- if (program.getSourceFile(targetFilename)) {
+ var referenceFile = ts.tryResolveScriptReference(program, sourceFile, comment);
+ if (referenceFile) {
return [{
- fileName: targetFilename,
+ fileName: referenceFile.filename,
textSpan: ts.TextSpan.fromBounds(0, 0),
kind: ScriptElementKind.scriptElement,
name: comment.filename,
@@ -21617,52 +22050,52 @@ var ts;
switch (node.kind) {
case 82 /* IfKeyword */:
case 74 /* ElseKeyword */:
- if (hasKind(node.parent, 165 /* IfStatement */)) {
+ if (hasKind(node.parent, 166 /* IfStatement */)) {
return getIfElseOccurrences(node.parent);
}
break;
case 88 /* ReturnKeyword */:
- if (hasKind(node.parent, 172 /* ReturnStatement */)) {
+ if (hasKind(node.parent, 173 /* ReturnStatement */)) {
return getReturnOccurrences(node.parent);
}
break;
case 92 /* ThrowKeyword */:
- if (hasKind(node.parent, 178 /* ThrowStatement */)) {
+ if (hasKind(node.parent, 179 /* ThrowStatement */)) {
return getThrowOccurrences(node.parent);
}
break;
case 94 /* TryKeyword */:
case 66 /* CatchKeyword */:
case 79 /* FinallyKeyword */:
- if (hasKind(parent(parent(node)), 179 /* TryStatement */)) {
+ if (hasKind(parent(parent(node)), 180 /* TryStatement */)) {
return getTryCatchFinallyOccurrences(node.parent.parent);
}
break;
case 90 /* SwitchKeyword */:
- if (hasKind(node.parent, 174 /* SwitchStatement */)) {
+ if (hasKind(node.parent, 175 /* SwitchStatement */)) {
return getSwitchCaseDefaultOccurrences(node.parent);
}
break;
case 65 /* CaseKeyword */:
case 71 /* DefaultKeyword */:
- if (hasKind(parent(parent(node)), 174 /* SwitchStatement */)) {
+ if (hasKind(parent(parent(node)), 175 /* SwitchStatement */)) {
return getSwitchCaseDefaultOccurrences(node.parent.parent);
}
break;
case 64 /* BreakKeyword */:
case 69 /* ContinueKeyword */:
- if (hasKind(node.parent, 171 /* BreakStatement */) || hasKind(node.parent, 170 /* ContinueStatement */)) {
+ if (hasKind(node.parent, 172 /* BreakStatement */) || hasKind(node.parent, 171 /* ContinueStatement */)) {
return getBreakOrContinueStatementOccurences(node.parent);
}
break;
case 80 /* ForKeyword */:
- if (hasKind(node.parent, 168 /* ForStatement */) || hasKind(node.parent, 169 /* ForInStatement */)) {
+ if (hasKind(node.parent, 169 /* ForStatement */) || hasKind(node.parent, 170 /* ForInStatement */)) {
return getLoopBreakContinueOccurrences(node.parent);
}
break;
case 98 /* WhileKeyword */:
case 73 /* DoKeyword */:
- if (hasKind(node.parent, 167 /* WhileStatement */) || hasKind(node.parent, 166 /* DoStatement */)) {
+ if (hasKind(node.parent, 168 /* WhileStatement */) || hasKind(node.parent, 167 /* DoStatement */)) {
return getLoopBreakContinueOccurrences(node.parent);
}
break;
@@ -21676,11 +22109,15 @@ var ts;
if (hasKind(node.parent, 127 /* GetAccessor */) || hasKind(node.parent, 128 /* SetAccessor */)) {
return getGetAndSetOccurrences(node.parent);
}
+ default:
+ if (ts.isModifier(node.kind) && node.parent && (ts.isDeclaration(node.parent) || node.parent.kind === 163 /* VariableStatement */)) {
+ return getModifierOccurrences(node.kind, node.parent);
+ }
}
return undefined;
function getIfElseOccurrences(ifStatement) {
var keywords = [];
- while (hasKind(ifStatement.parent, 165 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) {
+ while (hasKind(ifStatement.parent, 166 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) {
ifStatement = ifStatement.parent;
}
while (ifStatement) {
@@ -21691,7 +22128,7 @@ var ts;
break;
}
}
- if (!hasKind(ifStatement.elseStatement, 165 /* IfStatement */)) {
+ if (!hasKind(ifStatement.elseStatement, 166 /* IfStatement */)) {
break;
}
ifStatement = ifStatement.elseStatement;
@@ -21724,7 +22161,7 @@ var ts;
}
function getReturnOccurrences(returnStatement) {
var func = ts.getContainingFunction(returnStatement);
- if (!(func && hasKind(func.body, 186 /* FunctionBlock */))) {
+ if (!(func && hasKind(func.body, 187 /* FunctionBlock */))) {
return undefined;
}
var keywords = [];
@@ -21745,7 +22182,7 @@ var ts;
ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) {
pushKeywordIf(keywords, throwStatement.getFirstToken(), 92 /* ThrowKeyword */);
});
- if (owner.kind === 186 /* FunctionBlock */) {
+ if (owner.kind === 187 /* FunctionBlock */) {
ts.forEachReturnStatement(owner, function (returnStatement) {
pushKeywordIf(keywords, returnStatement.getFirstToken(), 88 /* ReturnKeyword */);
});
@@ -21757,10 +22194,10 @@ var ts;
aggregate(node);
return statementAccumulator;
function aggregate(node) {
- if (node.kind === 178 /* ThrowStatement */) {
+ if (node.kind === 179 /* ThrowStatement */) {
statementAccumulator.push(node);
}
- else if (node.kind === 179 /* TryStatement */) {
+ else if (node.kind === 180 /* TryStatement */) {
var tryStatement = node;
if (tryStatement.catchBlock) {
aggregate(tryStatement.catchBlock);
@@ -21782,10 +22219,10 @@ var ts;
var child = throwStatement;
while (child.parent) {
var parent = child.parent;
- if (parent.kind === 186 /* FunctionBlock */ || parent.kind === 196 /* SourceFile */) {
+ if (parent.kind === 187 /* FunctionBlock */ || parent.kind === 197 /* SourceFile */) {
return parent;
}
- if (parent.kind === 179 /* TryStatement */) {
+ if (parent.kind === 180 /* TryStatement */) {
var tryStatement = parent;
if (tryStatement.tryBlock === child && tryStatement.catchBlock) {
return child;
@@ -21809,7 +22246,7 @@ var ts;
function getLoopBreakContinueOccurrences(loopNode) {
var keywords = [];
if (pushKeywordIf(keywords, loopNode.getFirstToken(), 80 /* ForKeyword */, 98 /* WhileKeyword */, 73 /* DoKeyword */)) {
- if (loopNode.kind === 166 /* DoStatement */) {
+ if (loopNode.kind === 167 /* DoStatement */) {
var loopTokens = loopNode.getChildren();
for (var i = loopTokens.length - 1; i >= 0; i--) {
if (pushKeywordIf(keywords, loopTokens[i], 98 /* WhileKeyword */)) {
@@ -21844,12 +22281,12 @@ var ts;
var owner = getBreakOrContinueOwner(breakOrContinueStatement);
if (owner) {
switch (owner.kind) {
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 166 /* DoStatement */:
- case 167 /* WhileStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 167 /* DoStatement */:
+ case 168 /* WhileStatement */:
return getLoopBreakContinueOccurrences(owner);
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return getSwitchCaseDefaultOccurrences(owner);
}
}
@@ -21860,7 +22297,7 @@ var ts;
aggregate(node);
return statementAccumulator;
function aggregate(node) {
- if (node.kind === 171 /* BreakStatement */ || node.kind === 170 /* ContinueStatement */) {
+ if (node.kind === 172 /* BreakStatement */ || node.kind === 171 /* ContinueStatement */) {
statementAccumulator.push(node);
}
else if (!ts.isAnyFunction(node)) {
@@ -21876,14 +22313,14 @@ var ts;
function getBreakOrContinueOwner(statement) {
for (var node = statement.parent; node; node = node.parent) {
switch (node.kind) {
- case 174 /* SwitchStatement */:
- if (statement.kind === 170 /* ContinueStatement */) {
+ case 175 /* SwitchStatement */:
+ if (statement.kind === 171 /* ContinueStatement */) {
continue;
}
- case 168 /* ForStatement */:
- case 169 /* ForInStatement */:
- case 167 /* WhileStatement */:
- case 166 /* DoStatement */:
+ case 169 /* ForStatement */:
+ case 170 /* ForInStatement */:
+ case 168 /* WhileStatement */:
+ case 167 /* DoStatement */:
if (!statement.label || isLabeledBy(node, statement.label.text)) {
return node;
}
@@ -21919,6 +22356,73 @@ var ts;
}
}
}
+ function getModifierOccurrences(modifier, declaration) {
+ var container = declaration.parent;
+ if (declaration.flags & 112 /* AccessibilityModifier */) {
+ if (!(container.kind === 188 /* ClassDeclaration */ || (declaration.kind === 123 /* Parameter */ && hasKind(container, 126 /* Constructor */)))) {
+ return undefined;
+ }
+ }
+ else if (declaration.flags & 128 /* Static */) {
+ if (container.kind !== 188 /* ClassDeclaration */) {
+ return undefined;
+ }
+ }
+ else if (declaration.flags & (1 /* Export */ | 2 /* Ambient */)) {
+ if (!(container.kind === 193 /* ModuleBlock */ || container.kind === 197 /* SourceFile */)) {
+ return undefined;
+ }
+ }
+ var keywords = [];
+ var modifierFlag = getFlagFromModifier(modifier);
+ var nodes;
+ switch (container.kind) {
+ case 193 /* ModuleBlock */:
+ case 197 /* SourceFile */:
+ nodes = container.statements;
+ break;
+ case 126 /* Constructor */:
+ nodes = container.parameters.concat(container.parent.members);
+ break;
+ case 188 /* ClassDeclaration */:
+ nodes = container.members;
+ if (modifierFlag & 112 /* AccessibilityModifier */) {
+ var constructor = ts.forEach(container.members, function (member) {
+ return member.kind === 126 /* Constructor */ && member;
+ });
+ if (constructor) {
+ nodes = nodes.concat(constructor.parameters);
+ }
+ }
+ break;
+ default:
+ ts.Debug.fail("Invalid container kind.");
+ }
+ ts.forEach(nodes, function (node) {
+ if (node.flags & modifierFlag) {
+ ts.forEach(node.getChildren(), function (child) { return pushKeywordIf(keywords, child, modifier); });
+ }
+ });
+ return ts.map(keywords, getReferenceEntryFromNode);
+ function getFlagFromModifier(modifier) {
+ switch (modifier) {
+ case 106 /* PublicKeyword */:
+ return 16 /* Public */;
+ case 104 /* PrivateKeyword */:
+ return 32 /* Private */;
+ case 105 /* ProtectedKeyword */:
+ return 64 /* Protected */;
+ case 107 /* StaticKeyword */:
+ return 128 /* Static */;
+ case 76 /* ExportKeyword */:
+ return 1 /* Export */;
+ case 112 /* DeclareKeyword */:
+ return 2 /* Ambient */;
+ default:
+ ts.Debug.fail();
+ }
+ }
+ }
function hasKind(node, kind) {
return node !== undefined && node.kind === kind;
}
@@ -21983,30 +22487,38 @@ var ts;
}
var result;
var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations);
- var symbolName = getNormalizedSymbolName(symbol.name, declarations);
+ var declaredName = getDeclaredName(symbol);
var scope = getSymbolScope(symbol);
if (scope) {
result = [];
- getReferencesInNode(scope, symbol, symbolName, node, searchMeaning, findInStrings, findInComments, result);
+ getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result);
}
else {
+ var internedName = getInternedName(symbol, declarations);
ts.forEach(sourceFiles, function (sourceFile) {
cancellationToken.throwIfCancellationRequested();
- if (ts.lookUp(sourceFile.identifiers, symbolName)) {
+ if (ts.lookUp(sourceFile.identifiers, internedName)) {
result = result || [];
- getReferencesInNode(sourceFile, symbol, symbolName, node, searchMeaning, findInStrings, findInComments, result);
+ getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result);
}
});
}
return result;
- function getNormalizedSymbolName(symbolName, declarations) {
+ function getDeclaredName(symbol) {
+ var name = typeInfoResolver.symbolToString(symbol);
+ return stripQuotes(name);
+ }
+ function getInternedName(symbol, declarations) {
var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 152 /* FunctionExpression */ ? d : undefined; });
if (functionExpression && functionExpression.name) {
var name = functionExpression.name.text;
}
else {
- var name = symbolName;
+ var name = symbol.name;
}
+ return stripQuotes(name);
+ }
+ function stripQuotes(name) {
var length = name.length;
if (length >= 2 && name.charCodeAt(0) === 34 /* doubleQuote */ && name.charCodeAt(length - 1) === 34 /* doubleQuote */) {
return name.substring(1, length - 1);
@@ -22018,7 +22530,7 @@ var ts;
if (symbol.getFlags() && (4 /* Property */ | 8192 /* Method */)) {
var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; });
if (privateDeclaration) {
- return ts.getAncestor(privateDeclaration, 187 /* ClassDeclaration */);
+ return ts.getAncestor(privateDeclaration, 188 /* ClassDeclaration */);
}
}
if (symbol.parent) {
@@ -22035,7 +22547,7 @@ var ts;
if (scope && scope !== container) {
return undefined;
}
- if (container.kind === 196 /* SourceFile */ && !ts.isExternalModule(container)) {
+ if (container.kind === 197 /* SourceFile */ && !ts.isExternalModule(container)) {
return undefined;
}
scope = container;
@@ -22201,18 +22713,18 @@ var ts;
staticFlag &= searchSpaceNode.flags;
searchSpaceNode = searchSpaceNode.parent;
break;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
if (ts.isExternalModule(searchSpaceNode)) {
return undefined;
}
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
break;
default:
return undefined;
}
var result = [];
- if (searchSpaceNode.kind === 196 /* SourceFile */) {
+ if (searchSpaceNode.kind === 197 /* SourceFile */) {
ts.forEach(sourceFiles, function (sourceFile) {
var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd());
getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, result);
@@ -22234,18 +22746,18 @@ var ts;
var container = ts.getThisContainer(node, false);
switch (searchSpaceNode.kind) {
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
if (searchSpaceNode.symbol === container.symbol) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) {
result.push(getReferenceEntryFromNode(node));
}
break;
- case 196 /* SourceFile */:
- if (container.kind === 196 /* SourceFile */ && !ts.isExternalModule(container)) {
+ case 197 /* SourceFile */:
+ if (container.kind === 197 /* SourceFile */ && !ts.isExternalModule(container)) {
result.push(getReferenceEntryFromNode(node));
}
break;
@@ -22277,11 +22789,11 @@ var ts;
function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) {
if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) {
ts.forEach(symbol.getDeclarations(), function (declaration) {
- if (declaration.kind === 187 /* ClassDeclaration */) {
+ if (declaration.kind === 188 /* ClassDeclaration */) {
getPropertySymbolFromTypeReference(declaration.baseType);
ts.forEach(declaration.implementedTypes, getPropertySymbolFromTypeReference);
}
- else if (declaration.kind === 188 /* InterfaceDeclaration */) {
+ else if (declaration.kind === 189 /* InterfaceDeclaration */) {
ts.forEach(declaration.baseTypes, getPropertySymbolFromTypeReference);
}
});
@@ -22495,7 +23007,7 @@ var ts;
writer = undefined;
return emitOutput;
}
- var emitFilesResult = getFullTypeCheckChecker().invokeEmitter(targetSourceFile);
+ var emitFilesResult = getFullTypeCheckChecker().emitFiles(targetSourceFile);
emitOutput.emitOutputStatus = emitFilesResult.emitResultStatus;
writer = undefined;
return emitOutput;
@@ -22503,29 +23015,29 @@ var ts;
function getMeaningFromDeclaration(node) {
switch (node.kind) {
case 123 /* Parameter */:
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 124 /* Property */:
case 143 /* PropertyAssignment */:
case 144 /* ShorthandPropertyAssignment */:
- case 195 /* EnumMember */:
+ case 196 /* EnumMember */:
case 125 /* Method */:
case 126 /* Constructor */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
- case 181 /* CatchBlock */:
+ case 182 /* CatchBlock */:
return 1 /* Value */;
case 122 /* TypeParameter */:
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
case 136 /* TypeLiteral */:
return 2 /* Type */;
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
return 1 /* Value */ | 2 /* Type */;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (node.name.kind === 7 /* StringLiteral */) {
return 4 /* Namespace */ | 1 /* Value */;
}
@@ -22535,9 +23047,9 @@ var ts;
else {
return 4 /* Namespace */;
}
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
- case 196 /* SourceFile */:
+ case 197 /* SourceFile */:
return 4 /* Namespace */ | 1 /* Value */;
}
ts.Debug.fail("Unknown declaration type");
@@ -22562,17 +23074,17 @@ var ts;
while (node.parent.kind === 121 /* QualifiedName */) {
node = node.parent;
}
- return node.parent.kind === 193 /* ImportDeclaration */ && node.parent.entityName === node;
+ return node.parent.kind === 194 /* ImportDeclaration */ && node.parent.entityName === node;
}
function getMeaningFromRightHandSideOfImport(node) {
ts.Debug.assert(node.kind === 63 /* Identifier */);
- if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 193 /* ImportDeclaration */) {
+ if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 194 /* ImportDeclaration */) {
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
}
return 4 /* Namespace */;
}
function getMeaningFromLocation(node) {
- if (node.parent.kind === 194 /* ExportAssignment */) {
+ if (node.parent.kind === 195 /* ExportAssignment */) {
return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */;
}
else if (isInRightSideOfImport(node)) {
@@ -22597,54 +23109,6 @@ var ts;
var sourceFile = getSourceFile(fileName);
return ts.SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
}
- function getSignatureAtPosition(filename, position) {
- var signatureHelpItems = getSignatureHelpItems(filename, position);
- if (!signatureHelpItems) {
- return undefined;
- }
- var currentArgumentState = { argumentIndex: signatureHelpItems.argumentIndex, argumentCount: signatureHelpItems.argumentCount };
- var formalSignatures = [];
- ts.forEach(signatureHelpItems.items, function (signature) {
- var signatureInfoString = displayPartsToString(signature.prefixDisplayParts);
- var parameters = [];
- if (signature.parameters) {
- for (var i = 0, n = signature.parameters.length; i < n; i++) {
- var parameter = signature.parameters[i];
- if (i) {
- signatureInfoString += displayPartsToString(signature.separatorDisplayParts);
- }
- var start = signatureInfoString.length;
- signatureInfoString += displayPartsToString(parameter.displayParts);
- var end = signatureInfoString.length;
- parameters.push({
- name: parameter.name,
- isVariable: i === n - 1 && signature.isVariadic,
- docComment: displayPartsToString(parameter.documentation),
- minChar: start,
- limChar: end
- });
- }
- }
- signatureInfoString += displayPartsToString(signature.suffixDisplayParts);
- formalSignatures.push({
- signatureInfo: signatureInfoString,
- docComment: displayPartsToString(signature.documentation),
- parameters: parameters,
- typeParameters: []
- });
- });
- var actualSignature = {
- parameterMinChar: signatureHelpItems.applicableSpan.start(),
- parameterLimChar: signatureHelpItems.applicableSpan.end(),
- currentParameterIsTypeParameter: false,
- currentParameter: currentArgumentState.argumentIndex
- };
- return {
- actual: actualSignature,
- formal: formalSignatures,
- activeFormal: 0
- };
- }
function getCurrentSourceFile(filename) {
filename = ts.normalizeSlashes(filename);
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(filename);
@@ -22676,7 +23140,7 @@ var ts;
nodeForStartPos = nodeForStartPos.parent;
}
else if (isNameOfModuleDeclaration(nodeForStartPos)) {
- if (nodeForStartPos.parent.parent.kind === 191 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) {
+ if (nodeForStartPos.parent.parent.kind === 192 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) {
nodeForStartPos = nodeForStartPos.parent.parent.name;
}
else {
@@ -22728,7 +23192,7 @@ var ts;
return undefined;
function hasValueSideModule(symbol) {
return ts.forEach(symbol.declarations, function (declaration) {
- return declaration.kind === 191 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */;
+ return declaration.kind === 192 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */;
});
}
}
@@ -22789,7 +23253,7 @@ var ts;
}
}
if (ts.isPunctuation(token.kind)) {
- if (token.parent.kind === 156 /* BinaryExpression */ || token.parent.kind === 184 /* VariableDeclaration */ || token.parent.kind === 154 /* PrefixOperator */ || token.parent.kind === 155 /* PostfixOperator */ || token.parent.kind === 157 /* ConditionalExpression */) {
+ if (token.parent.kind === 156 /* BinaryExpression */ || token.parent.kind === 185 /* VariableDeclaration */ || token.parent.kind === 154 /* PrefixOperator */ || token.parent.kind === 155 /* PostfixOperator */ || token.parent.kind === 157 /* ConditionalExpression */) {
return ClassificationTypeNames.operator;
}
else {
@@ -22810,7 +23274,7 @@ var ts;
}
else if (tokenKind === 63 /* Identifier */) {
switch (token.parent.kind) {
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
if (token.parent.name === token) {
return ClassificationTypeNames.className;
}
@@ -22820,17 +23284,17 @@ var ts;
return ClassificationTypeNames.typeParameterName;
}
return;
- case 188 /* InterfaceDeclaration */:
+ case 189 /* InterfaceDeclaration */:
if (token.parent.name === token) {
return ClassificationTypeNames.interfaceName;
}
return;
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
if (token.parent.name === token) {
return ClassificationTypeNames.enumName;
}
return;
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (token.parent.name === token) {
return ClassificationTypeNames.moduleName;
}
@@ -23072,7 +23536,7 @@ var ts;
getFormattingEditsForDocument: getFormattingEditsForDocument,
getFormattingEditsAfterKeystroke: getFormattingEditsAfterKeystroke,
getEmitOutput: getEmitOutput,
- getSignatureAtPosition: getSignatureAtPosition
+ getSourceFile: getCurrentSourceFile
};
}
ts.createLanguageService = createLanguageService;
@@ -23109,7 +23573,7 @@ var ts;
}
return true;
}
- function getClassificationsForLine(text, lexState) {
+ function getClassificationsForLine(text, lexState, classifyKeywordsInGenerics) {
var offset = 0;
var token = 0 /* Unknown */;
var lastNonTriviaToken = 0 /* Unknown */;
@@ -23154,7 +23618,7 @@ var ts;
angleBracketStack--;
}
else if (token === 109 /* AnyKeyword */ || token === 118 /* StringKeyword */ || token === 116 /* NumberKeyword */ || token === 110 /* BooleanKeyword */) {
- if (angleBracketStack > 0) {
+ if (angleBracketStack > 0 && !classifyKeywordsInGenerics) {
token = 63 /* Identifier */;
}
}
@@ -23285,7 +23749,7 @@ var ts;
getNodeConstructor: function (kind) {
function Node() {
}
- var proto = kind === 196 /* SourceFile */ ? new SourceFileObject() : new NodeObject();
+ var proto = kind === 197 /* SourceFile */ ? new SourceFileObject() : new NodeObject();
proto.kind = kind;
proto.pos = 0;
proto.end = 0;
@@ -23339,10 +23803,10 @@ var ts;
function spanInNode(node) {
if (node) {
if (ts.isExpression(node)) {
- if (node.parent.kind === 166 /* DoStatement */) {
+ if (node.parent.kind === 167 /* DoStatement */) {
return spanInPreviousNode(node);
}
- if (node.parent.kind === 168 /* ForStatement */) {
+ if (node.parent.kind === 169 /* ForStatement */) {
return textSpan(node);
}
if (node.parent.kind === 156 /* BinaryExpression */ && node.parent.operator === 22 /* CommaToken */) {
@@ -23353,14 +23817,14 @@ var ts;
}
}
switch (node.kind) {
- case 162 /* VariableStatement */:
+ case 163 /* VariableStatement */:
return spanInVariableDeclaration(node.declarations[0]);
- case 184 /* VariableDeclaration */:
+ case 185 /* VariableDeclaration */:
case 124 /* Property */:
return spanInVariableDeclaration(node);
case 123 /* Parameter */:
return spanInParameterDeclaration(node);
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 125 /* Method */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
@@ -23368,62 +23832,62 @@ var ts;
case 152 /* FunctionExpression */:
case 153 /* ArrowFunction */:
return spanInFunctionDeclaration(node);
- case 186 /* FunctionBlock */:
+ case 187 /* FunctionBlock */:
return spanInFunctionBlock(node);
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
- case 192 /* ModuleBlock */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
+ case 193 /* ModuleBlock */:
return spanInBlock(node);
- case 164 /* ExpressionStatement */:
+ case 165 /* ExpressionStatement */:
return textSpan(node.expression);
- case 172 /* ReturnStatement */:
+ case 173 /* ReturnStatement */:
return textSpan(node.getChildAt(0), node.expression);
- case 167 /* WhileStatement */:
+ case 168 /* WhileStatement */:
return textSpan(node, ts.findNextToken(node.expression, node));
- case 166 /* DoStatement */:
+ case 167 /* DoStatement */:
return spanInNode(node.statement);
- case 183 /* DebuggerStatement */:
+ case 184 /* DebuggerStatement */:
return textSpan(node.getChildAt(0));
- case 165 /* IfStatement */:
+ case 166 /* IfStatement */:
return textSpan(node, ts.findNextToken(node.expression, node));
- case 177 /* LabeledStatement */:
+ case 178 /* LabeledStatement */:
return spanInNode(node.statement);
- case 171 /* BreakStatement */:
- case 170 /* ContinueStatement */:
+ case 172 /* BreakStatement */:
+ case 171 /* ContinueStatement */:
return textSpan(node.getChildAt(0), node.label);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return spanInForStatement(node);
- case 169 /* ForInStatement */:
+ case 170 /* ForInStatement */:
return textSpan(node, ts.findNextToken(node.expression, node));
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return textSpan(node, ts.findNextToken(node.expression, node));
- case 175 /* CaseClause */:
- case 176 /* DefaultClause */:
+ case 176 /* CaseClause */:
+ case 177 /* DefaultClause */:
return spanInNode(node.statements[0]);
- case 179 /* TryStatement */:
+ case 180 /* TryStatement */:
return spanInBlock(node.tryBlock);
- case 178 /* ThrowStatement */:
+ case 179 /* ThrowStatement */:
return textSpan(node, node.expression);
- case 194 /* ExportAssignment */:
+ case 195 /* ExportAssignment */:
return textSpan(node, node.exportName);
- case 193 /* ImportDeclaration */:
+ case 194 /* ImportDeclaration */:
return textSpan(node, node.entityName || node.externalModuleName);
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) {
return undefined;
}
- case 187 /* ClassDeclaration */:
- case 190 /* EnumDeclaration */:
- case 195 /* EnumMember */:
+ case 188 /* ClassDeclaration */:
+ case 191 /* EnumDeclaration */:
+ case 196 /* EnumMember */:
case 147 /* CallExpression */:
case 148 /* NewExpression */:
return textSpan(node);
- case 173 /* WithStatement */:
+ case 174 /* WithStatement */:
return spanInNode(node.statement);
- case 188 /* InterfaceDeclaration */:
- case 189 /* TypeAliasDeclaration */:
+ case 189 /* InterfaceDeclaration */:
+ case 190 /* TypeAliasDeclaration */:
return undefined;
case 21 /* SemicolonToken */:
case 1 /* EndOfFileToken */:
@@ -23463,11 +23927,11 @@ var ts;
}
}
function spanInVariableDeclaration(variableDeclaration) {
- if (variableDeclaration.parent.kind === 169 /* ForInStatement */) {
+ if (variableDeclaration.parent.kind === 170 /* ForInStatement */) {
return spanInNode(variableDeclaration.parent);
}
- var isParentVariableStatement = variableDeclaration.parent.kind === 162 /* VariableStatement */;
- var isDeclarationOfForStatement = variableDeclaration.parent.kind === 168 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration);
+ var isParentVariableStatement = variableDeclaration.parent.kind === 163 /* VariableStatement */;
+ var isDeclarationOfForStatement = variableDeclaration.parent.kind === 169 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration);
var declarations = isParentVariableStatement ? variableDeclaration.parent.declarations : isDeclarationOfForStatement ? variableDeclaration.parent.declarations : undefined;
if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) {
if (declarations && declarations[0] === variableDeclaration) {
@@ -23507,7 +23971,7 @@ var ts;
}
}
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) {
- return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 187 /* ClassDeclaration */ && functionDeclaration.kind !== 126 /* Constructor */);
+ return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 188 /* ClassDeclaration */ && functionDeclaration.kind !== 126 /* Constructor */);
}
function spanInFunctionDeclaration(functionDeclaration) {
if (!functionDeclaration.body) {
@@ -23527,15 +23991,15 @@ var ts;
}
function spanInBlock(block) {
switch (block.parent.kind) {
- case 191 /* ModuleDeclaration */:
+ case 192 /* ModuleDeclaration */:
if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) {
return undefined;
}
- case 167 /* WhileStatement */:
- case 165 /* IfStatement */:
- case 169 /* ForInStatement */:
+ case 168 /* WhileStatement */:
+ case 166 /* IfStatement */:
+ case 170 /* ForInStatement */:
return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]);
- case 168 /* ForStatement */:
+ case 169 /* ForStatement */:
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]);
}
return spanInNode(block.statements[0]);
@@ -23556,34 +24020,34 @@ var ts;
}
function spanInOpenBraceToken(node) {
switch (node.parent.kind) {
- case 190 /* EnumDeclaration */:
+ case 191 /* EnumDeclaration */:
var enumDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile));
- case 187 /* ClassDeclaration */:
+ case 188 /* ClassDeclaration */:
var classDeclaration = node.parent;
return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile));
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
return spanInNodeIfStartsOnSameLine(node.parent, node.parent.clauses[0]);
}
return spanInNode(node.parent);
}
function spanInCloseBraceToken(node) {
switch (node.parent.kind) {
- case 192 /* ModuleBlock */:
+ case 193 /* ModuleBlock */:
if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) {
return undefined;
}
- case 186 /* FunctionBlock */:
- case 190 /* EnumDeclaration */:
- case 187 /* ClassDeclaration */:
+ case 187 /* FunctionBlock */:
+ case 191 /* EnumDeclaration */:
+ case 188 /* ClassDeclaration */:
return textSpan(node);
- case 161 /* Block */:
- case 180 /* TryBlock */:
- case 181 /* CatchBlock */:
- case 182 /* FinallyBlock */:
+ case 162 /* Block */:
+ case 181 /* TryBlock */:
+ case 182 /* CatchBlock */:
+ case 183 /* FinallyBlock */:
return spanInNode(node.parent.statements[node.parent.statements.length - 1]);
;
- case 174 /* SwitchStatement */:
+ case 175 /* SwitchStatement */:
var switchStatement = node.parent;
var lastClause = switchStatement.clauses[switchStatement.clauses.length - 1];
if (lastClause) {
@@ -23595,7 +24059,7 @@ var ts;
}
}
function spanInOpenParenToken(node) {
- if (node.parent.kind === 166 /* DoStatement */) {
+ if (node.parent.kind === 167 /* DoStatement */) {
return spanInPreviousNode(node);
}
return spanInNode(node.parent);
@@ -23603,15 +24067,15 @@ var ts;
function spanInCloseParenToken(node) {
switch (node.parent.kind) {
case 152 /* FunctionExpression */:
- case 185 /* FunctionDeclaration */:
+ case 186 /* FunctionDeclaration */:
case 153 /* ArrowFunction */:
case 125 /* Method */:
case 127 /* GetAccessor */:
case 128 /* SetAccessor */:
case 126 /* Constructor */:
- case 167 /* WhileStatement */:
- case 166 /* DoStatement */:
- case 168 /* ForStatement */:
+ case 168 /* WhileStatement */:
+ case 167 /* DoStatement */:
+ case 169 /* ForStatement */:
return spanInPreviousNode(node);
default:
return spanInNode(node.parent);
@@ -23631,7 +24095,7 @@ var ts;
return spanInNode(node.parent);
}
function spanInWhileKeyword(node) {
- if (node.parent.kind === 166 /* DoStatement */) {
+ if (node.parent.kind === 167 /* DoStatement */) {
return textSpan(node, ts.findNextToken(node.parent.expression, node.parent));
}
return spanInNode(node.parent);
@@ -23950,12 +24414,6 @@ var ts;
return signatureInfo;
});
};
- LanguageServiceShimObject.prototype.getSignatureAtPosition = function (fileName, position) {
- var _this = this;
- return this.forwardJSONCall("getSignatureAtPosition('" + fileName + "', " + position + ")", function () {
- return _this.languageService.getSignatureAtPosition(fileName, position);
- });
- };
LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) {
var _this = this;
return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () {
@@ -24082,8 +24540,8 @@ var ts;
this.logger = logger;
this.classifier = ts.createClassifier(this.logger);
}
- ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState) {
- var classification = this.classifier.getClassificationsForLine(text, lexState);
+ ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) {
+ var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics);
var items = classification.entries;
var result = "";
for (var i = 0; i < items.length; i++) {
diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts
index 9896fa598e..2f573e57af 100644
--- a/src/compiler/emitter.ts
+++ b/src/compiler/emitter.ts
@@ -728,7 +728,7 @@ module ts {
};
}
}
-
+
function emitEnumDeclaration(node: EnumDeclaration) {
if (resolver.isDeclarationVisible(node)) {
emitJsDocComments(node);
@@ -3200,7 +3200,10 @@ module ts {
}
function emitModuleDeclaration(node: ModuleDeclaration) {
- if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) {
+ var shouldEmit = getModuleInstanceState(node) === ModuleInstanceState.Instantiated ||
+ (getModuleInstanceState(node) === ModuleInstanceState.ConstEnumOnly && compilerOptions.preserveConstEnums);
+
+ if (!shouldEmit) {
return emitPinnedOrTripleSlashComments(node);
}
emitLeadingComments(node);
@@ -3584,7 +3587,7 @@ module ts {
return leadingComments;
}
-
+
function getLeadingCommentsToEmit(node: Node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) {
diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts
index a796e163a3..c677f0916c 100644
--- a/src/compiler/parser.ts
+++ b/src/compiler/parser.ts
@@ -612,6 +612,7 @@ module ts {
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
+ case SyntaxKind.Constructor:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.TypeAliasDeclaration:
diff --git a/src/services/formatting.ts b/src/services/formatting.ts
index 2fdbebad79..f58f1ccb33 100644
--- a/src/services/formatting.ts
+++ b/src/services/formatting.ts
@@ -505,7 +505,7 @@ module ts.formatting {
if (isToken(child)) {
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
- var tokenInfo = formattingScanner.readTokenInfo(node);
+ var tokenInfo = formattingScanner.readTokenInfo(child);
Debug.assert(tokenInfo.token.end === child.end);
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation);
return inheritedIndentation;
diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts
index 9cf2a05a5d..220ac21bd8 100644
--- a/src/services/formatting/formattingScanner.ts
+++ b/src/services/formatting/formattingScanner.ts
@@ -114,7 +114,8 @@ module ts.formatting {
}
function shouldRescanTemplateToken(container: Node): boolean {
- return container.kind === SyntaxKind.TemplateSpan;
+ return container.kind === SyntaxKind.TemplateMiddle ||
+ container.kind === SyntaxKind.TemplateTail;
}
function startsWithSlashToken(t: SyntaxKind): boolean {
diff --git a/src/services/services.ts b/src/services/services.ts
index 67e8aba34d..ed8cb03fae 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -3446,6 +3446,11 @@ module ts {
if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) {
return getGetAndSetOccurrences(node.parent);
}
+ default:
+ if (isModifier(node.kind) && node.parent &&
+ (isDeclaration(node.parent) || node.parent.kind === SyntaxKind.VariableStatement)) {
+ return getModifierOccurrences(node.kind, node.parent);
+ }
}
return undefined;
@@ -3790,6 +3795,87 @@ module ts {
}
}
+ function getModifierOccurrences(modifier: SyntaxKind, declaration: Declaration) {
+ var container = declaration.parent;
+
+ // Make sure we only highlight the keyword when it makes sense to do so.
+ if (declaration.flags & NodeFlags.AccessibilityModifier) {
+ if (!(container.kind === SyntaxKind.ClassDeclaration ||
+ (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) {
+ return undefined;
+ }
+ }
+ else if (declaration.flags & NodeFlags.Static) {
+ if (container.kind !== SyntaxKind.ClassDeclaration) {
+ return undefined;
+ }
+ }
+ else if (declaration.flags & (NodeFlags.Export | NodeFlags.Ambient)) {
+ if (!(container.kind === SyntaxKind.ModuleBlock || container.kind === SyntaxKind.SourceFile)) {
+ return undefined;
+ }
+ }
+
+ var keywords: Node[] = [];
+ var modifierFlag: NodeFlags = getFlagFromModifier(modifier);
+
+ var nodes: Node[];
+ switch (container.kind) {
+ case SyntaxKind.ModuleBlock:
+ case SyntaxKind.SourceFile:
+ nodes = (container).statements;
+ break;
+ case SyntaxKind.Constructor:
+ nodes = ((container).parameters).concat(
+ (container.parent).members);
+ break;
+ case SyntaxKind.ClassDeclaration:
+ nodes = (container).members;
+
+ // If we're an accessibility modifier, we're in an instance member and should search
+ // the constructor's parameter list for instance members as well.
+ if (modifierFlag & NodeFlags.AccessibilityModifier) {
+ var constructor = forEach((container).members, member => {
+ return member.kind === SyntaxKind.Constructor && member;
+ });
+
+ if (constructor) {
+ nodes = nodes.concat(constructor.parameters);
+ }
+ }
+ break;
+ default:
+ Debug.fail("Invalid container kind.")
+ }
+
+ forEach(nodes, node => {
+ if (node.flags & modifierFlag) {
+ forEach(node.getChildren(), child => pushKeywordIf(keywords, child, modifier));
+ }
+ });
+
+ return map(keywords, getReferenceEntryFromNode);
+
+ function getFlagFromModifier(modifier: SyntaxKind) {
+ switch (modifier) {
+ case SyntaxKind.PublicKeyword:
+ return NodeFlags.Public;
+ case SyntaxKind.PrivateKeyword:
+ return NodeFlags.Private;
+ case SyntaxKind.ProtectedKeyword:
+ return NodeFlags.Protected;
+ case SyntaxKind.StaticKeyword:
+ return NodeFlags.Static;
+ case SyntaxKind.ExportKeyword:
+ return NodeFlags.Export;
+ case SyntaxKind.DeclareKeyword:
+ return NodeFlags.Ambient;
+ default:
+ Debug.fail();
+ }
+ }
+ }
+
// returns true if 'node' is defined and has a matching 'kind'.
function hasKind(node: Node, kind: SyntaxKind) {
return node !== undefined && node.kind === kind;
diff --git a/tests/cases/fourslash/formattingRegexes.ts b/tests/cases/fourslash/formattingRegexes.ts
new file mode 100644
index 0000000000..136fba6a8b
--- /dev/null
+++ b/tests/cases/fourslash/formattingRegexes.ts
@@ -0,0 +1,8 @@
+///
+
+////removeAllButLast(sortedTypes, undefinedType, /keepNullableType**/ true)/*1*/
+
+goTo.marker("1");
+edit.insert(";");
+verify.currentLineContentIs("removeAllButLast(sortedTypes, undefinedType, /keepNullableType**/ true);");
+
diff --git a/tests/cases/fourslash/getOccurrencesDeclare1.ts b/tests/cases/fourslash/getOccurrencesDeclare1.ts
new file mode 100644
index 0000000000..1cdad07eb7
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesDeclare1.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export [|declare|] module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// [|declare|] var ambientThing: number;
+//// export var exportedThing = 10;
+//// [|declare|] function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesDeclare2.ts b/tests/cases/fourslash/getOccurrencesDeclare2.ts
new file mode 100644
index 0000000000..3d719e5d03
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesDeclare2.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// [|declare|] var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesDeclare3.ts b/tests/cases/fourslash/getOccurrencesDeclare3.ts
new file mode 100644
index 0000000000..048dd8efea
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesDeclare3.ts
@@ -0,0 +1,72 @@
+///
+
+////
+////[|declare|] var x;
+////export [|declare|] var y, z;
+////
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+////
+////[|declare|] export var v1, v2;
+////[|declare|] module dm { }
+////export class EC { }
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesExport1.ts b/tests/cases/fourslash/getOccurrencesExport1.ts
new file mode 100644
index 0000000000..c47c39cf54
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesExport1.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// [|export|] class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// [|export|] interface I1 {
+//// }
+////
+//// [|export|] declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// [|export|] module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// [|export|] var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesExport2.ts b/tests/cases/fourslash/getOccurrencesExport2.ts
new file mode 100644
index 0000000000..a8e43e744b
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesExport2.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// [|export|] class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesExport3.ts b/tests/cases/fourslash/getOccurrencesExport3.ts
new file mode 100644
index 0000000000..009b891992
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesExport3.ts
@@ -0,0 +1,72 @@
+///
+
+////
+////declare var x;
+////[|export|] declare var y, z;
+////
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+////
+////declare [|export|] var v1, v2;
+////declare module dm { }
+////[|export|] class EC { }
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts
new file mode 100644
index 0000000000..ac74fc2192
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesModifiersNegatives1.ts
@@ -0,0 +1,41 @@
+///
+
+////class C {
+//// [|export|] foo;
+//// [|declare|] bar;
+//// [|export|] [|declare|] foobar;
+//// [|declare|] [|export|] barfoo;
+////
+//// constructor([|export|] conFoo,
+//// [|declare|] conBar,
+//// [|export|] [|declare|] conFooBar,
+//// [|declare|] [|export|] conBarFoo,
+//// [|static|] sue,
+//// [|static|] [|export|] [|declare|] sueFooBar,
+//// [|static|] [|declare|] [|export|] sueBarFoo,
+//// [|declare|] [|static|] [|export|] barSueFoo) {
+//// }
+////}
+////
+////module m {
+//// [|static|] a;
+//// [|public|] b;
+//// [|private|] c;
+//// [|protected|] d;
+//// [|static|] [|public|] [|private|] [|protected|] e;
+//// [|public|] [|static|] [|protected|] [|private|] f;
+//// [|protected|] [|static|] [|public|] g;
+////}
+////[|static|] a;
+////[|public|] b;
+////[|private|] c;
+////[|protected|] d;
+////[|static|] [|public|] [|private|] [|protected|] e;
+////[|public|] [|static|] [|protected|] [|private|] f;
+////[|protected|] [|static|] [|public|] g;
+
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(0);
+});
diff --git a/tests/cases/fourslash/getOccurrencesPrivate1.ts b/tests/cases/fourslash/getOccurrencesPrivate1.ts
new file mode 100644
index 0000000000..991ed3ea31
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesPrivate1.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// [|private|] priv1;
+//// [|private|] priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// [|private|] private;
+//// protected protected;
+////
+//// public constructor(public a, [|private|] b, protected c, public d, [|private|] e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// [|private|] static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesPrivate2.ts b/tests/cases/fourslash/getOccurrencesPrivate2.ts
new file mode 100644
index 0000000000..19397443af
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesPrivate2.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// [|private|] priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, [|private|] private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesProtected1.ts b/tests/cases/fourslash/getOccurrencesProtected1.ts
new file mode 100644
index 0000000000..af9e330296
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesProtected1.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// [|protected|] prot1;
+//// [|protected|] prot2;
+////
+//// public public;
+//// private private;
+//// [|protected|] protected;
+////
+//// public constructor(public a, private b, [|protected|] c, public d, private e, [|protected|] f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// [|protected|] static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesProtected2.ts b/tests/cases/fourslash/getOccurrencesProtected2.ts
new file mode 100644
index 0000000000..666736eee1
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesProtected2.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// [|protected|] prot1;
+////
+//// [|protected|] constructor(public public, [|protected|] protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesPublic1.ts b/tests/cases/fourslash/getOccurrencesPublic1.ts
new file mode 100644
index 0000000000..a451a70c1c
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesPublic1.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// [|public|] pub1;
+//// [|public|] pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// [|public|] public;
+//// private private;
+//// protected protected;
+////
+//// [|public|] constructor([|public|] a, private b, protected c, [|public|] d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// [|public|] get x() { return 10; }
+//// [|public|] set x(value) { }
+////
+//// [|public|] static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesPublic2.ts b/tests/cases/fourslash/getOccurrencesPublic2.ts
new file mode 100644
index 0000000000..b4887e18e8
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesPublic2.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public static statPub;
+//// private static statPriv;
+//// protected static statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// [|public|] pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor([|public|] public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});
diff --git a/tests/cases/fourslash/getOccurrencesStatic1.ts b/tests/cases/fourslash/getOccurrencesStatic1.ts
new file mode 100644
index 0000000000..8be9862d5e
--- /dev/null
+++ b/tests/cases/fourslash/getOccurrencesStatic1.ts
@@ -0,0 +1,64 @@
+///
+
+////module m {
+//// export class C1 {
+//// public pub1;
+//// public pub2;
+//// private priv1;
+//// private priv2;
+//// protected prot1;
+//// protected prot2;
+////
+//// public public;
+//// private private;
+//// protected protected;
+////
+//// public constructor(public a, private b, protected c, public d, private e, protected f) {
+//// this.public = 10;
+//// this.private = 10;
+//// this.protected = 10;
+//// }
+////
+//// public get x() { return 10; }
+//// public set x(value) { }
+////
+//// public [|static|] statPub;
+//// private [|static|] statPriv;
+//// protected [|static|] statProt;
+//// }
+////
+//// export interface I1 {
+//// }
+////
+//// export declare module ma.m1.m2.m3 {
+//// interface I2 {
+//// }
+//// }
+////
+//// export module mb.m1.m2.m3 {
+//// declare var foo;
+////
+//// export class C2 {
+//// public pub1;
+//// private priv1;
+//// protected prot1;
+////
+//// protected constructor(public public, protected protected, private private) {
+//// public = private = protected;
+//// }
+//// }
+//// }
+////
+//// declare var ambientThing: number;
+//// export var exportedThing = 10;
+//// declare function foo(): string;
+////}
+
+test.ranges().forEach(r => {
+ goTo.position(r.start);
+ verify.occurrencesAtPositionCount(test.ranges().length);
+
+ test.ranges().forEach(range => {
+ verify.occurrencesAtPositionContains(range, false);
+ });
+});