diff --git a/lib/tsc.js b/lib/tsc.js
index a98799b1d86..3983b8c1e1b 100644
--- a/lib/tsc.js
+++ b/lib/tsc.js
@@ -1248,7 +1248,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." },
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
- An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -1419,6 +1419,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." },
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." },
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -1431,8 +1432,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.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_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -1625,6 +1628,10 @@ var ts;
///
var ts;
(function (ts) {
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113,
"any": 115,
@@ -2916,7 +2923,7 @@ var ts;
return token = 234;
}
function scanJsxIdentifier() {
- if (token === 67) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -4032,6 +4039,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 <= node.kind && node.kind <= 158) {
return true;
@@ -6434,10 +6442,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8;
}
@@ -6457,7 +6465,7 @@ var ts;
return parsePropertyNameWorker(false);
}
function isSimplePropertyName() {
- return token === 9 || token === 8 || isIdentifierOrKeyword();
+ return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
var node = createNode(134);
@@ -6548,9 +6556,9 @@ var ts;
case 20:
return isHeritageClause();
case 21:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13:
- return isIdentifierOrKeyword() || token === 15;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15;
case 14:
return true;
case 22:
@@ -6576,7 +6584,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 ||
@@ -6944,7 +6952,7 @@ var ts;
return entity;
}
function parseRightSideOfDot(allowIdentifierNames) {
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
return createMissingNode(67, true, ts.Diagnostics.Identifier_expected);
@@ -7234,7 +7242,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -8527,12 +8535,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -8540,7 +8545,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -8568,7 +8573,7 @@ var ts;
case 87:
nextToken();
return token === 9 || token === 37 ||
- token === 15 || isIdentifierOrKeyword();
+ token === 15 || ts.tokenIsIdentifierOrKeyword(token);
case 80:
nextToken();
if (token === 55 || token === 37 ||
@@ -9055,7 +9060,7 @@ var ts;
if (isIndexSignature()) {
return parseIndexSignatureDeclaration(fullStart, decorators, modifiers);
}
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8 ||
token === 37 ||
@@ -9183,12 +9188,13 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216, fullStart);
+ var namespaceFlag = flags & 131072;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -9448,7 +9454,7 @@ var ts;
case 95:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -10968,7 +10974,7 @@ var ts;
var moduleReferenceLiteral = moduleReferenceExpression;
var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName);
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -12099,52 +12105,52 @@ var ts;
return checkIdentifier(declaration.name);
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, false);
}
return undefined;
}
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
}
return createTupleType(elementTypes);
}
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
var type = getTypeForVariableLikeDeclaration(declaration);
@@ -13466,11 +13472,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -13958,7 +13964,9 @@ var ts;
}
return 0;
}
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
if (source.flags & 16384) {
@@ -14357,8 +14365,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
return -1;
}
@@ -14366,8 +14374,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -14690,6 +14698,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -15586,7 +15595,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, true);
}
}
return undefined;
@@ -15878,11 +15887,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 && !!node.initializer) ||
+ (node.kind === 179 && node.operatorToken.kind === 55);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -15903,12 +15913,35 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183;
}
if (!hasSpreadElement) {
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ if (pattern && (pattern.kind === 160 || pattern.kind === 162)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -15940,6 +15973,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -15960,6 +15996,20 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 | 67108864 | member.flags, member.name);
+ if (inDestructuringPattern) {
+ if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -15978,11 +16028,26 @@ var ts;
}
propertiesArray.push(member);
}
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0);
var numberIndexType = getIndexType(1);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -17066,7 +17131,7 @@ var ts;
if (expressionType === unknownType) {
return resolveErrorCall(node);
}
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -19732,6 +19797,9 @@ var ts;
function getTargetSymbol(s) {
return s.flags & 16777216 ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
// TypeScript 1.0 spec (April 2014): 8.2.3
// A derived class inherits all members from its base class it doesn't override.
@@ -19758,9 +19826,14 @@ var ts;
ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
if (derived) {
if (derived === base) {
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -23696,6 +23769,7 @@ var ts;
var scopeEmitStart = function (scopeDeclaration, scopeName) { };
var scopeEmitEnd = function () { };
var sourceMapData;
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -25364,7 +25438,8 @@ var ts;
operand.kind !== 178 &&
operand.kind !== 167 &&
!(operand.kind === 166 && node.parent.kind === 167) &&
- !(operand.kind === 171 && node.parent.kind === 166)) {
+ !(operand.kind === 171 && node.parent.kind === 166) &&
+ !(operand.kind === 8 && node.parent.kind === 164)) {
emit(operand);
return;
}
@@ -26432,7 +26507,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (node.kind !== 141 && node.kind !== 140 &&
node.parent && node.parent.kind !== 243 &&
@@ -26750,7 +26825,7 @@ var ts;
}
else if (member.kind === 141 || node.kind === 140) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -26816,7 +26891,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 || node.kind === 140) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 ||
member.kind === 143 ||
@@ -26863,7 +26938,7 @@ var ts;
var hasInstancePropertyWithInitializer = false;
ts.forEach(node.members, function (member) {
if (member.kind === 142 && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) {
hasInstancePropertyWithInitializer = true;
@@ -27493,7 +27568,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -27600,7 +27675,7 @@ var ts;
function emitModuleDeclaration(node) {
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -28738,7 +28813,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
return emitNodeWithoutSourceMap(node);
@@ -28970,14 +29045,20 @@ var ts;
}
return leadingComments;
}
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
+ }
+ function isTripleSlashComment(comment) {
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
if (node.parent) {
@@ -28998,26 +29079,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, true);
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitTrailingComments(node) {
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = getTrailingCommentsToEmit(node);
ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment);
}
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
leadingComments = getLeadingCommentsWithoutDetachedComments();
@@ -29025,12 +29126,19 @@ var ts;
else {
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -29068,17 +29176,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -29354,7 +29451,7 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
var emptyArray = [];
- ts.version = "1.6.2";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -30019,7 +30116,7 @@ var ts;
if (importedFile && resolution.isExternalLibraryImport) {
if (!ts.isExternalModule(importedFile)) {
var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
- fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.File_0_is_not_a_module, importedFile.fileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
@@ -30549,10 +30646,10 @@ var ts;
}
}
ts.parseCommandLine = parseCommandLine;
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -30821,7 +30918,7 @@ var ts;
function performCompilation() {
if (!cachedProgram) {
if (configFileName) {
- var result = ts.readConfigFile(configFileName);
+ var result = ts.readConfigFile(configFileName, ts.sys.readFile);
if (result.error) {
reportDiagnostic(result.error);
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
diff --git a/lib/tsserver.js b/lib/tsserver.js
index ce095409d9a..875e63028b2 100644
--- a/lib/tsserver.js
+++ b/lib/tsserver.js
@@ -47,7 +47,6 @@ var ts;
})(ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
var DiagnosticCategory = ts.DiagnosticCategory;
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
function createFileMap(getCanonicalFileName) {
@@ -569,9 +568,6 @@ var ts;
}
ts.getNormalizedPathFromPathComponents = getNormalizedPathFromPathComponents;
function getNormalizedPathComponentsOfUrl(url) {
- // Get root length of http://www.website.com/folder1/foler2/
- // In this example the root is: http://www.website.com/
- // normalized path components should be ["http://www.website.com/", "folder1", "folder2"]
var urlLength = url.length;
var rootLength = url.indexOf("://") + "://".length;
while (rootLength < urlLength) {
@@ -731,7 +727,6 @@ var ts;
Debug.fail = fail;
})(Debug = ts.Debug || (ts.Debug = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
ts.sys = (function () {
@@ -1003,7 +998,6 @@ var ts;
}
})();
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
ts.Diagnostics = {
@@ -1248,7 +1242,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." },
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
- An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -1419,6 +1413,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." },
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." },
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -1431,8 +1426,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.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_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -1621,10 +1618,12 @@ var ts;
A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A constructor cannot contain a 'super' call when its class extends 'null'" }
};
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113,
"any": 115,
@@ -1872,16 +1871,6 @@ var ts;
}
ts.isWhiteSpace = isWhiteSpace;
function isLineBreak(ch) {
- // ES5 7.3:
- // The ECMAScript line terminator characters are listed in Table 3.
- // Table 3: Line Terminator Characters
- // Code Unit Value Name Formal Name
- // \u000A Line Feed
- // \u000D Carriage Return
- // \u2028 Line separator
- // \u2029 Paragraph separator
- // Only the characters in Table 3 are treated as line terminators. Other new line or line
- // breaking characters are treated as white space but not as line terminators.
return ch === 10 ||
ch === 13 ||
ch === 8232 ||
@@ -2916,7 +2905,7 @@ var ts;
return token = 234;
}
function scanJsxIdentifier() {
- if (token === 67) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -2983,10 +2972,6 @@ var ts;
}
ts.createScanner = createScanner;
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
ts.optionDeclarations = [
@@ -3341,10 +3326,10 @@ var ts;
}
}
ts.parseCommandLine = parseCommandLine;
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -3445,7 +3430,6 @@ var ts;
}
ts.parseConfigFile = parseConfigFile;
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
function getDeclarationOfKind(symbol, kind) {
@@ -3780,6 +3764,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 <= node.kind && node.kind <= 158) {
return true;
@@ -5393,8 +5378,6 @@ var ts;
}
ts.getTypeParameterOwner = getTypeParameterOwner;
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var nodeConstructors = new Array(270);
@@ -5885,10 +5868,6 @@ var ts;
}
}
function fixupParentReferences(sourceFile) {
- // normally parent references are set during binding. However, for clients that only need
- // a syntax tree, and no semantic features, then the binding process is an unnecessary
- // overhead. This functions allows us to set all the parents, without all the expense of
- // binding.
var parent = sourceFile;
forEachChild(sourceFile, visitNode);
return;
@@ -6182,10 +6161,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8;
}
@@ -6205,7 +6184,7 @@ var ts;
return parsePropertyNameWorker(false);
}
function isSimplePropertyName() {
- return token === 9 || token === 8 || isIdentifierOrKeyword();
+ return token === 9 || token === 8 || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
var node = createNode(134);
@@ -6296,9 +6275,9 @@ var ts;
case 20:
return isHeritageClause();
case 21:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13:
- return isIdentifierOrKeyword() || token === 15;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15;
case 14:
return true;
case 22:
@@ -6324,7 +6303,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 ||
@@ -6692,7 +6671,7 @@ var ts;
return entity;
}
function parseRightSideOfDot(allowIdentifierNames) {
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
return createMissingNode(67, true, ts.Diagnostics.Identifier_expected);
@@ -6982,7 +6961,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -7220,9 +7199,6 @@ var ts;
return allowInAnd(parseExpression);
}
function parseExpression() {
- // Expression[in]:
- // AssignmentExpression[in]
- // Expression[in] , AssignmentExpression[in]
var saveDecoratorContext = inDecoratorContext();
if (saveDecoratorContext) {
setDecoratorContext(false);
@@ -7247,15 +7223,6 @@ var ts;
return parseAssignmentExpressionOrHigher();
}
function parseAssignmentExpressionOrHigher() {
- // AssignmentExpression[in,yield]:
- // 1) ConditionalExpression[?in,?yield]
- // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
- // 3) LeftHandSideExpression AssignmentOperator AssignmentExpression[?in,?yield]
- // 4) ArrowFunctionExpression[?in,?yield]
- // 5) [+Yield] YieldExpression[?In]
- //
- // Note: for ease of implementation we treat productions '2' and '3' as the same thing.
- // (i.e. they're both BinaryExpressions with an assignment operator in it).
if (isYieldExpression()) {
return parseYieldExpression();
}
@@ -8224,8 +8191,6 @@ var ts;
return finishNode(node);
}
function parseThrowStatement() {
- // ThrowStatement[Yield] :
- // throw [no LineTerminator here]Expression[In, ?Yield];
var node = createNode(206);
parseExpected(96);
node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
@@ -8275,12 +8240,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -8288,7 +8250,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -8316,7 +8278,7 @@ var ts;
case 87:
nextToken();
return token === 9 || token === 37 ||
- token === 15 || isIdentifierOrKeyword();
+ token === 15 || ts.tokenIsIdentifierOrKeyword(token);
case 80:
nextToken();
if (token === 55 || token === 37 ||
@@ -8803,7 +8765,7 @@ var ts;
if (isIndexSignature()) {
return parseIndexSignatureDeclaration(fullStart, decorators, modifiers);
}
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 ||
token === 8 ||
token === 37 ||
@@ -8840,8 +8802,6 @@ var ts;
return finishNode(node);
}
function parseHeritageClauses(isClassHeritageClause) {
- // ClassTail[Yield,Await] : (Modified) See 14.5
- // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt }
if (isHeritageClause()) {
return parseList(20, parseHeritageClause);
}
@@ -8931,12 +8891,13 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216, fullStart);
+ var namespaceFlag = flags & 131072;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -9007,12 +8968,6 @@ var ts;
return finishNode(importDeclaration);
}
function parseImportClause(identifier, fullStart) {
- // ImportClause:
- // ImportedDefaultBinding
- // NameSpaceImport
- // NamedImports
- // ImportedDefaultBinding, NameSpaceImport
- // ImportedDefaultBinding, NamedImports
var importClause = createNode(221, fullStart);
if (identifier) {
importClause.name = identifier;
@@ -9196,7 +9151,7 @@ var ts;
case 95:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -9969,7 +9924,6 @@ var ts;
}
})(IncrementalParser || (IncrementalParser = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
ts.bindTime = 0;
@@ -10683,7 +10637,6 @@ var ts;
}
}
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var nextSymbolId = 1;
@@ -11430,7 +11383,7 @@ var ts;
var moduleReferenceLiteral = moduleReferenceExpression;
var searchPath = ts.getDirectoryPath(getSourceFile(location).fileName);
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -12561,52 +12514,52 @@ var ts;
return checkIdentifier(declaration.name);
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, false);
}
return undefined;
}
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
}
return createTupleType(elementTypes);
}
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
var type = getTypeForVariableLikeDeclaration(declaration);
@@ -13928,11 +13881,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -14420,7 +14373,9 @@ var ts;
}
return 0;
}
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
if (source.flags & 16384) {
@@ -14819,8 +14774,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
return -1;
}
@@ -14828,8 +14783,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -15152,6 +15107,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -16048,7 +16004,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, true);
}
}
return undefined;
@@ -16340,11 +16296,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 && !!node.initializer) ||
+ (node.kind === 179 && node.operatorToken.kind === 55);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -16365,12 +16322,35 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183;
}
if (!hasSpreadElement) {
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ if (pattern && (pattern.kind === 160 || pattern.kind === 162)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -16402,6 +16382,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 || contextualType.pattern.kind === 163);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -16422,6 +16405,20 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 | 67108864 | member.flags, member.name);
+ if (inDestructuringPattern) {
+ if (memberDecl.kind === 243 && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -16440,11 +16437,26 @@ var ts;
}
propertiesArray.push(member);
}
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0);
var numberIndexType = getIndexType(1);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576;
result.flags |= 524288 | 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -17528,7 +17540,7 @@ var ts;
if (expressionType === unknownType) {
return resolveErrorCall(node);
}
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -18523,10 +18535,6 @@ var ts;
}
}
function checkParameter(node) {
- // Grammar checking
- // It is a SyntaxError if the Identifier "eval" or the Identifier "arguments" occurs as the
- // Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code
- // or if its FunctionBody is strict code(11.1.5).
checkGrammarDecorators(node) || checkGrammarModifiers(node);
checkVariableLikeDeclaration(node);
var func = ts.getContainingFunction(node);
@@ -19169,15 +19177,6 @@ var ts;
return type;
}
function getPromisedType(promise) {
- //
- // { // promise
- // then( // thenFunction
- // onfulfilled: ( // onfulfilledParameterType
- // value: T // valueParameterType
- // ) => any
- // ): any;
- // }
- //
if (promise.flags & 1) {
return undefined;
}
@@ -19520,9 +19519,6 @@ var ts;
}
}
function checkVarDeclaredNamesNotShadowed(node) {
- // - ScriptBody : StatementList
- // It is a Syntax Error if any element of the LexicallyDeclaredNames of StatementList
- // also occurs in the VarDeclaredNames of StatementList.
if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) {
return;
}
@@ -20194,20 +20190,10 @@ var ts;
function getTargetSymbol(s) {
return s.flags & 16777216 ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
- // TypeScript 1.0 spec (April 2014): 8.2.3
- // A derived class inherits all members from its base class it doesn't override.
- // Inheritance means that a derived class implicitly contains all non - overridden members of the base class.
- // Both public and private property members are inherited, but only public property members can be overridden.
- // A property member in a derived class is said to override a property member in a base class
- // when the derived class property member has the same name and kind(instance or static)
- // as the base class property member.
- // The type of an overriding property member must be assignable(section 3.8.4)
- // to the type of the overridden property member, or otherwise a compile - time error occurs.
- // Base class instance member functions can be overridden by derived class instance member functions,
- // but not by other kinds of members.
- // Base class instance member variables and accessors can be overridden by
- // derived class instance member variables and accessors, but not by other kinds of members.
var baseProperties = getPropertiesOfObjectType(baseType);
for (var _i = 0; _i < baseProperties.length; _i++) {
var baseProperty = baseProperties[_i];
@@ -20220,9 +20206,14 @@ var ts;
ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
if (derived) {
if (derived === base) {
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -22736,7 +22727,6 @@ var ts;
}
ts.createTypeChecker = createTypeChecker;
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
function getDeclarationDiagnostics(host, resolver, targetSourceFile) {
@@ -24064,8 +24054,6 @@ var ts;
}
ts.writeDeclarationFile = writeDeclarationFile;
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
function isExternalModuleOrDeclarationFile(sourceFile) {
@@ -24158,6 +24146,7 @@ var ts;
var scopeEmitStart = function (scopeDeclaration, scopeName) { };
var scopeEmitEnd = function () { };
var sourceMapData;
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -24804,19 +24793,6 @@ var ts;
write(")");
}
function shouldEmitTemplateHead() {
- // If this expression has an empty head literal and the first template span has a non-empty
- // literal, then emitting the empty head literal is not necessary.
- // `${ foo } and ${ bar }`
- // can be emitted as
- // foo + " and " + bar
- // This is because it is only required that one of the first two operands in the emit
- // output must be a string literal, so that the other operand and all following operands
- // are forced into strings.
- //
- // If the first template span has an empty literal, then the head must still be emitted.
- // `${ foo }${ bar }`
- // must still be emitted as
- // "" + foo + bar
ts.Debug.assert(node.templateSpans.length !== 0);
return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
}
@@ -25826,7 +25802,8 @@ var ts;
operand.kind !== 178 &&
operand.kind !== 167 &&
!(operand.kind === 166 && node.parent.kind === 167) &&
- !(operand.kind === 171 && node.parent.kind === 166)) {
+ !(operand.kind === 171 && node.parent.kind === 166) &&
+ !(operand.kind === 8 && node.parent.kind === 164)) {
emit(operand);
return;
}
@@ -26156,26 +26133,6 @@ var ts;
emitEmbeddedStatement(node.statement);
}
function emitDownLevelForOfStatement(node) {
- // The following ES6 code:
- //
- // for (let v of expr) { }
- //
- // should be emitted as
- //
- // for (let _i = 0, _a = expr; _i < _a.length; _i++) {
- // let v = _a[_i];
- // }
- //
- // where _a and _i are temps emitted to capture the RHS and the counter,
- // respectively.
- // When the left hand side is an expression instead of a let declaration,
- // the "let v" is not emitted.
- // When the left hand side is a let/const, the v is renamed if there is
- // another v in scope.
- // Note that all assignments to the LHS are emitted in the body, including
- // all destructuring.
- // Note also that because an extra statement is needed to assign to the LHS,
- // for-of bodies are always emitted as blocks.
var endPos = emitToken(84, node.pos);
write(" ");
endPos = emitToken(17, endPos);
@@ -26894,7 +26851,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (node.kind !== 141 && node.kind !== 140 &&
node.parent && node.parent.kind !== 243 &&
@@ -27212,7 +27169,7 @@ var ts;
}
else if (member.kind === 141 || node.kind === 140) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -27278,7 +27235,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 || node.kind === 140) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 ||
member.kind === 143 ||
@@ -27325,7 +27282,7 @@ var ts;
var hasInstancePropertyWithInitializer = false;
ts.forEach(node.members, function (member) {
if (member.kind === 142 && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
if (member.kind === 139 && member.initializer && (member.flags & 128) === 0) {
hasInstancePropertyWithInitializer = true;
@@ -27955,7 +27912,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -28062,7 +28019,7 @@ var ts;
function emitModuleDeclaration(node) {
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -28906,17 +28863,6 @@ var ts;
write("});");
}
function emitAMDDependencies(node, includeNonAmdDependencies) {
- // An AMD define function has the following shape:
- // define(id?, dependencies?, factory);
- //
- // This has the shape of
- // define(name, ["module1", "module2"], function (module1Alias) {
- // The location of the alias in the parameter list in the factory function needs to
- // match the position of the module name in the dependency list.
- //
- // To ensure this is true in cases of modules with no aliases, e.g.:
- // `import "module"` or ``
- // we need to add modules without alias names to the end of the dependencies list
var aliasedModuleNames = [];
var unaliasedModuleNames = [];
var importAliasNames = [];
@@ -29200,7 +29146,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
return emitNodeWithoutSourceMap(node);
@@ -29432,14 +29378,20 @@ var ts;
}
return leadingComments;
}
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
+ }
+ function isTripleSlashComment(comment) {
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
if (node.parent) {
@@ -29460,26 +29412,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, true);
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitTrailingComments(node) {
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = getTrailingCommentsToEmit(node);
ts.emitComments(currentSourceFile, writer, trailingComments, false, newLine, writeComment);
}
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
ts.emitComments(currentSourceFile, writer, trailingComments, true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
leadingComments = getLeadingCommentsWithoutDetachedComments();
@@ -29487,12 +29459,19 @@ var ts;
else {
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -29530,17 +29509,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -29806,9 +29774,6 @@ var ts;
"diams": 0x2666
};
})(ts || (ts = {}));
-///
-///
-///
var ts;
(function (ts) {
ts.programTime = 0;
@@ -29816,7 +29781,7 @@ var ts;
ts.ioReadTime = 0;
ts.ioWriteTime = 0;
var emptyArray = [];
- ts.version = "1.6.2";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -30481,7 +30446,7 @@ var ts;
if (importedFile && resolution.isExternalLibraryImport) {
if (!ts.isExternalModule(importedFile)) {
var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
- fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.File_0_is_not_a_module, importedFile.fileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
@@ -30653,9 +30618,6 @@ var ts;
}
ts.createProgram = createProgram;
})(ts || (ts = {}));
-// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
-// See LICENSE.txt in the project root for complete license information.
-///
var ts;
(function (ts) {
var BreakpointResolver;
@@ -31315,7 +31277,6 @@ var ts;
NavigateTo.getNavigateToItems = getNavigateToItems;
})(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var NavigationBar;
@@ -32136,7 +32097,6 @@ var ts;
return transition;
}
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var SignatureHelp;
@@ -33104,8 +33064,6 @@ var ts;
}
ts.stripQuotes = stripQuotes;
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33299,7 +33257,6 @@ var ts;
formatting.getFormattingScanner = getFormattingScanner;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -33378,8 +33335,6 @@ var ts;
formatting.FormattingContext = FormattingContext;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33401,8 +33356,6 @@ var ts;
formatting.Rule = Rule;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33433,8 +33386,6 @@ var ts;
formatting.RuleDescriptor = RuleDescriptor;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -33462,7 +33413,6 @@ var ts;
formatting.RuleOperation = RuleOperation;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -33496,16 +33446,12 @@ var ts;
formatting.RuleOperationContext = RuleOperationContext;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
(function (formatting) {
var Rules = (function () {
function Rules() {
- ///
- /// Common Rules
- ///
this.IgnoreBeforeComment = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.Comments), formatting.RuleOperation.create1(1));
this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1));
this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
@@ -33546,7 +33492,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
+ this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100, 96, 90, 76, 92, 99, 117]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2));
@@ -33560,7 +33506,7 @@ var ts;
this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2));
this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(119, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123, 125]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113, 71, 120, 75, 79, 80, 81, 121, 104, 87, 105, 123, 124, 108, 110, 109, 127, 111, 130]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81, 104])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2));
this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(34, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
@@ -33581,19 +33527,7 @@ var ts;
this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(112, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8));
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 37]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2));
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116, 85), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67, formatting.Shared.TokenRange.FromTokens([11, 12])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8));
- this.SpaceBeforeAmpersand = new formatting.Rule(formatting.RuleDescriptor.create3(45, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
- this.SpaceAfterAmpersand = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 45), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2));
this.HighPriorityCommonRules =
[
this.IgnoreBeforeComment, this.IgnoreAfterLineComment,
@@ -33619,12 +33553,8 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
- this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
- this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
- this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
- this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
- this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
- this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand,
+ this.SpaceBetweenAsyncAndFunctionKeyword,
+ this.SpaceBetweenTagAndTemplateString,
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
this.SpaceAfterModuleName,
@@ -33700,6 +33630,8 @@ var ts;
case 180:
case 187:
case 148:
+ case 156:
+ case 157:
return true;
case 161:
case 214:
@@ -33724,22 +33656,6 @@ var ts;
return context.contextNode.kind === 180;
};
Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) {
- //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction.
- ////
- //// Ex:
- //// if (1) { ....
- //// * ) and { are on the same line so apply the rule. Here we don't care whether it's same or multi block context
- ////
- //// Ex:
- //// if (1)
- //// { ... }
- //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we don't format.
- ////
- //// Ex:
- //// if (1)
- //// { ...
- //// }
- //// * ) and { are on differnet lines. We only need to format if the block is multiline context. So in this case we format.
return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context);
};
Rules.IsBeforeMultilineBlockContext = function (context) {
@@ -33923,7 +33839,6 @@ var ts;
formatting.Rules = Rules;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -34060,7 +33975,6 @@ var ts;
formatting.RulesBucket = RulesBucket;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -34175,19 +34089,6 @@ var ts;
})(Shared = formatting.Shared || (formatting.Shared = {}));
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -34283,10 +34184,6 @@ var ts;
formatting.RulesProvider = RulesProvider;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
var formatting;
@@ -34543,13 +34440,14 @@ var ts;
}
function getDynamicIndentation(node, nodeStartLine, indentation, delta) {
return {
- getIndentationForComment: function (kind) {
+ getIndentationForComment: function (kind, tokenIndentation) {
switch (kind) {
case 16:
case 20:
+ case 18:
return indentation + delta;
}
- return indentation;
+ return tokenIndentation !== -1 ? tokenIndentation : indentation;
},
getIndentationForToken: function (line, kind) {
if (nodeStartLine !== line && node.decorators) {
@@ -34718,8 +34616,12 @@ var ts;
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
}
if (indentToken) {
- var indentNextTokenOrTrivia = true;
+ var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
+ dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
+ -1;
if (currentTokenInfo.leadingTrivia) {
+ var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
+ var indentNextTokenOrTrivia = true;
for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) {
var triviaItem = _a[_i];
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
@@ -34727,14 +34629,12 @@ var ts;
}
switch (triviaItem.kind) {
case 3:
- var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case 2:
if (indentNextTokenOrTrivia) {
- var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
- insertIndentation(triviaItem.pos, commentIndentation_1, false);
+ insertIndentation(triviaItem.pos, commentIndentation, false);
indentNextTokenOrTrivia = false;
}
break;
@@ -34744,8 +34644,7 @@ var ts;
}
}
}
- if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
- var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
+ if (tokenIndentation !== -1) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
@@ -35033,7 +34932,6 @@ var ts;
formatting.getIndentationString = getIndentationString;
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var ts;
(function (ts) {
var formatting;
@@ -35392,21 +35290,11 @@ var ts;
})(SmartIndenter = formatting.SmartIndenter || (formatting.SmartIndenter = {}));
})(formatting = ts.formatting || (ts.formatting = {}));
})(ts || (ts = {}));
-///
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
-///
-///
-///
-///
-///
-///
-///
-///
-///
var ts;
(function (ts) {
ts.servicesVersion = "0.4";
@@ -39357,6 +39245,7 @@ var ts;
result.push(getReferenceEntryFromNode(node));
}
break;
+ case 184:
case 212:
if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) {
result.push(getReferenceEntryFromNode(node));
@@ -40240,8 +40129,6 @@ var ts;
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
function getTodoCommentsRegExp() {
- // NOTE: ?: means 'non-capture group'. It allows us to have groups without having to
- // filter them out later in the final result array.
var singleLineCommentStart = /(?:\/\/+\s*)/.source;
var multiLineCommentStart = /(?:\/\*+\s*)/.source;
var anyNumberOfSpacesAndAsterixesAtStartOfLine = /(?:^(?:\s|\*)*)/.source;
@@ -40744,10 +40631,6 @@ var ts;
}
initializeServices();
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
var server;
@@ -41710,10 +41593,6 @@ var ts;
server.Session = Session;
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
-///
-///
-///
-///
var ts;
(function (ts) {
var server;
@@ -43496,8 +43375,6 @@ var ts;
server.LineLeaf = LineLeaf;
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
-///
-///
var ts;
(function (ts) {
var server;
@@ -43720,21 +43597,6 @@ var ts;
ioSession.listen();
})(server = ts.server || (ts.server = {}));
})(ts || (ts = {}));
-//
-// Copyright (c) Microsoft Corporation. All rights reserved.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-///
var debugObjectHost = this;
var ts;
(function (ts) {
diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts
index ec4ccd15589..2cd3a663fce 100644
--- a/lib/typescript.d.ts
+++ b/lib/typescript.d.ts
@@ -1208,9 +1208,11 @@ declare namespace ts {
UnionOrIntersection = 49152,
StructuredType = 130048,
}
+ type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
flags: TypeFlags;
symbol?: Symbol;
+ pattern?: DestructuringPattern;
}
interface StringLiteralType extends Type {
text: string;
@@ -1237,7 +1239,6 @@ declare namespace ts {
}
interface TupleType extends ObjectType {
elementTypes: Type[];
- baseArrayType: TypeReference;
}
interface UnionOrIntersectionType extends Type {
types: Type[];
@@ -1532,7 +1533,7 @@ declare namespace ts {
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName: string): {
+ function readConfigFile(fileName: string, readFile: (path: string) => string): {
config?: any;
error?: Diagnostic;
};
diff --git a/lib/typescript.js b/lib/typescript.js
index ebc0ba70357..2c70f56d0a6 100644
--- a/lib/typescript.js
+++ b/lib/typescript.js
@@ -2117,7 +2117,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." },
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
- An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -2288,6 +2288,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." },
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." },
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -2300,8 +2301,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.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_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -2494,6 +2497,11 @@ var ts;
///
var ts;
(function (ts) {
+ /* @internal */
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67 /* Identifier */;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113 /* AbstractKeyword */,
"any": 115 /* AnyKeyword */,
@@ -3929,7 +3937,7 @@ var ts;
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
function scanJsxIdentifier() {
- if (token === 67 /* Identifier */) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -5331,6 +5339,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) {
return true;
@@ -8131,10 +8140,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */;
}
@@ -8154,7 +8163,7 @@ var ts;
return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false);
}
function isSimplePropertyName() {
- return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword();
+ return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
// PropertyName [Yield]:
@@ -8270,9 +8279,9 @@ var ts;
case 20 /* HeritageClauses */:
return isHeritageClause();
case 21 /* ImportOrExportSpecifiers */:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13 /* JsxAttributes */:
- return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */;
case 14 /* JsxChildren */:
return true;
case 22 /* JSDocFunctionParameters */:
@@ -8305,7 +8314,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 /* ImplementsKeyword */ ||
@@ -8799,7 +8808,7 @@ var ts;
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
// In the first case though, ASI will not take effect because there is not a
// line terminator after the identifier or keyword.
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
// Report that we need an identifier. However, report it right after the dot,
@@ -9183,7 +9192,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -10776,12 +10785,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67 /* Identifier */;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -10789,7 +10795,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -10839,7 +10845,7 @@ var ts;
case 87 /* ImportKeyword */:
nextToken();
return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ ||
- token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword();
+ token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token);
case 80 /* ExportKeyword */:
nextToken();
if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ ||
@@ -11379,7 +11385,7 @@ var ts;
}
// It is very important that we check this *after* checking indexers because
// the [ token can start an index signature or a computed property name
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */ ||
token === 37 /* AsteriskToken */ ||
@@ -11518,12 +11524,15 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216 /* ModuleDeclaration */, fullStart);
+ // If we are parsing a dotted namespace name, we want to
+ // propagate the 'Namespace' flag across the names if set.
+ var namespaceFlag = flags & 131072 /* Namespace */;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21 /* DotToken */)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -11857,7 +11866,7 @@ var ts;
case 95 /* ThisKeyword */:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -13747,7 +13756,7 @@ var ts;
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -15051,7 +15060,7 @@ var ts;
}
// If the declaration specifies a binding pattern, use the type implied by the binding pattern
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false);
}
// No type specified and nothing can be inferred
return undefined;
@@ -15059,45 +15068,45 @@ var ts;
// Return the type implied by a binding pattern element. This is the type of the initializer of the element if
// one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
// pattern. Otherwise, it is the type any.
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
// Return the type implied by an object binding pattern
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
// Return the type implied by an array binding pattern
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 /* ES6 */ ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
- }
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
+ }
return createTupleType(elementTypes);
}
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
@@ -15107,10 +15116,10 @@ var ts;
// used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring
// parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of
// the parameter.
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159 /* ObjectBindingPattern */
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
// Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type
// specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it
@@ -16578,11 +16587,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -17119,7 +17128,9 @@ var ts;
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152 /* UnionOrIntersection */) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
// Note that the "each" checks must precede the "some" checks to produce the correct results
@@ -17567,8 +17578,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
// of whether the constructed object is abstract or not.
@@ -17578,8 +17589,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -17928,6 +17939,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -18949,7 +18961,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true);
}
}
return undefined;
@@ -19307,11 +19319,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 /* BindingElement */ && !!node.initializer) ||
+ (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -19344,12 +19357,39 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */;
}
if (!hasSpreadElement) {
+ // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such
+ // that we get the same behavior for "var [x, y] = []" and "[x, y] = []".
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting
+ // tuple type with the corresponding binding or assignment element types to make the lengths equal.
+ if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185 /* OmittedExpression */) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -19407,6 +19447,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -19427,6 +19470,24 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name);
+ if (inDestructuringPattern) {
+ // If object literal is an assignment pattern and if the assignment pattern specifies a default value
+ // for the property, make the property optional.
+ if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912 /* Optional */;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ // If object literal is contextually typed by the implied type of a binding pattern, and if the
+ // binding pattern specifies a default value for the property, make the property optional.
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912 /* Optional */;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -19450,11 +19511,28 @@ var ts;
}
propertiesArray.push(member);
}
+ // If object literal is contextually typed by the implied type of a binding pattern, augment the result
+ // type with those properties for which the binding pattern specifies a default value.
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912 /* Optional */)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0 /* String */);
var numberIndexType = getIndexType(1 /* Number */);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */;
result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -20963,7 +21041,7 @@ var ts;
// Note, only class declarations can be declared abstract.
// In the case of a merged class-module or class-interface declaration,
// only the class declaration node will have the Abstract flag set.
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256 /* Abstract */) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -24274,6 +24352,9 @@ var ts;
// so we'll need to get back original 'target' symbol to work with correct set of flags
return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
// TypeScript 1.0 spec (April 2014): 8.2.3
// A derived class inherits all members from its base class it doesn't override.
@@ -24305,12 +24386,17 @@ var ts;
// type declaration, derived and base resolve to the same symbol even in the case of generic classes.
if (derived === base) {
// derived class inherits base without override/redeclaration
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
// It is an error to inherit an abstract member without implementing it or being declared abstract.
// If there is no declaration for the derived class (as in the case of class expressions),
// then the class cannot be declared abstract.
if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184 /* ClassExpression */) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -28622,6 +28708,8 @@ var ts;
var scopeEmitEnd = function () { };
/** Sourcemap data that will get encoded */
var sourceMapData;
+ /** If removeComments is true, no leading-comments needed to be emitted **/
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -30532,7 +30620,8 @@ var ts;
operand.kind !== 178 /* PostfixUnaryExpression */ &&
operand.kind !== 167 /* NewExpression */ &&
!(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) &&
- !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) {
+ !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) &&
+ !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) {
emit(operand);
return;
}
@@ -31723,7 +31812,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
// TODO (yuisu) : we should not have special cases to condition emitting comments
// but have one place to fix check for these conditions.
@@ -32149,7 +32238,7 @@ var ts;
}
else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -32215,7 +32304,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 /* MethodDeclaration */ ||
member.kind === 143 /* GetAccessor */ ||
@@ -32266,7 +32355,7 @@ var ts;
// Emit the constructor overload pinned comments
ts.forEach(node.members, function (member) {
if (member.kind === 142 /* Constructor */ && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
// Check if there is any non-static property assignment
if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) {
@@ -33070,7 +33159,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -33182,7 +33271,7 @@ var ts;
// Emit only if this module is non-ambient.
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -34474,7 +34563,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2 /* Ambient */) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
// This is the node that will handle its own comments and sourcemap
@@ -34722,21 +34811,27 @@ var ts;
}
return leadingComments;
}
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
+ }
/**
- * Removes all but the pinned or triple slash comments.
- * @param ranges The array to be filtered
- * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
- */
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- // If we're removing comments, then we want to strip out all but the pinned or
- // triple slash comments.
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ * Determine if the given comment is a triple-slash
+ *
+ * @return true if the comment is a triple-slash comment else false
+ **/
+ function isTripleSlashComment(comment) {
+ // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
+ // so that we don't end up computing comment string and doing match for all // comments
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
@@ -34761,23 +34856,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true);
+ /**
+ * Emit comments associated with node that will not be emitted into JS file
+ */
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- // If the caller only wants pinned or triple slash comments, then always filter
- // down to that set. Otherwise, filter based on the current compiler options.
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
+ // unless it is a triple slash comment at the top of the file.
+ // For Example:
+ // ///
+ // declare var x;
+ // ///
+ // interface F {}
+ // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
- ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
+ ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
}
function emitTrailingComments(node) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
// Emit the trailing comments only if the parent's end doesn't match
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ var trailingComments = getTrailingCommentsToEmit(node);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
}
@@ -34787,11 +34905,17 @@ var ts;
* ^ => pos; the function will emit "comment1" in the emitJS
*/
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
// get comments without detached comments
@@ -34801,13 +34925,26 @@ var ts;
// get the leading comments from the node
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ // removeComments is true, only reserve pinned comment at the top of file
+ // For example:
+ // /*! Pinned Comment */
+ //
+ // var x = 10;
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ // removeComments is false, just get detached as normal and bypass the process to filter comment
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -34852,17 +34989,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -35139,7 +35265,7 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
var emptyArray = [];
- ts.version = "1.6.2";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -35868,7 +35994,7 @@ var ts;
if (importedFile && resolution.isExternalLibraryImport) {
if (!ts.isExternalModule(importedFile)) {
var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
- fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.File_0_is_not_a_module, importedFile.fileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
@@ -36423,10 +36549,10 @@ var ts;
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -39743,7 +39869,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
@@ -39767,7 +39893,7 @@ var ts;
// Use of module as a function call. e.g.: import m2 = module("m2");
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space around certain TypeScript keywords
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */));
@@ -39795,22 +39921,8 @@ var ts;
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // Type alias declaration
- this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // type operation
- this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceBeforeAmpersand = new formatting.Rule(formatting.RuleDescriptor.create3(45 /* AmpersandToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceAfterAmpersand = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 45 /* AmpersandToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -39837,12 +39949,8 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
- this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
- this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
- this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
- this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
- this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
- this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand,
+ this.SpaceBetweenAsyncAndFunctionKeyword,
+ this.SpaceBetweenTagAndTemplateString,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@@ -39937,6 +40045,8 @@ var ts;
case 180 /* ConditionalExpression */:
case 187 /* AsExpression */:
case 148 /* TypePredicate */:
+ case 156 /* UnionType */:
+ case 157 /* IntersectionType */:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
case 161 /* BindingElement */:
@@ -40894,7 +41004,7 @@ var ts;
}
function getDynamicIndentation(node, nodeStartLine, indentation, delta) {
return {
- getIndentationForComment: function (kind) {
+ getIndentationForComment: function (kind, tokenIndentation) {
switch (kind) {
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
// .. {
@@ -40902,9 +41012,10 @@ var ts;
// }
case 16 /* CloseBraceToken */:
case 20 /* CloseBracketToken */:
+ case 18 /* CloseParenToken */:
return indentation + delta;
}
- return indentation;
+ return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation;
},
getIndentationForToken: function (line, kind) {
if (nodeStartLine !== line && node.decorators) {
@@ -41106,8 +41217,12 @@ var ts;
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
}
if (indentToken) {
- var indentNextTokenOrTrivia = true;
+ var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
+ dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
+ -1 /* Unknown */;
if (currentTokenInfo.leadingTrivia) {
+ var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
+ var indentNextTokenOrTrivia = true;
for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) {
var triviaItem = _a[_i];
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
@@ -41115,14 +41230,12 @@ var ts;
}
switch (triviaItem.kind) {
case 3 /* MultiLineCommentTrivia */:
- var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case 2 /* SingleLineCommentTrivia */:
if (indentNextTokenOrTrivia) {
- var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
- insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false);
+ insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
indentNextTokenOrTrivia = false;
}
break;
@@ -41133,8 +41246,7 @@ var ts;
}
}
// indent token only if is it is in target range and does not overlap with any error ranges
- if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
- var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
+ if (tokenIndentation !== -1 /* Unknown */) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
@@ -46451,6 +46563,7 @@ var ts;
result.push(getReferenceEntryFromNode(node));
}
break;
+ case 184 /* ClassExpression */:
case 212 /* ClassDeclaration */:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts
index 4ce3cd34cb5..761ce39d418 100644
--- a/lib/typescriptServices.d.ts
+++ b/lib/typescriptServices.d.ts
@@ -1208,9 +1208,11 @@ declare namespace ts {
UnionOrIntersection = 49152,
StructuredType = 130048,
}
+ type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression;
interface Type {
flags: TypeFlags;
symbol?: Symbol;
+ pattern?: DestructuringPattern;
}
interface StringLiteralType extends Type {
text: string;
@@ -1237,7 +1239,6 @@ declare namespace ts {
}
interface TupleType extends ObjectType {
elementTypes: Type[];
- baseArrayType: TypeReference;
}
interface UnionOrIntersectionType extends Type {
types: Type[];
@@ -1532,7 +1533,7 @@ declare namespace ts {
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName: string): {
+ function readConfigFile(fileName: string, readFile: (path: string) => string): {
config?: any;
error?: Diagnostic;
};
diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js
index ebc0ba70357..2c70f56d0a6 100644
--- a/lib/typescriptServices.js
+++ b/lib/typescriptServices.js
@@ -2117,7 +2117,7 @@ var ts;
Property_0_does_not_exist_on_type_1: { code: 2339, category: ts.DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." },
Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: ts.DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." },
Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: ts.DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." },
- An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." },
+ An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: ts.DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." },
Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." },
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: { code: 2345, category: ts.DiagnosticCategory.Error, key: "Argument of type '{0}' is not assignable to parameter of type '{1}'." },
Supplied_parameters_do_not_match_any_signature_of_call_target: { code: 2346, category: ts.DiagnosticCategory.Error, key: "Supplied parameters do not match any signature of call target." },
@@ -2288,6 +2288,7 @@ var ts;
The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." },
yield_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2523, category: ts.DiagnosticCategory.Error, key: "'yield' expressions cannot be used in a parameter initializer." },
await_expressions_cannot_be_used_in_a_parameter_initializer: { code: 2524, category: ts.DiagnosticCategory.Error, key: "'await' expressions cannot be used in a parameter initializer." },
+ Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value: { code: 2525, category: ts.DiagnosticCategory.Error, key: "Initializer provides no value for this binding element and the binding element has no default value." },
JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: ts.DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." },
The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: ts.DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." },
JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: { code: 2602, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist." },
@@ -2300,8 +2301,10 @@ var ts;
Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" },
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." },
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." },
+ Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." },
Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." },
Exported_external_package_typings_can_only_be_in_d_ts_files_Please_contact_the_package_author_to_update_the_package_definition: { code: 2655, category: ts.DiagnosticCategory.Error, key: "Exported external package typings can only be in '.d.ts' files. Please contact the package author to update the package definition." },
+ Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." },
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.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_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
@@ -2494,6 +2497,11 @@ var ts;
///
var ts;
(function (ts) {
+ /* @internal */
+ function tokenIsIdentifierOrKeyword(token) {
+ return token >= 67 /* Identifier */;
+ }
+ ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
var textToToken = {
"abstract": 113 /* AbstractKeyword */,
"any": 115 /* AnyKeyword */,
@@ -3929,7 +3937,7 @@ var ts;
// Scans a JSX identifier; these differ from normal identifiers in that
// they allow dashes
function scanJsxIdentifier() {
- if (token === 67 /* Identifier */) {
+ if (tokenIsIdentifierOrKeyword(token)) {
var firstCharPosition = pos;
while (pos < end) {
var ch = text.charCodeAt(pos);
@@ -5331,6 +5339,7 @@ var ts;
}
ts.getJsDocComments = getJsDocComments;
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/;
+ ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/;
function isTypeNode(node) {
if (149 /* FirstTypeNode */ <= node.kind && node.kind <= 158 /* LastTypeNode */) {
return true;
@@ -8131,10 +8140,10 @@ var ts;
return createIdentifier(isIdentifier(), diagnosticMessage);
}
function parseIdentifierName() {
- return createIdentifier(isIdentifierOrKeyword());
+ return createIdentifier(ts.tokenIsIdentifierOrKeyword(token));
}
function isLiteralPropertyName() {
- return isIdentifierOrKeyword() ||
+ return ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */;
}
@@ -8154,7 +8163,7 @@ var ts;
return parsePropertyNameWorker(/*allowComputedPropertyNames:*/ false);
}
function isSimplePropertyName() {
- return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || isIdentifierOrKeyword();
+ return token === 9 /* StringLiteral */ || token === 8 /* NumericLiteral */ || ts.tokenIsIdentifierOrKeyword(token);
}
function parseComputedPropertyName() {
// PropertyName [Yield]:
@@ -8270,9 +8279,9 @@ var ts;
case 20 /* HeritageClauses */:
return isHeritageClause();
case 21 /* ImportOrExportSpecifiers */:
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
case 13 /* JsxAttributes */:
- return isIdentifierOrKeyword() || token === 15 /* OpenBraceToken */;
+ return ts.tokenIsIdentifierOrKeyword(token) || token === 15 /* OpenBraceToken */;
case 14 /* JsxChildren */:
return true;
case 22 /* JSDocFunctionParameters */:
@@ -8305,7 +8314,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeyword() {
nextToken();
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
function isHeritageClauseExtendsOrImplementsKeyword() {
if (token === 104 /* ImplementsKeyword */ ||
@@ -8799,7 +8808,7 @@ var ts;
// the code would be implicitly: "name.identifierOrKeyword; identifierNameOrKeyword".
// In the first case though, ASI will not take effect because there is not a
// line terminator after the identifier or keyword.
- if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) {
+ if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token)) {
var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
if (matchesPattern) {
// Report that we need an identifier. However, report it right after the dot,
@@ -9183,7 +9192,7 @@ var ts;
return result;
}
}
- if (isIdentifierOrKeyword()) {
+ if (ts.tokenIsIdentifierOrKeyword(token)) {
return parsePropertyOrMethodSignature();
}
}
@@ -10776,12 +10785,9 @@ var ts;
return finishNode(expressionStatement);
}
}
- function isIdentifierOrKeyword() {
- return token >= 67 /* Identifier */;
- }
function nextTokenIsIdentifierOrKeywordOnSameLine() {
nextToken();
- return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak();
+ return ts.tokenIsIdentifierOrKeyword(token) && !scanner.hasPrecedingLineBreak();
}
function nextTokenIsFunctionKeywordOnSameLine() {
nextToken();
@@ -10789,7 +10795,7 @@ var ts;
}
function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() {
nextToken();
- return (isIdentifierOrKeyword() || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
+ return (ts.tokenIsIdentifierOrKeyword(token) || token === 8 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak();
}
function isDeclaration() {
while (true) {
@@ -10839,7 +10845,7 @@ var ts;
case 87 /* ImportKeyword */:
nextToken();
return token === 9 /* StringLiteral */ || token === 37 /* AsteriskToken */ ||
- token === 15 /* OpenBraceToken */ || isIdentifierOrKeyword();
+ token === 15 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token);
case 80 /* ExportKeyword */:
nextToken();
if (token === 55 /* EqualsToken */ || token === 37 /* AsteriskToken */ ||
@@ -11379,7 +11385,7 @@ var ts;
}
// It is very important that we check this *after* checking indexers because
// the [ token can start an index signature or a computed property name
- if (isIdentifierOrKeyword() ||
+ if (ts.tokenIsIdentifierOrKeyword(token) ||
token === 9 /* StringLiteral */ ||
token === 8 /* NumericLiteral */ ||
token === 37 /* AsteriskToken */ ||
@@ -11518,12 +11524,15 @@ var ts;
}
function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) {
var node = createNode(216 /* ModuleDeclaration */, fullStart);
+ // If we are parsing a dotted namespace name, we want to
+ // propagate the 'Namespace' flag across the names if set.
+ var namespaceFlag = flags & 131072 /* Namespace */;
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(21 /* DotToken */)
- ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */)
+ ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag)
: parseModuleBlock();
return finishNode(node);
}
@@ -11857,7 +11866,7 @@ var ts;
case 95 /* ThisKeyword */:
return true;
}
- return isIdentifierOrKeyword();
+ return ts.tokenIsIdentifierOrKeyword(token);
}
JSDocParser.isJSDocType = isJSDocType;
function parseJSDocTypeExpressionForTests(content, start, length) {
@@ -13747,7 +13756,7 @@ var ts;
// Module names are escaped in our symbol table. However, string literal values aren't.
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
var moduleName = ts.escapeIdentifier(moduleReferenceLiteral.text);
- if (!moduleName) {
+ if (moduleName === undefined) {
return;
}
var isRelative = isExternalModuleNameRelative(moduleName);
@@ -15051,7 +15060,7 @@ var ts;
}
// If the declaration specifies a binding pattern, use the type implied by the binding pattern
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false);
}
// No type specified and nothing can be inferred
return undefined;
@@ -15059,45 +15068,45 @@ var ts;
// Return the type implied by a binding pattern element. This is the type of the initializer of the element if
// one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding
// pattern. Otherwise, it is the type any.
- function getTypeFromBindingElement(element) {
+ function getTypeFromBindingElement(element, includePatternInType) {
if (element.initializer) {
return getWidenedType(checkExpressionCached(element.initializer));
}
if (ts.isBindingPattern(element.name)) {
- return getTypeFromBindingPattern(element.name);
+ return getTypeFromBindingPattern(element.name, includePatternInType);
}
return anyType;
}
// Return the type implied by an object binding pattern
- function getTypeFromObjectBindingPattern(pattern) {
+ function getTypeFromObjectBindingPattern(pattern, includePatternInType) {
var members = {};
ts.forEach(pattern.elements, function (e) {
var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0);
var name = e.propertyName || e.name;
var symbol = createSymbol(flags, name.text);
- symbol.type = getTypeFromBindingElement(e);
+ symbol.type = getTypeFromBindingElement(e, includePatternInType);
+ symbol.bindingElement = e;
members[symbol.name] = symbol;
});
- return createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined);
+ if (includePatternInType) {
+ result.pattern = pattern;
+ }
+ return result;
}
// Return the type implied by an array binding pattern
- function getTypeFromArrayBindingPattern(pattern) {
- var hasSpreadElement = false;
- var elementTypes = [];
- ts.forEach(pattern.elements, function (e) {
- elementTypes.push(e.kind === 185 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e));
- if (e.dotDotDotToken) {
- hasSpreadElement = true;
- }
- });
- if (!elementTypes.length) {
+ function getTypeFromArrayBindingPattern(pattern, includePatternInType) {
+ var elements = pattern.elements;
+ if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) {
return languageVersion >= 2 /* ES6 */ ? createIterableType(anyType) : anyArrayType;
}
- else if (hasSpreadElement) {
- var unionOfElements = getUnionType(elementTypes);
- return languageVersion >= 2 /* ES6 */ ? createIterableType(unionOfElements) : createArrayType(unionOfElements);
- }
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
+ var elementTypes = ts.map(elements, function (e) { return e.kind === 185 /* OmittedExpression */ ? anyType : getTypeFromBindingElement(e, includePatternInType); });
+ if (includePatternInType) {
+ var result = createNewTupleType(elementTypes);
+ result.pattern = pattern;
+ return result;
+ }
return createTupleType(elementTypes);
}
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
@@ -15107,10 +15116,10 @@ var ts;
// used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring
// parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of
// the parameter.
- function getTypeFromBindingPattern(pattern) {
+ function getTypeFromBindingPattern(pattern, includePatternInType) {
return pattern.kind === 159 /* ObjectBindingPattern */
- ? getTypeFromObjectBindingPattern(pattern)
- : getTypeFromArrayBindingPattern(pattern);
+ ? getTypeFromObjectBindingPattern(pattern, includePatternInType)
+ : getTypeFromArrayBindingPattern(pattern, includePatternInType);
}
// Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type
// specified in a type annotation or inferred from an initializer. However, in the case of a destructuring declaration it
@@ -16578,11 +16587,11 @@ var ts;
}
function createTupleType(elementTypes) {
var id = getTypeListId(elementTypes);
- var type = tupleTypes[id];
- if (!type) {
- type = tupleTypes[id] = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
- type.elementTypes = elementTypes;
- }
+ return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes));
+ }
+ function createNewTupleType(elementTypes) {
+ var type = createObjectType(8192 /* Tuple */ | getPropagatingFlagsOfTypes(elementTypes));
+ type.elementTypes = elementTypes;
return type;
}
function getTypeFromTupleTypeNode(node) {
@@ -17119,7 +17128,9 @@ var ts;
// and intersection types are further deconstructed on the target side, we don't want to
// make the check again (as it might fail for a partial target type). Therefore we obtain
// the regular source type and proceed with that.
- source = getRegularTypeOfObjectLiteral(source);
+ if (target.flags & 49152 /* UnionOrIntersection */) {
+ source = getRegularTypeOfObjectLiteral(source);
+ }
}
var saveErrorInfo = errorInfo;
// Note that the "each" checks must precede the "some" checks to produce the correct results
@@ -17567,8 +17578,8 @@ var ts;
return result;
function abstractSignatureRelatedTo(source, sourceSig, target, targetSig) {
if (sourceSig && targetSig) {
- var sourceDecl = source.symbol && ts.getDeclarationOfKind(source.symbol, 212 /* ClassDeclaration */);
- var targetDecl = target.symbol && ts.getDeclarationOfKind(target.symbol, 212 /* ClassDeclaration */);
+ var sourceDecl = source.symbol && getClassLikeDeclarationOfSymbol(source.symbol);
+ var targetDecl = target.symbol && getClassLikeDeclarationOfSymbol(target.symbol);
if (!sourceDecl) {
// If the source object isn't itself a class declaration, it can be freely assigned, regardless
// of whether the constructed object is abstract or not.
@@ -17578,8 +17589,8 @@ var ts;
var targetErasedSignature = getErasedSignature(targetSig);
var sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature);
var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature);
- var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && ts.getDeclarationOfKind(sourceReturnType.symbol, 212 /* ClassDeclaration */);
- var targetReturnDecl = targetReturnType && targetReturnType.symbol && ts.getDeclarationOfKind(targetReturnType.symbol, 212 /* ClassDeclaration */);
+ var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol);
+ var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol);
var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */;
var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */;
if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) {
@@ -17928,6 +17939,7 @@ var ts;
regularType.constructSignatures = type.constructSignatures;
regularType.stringIndexType = type.stringIndexType;
regularType.numberIndexType = type.numberIndexType;
+ type.regularType = regularType;
}
return regularType;
}
@@ -18949,7 +18961,7 @@ var ts;
}
}
if (ts.isBindingPattern(declaration.name)) {
- return getTypeFromBindingPattern(declaration.name);
+ return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true);
}
}
return undefined;
@@ -19307,11 +19319,12 @@ var ts;
var arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
}
+ function hasDefaultValue(node) {
+ return (node.kind === 161 /* BindingElement */ && !!node.initializer) ||
+ (node.kind === 179 /* BinaryExpression */ && node.operatorToken.kind === 55 /* EqualsToken */);
+ }
function checkArrayLiteral(node, contextualMapper) {
var elements = node.elements;
- if (!elements.length) {
- return createArrayType(undefinedType);
- }
var hasSpreadElement = false;
var elementTypes = [];
var inDestructuringPattern = isAssignmentTarget(node);
@@ -19344,12 +19357,39 @@ var ts;
hasSpreadElement = hasSpreadElement || e.kind === 183 /* SpreadElementExpression */;
}
if (!hasSpreadElement) {
+ // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such
+ // that we get the same behavior for "var [x, y] = []" and "[x, y] = []".
+ if (inDestructuringPattern && elementTypes.length) {
+ var type = createNewTupleType(elementTypes);
+ type.pattern = node;
+ return type;
+ }
var contextualType = getContextualType(node);
- if (contextualType && contextualTypeIsTupleLikeType(contextualType) || inDestructuringPattern) {
- return createTupleType(elementTypes);
+ if (contextualType && contextualTypeIsTupleLikeType(contextualType)) {
+ var pattern = contextualType.pattern;
+ // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting
+ // tuple type with the corresponding binding or assignment element types to make the lengths equal.
+ if (pattern && (pattern.kind === 160 /* ArrayBindingPattern */ || pattern.kind === 162 /* ArrayLiteralExpression */)) {
+ var patternElements = pattern.elements;
+ for (var i = elementTypes.length; i < patternElements.length; i++) {
+ var patternElement = patternElements[i];
+ if (hasDefaultValue(patternElement)) {
+ elementTypes.push(contextualType.elementTypes[i]);
+ }
+ else {
+ if (patternElement.kind !== 185 /* OmittedExpression */) {
+ error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ elementTypes.push(unknownType);
+ }
+ }
+ }
+ if (elementTypes.length) {
+ return createTupleType(elementTypes);
+ }
}
}
- return createArrayType(getUnionType(elementTypes));
+ return createArrayType(elementTypes.length ? getUnionType(elementTypes) : undefinedType);
}
function isNumericName(name) {
return name.kind === 134 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text);
@@ -19407,6 +19447,9 @@ var ts;
var propertiesTable = {};
var propertiesArray = [];
var contextualType = getContextualType(node);
+ var contextualTypeHasPattern = contextualType && contextualType.pattern &&
+ (contextualType.pattern.kind === 159 /* ObjectBindingPattern */ || contextualType.pattern.kind === 163 /* ObjectLiteralExpression */);
+ var inDestructuringPattern = isAssignmentTarget(node);
var typeFlags = 0;
for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
var memberDecl = _a[_i];
@@ -19427,6 +19470,24 @@ var ts;
}
typeFlags |= type.flags;
var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | member.flags, member.name);
+ if (inDestructuringPattern) {
+ // If object literal is an assignment pattern and if the assignment pattern specifies a default value
+ // for the property, make the property optional.
+ if (memberDecl.kind === 243 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) {
+ prop.flags |= 536870912 /* Optional */;
+ }
+ }
+ else if (contextualTypeHasPattern) {
+ // If object literal is contextually typed by the implied type of a binding pattern, and if the
+ // binding pattern specifies a default value for the property, make the property optional.
+ var impliedProp = getPropertyOfType(contextualType, member.name);
+ if (impliedProp) {
+ prop.flags |= impliedProp.flags & 536870912 /* Optional */;
+ }
+ else if (!compilerOptions.suppressExcessPropertyErrors) {
+ error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
+ }
+ }
prop.declarations = member.declarations;
prop.parent = member.parent;
if (member.valueDeclaration) {
@@ -19450,11 +19511,28 @@ var ts;
}
propertiesArray.push(member);
}
+ // If object literal is contextually typed by the implied type of a binding pattern, augment the result
+ // type with those properties for which the binding pattern specifies a default value.
+ if (contextualTypeHasPattern) {
+ for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) {
+ var prop = _c[_b];
+ if (!ts.hasProperty(propertiesTable, prop.name)) {
+ if (!(prop.flags & 536870912 /* Optional */)) {
+ error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
+ }
+ propertiesTable[prop.name] = prop;
+ propertiesArray.push(prop);
+ }
+ }
+ }
var stringIndexType = getIndexType(0 /* String */);
var numberIndexType = getIndexType(1 /* Number */);
var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType);
var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshObjectLiteral */;
result.flags |= 524288 /* ObjectLiteral */ | 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */);
+ if (inDestructuringPattern) {
+ result.pattern = node;
+ }
return result;
function getIndexType(kind) {
if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) {
@@ -20963,7 +21041,7 @@ var ts;
// Note, only class declarations can be declared abstract.
// In the case of a merged class-module or class-interface declaration,
// only the class declaration node will have the Abstract flag set.
- var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 212 /* ClassDeclaration */);
+ var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol);
if (valueDecl && valueDecl.flags & 256 /* Abstract */) {
error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name));
return resolveErrorCall(node);
@@ -24274,6 +24352,9 @@ var ts;
// so we'll need to get back original 'target' symbol to work with correct set of flags
return s.flags & 16777216 /* Instantiated */ ? getSymbolLinks(s).target : s;
}
+ function getClassLikeDeclarationOfSymbol(symbol) {
+ return ts.forEach(symbol.declarations, function (d) { return ts.isClassLike(d) ? d : undefined; });
+ }
function checkKindsOfPropertyMemberOverrides(type, baseType) {
// TypeScript 1.0 spec (April 2014): 8.2.3
// A derived class inherits all members from its base class it doesn't override.
@@ -24305,12 +24386,17 @@ var ts;
// type declaration, derived and base resolve to the same symbol even in the case of generic classes.
if (derived === base) {
// derived class inherits base without override/redeclaration
- var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 212 /* ClassDeclaration */);
+ var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol);
// It is an error to inherit an abstract member without implementing it or being declared abstract.
// If there is no declaration for the derived class (as in the case of class expressions),
// then the class cannot be declared abstract.
if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) {
- error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ if (derivedClassDecl.kind === 184 /* ClassExpression */) {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
+ }
+ else {
+ error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
+ }
}
}
else {
@@ -28622,6 +28708,8 @@ var ts;
var scopeEmitEnd = function () { };
/** Sourcemap data that will get encoded */
var sourceMapData;
+ /** If removeComments is true, no leading-comments needed to be emitted **/
+ var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? function (pos) { } : emitLeadingCommentsOfPositionWorker;
if (compilerOptions.sourceMap || compilerOptions.inlineSourceMap) {
initializeEmitterWithSourceMaps();
}
@@ -30532,7 +30620,8 @@ var ts;
operand.kind !== 178 /* PostfixUnaryExpression */ &&
operand.kind !== 167 /* NewExpression */ &&
!(operand.kind === 166 /* CallExpression */ && node.parent.kind === 167 /* NewExpression */) &&
- !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */)) {
+ !(operand.kind === 171 /* FunctionExpression */ && node.parent.kind === 166 /* CallExpression */) &&
+ !(operand.kind === 8 /* NumericLiteral */ && node.parent.kind === 164 /* PropertyAccessExpression */)) {
emit(operand);
return;
}
@@ -31723,7 +31812,7 @@ var ts;
}
function emitFunctionDeclaration(node) {
if (ts.nodeIsMissing(node.body)) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
// TODO (yuisu) : we should not have special cases to condition emitting comments
// but have one place to fix check for these conditions.
@@ -32149,7 +32238,7 @@ var ts;
}
else if (member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) {
if (!member.body) {
- return emitOnlyPinnedOrTripleSlashComments(member);
+ return emitCommentsOnNotEmittedNode(member);
}
writeLine();
emitLeadingComments(member);
@@ -32215,7 +32304,7 @@ var ts;
for (var _a = 0, _b = node.members; _a < _b.length; _a++) {
var member = _b[_a];
if ((member.kind === 141 /* MethodDeclaration */ || node.kind === 140 /* MethodSignature */) && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
else if (member.kind === 141 /* MethodDeclaration */ ||
member.kind === 143 /* GetAccessor */ ||
@@ -32266,7 +32355,7 @@ var ts;
// Emit the constructor overload pinned comments
ts.forEach(node.members, function (member) {
if (member.kind === 142 /* Constructor */ && !member.body) {
- emitOnlyPinnedOrTripleSlashComments(member);
+ emitCommentsOnNotEmittedNode(member);
}
// Check if there is any non-static property assignment
if (member.kind === 139 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) {
@@ -33070,7 +33159,7 @@ var ts;
return argumentsWritten;
}
function emitInterfaceDeclaration(node) {
- emitOnlyPinnedOrTripleSlashComments(node);
+ emitCommentsOnNotEmittedNode(node);
}
function shouldEmitEnumDeclaration(node) {
var isConstEnum = ts.isConst(node);
@@ -33182,7 +33271,7 @@ var ts;
// Emit only if this module is non-ambient.
var shouldEmit = shouldEmitModuleDeclaration(node);
if (!shouldEmit) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
var hoistedInDeclarationScope = shouldHoistDeclarationInSystemJsModule(node);
var emitVarForModule = !hoistedInDeclarationScope && !isModuleMergedWithES6Class(node);
@@ -34474,7 +34563,7 @@ var ts;
function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) {
if (node) {
if (node.flags & 2 /* Ambient */) {
- return emitOnlyPinnedOrTripleSlashComments(node);
+ return emitCommentsOnNotEmittedNode(node);
}
if (isSpecializedCommentHandling(node)) {
// This is the node that will handle its own comments and sourcemap
@@ -34722,21 +34811,27 @@ var ts;
}
return leadingComments;
}
+ function isPinnedComments(comment) {
+ return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
+ }
/**
- * Removes all but the pinned or triple slash comments.
- * @param ranges The array to be filtered
- * @param onlyPinnedOrTripleSlashComments whether the filtering should be performed.
- */
- function filterComments(ranges, onlyPinnedOrTripleSlashComments) {
- // If we're removing comments, then we want to strip out all but the pinned or
- // triple slash comments.
- if (ranges && onlyPinnedOrTripleSlashComments) {
- ranges = ts.filter(ranges, isPinnedOrTripleSlashComment);
- if (ranges.length === 0) {
- return undefined;
- }
+ * Determine if the given comment is a triple-slash
+ *
+ * @return true if the comment is a triple-slash comment else false
+ **/
+ function isTripleSlashComment(comment) {
+ // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
+ // so that we don't end up computing comment string and doing match for all // comments
+ if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
+ comment.pos + 2 < comment.end &&
+ currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */) {
+ var textSubStr = currentSourceFile.text.substring(comment.pos, comment.end);
+ return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
+ textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ?
+ true : false;
}
- return ranges;
+ return false;
}
function getLeadingCommentsToEmit(node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
@@ -34761,23 +34856,46 @@ var ts;
}
}
}
- function emitOnlyPinnedOrTripleSlashComments(node) {
- emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ true);
+ /**
+ * Emit comments associated with node that will not be emitted into JS file
+ */
+ function emitCommentsOnNotEmittedNode(node) {
+ emitLeadingCommentsWorker(node, /*isEmittedNode:*/ false);
}
function emitLeadingComments(node) {
- return emitLeadingCommentsWorker(node, /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ return emitLeadingCommentsWorker(node, /*isEmittedNode:*/ true);
}
- function emitLeadingCommentsWorker(node, onlyPinnedOrTripleSlashComments) {
- // If the caller only wants pinned or triple slash comments, then always filter
- // down to that set. Otherwise, filter based on the current compiler options.
- var leadingComments = filterComments(getLeadingCommentsToEmit(node), onlyPinnedOrTripleSlashComments);
+ function emitLeadingCommentsWorker(node, isEmittedNode) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var leadingComments;
+ if (isEmittedNode) {
+ leadingComments = getLeadingCommentsToEmit(node);
+ }
+ else {
+ // If the node will not be emitted in JS, remove all the comments(normal, pinned and ///) associated with the node,
+ // unless it is a triple slash comment at the top of the file.
+ // For Example:
+ // ///
+ // declare var x;
+ // ///
+ // interface F {}
+ // The first /// will NOT be removed while the second one will be removed eventhough both node will not be emitted
+ if (node.pos === 0) {
+ leadingComments = ts.filter(getLeadingCommentsToEmit(node), isTripleSlashComment);
+ }
+ }
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
- ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
+ ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator:*/ true, newLine, writeComment);
}
function emitTrailingComments(node) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
// Emit the trailing comments only if the parent's end doesn't match
- var trailingComments = filterComments(getTrailingCommentsToEmit(node), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ var trailingComments = getTrailingCommentsToEmit(node);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ false, newLine, writeComment);
}
@@ -34787,11 +34905,17 @@ var ts;
* ^ => pos; the function will emit "comment1" in the emitJS
*/
function emitTrailingCommentsOfPosition(pos) {
- var trailingComments = filterComments(ts.getTrailingCommentRanges(currentSourceFile.text, pos), /*onlyPinnedOrTripleSlashComments:*/ compilerOptions.removeComments);
+ if (compilerOptions.removeComments) {
+ return;
+ }
+ var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, pos);
// trailing comments are emitted at space/*trailing comment1 */space/*trailing comment*/
ts.emitComments(currentSourceFile, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
- function emitLeadingCommentsOfPosition(pos) {
+ function emitLeadingCommentsOfPositionWorker(pos) {
+ if (compilerOptions.removeComments) {
+ return;
+ }
var leadingComments;
if (hasDetachedComments(pos)) {
// get comments without detached comments
@@ -34801,13 +34925,26 @@ var ts;
// get the leading comments from the node
leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, pos);
}
- leadingComments = filterComments(leadingComments, compilerOptions.removeComments);
ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
}
function emitDetachedComments(node) {
- var leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ var leadingComments;
+ if (compilerOptions.removeComments) {
+ // removeComments is true, only reserve pinned comment at the top of file
+ // For example:
+ // /*! Pinned Comment */
+ //
+ // var x = 10;
+ if (node.pos === 0) {
+ leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments);
+ }
+ }
+ else {
+ // removeComments is false, just get detached as normal and bypass the process to filter comment
+ leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos);
+ }
if (leadingComments) {
var detachedComments = [];
var lastComment;
@@ -34852,17 +34989,6 @@ var ts;
write(shebang);
}
}
- function isPinnedOrTripleSlashComment(comment) {
- if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
- return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
- }
- else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ &&
- comment.pos + 2 < comment.end &&
- currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ &&
- currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
- return true;
- }
- }
}
function emitFile(jsFilePath, sourceFile) {
emitJavaScript(jsFilePath, sourceFile);
@@ -35139,7 +35265,7 @@ var ts;
/* @internal */ ts.ioWriteTime = 0;
/** The version of the TypeScript compiler release */
var emptyArray = [];
- ts.version = "1.6.2";
+ ts.version = "1.7.0";
function findConfigFile(searchPath) {
var fileName = "tsconfig.json";
while (true) {
@@ -35868,7 +35994,7 @@ var ts;
if (importedFile && resolution.isExternalLibraryImport) {
if (!ts.isExternalModule(importedFile)) {
var start_2 = ts.getTokenPosOfNode(file.imports[i], file);
- fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.File_0_is_not_a_module, importedFile.fileName));
+ fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_2, file.imports[i].end - start_2, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (!ts.fileExtensionIs(importedFile.fileName, ".d.ts")) {
var start_3 = ts.getTokenPosOfNode(file.imports[i], file);
@@ -36423,10 +36549,10 @@ var ts;
* Read tsconfig.json file
* @param fileName The path to the config file
*/
- function readConfigFile(fileName) {
+ function readConfigFile(fileName, readFile) {
var text = "";
try {
- text = ts.sys.readFile(fileName);
+ text = readFile(fileName);
}
catch (e) {
return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) };
@@ -39743,7 +39869,7 @@ var ts;
this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 36 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* MinusToken */, 41 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */));
this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 24 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([100 /* VarKeyword */, 96 /* ThrowKeyword */, 90 /* NewKeyword */, 76 /* DeleteKeyword */, 92 /* ReturnKeyword */, 99 /* TypeOfKeyword */, 117 /* AwaitKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([106 /* LetKeyword */, 72 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */));
this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */));
this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(85 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */));
@@ -39767,7 +39893,7 @@ var ts;
// Use of module as a function call. e.g.: import m2 = module("m2");
this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([123 /* ModuleKeyword */, 125 /* RequireKeyword */]), 17 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// Add a space around certain TypeScript keywords
- this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
+ this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([113 /* AbstractKeyword */, 71 /* ClassKeyword */, 120 /* DeclareKeyword */, 75 /* DefaultKeyword */, 79 /* EnumKeyword */, 80 /* ExportKeyword */, 81 /* ExtendsKeyword */, 121 /* GetKeyword */, 104 /* ImplementsKeyword */, 87 /* ImportKeyword */, 105 /* InterfaceKeyword */, 123 /* ModuleKeyword */, 124 /* NamespaceKeyword */, 108 /* PrivateKeyword */, 110 /* PublicKeyword */, 109 /* ProtectedKeyword */, 127 /* SetKeyword */, 111 /* StaticKeyword */, 130 /* TypeKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([81 /* ExtendsKeyword */, 104 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 15 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */));
@@ -39795,22 +39921,8 @@ var ts;
this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* YieldKeyword */, 37 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */));
// Async-await
this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* AsyncKeyword */, 85 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterAwaitKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(117 /* AwaitKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // Type alias declaration
- this.SpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterTypeKeyword = new formatting.Rule(formatting.RuleDescriptor.create3(130 /* TypeKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
// template string
this.SpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(67 /* Identifier */, formatting.Shared.TokenRange.FromTokens([11 /* NoSubstitutionTemplateLiteral */, 12 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- // type operation
- this.SpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceBeforeBar = new formatting.Rule(formatting.RuleDescriptor.create3(46 /* BarToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.NoSpaceAfterBar = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 46 /* BarToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */));
- this.SpaceBeforeAmpersand = new formatting.Rule(formatting.RuleDescriptor.create3(45 /* AmpersandToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
- this.SpaceAfterAmpersand = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 45 /* AmpersandToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -39837,12 +39949,8 @@ var ts;
this.NoSpaceBeforeOpenParenInFuncCall,
this.SpaceBeforeBinaryKeywordOperator, this.SpaceAfterBinaryKeywordOperator,
this.SpaceAfterVoidOperator,
- this.SpaceBetweenAsyncAndFunctionKeyword, this.NoSpaceBetweenAsyncAndFunctionKeyword,
- this.SpaceAfterAwaitKeyword, this.NoSpaceAfterAwaitKeyword,
- this.SpaceAfterTypeKeyword, this.NoSpaceAfterTypeKeyword,
- this.SpaceBetweenTagAndTemplateString, this.NoSpaceBetweenTagAndTemplateString,
- this.SpaceBeforeBar, this.NoSpaceBeforeBar, this.SpaceAfterBar, this.NoSpaceAfterBar,
- this.SpaceBeforeAmpersand, this.SpaceAfterAmpersand,
+ this.SpaceBetweenAsyncAndFunctionKeyword,
+ this.SpaceBetweenTagAndTemplateString,
// TypeScript-specific rules
this.NoSpaceAfterConstructor, this.NoSpaceAfterModuleImport,
this.SpaceAfterCertainTypeScriptKeywords, this.SpaceBeforeCertainTypeScriptKeywords,
@@ -39937,6 +40045,8 @@ var ts;
case 180 /* ConditionalExpression */:
case 187 /* AsExpression */:
case 148 /* TypePredicate */:
+ case 156 /* UnionType */:
+ case 157 /* IntersectionType */:
return true;
// equals in binding elements: function foo([[x, y] = [1, 2]])
case 161 /* BindingElement */:
@@ -40894,7 +41004,7 @@ var ts;
}
function getDynamicIndentation(node, nodeStartLine, indentation, delta) {
return {
- getIndentationForComment: function (kind) {
+ getIndentationForComment: function (kind, tokenIndentation) {
switch (kind) {
// preceding comment to the token that closes the indentation scope inherits the indentation from the scope
// .. {
@@ -40902,9 +41012,10 @@ var ts;
// }
case 16 /* CloseBraceToken */:
case 20 /* CloseBracketToken */:
+ case 18 /* CloseParenToken */:
return indentation + delta;
}
- return indentation;
+ return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation;
},
getIndentationForToken: function (line, kind) {
if (nodeStartLine !== line && node.decorators) {
@@ -41106,8 +41217,12 @@ var ts;
processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation);
}
if (indentToken) {
- var indentNextTokenOrTrivia = true;
+ var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
+ dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind) :
+ -1 /* Unknown */;
if (currentTokenInfo.leadingTrivia) {
+ var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation);
+ var indentNextTokenOrTrivia = true;
for (var _i = 0, _a = currentTokenInfo.leadingTrivia; _i < _a.length; _i++) {
var triviaItem = _a[_i];
if (!ts.rangeContainsRange(originalRange, triviaItem)) {
@@ -41115,14 +41230,12 @@ var ts;
}
switch (triviaItem.kind) {
case 3 /* MultiLineCommentTrivia */:
- var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia);
indentNextTokenOrTrivia = false;
break;
case 2 /* SingleLineCommentTrivia */:
if (indentNextTokenOrTrivia) {
- var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
- insertIndentation(triviaItem.pos, commentIndentation_1, /*lineAdded*/ false);
+ insertIndentation(triviaItem.pos, commentIndentation, /*lineAdded*/ false);
indentNextTokenOrTrivia = false;
}
break;
@@ -41133,8 +41246,7 @@ var ts;
}
}
// indent token only if is it is in target range and does not overlap with any error ranges
- if (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) {
- var tokenIndentation = dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind);
+ if (tokenIndentation !== -1 /* Unknown */) {
insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAdded);
lastIndentedLine = tokenStart.line;
indentationOnLastIndentedLine = tokenIndentation;
@@ -46451,6 +46563,7 @@ var ts;
result.push(getReferenceEntryFromNode(node));
}
break;
+ case 184 /* ClassExpression */:
case 212 /* ClassDeclaration */:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.