diff --git a/lib/tsc.js b/lib/tsc.js index 94ec709879f..f42b484993c 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -132,7 +132,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.3"; + ts.version = "2.1.4"; })(ts || (ts = {})); (function (ts) { var createObject = Object.create; @@ -2668,6 +2668,7 @@ var ts; 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_2340", message: "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_2341", message: "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_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { code: 2343, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", message: "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "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_2345", message: "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_2346", message: "Supplied parameters do not match any signature of call target." }, @@ -2678,6 +2679,7 @@ var ts; Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Type_0_cannot_be_converted_to_type_1: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_converted_to_type_1_2352", message: "Type '{0}' cannot be converted to type '{1}'." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { code: 2354, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", message: "This syntax requires an imported helper but module '{0}' cannot be found." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, @@ -2984,6 +2986,8 @@ var ts; Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { code: 4083, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", message: "Type parameter '{0}' of exported type alias has or is using private name '{1}'." }, Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -4869,17 +4873,17 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 4194304) !== 0; + return (node.flags & 131072) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 8388608)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || + if (!(node.flags & 262144)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 4194304; + node.flags |= 131072; } - node.flags |= 8388608; + node.flags |= 262144; } } function getSourceFileOfNode(node) { @@ -5103,6 +5107,10 @@ var ts; return false; } ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isEffectiveExternalModule(node, compilerOptions) { + return ts.isExternalModule(node) || compilerOptions.isolatedModules; + } + ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { case 261: @@ -5858,7 +5866,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 2097152); + return node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { @@ -6097,7 +6105,7 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 2097152)) { + if (node && (node.flags & 65536)) { if (node.type && node.type.kind === 275 || ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { return true; @@ -11636,7 +11644,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(5, true); - var disallowInAndDecoratorContext = 65536 | 262144; + var disallowInAndDecoratorContext = 2048 | 8192; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -11684,7 +11692,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 || scriptKind === 2 ? 2097152 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 65536 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -11779,16 +11787,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 65536); + setContextFlag(val, 2048); } function setYieldContext(val) { - setContextFlag(val, 131072); + setContextFlag(val, 4096); } function setDecoratorContext(val) { - setContextFlag(val, 262144); + setContextFlag(val, 8192); } function setAwaitContext(val) { - setContextFlag(val, 524288); + setContextFlag(val, 16384); } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; @@ -11811,40 +11819,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(65536, func); + return doOutsideOfContext(2048, func); } function disallowInAnd(func) { - return doInsideOfContext(65536, func); + return doInsideOfContext(2048, func); } function doInYieldContext(func) { - return doInsideOfContext(131072, func); + return doInsideOfContext(4096, func); } function doInDecoratorContext(func) { - return doInsideOfContext(262144, func); + return doInsideOfContext(8192, func); } function doInAwaitContext(func) { - return doInsideOfContext(524288, func); + return doInsideOfContext(16384, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(524288, func); + return doOutsideOfContext(16384, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(131072 | 524288, func); + return doInsideOfContext(4096 | 16384, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(131072); + return inContext(4096); } function inDisallowInContext() { - return inContext(65536); + return inContext(2048); } function inDecoratorContext() { - return inContext(262144); + return inContext(8192); } function inAwaitContext() { - return inContext(524288); + return inContext(16384); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -12006,7 +12014,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 1048576; + node.flags |= 32768; } return node; } @@ -12324,7 +12332,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 3080192; + var nodeContextFlags = node.flags & 96256; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -13132,7 +13140,7 @@ var ts; } } function parseType() { - return doOutsideOfContext(655360, parseTypeWorker); + return doOutsideOfContext(20480, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { @@ -14763,7 +14771,7 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = ts.hasModifier(property, 32) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(131072 | 65536, parseNonParameterInitializer); + : doOutsideOfContext(4096 | 2048, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -16737,7 +16745,7 @@ var ts; activeLabels = undefined; hasExplicitReturn = false; bindChildren(node); - node.flags &= ~64896; + node.flags &= ~1408; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { node.flags |= 128; if (hasExplicitReturn) @@ -17920,9 +17928,6 @@ var ts; return bindParameter(node); case 223: case 174: - if (node.dotDotDotToken && node.parent.kind === 172) { - emitFlags |= 32768; - } return bindVariableDeclarationOrBindingElement(node); case 147: case 146: @@ -17949,7 +17954,6 @@ var ts; } root = root.parent; } - emitFlags |= hasRest ? 32768 : 16384; return; case 153: case 154: @@ -18145,14 +18149,6 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { - emitFlags |= 1024; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048; - } - } if (node.kind === 226) { bindBlockScopedDeclaration(node, 32, 899519); } @@ -18196,11 +18192,6 @@ var ts; } } function bindParameter(node) { - if (!ts.isDeclarationFile(file) && - !ts.isInAmbientContext(node) && - ts.nodeIsDecorated(node)) { - emitFlags |= (2048 | 4096); - } if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } @@ -18218,7 +18209,7 @@ var ts; function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; + emitFlags |= 1024; } } checkStrictModeFunctionName(node); @@ -18233,7 +18224,7 @@ var ts; function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; + emitFlags |= 1024; } } if (currentFlow) { @@ -18246,10 +18237,7 @@ var ts; function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048; + emitFlags |= 1024; } } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -19539,6 +19527,8 @@ var ts; ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { var cancellationToken; + var requestedExternalEmitHelpers; + var externalHelpersModule; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -21867,7 +21857,13 @@ var ts; return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - ts.Debug.assert(!!(source.flags & 32768), "Rest types only support object types right now."); + source = filterType(source, function (t) { return !(t.flags & 6144); }); + if (source.flags & 8192) { + return emptyObjectType; + } + if (source.flags & 65536) { + return mapType(source, function (t) { return getRestType(t, properties, symbol); }); + } var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { @@ -21903,7 +21899,7 @@ var ts; var type; if (pattern.kind === 172) { if (declaration.dotDotDotToken) { - if (!(parentType.flags & 32768)) { + if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return unknownType; } @@ -21981,7 +21977,7 @@ var ts; return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -22000,7 +21996,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 2097152) && + if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { @@ -22061,13 +22057,18 @@ var ts; } function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createMap(); + var stringIndexInfo; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name) || e.dotDotDotToken) { + if (isComputedNonLiteralName(name)) { hasComputedProperties = true; return; } + if (e.dotDotDotToken) { + stringIndexInfo = createIndexInfo(anyType, false); + return; + } var text = ts.getTextOfPropertyName(name); var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var symbol = createSymbol(flags, text); @@ -22075,7 +22076,7 @@ var ts; symbol.bindingElement = e; members[symbol.name] = symbol; }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { result.pattern = pattern; } @@ -22140,7 +22141,7 @@ var ts; if (declaration.kind === 240) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 2097152 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -22149,7 +22150,7 @@ var ts; var type = void 0; if (declaration.kind === 192 || declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var jsdocType = ts.getJSDocType(declaration.parent); if (jsdocType) { return links.type = getTypeFromTypeNode(jsdocType); @@ -22203,7 +22204,7 @@ var ts; if (!links.type) { var getter = ts.getDeclarationOfKind(symbol, 151); var setter = ts.getDeclarationOfKind(symbol, 152); - if (getter && getter.flags & 2097152) { + if (getter && getter.flags & 65536) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -23074,7 +23075,7 @@ var ts; var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName); var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912); var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); - prop.type = addOptionality(propType, isOptional); + prop.type = propType; prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp); members[propName] = prop; } @@ -23095,7 +23096,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) : unknownType); } function getIsomorphicTypeFromMappedType(type) { @@ -23344,7 +23345,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -23372,7 +23373,7 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 2097152) { + if (node.flags & 65536) { if (node.type && node.type.kind === 273) { return true; } @@ -23501,7 +23502,7 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -24308,7 +24309,7 @@ var ts; } var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return addOptionality(instantiateType(getTemplateTypeFromMappedType(type), templateMapper), !!type.declaration.questionToken); + return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (indexType.flags & 16384 || @@ -24384,10 +24385,23 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function getSpreadType(left, right, isFromObjectLiteral) { - ts.Debug.assert(!!(left.flags & (32768 | 1)) && !!(right.flags & (32768 | 1)), "Only object types may be spread."); if (left.flags & 1 || right.flags & 1) { return anyType; } + left = filterType(left, function (t) { return !(t.flags & 6144); }); + if (left.flags & 8192) { + return right; + } + right = filterType(right, function (t) { return !(t.flags & 6144); }); + if (right.flags & 8192) { + return left; + } + if (left.flags & 65536) { + return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + } + if (right.flags & 65536) { + return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); var stringIndexInfo; @@ -26312,6 +26326,8 @@ var ts; var typeInferences = createTypeInferencesObject(); var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); + var readonlyMask = target.declaration.readonlyToken ? false : true; + var optionalMask = target.declaration.questionToken ? 0 : 536870912; var properties = getPropertiesOfType(source); var members = createSymbolTable(properties); var hasInferredTypes = false; @@ -26319,10 +26335,10 @@ var ts; var prop = properties_4[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (inferredPropType) { - var inferredProp = createSymbol(4 | 67108864 | prop.flags & 536870912, prop.name); + var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = isReadonlySymbol(prop); + inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); members[prop.name] = inferredProp; hasInferredTypes = true; } @@ -26331,7 +26347,7 @@ var ts; if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); if (inferredIndexType) { - indexInfo = createIndexInfo(inferredIndexType, indexInfo.isReadonly); + indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly); hasInferredTypes = true; } } @@ -27668,7 +27684,7 @@ var ts; error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 524288) { + if (node.flags & 16384) { getNodeLinks(container).flags |= 8192; } return getTypeOfSymbol(symbol); @@ -28581,7 +28597,7 @@ var ts; if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; } - else if (!compilerOptions.suppressExcessPropertyErrors) { + else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); } } @@ -28595,6 +28611,9 @@ var ts; member = prop; } else if (memberDecl.kind === 259) { + if (languageVersion < 5) { + checkExternalEmitHelpers(memberDecl, 2); + } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), true); propertiesArray = []; @@ -28604,7 +28623,7 @@ var ts; typeFlags = 0; } var type = checkExpression(memberDecl.expression); - if (!(type.flags & (32768 | 1))) { + if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } @@ -28669,6 +28688,11 @@ var ts; return result; } } + function isValidSpreadType(type) { + return !!(type.flags & (1 | 4096 | 2048) || + type.flags & 32768 && !isGenericMappedType(type) || + type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); return jsxElementType || anyType; @@ -28743,6 +28767,9 @@ var ts; return exprType; } function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + if (compilerOptions.jsx === 2) { + checkExternalEmitHelpers(node, 2); + } var type = checkExpression(node.expression); var props = getPropertiesOfType(type); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { @@ -30489,7 +30516,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 524288)) { + if (!(node.flags & 16384)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -30647,6 +30674,9 @@ var ts; } } else if (property.kind === 259) { + if (languageVersion < 5) { + checkExternalEmitHelpers(property, 4); + } var nonRestNames = []; if (allProperties) { for (var i = 0; i < allProperties.length - 1; i++) { @@ -30997,7 +31027,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 131072) || isYieldExpressionInClass(node)) { + if (!(node.flags & 4096) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -31373,6 +31403,12 @@ var ts; node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } + if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { + checkExternalEmitHelpers(node, 64); + if (languageVersion < 2) { + checkExternalEmitHelpers(node, 128); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -32167,7 +32203,13 @@ var ts; if (!compilerOptions.experimentalDecorators) { error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } + var firstDecorator = node.decorators[0]; + checkExternalEmitHelpers(firstDecorator, 8); + if (node.kind === 144) { + checkExternalEmitHelpers(firstDecorator, 32); + } if (compilerOptions.emitDecoratorMetadata) { + checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { case 226: var constructor = ts.getFirstConstructorWithBody(node); @@ -32484,14 +32526,14 @@ var ts; } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "Promise")) { + if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -32588,6 +32630,9 @@ var ts; } } if (node.kind === 174) { + if (node.parent.kind === 172 && languageVersion < 5) { + checkExternalEmitHelpers(node, 4); + } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } @@ -32997,7 +33042,7 @@ var ts; } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 524288) { + if (node.flags & 16384) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -33243,6 +33288,9 @@ var ts; checkClassForDuplicateDeclarations(node); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { + if (languageVersion < 2) { + checkExternalEmitHelpers(baseTypeNode.parent, 1); + } var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; @@ -35150,8 +35198,6 @@ var ts; ts.bindSourceFile(file, compilerOptions); } var augmentations; - var requestedExternalEmitHelpers = 0; - var firstFileRequestingExternalHelpers; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; if (!ts.isExternalOrCommonJsModule(file)) { @@ -35171,15 +35217,6 @@ var ts; } } } - if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 64512; - if (fileRequestedExternalEmitHelpers) { - requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; - if (firstFileRequestingExternalHelpers === undefined) { - firstFileRequestingExternalHelpers = file; - } - } - } } if (augmentations) { for (var _d = 0, augmentations_1 = augmentations; _d < augmentations_1.length; _d++) { @@ -35234,44 +35271,46 @@ var ts; var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; - if (compilerOptions.importHelpers && firstFileRequestingExternalHelpers) { - var helpersModule = resolveExternalModule(firstFileRequestingExternalHelpers, ts.externalHelpersModuleNameText, ts.Diagnostics.Cannot_find_module_0, undefined); - if (helpersModule) { - var exports = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 && languageVersion < 2) { - verifyHelperSymbol(exports, "__extends", 107455); - } - if (requestedExternalEmitHelpers & 16384 && - (languageVersion < 5 || compilerOptions.jsx === 2)) { - verifyHelperSymbol(exports, "__assign", 107455); - } - if (languageVersion < 5 && requestedExternalEmitHelpers & 32768) { - verifyHelperSymbol(exports, "__rest", 107455); - } - if (requestedExternalEmitHelpers & 2048) { - verifyHelperSymbol(exports, "__decorate", 107455); - if (compilerOptions.emitDecoratorMetadata) { - verifyHelperSymbol(exports, "__metadata", 107455); - } - } - if (requestedExternalEmitHelpers & 4096) { - verifyHelperSymbol(exports, "__param", 107455); - } - if (requestedExternalEmitHelpers & 8192) { - verifyHelperSymbol(exports, "__awaiter", 107455); - if (languageVersion < 2) { - verifyHelperSymbol(exports, "__generator", 107455); + } + function checkExternalEmitHelpers(location, helpers) { + if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { + var sourceFile = ts.getSourceFileOfNode(location); + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var helpersModule = resolveHelpersModule(sourceFile, location); + if (helpersModule !== unknownSymbol) { + var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; + for (var helper = 1; helper <= 128; helper <<= 1) { + if (uncheckedHelpers & helper) { + var name_27 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455); + if (!symbol) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + } + } } } + requestedExternalEmitHelpers |= helpers; } } } - function verifyHelperSymbol(symbols, name, meaning) { - var symbol = getSymbol(symbols, ts.escapeIdentifier(name), meaning); - if (!symbol) { - error(undefined, ts.Diagnostics.Module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + function getHelperName(helper) { + switch (helper) { + case 1: return "__extends"; + case 2: return "__assign"; + case 4: return "__rest"; + case 8: return "__decorate"; + case 16: return "__metadata"; + case 32: return "__param"; + case 64: return "__awaiter"; + case 128: return "__generator"; } } + function resolveHelpersModule(node, errorNode) { + if (!externalHelpersModule) { + externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol; + } + return externalHelpersModule; + } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyGenericType) { @@ -35794,9 +35833,9 @@ var ts; if (prop.kind === 259) { continue; } - var name_27 = prop.name; - if (name_27.kind === 142) { - checkGrammarComputedPropertyName(name_27); + var name_28 = prop.name; + if (name_28.kind === 142) { + checkGrammarComputedPropertyName(name_28); } if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -35812,8 +35851,8 @@ var ts; var currentKind = void 0; if (prop.kind === 257 || prop.kind === 258) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8) { - checkGrammarNumericLiteral(name_27); + if (name_28.kind === 8) { + checkGrammarNumericLiteral(name_28); } currentKind = Property; } @@ -35829,7 +35868,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); if (effectiveName === undefined) { continue; } @@ -35839,18 +35878,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -35863,12 +35902,12 @@ var ts; continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_29 = jsxAttr.name; + if (!seen[name_29.text]) { + seen[name_29.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 252 && !initializer.expression) { @@ -37186,10 +37225,10 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_29 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_29, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_30, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); variable.original = original; - if (ts.isIdentifier(name_29)) { + if (ts.isIdentifier(name_30)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -37335,8 +37374,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_30 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_30); + var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_31); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -37378,7 +37417,7 @@ var ts; var restHelper = { name: "typescript:rest", scoped: false, - text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" + text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; function createRestCall(context, value, elements, computedTempVariables, location) { context.requestEmitHelper(restHelper); @@ -38248,14 +38287,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_31 = ts.getMutableClone(node); - name_31.flags &= ~8; - name_31.original = undefined; - name_31.parent = currentScope; + var name_32 = ts.getMutableClone(node); + name_32.flags &= ~8; + name_32.original = undefined; + name_32.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_31), ts.createLiteral("undefined")), name_31); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); } - return name_31; + return name_32; case 141: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -38285,7 +38324,7 @@ var ts; : name.expression; } else if (ts.isIdentifier(name)) { - return ts.createLiteral(name.text); + return ts.createLiteral(ts.unescapeIdentifier(name.text)); } else { return ts.getSynthesizedClone(name); @@ -38526,9 +38565,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_32 = node.symbol && node.symbol.name; - if (name_32) { - return currentScopeFirstDeclarationsOfName[name_32] === node; + var name_33 = node.symbol && node.symbol.name; + if (name_33) { + return currentScopeFirstDeclarationsOfName[name_33] === node; } } return false; @@ -38817,14 +38856,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_34 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_34); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, node); + return ts.createPropertyAssignment(name_34, initializer, node); } - return ts.createPropertyAssignment(name_33, exportedName, node); + return ts.createPropertyAssignment(name_34, exportedName, node); } } return node; @@ -39345,12 +39384,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_35 = node.tagName; + if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { + return ts.createLiteral(name_35.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_35); } } } @@ -40483,15 +40522,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); + if (ts.isBindingPattern(name_36)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); } } } @@ -42496,9 +42535,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_6 = ts.getMutableClone(name_36); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_6 = ts.getMutableClone(name_37); ts.setSourceMapRange(clone_6, node); ts.setCommentRange(clone_6, node); return clone_6; @@ -44667,8 +44706,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_37 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_37), node); + var name_38 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), node); } } } @@ -45925,9 +45964,9 @@ var ts; var count = 0; while (true) { count++; - var name_38 = baseName + "_" + count; - if (!(name_38 in currentIdentifiers)) { - return name_38; + var name_39 = baseName + "_" + count; + if (!(name_39 in currentIdentifiers)) { + return name_39; } } } @@ -46816,6 +46855,10 @@ var ts; return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 155: + return symbolAccessibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; case 149: case 148: if (ts.hasModifier(node.parent, 32)) { @@ -48890,21 +48933,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_39 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_39)) { + var name_40 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_40)) { tempFlags |= flags; - return name_39; + return name_40; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_40 = count < 26 + var name_41 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_40)) { - return name_40; + if (isUniqueName(name_41)) { + return name_41; } } } @@ -49240,10 +49283,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_41 = names_1[_i]; - var result = name_41 in cache - ? cache[name_41] - : cache[name_41] = loader(name_41, containingFile); + var name_42 = names_1[_i]; + var result = name_42 in cache + ? cache[name_42] + : cache[name_42] = loader(name_42, containingFile); resolutions.push(result); } return resolutions; @@ -51057,9 +51100,9 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_42 in options) { - if (ts.hasProperty(options, name_42)) { - switch (name_42) { + for (var name_43 in options) { + if (ts.hasProperty(options, name_43)) { + switch (name_43) { case "init": case "watch": case "version": @@ -51067,12 +51110,12 @@ var ts; case "project": break; default: - var value = options[name_42]; - var optionDefinition = optionsNameMap[name_42.toLowerCase()]; + var value = options[name_43]; + var optionDefinition = optionsNameMap[name_43.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { - result[name_42] = value; + result[name_43] = value; } else { if (optionDefinition.type === "list") { @@ -51081,10 +51124,10 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_42] = convertedValue; + result[name_43] = convertedValue; } else { - result[name_42] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -51933,17 +51976,17 @@ var ts; var nameSize = 0; var valueSize = 0; for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) { - var _a = statistics_1[_i], name_43 = _a.name, value = _a.value; - if (name_43.length > nameSize) { - nameSize = name_43.length; + var _a = statistics_1[_i], name_44 = _a.name, value = _a.value; + if (name_44.length > nameSize) { + nameSize = name_44.length; } if (value.length > valueSize) { valueSize = value.length; } } for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) { - var _c = statistics_2[_b], name_44 = _c.name, value = _c.value; - ts.sys.write(padRight(name_44 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); + var _c = statistics_2[_b], name_45 = _c.name, value = _c.value; + ts.sys.write(padRight(name_45 + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); } } function reportStatisticalValue(name, value) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 7450ef5ab69..077dbe8115d 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -137,7 +137,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.3"; + ts.version = "2.1.4"; })(ts || (ts = {})); (function (ts) { var createObject = Object.create; @@ -2673,6 +2673,7 @@ var ts; 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_2340", message: "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_2341", message: "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_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { code: 2343, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", message: "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "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_2345", message: "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_2346", message: "Supplied parameters do not match any signature of call target." }, @@ -2683,6 +2684,7 @@ var ts; Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Type_0_cannot_be_converted_to_type_1: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_converted_to_type_1_2352", message: "Type '{0}' cannot be converted to type '{1}'." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { code: 2354, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", message: "This syntax requires an imported helper but module '{0}' cannot be found." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, @@ -2989,6 +2991,8 @@ var ts; Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { code: 4083, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", message: "Type parameter '{0}' of exported type alias has or is using private name '{1}'." }, Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -6965,17 +6969,17 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 4194304) !== 0; + return (node.flags & 131072) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 8388608)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || + if (!(node.flags & 262144)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 4194304; + node.flags |= 131072; } - node.flags |= 8388608; + node.flags |= 262144; } } function getSourceFileOfNode(node) { @@ -7199,6 +7203,10 @@ var ts; return false; } ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isEffectiveExternalModule(node, compilerOptions) { + return ts.isExternalModule(node) || compilerOptions.isolatedModules; + } + ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { case 261: @@ -7954,7 +7962,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 2097152); + return node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { @@ -8193,7 +8201,7 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 2097152)) { + if (node && (node.flags & 65536)) { if (node.type && node.type.kind === 275 || ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { return true; @@ -13732,7 +13740,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(5, true); - var disallowInAndDecoratorContext = 65536 | 262144; + var disallowInAndDecoratorContext = 2048 | 8192; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -13780,7 +13788,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 || scriptKind === 2 ? 2097152 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 65536 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -13875,16 +13883,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 65536); + setContextFlag(val, 2048); } function setYieldContext(val) { - setContextFlag(val, 131072); + setContextFlag(val, 4096); } function setDecoratorContext(val) { - setContextFlag(val, 262144); + setContextFlag(val, 8192); } function setAwaitContext(val) { - setContextFlag(val, 524288); + setContextFlag(val, 16384); } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; @@ -13907,40 +13915,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(65536, func); + return doOutsideOfContext(2048, func); } function disallowInAnd(func) { - return doInsideOfContext(65536, func); + return doInsideOfContext(2048, func); } function doInYieldContext(func) { - return doInsideOfContext(131072, func); + return doInsideOfContext(4096, func); } function doInDecoratorContext(func) { - return doInsideOfContext(262144, func); + return doInsideOfContext(8192, func); } function doInAwaitContext(func) { - return doInsideOfContext(524288, func); + return doInsideOfContext(16384, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(524288, func); + return doOutsideOfContext(16384, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(131072 | 524288, func); + return doInsideOfContext(4096 | 16384, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(131072); + return inContext(4096); } function inDisallowInContext() { - return inContext(65536); + return inContext(2048); } function inDecoratorContext() { - return inContext(262144); + return inContext(8192); } function inAwaitContext() { - return inContext(524288); + return inContext(16384); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -14102,7 +14110,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 1048576; + node.flags |= 32768; } return node; } @@ -14420,7 +14428,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 3080192; + var nodeContextFlags = node.flags & 96256; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -15228,7 +15236,7 @@ var ts; } } function parseType() { - return doOutsideOfContext(655360, parseTypeWorker); + return doOutsideOfContext(20480, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { @@ -16859,7 +16867,7 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = ts.hasModifier(property, 32) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(131072 | 65536, parseNonParameterInitializer); + : doOutsideOfContext(4096 | 2048, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -18833,7 +18841,7 @@ var ts; activeLabels = undefined; hasExplicitReturn = false; bindChildren(node); - node.flags &= ~64896; + node.flags &= ~1408; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { node.flags |= 128; if (hasExplicitReturn) @@ -20016,9 +20024,6 @@ var ts; return bindParameter(node); case 223: case 174: - if (node.dotDotDotToken && node.parent.kind === 172) { - emitFlags |= 32768; - } return bindVariableDeclarationOrBindingElement(node); case 147: case 146: @@ -20045,7 +20050,6 @@ var ts; } root = root.parent; } - emitFlags |= hasRest ? 32768 : 16384; return; case 153: case 154: @@ -20241,14 +20245,6 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { - emitFlags |= 1024; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048; - } - } if (node.kind === 226) { bindBlockScopedDeclaration(node, 32, 899519); } @@ -20292,11 +20288,6 @@ var ts; } } function bindParameter(node) { - if (!ts.isDeclarationFile(file) && - !ts.isInAmbientContext(node) && - ts.nodeIsDecorated(node)) { - emitFlags |= (2048 | 4096); - } if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } @@ -20314,7 +20305,7 @@ var ts; function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; + emitFlags |= 1024; } } checkStrictModeFunctionName(node); @@ -20329,7 +20320,7 @@ var ts; function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; + emitFlags |= 1024; } } if (currentFlow) { @@ -20342,10 +20333,7 @@ var ts; function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048; + emitFlags |= 1024; } } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -21053,6 +21041,8 @@ var ts; ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { var cancellationToken; + var requestedExternalEmitHelpers; + var externalHelpersModule; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -23381,7 +23371,13 @@ var ts; return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - ts.Debug.assert(!!(source.flags & 32768), "Rest types only support object types right now."); + source = filterType(source, function (t) { return !(t.flags & 6144); }); + if (source.flags & 8192) { + return emptyObjectType; + } + if (source.flags & 65536) { + return mapType(source, function (t) { return getRestType(t, properties, symbol); }); + } var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { @@ -23417,7 +23413,7 @@ var ts; var type; if (pattern.kind === 172) { if (declaration.dotDotDotToken) { - if (!(parentType.flags & 32768)) { + if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return unknownType; } @@ -23495,7 +23491,7 @@ var ts; return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -23514,7 +23510,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 2097152) && + if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { @@ -23575,13 +23571,18 @@ var ts; } function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createMap(); + var stringIndexInfo; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name) || e.dotDotDotToken) { + if (isComputedNonLiteralName(name)) { hasComputedProperties = true; return; } + if (e.dotDotDotToken) { + stringIndexInfo = createIndexInfo(anyType, false); + return; + } var text = ts.getTextOfPropertyName(name); var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var symbol = createSymbol(flags, text); @@ -23589,7 +23590,7 @@ var ts; symbol.bindingElement = e; members[symbol.name] = symbol; }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { result.pattern = pattern; } @@ -23654,7 +23655,7 @@ var ts; if (declaration.kind === 240) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 2097152 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -23663,7 +23664,7 @@ var ts; var type = void 0; if (declaration.kind === 192 || declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var jsdocType = ts.getJSDocType(declaration.parent); if (jsdocType) { return links.type = getTypeFromTypeNode(jsdocType); @@ -23717,7 +23718,7 @@ var ts; if (!links.type) { var getter = ts.getDeclarationOfKind(symbol, 151); var setter = ts.getDeclarationOfKind(symbol, 152); - if (getter && getter.flags & 2097152) { + if (getter && getter.flags & 65536) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -24588,7 +24589,7 @@ var ts; var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName); var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912); var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); - prop.type = addOptionality(propType, isOptional); + prop.type = propType; prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp); members[propName] = prop; } @@ -24609,7 +24610,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) : unknownType); } function getIsomorphicTypeFromMappedType(type) { @@ -24858,7 +24859,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -24886,7 +24887,7 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 2097152) { + if (node.flags & 65536) { if (node.type && node.type.kind === 273) { return true; } @@ -25015,7 +25016,7 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -25822,7 +25823,7 @@ var ts; } var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return addOptionality(instantiateType(getTemplateTypeFromMappedType(type), templateMapper), !!type.declaration.questionToken); + return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (indexType.flags & 16384 || @@ -25898,10 +25899,23 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function getSpreadType(left, right, isFromObjectLiteral) { - ts.Debug.assert(!!(left.flags & (32768 | 1)) && !!(right.flags & (32768 | 1)), "Only object types may be spread."); if (left.flags & 1 || right.flags & 1) { return anyType; } + left = filterType(left, function (t) { return !(t.flags & 6144); }); + if (left.flags & 8192) { + return right; + } + right = filterType(right, function (t) { return !(t.flags & 6144); }); + if (right.flags & 8192) { + return left; + } + if (left.flags & 65536) { + return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + } + if (right.flags & 65536) { + return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); var stringIndexInfo; @@ -27826,6 +27840,8 @@ var ts; var typeInferences = createTypeInferencesObject(); var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); + var readonlyMask = target.declaration.readonlyToken ? false : true; + var optionalMask = target.declaration.questionToken ? 0 : 536870912; var properties = getPropertiesOfType(source); var members = createSymbolTable(properties); var hasInferredTypes = false; @@ -27833,10 +27849,10 @@ var ts; var prop = properties_4[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (inferredPropType) { - var inferredProp = createSymbol(4 | 67108864 | prop.flags & 536870912, prop.name); + var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = isReadonlySymbol(prop); + inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); members[prop.name] = inferredProp; hasInferredTypes = true; } @@ -27845,7 +27861,7 @@ var ts; if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); if (inferredIndexType) { - indexInfo = createIndexInfo(inferredIndexType, indexInfo.isReadonly); + indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly); hasInferredTypes = true; } } @@ -29182,7 +29198,7 @@ var ts; error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 524288) { + if (node.flags & 16384) { getNodeLinks(container).flags |= 8192; } return getTypeOfSymbol(symbol); @@ -30095,7 +30111,7 @@ var ts; if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; } - else if (!compilerOptions.suppressExcessPropertyErrors) { + else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); } } @@ -30109,6 +30125,9 @@ var ts; member = prop; } else if (memberDecl.kind === 259) { + if (languageVersion < 5) { + checkExternalEmitHelpers(memberDecl, 2); + } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), true); propertiesArray = []; @@ -30118,7 +30137,7 @@ var ts; typeFlags = 0; } var type = checkExpression(memberDecl.expression); - if (!(type.flags & (32768 | 1))) { + if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } @@ -30183,6 +30202,11 @@ var ts; return result; } } + function isValidSpreadType(type) { + return !!(type.flags & (1 | 4096 | 2048) || + type.flags & 32768 && !isGenericMappedType(type) || + type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); return jsxElementType || anyType; @@ -30257,6 +30281,9 @@ var ts; return exprType; } function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + if (compilerOptions.jsx === 2) { + checkExternalEmitHelpers(node, 2); + } var type = checkExpression(node.expression); var props = getPropertiesOfType(type); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { @@ -32003,7 +32030,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 524288)) { + if (!(node.flags & 16384)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -32161,6 +32188,9 @@ var ts; } } else if (property.kind === 259) { + if (languageVersion < 5) { + checkExternalEmitHelpers(property, 4); + } var nonRestNames = []; if (allProperties) { for (var i = 0; i < allProperties.length - 1; i++) { @@ -32511,7 +32541,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 131072) || isYieldExpressionInClass(node)) { + if (!(node.flags & 4096) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -32887,6 +32917,12 @@ var ts; node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } + if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { + checkExternalEmitHelpers(node, 64); + if (languageVersion < 2) { + checkExternalEmitHelpers(node, 128); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -33681,7 +33717,13 @@ var ts; if (!compilerOptions.experimentalDecorators) { error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } + var firstDecorator = node.decorators[0]; + checkExternalEmitHelpers(firstDecorator, 8); + if (node.kind === 144) { + checkExternalEmitHelpers(firstDecorator, 32); + } if (compilerOptions.emitDecoratorMetadata) { + checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { case 226: var constructor = ts.getFirstConstructorWithBody(node); @@ -33998,14 +34040,14 @@ var ts; } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "Promise")) { + if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34102,6 +34144,9 @@ var ts; } } if (node.kind === 174) { + if (node.parent.kind === 172 && languageVersion < 5) { + checkExternalEmitHelpers(node, 4); + } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } @@ -34511,7 +34556,7 @@ var ts; } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 524288) { + if (node.flags & 16384) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -34757,6 +34802,9 @@ var ts; checkClassForDuplicateDeclarations(node); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { + if (languageVersion < 2) { + checkExternalEmitHelpers(baseTypeNode.parent, 1); + } var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; @@ -36664,8 +36712,6 @@ var ts; ts.bindSourceFile(file, compilerOptions); } var augmentations; - var requestedExternalEmitHelpers = 0; - var firstFileRequestingExternalHelpers; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; if (!ts.isExternalOrCommonJsModule(file)) { @@ -36685,15 +36731,6 @@ var ts; } } } - if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 64512; - if (fileRequestedExternalEmitHelpers) { - requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; - if (firstFileRequestingExternalHelpers === undefined) { - firstFileRequestingExternalHelpers = file; - } - } - } } if (augmentations) { for (var _d = 0, augmentations_1 = augmentations; _d < augmentations_1.length; _d++) { @@ -36748,44 +36785,46 @@ var ts; var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; - if (compilerOptions.importHelpers && firstFileRequestingExternalHelpers) { - var helpersModule = resolveExternalModule(firstFileRequestingExternalHelpers, ts.externalHelpersModuleNameText, ts.Diagnostics.Cannot_find_module_0, undefined); - if (helpersModule) { - var exports_2 = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 && languageVersion < 2) { - verifyHelperSymbol(exports_2, "__extends", 107455); - } - if (requestedExternalEmitHelpers & 16384 && - (languageVersion < 5 || compilerOptions.jsx === 2)) { - verifyHelperSymbol(exports_2, "__assign", 107455); - } - if (languageVersion < 5 && requestedExternalEmitHelpers & 32768) { - verifyHelperSymbol(exports_2, "__rest", 107455); - } - if (requestedExternalEmitHelpers & 2048) { - verifyHelperSymbol(exports_2, "__decorate", 107455); - if (compilerOptions.emitDecoratorMetadata) { - verifyHelperSymbol(exports_2, "__metadata", 107455); - } - } - if (requestedExternalEmitHelpers & 4096) { - verifyHelperSymbol(exports_2, "__param", 107455); - } - if (requestedExternalEmitHelpers & 8192) { - verifyHelperSymbol(exports_2, "__awaiter", 107455); - if (languageVersion < 2) { - verifyHelperSymbol(exports_2, "__generator", 107455); + } + function checkExternalEmitHelpers(location, helpers) { + if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { + var sourceFile = ts.getSourceFileOfNode(location); + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var helpersModule = resolveHelpersModule(sourceFile, location); + if (helpersModule !== unknownSymbol) { + var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; + for (var helper = 1; helper <= 128; helper <<= 1) { + if (uncheckedHelpers & helper) { + var name_29 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_29), 107455); + if (!symbol) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_29); + } + } } } + requestedExternalEmitHelpers |= helpers; } } } - function verifyHelperSymbol(symbols, name, meaning) { - var symbol = getSymbol(symbols, ts.escapeIdentifier(name), meaning); - if (!symbol) { - error(undefined, ts.Diagnostics.Module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + function getHelperName(helper) { + switch (helper) { + case 1: return "__extends"; + case 2: return "__assign"; + case 4: return "__rest"; + case 8: return "__decorate"; + case 16: return "__metadata"; + case 32: return "__param"; + case 64: return "__awaiter"; + case 128: return "__generator"; } } + function resolveHelpersModule(node, errorNode) { + if (!externalHelpersModule) { + externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol; + } + return externalHelpersModule; + } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyGenericType) { @@ -37308,9 +37347,9 @@ var ts; if (prop.kind === 259) { continue; } - var name_29 = prop.name; - if (name_29.kind === 142) { - checkGrammarComputedPropertyName(name_29); + var name_30 = prop.name; + if (name_30.kind === 142) { + checkGrammarComputedPropertyName(name_30); } if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -37326,8 +37365,8 @@ var ts; var currentKind = void 0; if (prop.kind === 257 || prop.kind === 258) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_29.kind === 8) { - checkGrammarNumericLiteral(name_29); + if (name_30.kind === 8) { + checkGrammarNumericLiteral(name_30); } currentKind = Property; } @@ -37343,7 +37382,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_29); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); if (effectiveName === undefined) { continue; } @@ -37353,18 +37392,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_29, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_29)); + grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -37377,12 +37416,12 @@ var ts; continue; } var jsxAttr = attr; - var name_30 = jsxAttr.name; - if (!seen[name_30.text]) { - seen[name_30.text] = true; + var name_31 = jsxAttr.name; + if (!seen[name_31.text]) { + seen[name_31.text] = true; } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 252 && !initializer.expression) { @@ -38700,10 +38739,10 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_31 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_31, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_32 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_32, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); variable.original = original; - if (ts.isIdentifier(name_31)) { + if (ts.isIdentifier(name_32)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -38849,8 +38888,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_32 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_32); + var name_33 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_33); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -38892,7 +38931,7 @@ var ts; var restHelper = { name: "typescript:rest", scoped: false, - text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" + text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; function createRestCall(context, value, elements, computedTempVariables, location) { context.requestEmitHelper(restHelper); @@ -39762,14 +39801,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_33 = ts.getMutableClone(node); - name_33.flags &= ~8; - name_33.original = undefined; - name_33.parent = currentScope; + var name_34 = ts.getMutableClone(node); + name_34.flags &= ~8; + name_34.original = undefined; + name_34.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_34), ts.createLiteral("undefined")), name_34); } - return name_33; + return name_34; case 141: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -39799,7 +39838,7 @@ var ts; : name.expression; } else if (ts.isIdentifier(name)) { - return ts.createLiteral(name.text); + return ts.createLiteral(ts.unescapeIdentifier(name.text)); } else { return ts.getSynthesizedClone(name); @@ -40040,9 +40079,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_34 = node.symbol && node.symbol.name; - if (name_34) { - return currentScopeFirstDeclarationsOfName[name_34] === node; + var name_35 = node.symbol && node.symbol.name; + if (name_35) { + return currentScopeFirstDeclarationsOfName[name_35] === node; } } return false; @@ -40331,14 +40370,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_35 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_35); + var name_36 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_36); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_35, initializer, node); + return ts.createPropertyAssignment(name_36, initializer, node); } - return ts.createPropertyAssignment(name_35, exportedName, node); + return ts.createPropertyAssignment(name_36, exportedName, node); } } return node; @@ -40859,12 +40898,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_37 = node.tagName; + if (ts.isIdentifier(name_37) && ts.isIntrinsicJsxName(name_37.text)) { + return ts.createLiteral(name_37.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_37); } } } @@ -41997,15 +42036,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); + if (ts.isBindingPattern(name_38)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); } } } @@ -44010,9 +44049,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_38) { - var clone_6 = ts.getMutableClone(name_38); + var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_39) { + var clone_6 = ts.getMutableClone(name_39); ts.setSourceMapRange(clone_6, node); ts.setCommentRange(clone_6, node); return clone_6; @@ -45294,8 +45333,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_39 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); + var name_40 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); } } } @@ -46906,9 +46945,9 @@ var ts; var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name_41 = baseName + "_" + count; + if (!(name_41 in currentIdentifiers)) { + return name_41; } } } @@ -47797,6 +47836,10 @@ var ts; return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 155: + return symbolAccessibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; case 149: case 148: if (ts.hasModifier(node.parent, 32)) { @@ -50404,21 +50447,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name_42 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_42)) { tempFlags |= flags; - return name_41; + return name_42; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name_43 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name_43)) { + return name_43; } } } @@ -50754,10 +50797,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_43 = names_1[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + var name_44 = names_1[_i]; + var result = name_44 in cache + ? cache[name_44] + : cache[name_44] = loader(name_44, containingFile); resolutions.push(result); } return resolutions; @@ -54447,13 +54490,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { - if (nameTable[name_44] === position) { + for (var name_45 in nameTable) { + if (nameTable[name_45] === position) { continue; } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, true); + if (!uniqueNames[name_45]) { + uniqueNames[name_45] = name_45; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -55526,8 +55569,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name_46 = element.propertyName || element.name; + existingImportsOrExports[name_46.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -57662,10 +57705,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_46 in nameToDeclarations) { - var declarations = nameToDeclarations[name_46]; + for (var name_47 in nameToDeclarations) { + var declarations = nameToDeclarations[name_47]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_46); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); if (!matches) { continue; } @@ -57676,14 +57719,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_46); + matches = patternMatcher.getMatches(containers, name_47); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_46, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -57936,9 +57979,9 @@ var ts; case 174: case 223: var decl = node; - var name_47 = decl.name; - if (ts.isBindingPattern(name_47)) { - addChildrenRecursively(name_47); + var name_48 = decl.name; + if (ts.isBindingPattern(name_48)) { + addChildrenRecursively(name_48); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -60728,9 +60771,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_48 in o) { - if (o[name_48] === rule) { - return name_48; + for (var name_49 in o) { + if (o[name_49] === rule) { + return name_49; } } throw new Error("Unknown rule"); @@ -64215,15 +64258,15 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_49 = names_2[_i]; - var resolution = newResolutions[name_49]; + var name_50 = names_2[_i]; + var resolution = newResolutions[name_50]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_49]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_49] = resolution = loader(name_49, containingFile, compilerOptions, this); + newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -64951,9 +64994,7 @@ var ts; else if (hasExplicitListOfFiles) { this.compilerOptions.allowNonTsExtensions = true; } - if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { - this.compilerOptions.noEmitForJsFiles = true; - } + this.setInternalCompilerOptionsForEmittingJsFiles(); this.lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); this.lsHost.setCompilationSettings(this.compilerOptions); this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry); @@ -64975,6 +65016,11 @@ var ts; Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { return this.cachedUnresolvedImportsPerFile; }; + Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; + } + }; Project.prototype.getProjectErrors = function () { return this.projectErrors; }; @@ -65172,9 +65218,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_50 in file.resolvedModules) { - if (!file.resolvedModules[name_50] && !ts.isExternalModuleNameRelative(name_50)) { - var trimmed = name_50.trim(); + for (var name_51 in file.resolvedModules) { + if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { + var trimmed = name_51.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -65288,6 +65334,7 @@ var ts; this.lastCachedUnresolvedImportsList = undefined; } this.compilerOptions = compilerOptions; + this.setInternalCompilerOptionsForEmittingJsFiles(); this.lsHost.setCompilationSettings(compilerOptions); this.markAsDirty(); } @@ -67713,9 +67760,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_51 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_51, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index a93576fd993..bf014f3242b 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -1230,26 +1230,20 @@ declare namespace ts { HasImplicitReturn = 128, HasExplicitReturn = 256, GlobalAugmentation = 512, - HasClassExtends = 1024, - HasDecorators = 2048, - HasParamDecorators = 4096, - HasAsyncFunctions = 8192, - HasSpreadAttribute = 16384, - HasRestAttribute = 32768, - DisallowInContext = 65536, - YieldContext = 131072, - DecoratorContext = 262144, - AwaitContext = 524288, - ThisNodeHasError = 1048576, - JavaScriptFile = 2097152, - ThisNodeOrAnySubNodesHasError = 4194304, - HasAggregatedChildData = 8388608, + HasAsyncFunctions = 1024, + DisallowInContext = 2048, + YieldContext = 4096, + DecoratorContext = 8192, + AwaitContext = 16384, + ThisNodeHasError = 32768, + JavaScriptFile = 65536, + ThisNodeOrAnySubNodesHasError = 131072, + HasAggregatedChildData = 262144, BlockScoped = 3, ReachabilityCheckFlags = 384, - EmitHelperFlags = 64512, - ReachabilityAndEmitFlags = 64896, - ContextFlags = 3080192, - TypeExcludesFlags = 655360, + ReachabilityAndEmitFlags = 1408, + ContextFlags = 96256, + TypeExcludesFlags = 20480, } const enum ModifierFlags { None = 0, @@ -3491,6 +3485,18 @@ declare namespace ts { readonly text: string; readonly priority?: number; } + const enum ExternalEmitHelpers { + Extends = 1, + Assign = 2, + Rest = 4, + Decorate = 8, + Metadata = 16, + Param = 32, + Awaiter = 64, + Generator = 128, + FirstEmitHelper = 1, + LastEmitHelper = 128, + } const enum EmitContext { SourceFile = 0, Expression = 1, @@ -3563,7 +3569,7 @@ declare namespace ts.performance { function disable(): void; } declare namespace ts { - const version = "2.1.3"; + const version = "2.1.4"; } declare namespace ts { const enum Ternary { @@ -5358,6 +5364,12 @@ declare namespace ts { key: string; message: string; }; + This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Type_0_does_not_satisfy_the_constraint_1: { code: number; category: DiagnosticCategory; @@ -5418,6 +5430,12 @@ declare namespace ts { key: string; message: string; }; + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: number; category: DiagnosticCategory; @@ -7254,6 +7272,18 @@ declare namespace ts { key: string; message: string; }; + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; The_current_host_does_not_support_the_0_option: { code: number; category: DiagnosticCategory; @@ -8913,6 +8943,7 @@ declare namespace ts { function isBlockScopedContainerTopLevel(node: Node): boolean; function isGlobalScopeAugmentation(module: ModuleDeclaration): boolean; function isExternalModuleAugmentation(node: Node): boolean; + function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions): boolean; function isBlockScope(node: Node, parentNode: Node): boolean; function getEnclosingBlockScopeContainer(node: Node): Node; function declarationNameToString(name: DeclarationName): string; @@ -11106,6 +11137,7 @@ declare namespace ts.server { isJsOnlyProject(): boolean; getCachedUnresolvedImportsPerFile_TestOnly(): UnresolvedImportsMap; constructor(projectName: string, projectKind: ProjectKind, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, languageServiceEnabled: boolean, compilerOptions: CompilerOptions, compileOnSaveEnabled: boolean); + private setInternalCompilerOptionsForEmittingJsFiles(); getProjectErrors(): Diagnostic[]; getLanguageService(ensureSynchronized?: boolean): LanguageService; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index af13c561eeb..439d1d4d07e 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -137,7 +137,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.3"; + ts.version = "2.1.4"; })(ts || (ts = {})); (function (ts) { var createObject = Object.create; @@ -2673,6 +2673,7 @@ var ts; 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_2340", message: "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_2341", message: "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_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { code: 2343, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", message: "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "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_2345", message: "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_2346", message: "Supplied parameters do not match any signature of call target." }, @@ -2683,6 +2684,7 @@ var ts; Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Type_0_cannot_be_converted_to_type_1: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_converted_to_type_1_2352", message: "Type '{0}' cannot be converted to type '{1}'." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { code: 2354, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", message: "This syntax requires an imported helper but module '{0}' cannot be found." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, @@ -2989,6 +2991,8 @@ var ts; Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { code: 4083, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", message: "Type parameter '{0}' of exported type alias has or is using private name '{1}'." }, Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -6965,17 +6969,17 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 4194304) !== 0; + return (node.flags & 131072) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 8388608)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576) !== 0) || + if (!(node.flags & 262144)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 4194304; + node.flags |= 131072; } - node.flags |= 8388608; + node.flags |= 262144; } } function getSourceFileOfNode(node) { @@ -7199,6 +7203,10 @@ var ts; return false; } ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isEffectiveExternalModule(node, compilerOptions) { + return ts.isExternalModule(node) || compilerOptions.isolatedModules; + } + ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { case 261: @@ -7954,7 +7962,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 2097152); + return node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; function isRequireCall(expression, checkArgumentIsStringLiteral) { @@ -8193,7 +8201,7 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 2097152)) { + if (node && (node.flags & 65536)) { if (node.type && node.type.kind === 275 || ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { return true; @@ -13732,7 +13740,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(5, true); - var disallowInAndDecoratorContext = 65536 | 262144; + var disallowInAndDecoratorContext = 2048 | 8192; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -13780,7 +13788,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 || scriptKind === 2 ? 2097152 : 0; + contextFlags = scriptKind === 1 || scriptKind === 2 ? 65536 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); @@ -13875,16 +13883,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 65536); + setContextFlag(val, 2048); } function setYieldContext(val) { - setContextFlag(val, 131072); + setContextFlag(val, 4096); } function setDecoratorContext(val) { - setContextFlag(val, 262144); + setContextFlag(val, 8192); } function setAwaitContext(val) { - setContextFlag(val, 524288); + setContextFlag(val, 16384); } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; @@ -13907,40 +13915,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(65536, func); + return doOutsideOfContext(2048, func); } function disallowInAnd(func) { - return doInsideOfContext(65536, func); + return doInsideOfContext(2048, func); } function doInYieldContext(func) { - return doInsideOfContext(131072, func); + return doInsideOfContext(4096, func); } function doInDecoratorContext(func) { - return doInsideOfContext(262144, func); + return doInsideOfContext(8192, func); } function doInAwaitContext(func) { - return doInsideOfContext(524288, func); + return doInsideOfContext(16384, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(524288, func); + return doOutsideOfContext(16384, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(131072 | 524288, func); + return doInsideOfContext(4096 | 16384, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(131072); + return inContext(4096); } function inDisallowInContext() { - return inContext(65536); + return inContext(2048); } function inDecoratorContext() { - return inContext(262144); + return inContext(8192); } function inAwaitContext() { - return inContext(524288); + return inContext(16384); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -14102,7 +14110,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 1048576; + node.flags |= 32768; } return node; } @@ -14420,7 +14428,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 3080192; + var nodeContextFlags = node.flags & 96256; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -15228,7 +15236,7 @@ var ts; } } function parseType() { - return doOutsideOfContext(655360, parseTypeWorker); + return doOutsideOfContext(20480, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { @@ -16859,7 +16867,7 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = ts.hasModifier(property, 32) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(131072 | 65536, parseNonParameterInitializer); + : doOutsideOfContext(4096 | 2048, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -18833,7 +18841,7 @@ var ts; activeLabels = undefined; hasExplicitReturn = false; bindChildren(node); - node.flags &= ~64896; + node.flags &= ~1408; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { node.flags |= 128; if (hasExplicitReturn) @@ -20016,9 +20024,6 @@ var ts; return bindParameter(node); case 223: case 174: - if (node.dotDotDotToken && node.parent.kind === 172) { - emitFlags |= 32768; - } return bindVariableDeclarationOrBindingElement(node); case 147: case 146: @@ -20045,7 +20050,6 @@ var ts; } root = root.parent; } - emitFlags |= hasRest ? 32768 : 16384; return; case 153: case 154: @@ -20241,14 +20245,6 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { - emitFlags |= 1024; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048; - } - } if (node.kind === 226) { bindBlockScopedDeclaration(node, 32, 899519); } @@ -20292,11 +20288,6 @@ var ts; } } function bindParameter(node) { - if (!ts.isDeclarationFile(file) && - !ts.isInAmbientContext(node) && - ts.nodeIsDecorated(node)) { - emitFlags |= (2048 | 4096); - } if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } @@ -20314,7 +20305,7 @@ var ts; function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; + emitFlags |= 1024; } } checkStrictModeFunctionName(node); @@ -20329,7 +20320,7 @@ var ts; function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; + emitFlags |= 1024; } } if (currentFlow) { @@ -20342,10 +20333,7 @@ var ts; function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048; + emitFlags |= 1024; } } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -21053,6 +21041,8 @@ var ts; ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { var cancellationToken; + var requestedExternalEmitHelpers; + var externalHelpersModule; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -23381,7 +23371,13 @@ var ts; return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - ts.Debug.assert(!!(source.flags & 32768), "Rest types only support object types right now."); + source = filterType(source, function (t) { return !(t.flags & 6144); }); + if (source.flags & 8192) { + return emptyObjectType; + } + if (source.flags & 65536) { + return mapType(source, function (t) { return getRestType(t, properties, symbol); }); + } var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { @@ -23417,7 +23413,7 @@ var ts; var type; if (pattern.kind === 172) { if (declaration.dotDotDotToken) { - if (!(parentType.flags & 32768)) { + if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return unknownType; } @@ -23495,7 +23491,7 @@ var ts; return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -23514,7 +23510,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 2097152) && + if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { @@ -23575,13 +23571,18 @@ var ts; } function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createMap(); + var stringIndexInfo; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name) || e.dotDotDotToken) { + if (isComputedNonLiteralName(name)) { hasComputedProperties = true; return; } + if (e.dotDotDotToken) { + stringIndexInfo = createIndexInfo(anyType, false); + return; + } var text = ts.getTextOfPropertyName(name); var flags = 4 | 67108864 | (e.initializer ? 536870912 : 0); var symbol = createSymbol(flags, text); @@ -23589,7 +23590,7 @@ var ts; symbol.bindingElement = e; members[symbol.name] = symbol; }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { result.pattern = pattern; } @@ -23654,7 +23655,7 @@ var ts; if (declaration.kind === 240) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 2097152 && declaration.kind === 286 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 286 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -23663,7 +23664,7 @@ var ts; var type = void 0; if (declaration.kind === 192 || declaration.kind === 177 && declaration.parent.kind === 192) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var jsdocType = ts.getJSDocType(declaration.parent); if (jsdocType) { return links.type = getTypeFromTypeNode(jsdocType); @@ -23717,7 +23718,7 @@ var ts; if (!links.type) { var getter = ts.getDeclarationOfKind(symbol, 151); var setter = ts.getDeclarationOfKind(symbol, 152); - if (getter && getter.flags & 2097152) { + if (getter && getter.flags & 65536) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -24588,7 +24589,7 @@ var ts; var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName); var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912); var prop = createSymbol(4 | 67108864 | (isOptional ? 536870912 : 0), propName); - prop.type = addOptionality(propType, isOptional); + prop.type = propType; prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp); members[propName] = prop; } @@ -24609,7 +24610,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) : unknownType); } function getIsomorphicTypeFromMappedType(type) { @@ -24858,7 +24859,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -24886,7 +24887,7 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 2097152) { + if (node.flags & 65536) { if (node.type && node.type.kind === 273) { return true; } @@ -25015,7 +25016,7 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 2097152) { + if (declaration.flags & 65536) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -25822,7 +25823,7 @@ var ts; } var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return addOptionality(instantiateType(getTemplateTypeFromMappedType(type), templateMapper), !!type.declaration.questionToken); + return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (indexType.flags & 16384 || @@ -25898,10 +25899,23 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function getSpreadType(left, right, isFromObjectLiteral) { - ts.Debug.assert(!!(left.flags & (32768 | 1)) && !!(right.flags & (32768 | 1)), "Only object types may be spread."); if (left.flags & 1 || right.flags & 1) { return anyType; } + left = filterType(left, function (t) { return !(t.flags & 6144); }); + if (left.flags & 8192) { + return right; + } + right = filterType(right, function (t) { return !(t.flags & 6144); }); + if (right.flags & 8192) { + return left; + } + if (left.flags & 65536) { + return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + } + if (right.flags & 65536) { + return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); var stringIndexInfo; @@ -27826,6 +27840,8 @@ var ts; var typeInferences = createTypeInferencesObject(); var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); + var readonlyMask = target.declaration.readonlyToken ? false : true; + var optionalMask = target.declaration.questionToken ? 0 : 536870912; var properties = getPropertiesOfType(source); var members = createSymbolTable(properties); var hasInferredTypes = false; @@ -27833,10 +27849,10 @@ var ts; var prop = properties_4[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (inferredPropType) { - var inferredProp = createSymbol(4 | 67108864 | prop.flags & 536870912, prop.name); + var inferredProp = createSymbol(4 | 67108864 | prop.flags & optionalMask, prop.name); inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = isReadonlySymbol(prop); + inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); members[prop.name] = inferredProp; hasInferredTypes = true; } @@ -27845,7 +27861,7 @@ var ts; if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); if (inferredIndexType) { - indexInfo = createIndexInfo(inferredIndexType, indexInfo.isReadonly); + indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly); hasInferredTypes = true; } } @@ -29182,7 +29198,7 @@ var ts; error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 524288) { + if (node.flags & 16384) { getNodeLinks(container).flags |= 8192; } return getTypeOfSymbol(symbol); @@ -30095,7 +30111,7 @@ var ts; if (impliedProp) { prop.flags |= impliedProp.flags & 536870912; } - else if (!compilerOptions.suppressExcessPropertyErrors) { + else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); } } @@ -30109,6 +30125,9 @@ var ts; member = prop; } else if (memberDecl.kind === 259) { + if (languageVersion < 5) { + checkExternalEmitHelpers(memberDecl, 2); + } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), true); propertiesArray = []; @@ -30118,7 +30137,7 @@ var ts; typeFlags = 0; } var type = checkExpression(memberDecl.expression); - if (!(type.flags & (32768 | 1))) { + if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } @@ -30183,6 +30202,11 @@ var ts; return result; } } + function isValidSpreadType(type) { + return !!(type.flags & (1 | 4096 | 2048) || + type.flags & 32768 && !isGenericMappedType(type) || + type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); return jsxElementType || anyType; @@ -30257,6 +30281,9 @@ var ts; return exprType; } function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + if (compilerOptions.jsx === 2) { + checkExternalEmitHelpers(node, 2); + } var type = checkExpression(node.expression); var props = getPropertiesOfType(type); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { @@ -32003,7 +32030,7 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 524288)) { + if (!(node.flags & 16384)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -32161,6 +32188,9 @@ var ts; } } else if (property.kind === 259) { + if (languageVersion < 5) { + checkExternalEmitHelpers(property, 4); + } var nonRestNames = []; if (allProperties) { for (var i = 0; i < allProperties.length - 1; i++) { @@ -32511,7 +32541,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 131072) || isYieldExpressionInClass(node)) { + if (!(node.flags & 4096) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -32887,6 +32917,12 @@ var ts; node.kind === 154) { checkGrammarFunctionLikeDeclaration(node); } + if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { + checkExternalEmitHelpers(node, 64); + if (languageVersion < 2) { + checkExternalEmitHelpers(node, 128); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -33681,7 +33717,13 @@ var ts; if (!compilerOptions.experimentalDecorators) { error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } + var firstDecorator = node.decorators[0]; + checkExternalEmitHelpers(firstDecorator, 8); + if (node.kind === 144) { + checkExternalEmitHelpers(firstDecorator, 32); + } if (compilerOptions.emitDecoratorMetadata) { + checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { case 226: var constructor = ts.getFirstConstructorWithBody(node); @@ -33998,14 +34040,14 @@ var ts; } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "Promise")) { + if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } if (node.kind === 230 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192) { + if (parent.kind === 261 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -34102,6 +34144,9 @@ var ts; } } if (node.kind === 174) { + if (node.parent.kind === 172 && languageVersion < 5) { + checkExternalEmitHelpers(node, 4); + } if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } @@ -34511,7 +34556,7 @@ var ts; } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 524288) { + if (node.flags & 16384) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -34757,6 +34802,9 @@ var ts; checkClassForDuplicateDeclarations(node); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { + if (languageVersion < 2) { + checkExternalEmitHelpers(baseTypeNode.parent, 1); + } var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; @@ -36664,8 +36712,6 @@ var ts; ts.bindSourceFile(file, compilerOptions); } var augmentations; - var requestedExternalEmitHelpers = 0; - var firstFileRequestingExternalHelpers; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; if (!ts.isExternalOrCommonJsModule(file)) { @@ -36685,15 +36731,6 @@ var ts; } } } - if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 64512; - if (fileRequestedExternalEmitHelpers) { - requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; - if (firstFileRequestingExternalHelpers === undefined) { - firstFileRequestingExternalHelpers = file; - } - } - } } if (augmentations) { for (var _d = 0, augmentations_1 = augmentations; _d < augmentations_1.length; _d++) { @@ -36748,44 +36785,46 @@ var ts; var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; - if (compilerOptions.importHelpers && firstFileRequestingExternalHelpers) { - var helpersModule = resolveExternalModule(firstFileRequestingExternalHelpers, ts.externalHelpersModuleNameText, ts.Diagnostics.Cannot_find_module_0, undefined); - if (helpersModule) { - var exports_2 = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 && languageVersion < 2) { - verifyHelperSymbol(exports_2, "__extends", 107455); - } - if (requestedExternalEmitHelpers & 16384 && - (languageVersion < 5 || compilerOptions.jsx === 2)) { - verifyHelperSymbol(exports_2, "__assign", 107455); - } - if (languageVersion < 5 && requestedExternalEmitHelpers & 32768) { - verifyHelperSymbol(exports_2, "__rest", 107455); - } - if (requestedExternalEmitHelpers & 2048) { - verifyHelperSymbol(exports_2, "__decorate", 107455); - if (compilerOptions.emitDecoratorMetadata) { - verifyHelperSymbol(exports_2, "__metadata", 107455); - } - } - if (requestedExternalEmitHelpers & 4096) { - verifyHelperSymbol(exports_2, "__param", 107455); - } - if (requestedExternalEmitHelpers & 8192) { - verifyHelperSymbol(exports_2, "__awaiter", 107455); - if (languageVersion < 2) { - verifyHelperSymbol(exports_2, "__generator", 107455); + } + function checkExternalEmitHelpers(location, helpers) { + if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { + var sourceFile = ts.getSourceFileOfNode(location); + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var helpersModule = resolveHelpersModule(sourceFile, location); + if (helpersModule !== unknownSymbol) { + var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; + for (var helper = 1; helper <= 128; helper <<= 1) { + if (uncheckedHelpers & helper) { + var name_29 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_29), 107455); + if (!symbol) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_29); + } + } } } + requestedExternalEmitHelpers |= helpers; } } } - function verifyHelperSymbol(symbols, name, meaning) { - var symbol = getSymbol(symbols, ts.escapeIdentifier(name), meaning); - if (!symbol) { - error(undefined, ts.Diagnostics.Module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + function getHelperName(helper) { + switch (helper) { + case 1: return "__extends"; + case 2: return "__assign"; + case 4: return "__rest"; + case 8: return "__decorate"; + case 16: return "__metadata"; + case 32: return "__param"; + case 64: return "__awaiter"; + case 128: return "__generator"; } } + function resolveHelpersModule(node, errorNode) { + if (!externalHelpersModule) { + externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol; + } + return externalHelpersModule; + } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyGenericType) { @@ -37308,9 +37347,9 @@ var ts; if (prop.kind === 259) { continue; } - var name_29 = prop.name; - if (name_29.kind === 142) { - checkGrammarComputedPropertyName(name_29); + var name_30 = prop.name; + if (name_30.kind === 142) { + checkGrammarComputedPropertyName(name_30); } if (prop.kind === 258 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -37326,8 +37365,8 @@ var ts; var currentKind = void 0; if (prop.kind === 257 || prop.kind === 258) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_29.kind === 8) { - checkGrammarNumericLiteral(name_29); + if (name_30.kind === 8) { + checkGrammarNumericLiteral(name_30); } currentKind = Property; } @@ -37343,7 +37382,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_29); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); if (effectiveName === undefined) { continue; } @@ -37353,18 +37392,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_29, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_29)); + grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -37377,12 +37416,12 @@ var ts; continue; } var jsxAttr = attr; - var name_30 = jsxAttr.name; - if (!seen[name_30.text]) { - seen[name_30.text] = true; + var name_31 = jsxAttr.name; + if (!seen[name_31.text]) { + seen[name_31.text] = true; } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 252 && !initializer.expression) { @@ -38700,10 +38739,10 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_31 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_31, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_32 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_32, undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); variable.original = original; - if (ts.isIdentifier(name_31)) { + if (ts.isIdentifier(name_32)) { ts.setEmitFlags(variable, 64); } ts.aggregateTransformFlags(variable); @@ -38849,8 +38888,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_32 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_32); + var name_33 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_33); } } function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { @@ -38892,7 +38931,7 @@ var ts; var restHelper = { name: "typescript:rest", scoped: false, - text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" + text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; function createRestCall(context, value, elements, computedTempVariables, location) { context.requestEmitHelper(restHelper); @@ -39762,14 +39801,14 @@ var ts; function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { case 70: - var name_33 = ts.getMutableClone(node); - name_33.flags &= ~8; - name_33.original = undefined; - name_33.parent = currentScope; + var name_34 = ts.getMutableClone(node); + name_34.flags &= ~8; + name_34.original = undefined; + name_34.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_33), ts.createLiteral("undefined")), name_33); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_34), ts.createLiteral("undefined")), name_34); } - return name_33; + return name_34; case 141: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -39799,7 +39838,7 @@ var ts; : name.expression; } else if (ts.isIdentifier(name)) { - return ts.createLiteral(name.text); + return ts.createLiteral(ts.unescapeIdentifier(name.text)); } else { return ts.getSynthesizedClone(name); @@ -40040,9 +40079,9 @@ var ts; } function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_34 = node.symbol && node.symbol.name; - if (name_34) { - return currentScopeFirstDeclarationsOfName[name_34] === node; + var name_35 = node.symbol && node.symbol.name; + if (name_35) { + return currentScopeFirstDeclarationsOfName[name_35] === node; } } return false; @@ -40331,14 +40370,14 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2) { - var name_35 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_35); + var name_36 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_36); if (exportedName) { if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_35, initializer, node); + return ts.createPropertyAssignment(name_36, initializer, node); } - return ts.createPropertyAssignment(name_35, exportedName, node); + return ts.createPropertyAssignment(name_36, exportedName, node); } } return node; @@ -40859,12 +40898,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_36 = node.tagName; - if (ts.isIdentifier(name_36) && ts.isIntrinsicJsxName(name_36.text)) { - return ts.createLiteral(name_36.text); + var name_37 = node.tagName; + if (ts.isIdentifier(name_37) && ts.isIntrinsicJsxName(name_37.text)) { + return ts.createLiteral(name_37.text); } else { - return ts.createExpressionFromEntityName(name_36); + return ts.createExpressionFromEntityName(name_37); } } } @@ -41997,15 +42036,15 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_37 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_38 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_37)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); + if (ts.isBindingPattern(name_38)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_38, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_38, initializer); } } } @@ -44010,9 +44049,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_38) { - var clone_6 = ts.getMutableClone(name_38); + var name_39 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_39) { + var clone_6 = ts.getMutableClone(name_39); ts.setSourceMapRange(clone_6, node); ts.setCommentRange(clone_6, node); return clone_6; @@ -45294,8 +45333,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_39 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); + var name_40 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_40), node); } } } @@ -46906,9 +46945,9 @@ var ts; var count = 0; while (true) { count++; - var name_40 = baseName + "_" + count; - if (!(name_40 in currentIdentifiers)) { - return name_40; + var name_41 = baseName + "_" + count; + if (!(name_41 in currentIdentifiers)) { + return name_41; } } } @@ -47797,6 +47836,10 @@ var ts; return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 155: + return symbolAccessibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; case 149: case 148: if (ts.hasModifier(node.parent, 32)) { @@ -50404,21 +50447,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_41 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_41)) { + var name_42 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_42)) { tempFlags |= flags; - return name_41; + return name_42; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_42 = count < 26 + var name_43 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_42)) { - return name_42; + if (isUniqueName(name_43)) { + return name_43; } } } @@ -50754,10 +50797,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_43 = names_1[_i]; - var result = name_43 in cache - ? cache[name_43] - : cache[name_43] = loader(name_43, containingFile); + var name_44 = names_1[_i]; + var result = name_44 in cache + ? cache[name_44] + : cache[name_44] = loader(name_44, containingFile); resolutions.push(result); } return resolutions; @@ -54447,13 +54490,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_44 in nameTable) { - if (nameTable[name_44] === position) { + for (var name_45 in nameTable) { + if (nameTable[name_45] === position) { continue; } - if (!uniqueNames[name_44]) { - uniqueNames[name_44] = name_44; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, true); + if (!uniqueNames[name_45]) { + uniqueNames[name_45] = name_45; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_45), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -55526,8 +55569,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_45 = element.propertyName || element.name; - existingImportsOrExports[name_45.text] = true; + var name_46 = element.propertyName || element.name; + existingImportsOrExports[name_46.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -57662,10 +57705,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_46 in nameToDeclarations) { - var declarations = nameToDeclarations[name_46]; + for (var name_47 in nameToDeclarations) { + var declarations = nameToDeclarations[name_47]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_46); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); if (!matches) { continue; } @@ -57676,14 +57719,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_46); + matches = patternMatcher.getMatches(containers, name_47); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_46, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -57936,9 +57979,9 @@ var ts; case 174: case 223: var decl = node; - var name_47 = decl.name; - if (ts.isBindingPattern(name_47)) { - addChildrenRecursively(name_47); + var name_48 = decl.name; + if (ts.isBindingPattern(name_48)) { + addChildrenRecursively(name_48); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -60728,9 +60771,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_48 in o) { - if (o[name_48] === rule) { - return name_48; + for (var name_49 in o) { + if (o[name_49] === rule) { + return name_49; } } throw new Error("Unknown rule"); @@ -64215,15 +64258,15 @@ var ts; var compilerOptions = this.getCompilationSettings(); var lastDeletedFileName = this.project.projectService.lastDeletedFile && this.project.projectService.lastDeletedFile.fileName; for (var _i = 0, names_2 = names; _i < names_2.length; _i++) { - var name_49 = names_2[_i]; - var resolution = newResolutions[name_49]; + var name_50 = names_2[_i]; + var resolution = newResolutions[name_50]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_49]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_50]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_49] = resolution = loader(name_49, containingFile, compilerOptions, this); + newResolutions[name_50] = resolution = loader(name_50, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -64951,9 +64994,7 @@ var ts; else if (hasExplicitListOfFiles) { this.compilerOptions.allowNonTsExtensions = true; } - if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { - this.compilerOptions.noEmitForJsFiles = true; - } + this.setInternalCompilerOptionsForEmittingJsFiles(); this.lsHost = new server.LSHost(this.projectService.host, this, this.projectService.cancellationToken); this.lsHost.setCompilationSettings(this.compilerOptions); this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry); @@ -64975,6 +65016,11 @@ var ts; Project.prototype.getCachedUnresolvedImportsPerFile_TestOnly = function () { return this.cachedUnresolvedImportsPerFile; }; + Project.prototype.setInternalCompilerOptionsForEmittingJsFiles = function () { + if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) { + this.compilerOptions.noEmitForJsFiles = true; + } + }; Project.prototype.getProjectErrors = function () { return this.projectErrors; }; @@ -65172,9 +65218,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_50 in file.resolvedModules) { - if (!file.resolvedModules[name_50] && !ts.isExternalModuleNameRelative(name_50)) { - var trimmed = name_50.trim(); + for (var name_51 in file.resolvedModules) { + if (!file.resolvedModules[name_51] && !ts.isExternalModuleNameRelative(name_51)) { + var trimmed = name_51.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -65288,6 +65334,7 @@ var ts; this.lastCachedUnresolvedImportsList = undefined; } this.compilerOptions = compilerOptions; + this.setInternalCompilerOptionsForEmittingJsFiles(); this.lsHost.setCompilationSettings(compilerOptions); this.markAsDirty(); } @@ -67713,9 +67760,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_51 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_52 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; var convertedSpan = replacementSpan ? _this.decorateSpan(replacementSpan, scriptInfo) : undefined; - result.push({ name: name_51, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_52, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 4414efb805f..a3a005c12d7 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -378,26 +378,20 @@ declare namespace ts { HasImplicitReturn = 128, HasExplicitReturn = 256, GlobalAugmentation = 512, - HasClassExtends = 1024, - HasDecorators = 2048, - HasParamDecorators = 4096, - HasAsyncFunctions = 8192, - HasSpreadAttribute = 16384, - HasRestAttribute = 32768, - DisallowInContext = 65536, - YieldContext = 131072, - DecoratorContext = 262144, - AwaitContext = 524288, - ThisNodeHasError = 1048576, - JavaScriptFile = 2097152, - ThisNodeOrAnySubNodesHasError = 4194304, - HasAggregatedChildData = 8388608, + HasAsyncFunctions = 1024, + DisallowInContext = 2048, + YieldContext = 4096, + DecoratorContext = 8192, + AwaitContext = 16384, + ThisNodeHasError = 32768, + JavaScriptFile = 65536, + ThisNodeOrAnySubNodesHasError = 131072, + HasAggregatedChildData = 262144, BlockScoped = 3, ReachabilityCheckFlags = 384, - EmitHelperFlags = 64512, - ReachabilityAndEmitFlags = 64896, - ContextFlags = 3080192, - TypeExcludesFlags = 655360, + ReachabilityAndEmitFlags = 1408, + ContextFlags = 96256, + TypeExcludesFlags = 20480, } enum ModifierFlags { None = 0, @@ -2145,7 +2139,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.1.3"; + const version = "2.1.4"; } declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; diff --git a/lib/typescript.js b/lib/typescript.js index 29a7baad1a1..cf735e4a3bc 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -399,28 +399,22 @@ var ts; NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; - NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; - NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["HasSpreadAttribute"] = 16384] = "HasSpreadAttribute"; - NodeFlags[NodeFlags["HasRestAttribute"] = 32768] = "HasRestAttribute"; - NodeFlags[NodeFlags["DisallowInContext"] = 65536] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 131072] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 262144] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 524288] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 1048576] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 2097152] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 4194304] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 8388608] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 64512] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 64896] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 3080192] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 655360] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -1066,6 +1060,24 @@ var ts; EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + /** + * Used by the checker, this enum keeps track of external emit helpers that should be type + * checked. + */ + /* @internal */ + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); /* @internal */ var EmitContext; (function (EmitContext) { @@ -1174,7 +1186,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.1.3"; + ts.version = "2.1.4"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -4110,6 +4122,7 @@ var ts; 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_2340", message: "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_2341", message: "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_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { code: 2343, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", message: "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "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_2345", message: "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_2346", message: "Supplied parameters do not match any signature of call target." }, @@ -4120,6 +4133,7 @@ var ts; Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Type_0_cannot_be_converted_to_type_1: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_converted_to_type_1_2352", message: "Type '{0}' cannot be converted to type '{1}'." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { code: 2354, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", message: "This syntax requires an imported helper but module '{0}' cannot be found." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, @@ -4426,6 +4440,8 @@ var ts; Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { code: 4083, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", message: "Type parameter '{0}' of exported type alias has or is using private name '{1}'." }, Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -6492,24 +6508,24 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 4194304 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 8388608 /* HasAggregatedChildData */)) { + if (!(node.flags & 262144 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 4194304 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 8388608 /* HasAggregatedChildData */; + node.flags |= 262144 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { @@ -6774,6 +6790,10 @@ var ts; return false; } ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isEffectiveExternalModule(node, compilerOptions) { + return ts.isExternalModule(node) || compilerOptions.isolatedModules; + } + ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { case 261 /* SourceFile */: @@ -7601,7 +7621,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 2097152 /* JavaScriptFile */); + return node && !!(node.flags & 65536 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** @@ -7867,7 +7887,7 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 2097152 /* JavaScriptFile */)) { + if (node && (node.flags & 65536 /* JavaScriptFile */)) { if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { return true; @@ -14335,7 +14355,7 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 65536 /* DisallowInContext */ | 262144 /* DecoratorContext */; + var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; var TokenConstructor; @@ -14459,7 +14479,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 2097152 /* JavaScriptFile */ : 0 /* None */; + contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 65536 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -14567,16 +14587,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 65536 /* DisallowInContext */); + setContextFlag(val, 2048 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 131072 /* YieldContext */); + setContextFlag(val, 4096 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 262144 /* DecoratorContext */); + setContextFlag(val, 8192 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 524288 /* AwaitContext */); + setContextFlag(val, 16384 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -14617,40 +14637,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(65536 /* DisallowInContext */, func); + return doOutsideOfContext(2048 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(65536 /* DisallowInContext */, func); + return doInsideOfContext(2048 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(131072 /* YieldContext */, func); + return doInsideOfContext(4096 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(262144 /* DecoratorContext */, func); + return doInsideOfContext(8192 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(524288 /* AwaitContext */, func); + return doInsideOfContext(16384 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(524288 /* AwaitContext */, func); + return doOutsideOfContext(16384 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(131072 /* YieldContext */ | 524288 /* AwaitContext */, func); + return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(131072 /* YieldContext */); + return inContext(4096 /* YieldContext */); } function inDisallowInContext() { - return inContext(65536 /* DisallowInContext */); + return inContext(2048 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(262144 /* DecoratorContext */); + return inContext(8192 /* DecoratorContext */); } function inAwaitContext() { - return inContext(524288 /* AwaitContext */); + return inContext(16384 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -14854,7 +14874,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 1048576 /* ThisNodeHasError */; + node.flags |= 32768 /* ThisNodeHasError */; } return node; } @@ -15248,7 +15268,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 3080192 /* ContextFlags */; + var nodeContextFlags = node.flags & 96256 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -16253,7 +16273,7 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(655360 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { @@ -18363,7 +18383,7 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = ts.hasModifier(property, 32 /* Static */) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(131072 /* YieldContext */ | 65536 /* DisallowInContext */, parseNonParameterInitializer); + : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -20844,8 +20864,7 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - // Reset all emit helper flags on node (for incremental scenarios) - node.flags &= ~64896 /* ReachabilityAndEmitFlags */; + node.flags &= ~1408 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { node.flags |= 128 /* HasImplicitReturn */; if (hasExplicitReturn) @@ -22158,9 +22177,6 @@ var ts; return bindParameter(node); case 223 /* VariableDeclaration */: case 174 /* BindingElement */: - if (node.dotDotDotToken && node.parent.kind === 172 /* ObjectBindingPattern */) { - emitFlags |= 32768 /* HasRestAttribute */; - } return bindVariableDeclarationOrBindingElement(node); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: @@ -22187,7 +22203,6 @@ var ts; } root = root.parent; } - emitFlags |= hasRest ? 32768 /* HasRestAttribute */ : 16384 /* HasSpreadAttribute */; return; case 153 /* CallSignature */: case 154 /* ConstructSignature */: @@ -22413,14 +22428,6 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { - emitFlags |= 1024 /* HasClassExtends */; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048 /* HasDecorators */; - } - } if (node.kind === 226 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } @@ -22483,11 +22490,6 @@ var ts; } } function bindParameter(node) { - if (!ts.isDeclarationFile(file) && - !ts.isInAmbientContext(node) && - ts.nodeIsDecorated(node)) { - emitFlags |= (2048 /* HasDecorators */ | 4096 /* HasParamDecorators */); - } if (inStrictMode) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) @@ -22509,7 +22511,7 @@ var ts; function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192 /* HasAsyncFunctions */; + emitFlags |= 1024 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); @@ -22524,7 +22526,7 @@ var ts; function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192 /* HasAsyncFunctions */; + emitFlags |= 1024 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -22537,10 +22539,7 @@ var ts; function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192 /* HasAsyncFunctions */; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048 /* HasDecorators */; + emitFlags |= 1024 /* HasAsyncFunctions */; } } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -24132,6 +24131,8 @@ var ts; // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if // they no longer need the information (for example, if the user started editing again). var cancellationToken; + var requestedExternalEmitHelpers; + var externalHelpersModule; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -26872,7 +26873,13 @@ var ts; return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - ts.Debug.assert(!!(source.flags & 32768 /* Object */), "Rest types only support object types right now."); + source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); + if (source.flags & 8192 /* Never */) { + return emptyObjectType; + } + if (source.flags & 65536 /* Union */) { + return mapType(source, function (t) { return getRestType(t, properties, symbol); }); + } var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { @@ -26913,7 +26920,7 @@ var ts; var type; if (pattern.kind === 172 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { - if (!(parentType.flags & 32768 /* Object */)) { + if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return unknownType; } @@ -27003,7 +27010,7 @@ var ts; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. @@ -27032,7 +27039,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 2097152 /* JavaScriptFile */) && + if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, @@ -27109,14 +27116,19 @@ var ts; // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createMap(); + var stringIndexInfo; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name) || e.dotDotDotToken) { - // do not include computed properties or rests in the implied type + if (isComputedNonLiteralName(name)) { + // do not include computed properties in the implied type hasComputedProperties = true; return; } + if (e.dotDotDotToken) { + stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + return; + } var text = ts.getTextOfPropertyName(name); var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); var symbol = createSymbol(flags, text); @@ -27124,7 +27136,7 @@ var ts; symbol.bindingElement = e; members[symbol.name] = symbol; }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { result.pattern = pattern; } @@ -27215,7 +27227,7 @@ var ts; if (declaration.kind === 240 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 2097152 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27231,7 +27243,7 @@ var ts; if (declaration.kind === 192 /* BinaryExpression */ || declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { var jsdocType = ts.getJSDocType(declaration.parent); if (jsdocType) { return links.type = getTypeFromTypeNode(jsdocType); @@ -27287,7 +27299,7 @@ var ts; if (!links.type) { var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); - if (getter && getter.flags & 2097152 /* JavaScriptFile */) { + if (getter && getter.flags & 65536 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -28252,7 +28264,7 @@ var ts; var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName); var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912 /* Optional */); var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); - prop.type = addOptionality(propType, isOptional); + prop.type = propType; prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp); members[propName] = prop; } @@ -28273,7 +28285,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) : unknownType); } function getIsomorphicTypeFromMappedType(type) { @@ -28563,7 +28575,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -28593,7 +28605,7 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 2097152 /* JavaScriptFile */) { + if (node.flags & 65536 /* JavaScriptFile */) { if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { return true; } @@ -28729,7 +28741,7 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -29611,7 +29623,7 @@ var ts; } var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return addOptionality(instantiateType(getTemplateTypeFromMappedType(type), templateMapper), !!type.declaration.questionToken); + return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (indexType.flags & 16384 /* TypeParameter */ || @@ -29703,10 +29715,23 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, isFromObjectLiteral) { - ts.Debug.assert(!!(left.flags & (32768 /* Object */ | 1 /* Any */)) && !!(right.flags & (32768 /* Object */ | 1 /* Any */)), "Only object types may be spread."); if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } + left = filterType(left, function (t) { return !(t.flags & 6144 /* Nullable */); }); + if (left.flags & 8192 /* Never */) { + return right; + } + right = filterType(right, function (t) { return !(t.flags & 6144 /* Nullable */); }); + if (right.flags & 8192 /* Never */) { + return left; + } + if (left.flags & 65536 /* Union */) { + return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + } + if (right.flags & 65536 /* Union */) { + return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); var stringIndexInfo; @@ -31872,6 +31897,8 @@ var ts; var typeInferences = createTypeInferencesObject(); var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); + var readonlyMask = target.declaration.readonlyToken ? false : true; + var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */; var properties = getPropertiesOfType(source); var members = createSymbolTable(properties); var hasInferredTypes = false; @@ -31879,10 +31906,10 @@ var ts; var prop = properties_4[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (inferredPropType) { - var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & 536870912 /* Optional */, prop.name); + var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name); inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = isReadonlySymbol(prop); + inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); members[prop.name] = inferredProp; hasInferredTypes = true; } @@ -31891,7 +31918,7 @@ var ts; if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); if (inferredIndexType) { - indexInfo = createIndexInfo(inferredIndexType, indexInfo.isReadonly); + indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly); hasInferredTypes = true; } } @@ -33414,7 +33441,7 @@ var ts; error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 524288 /* AwaitContext */) { + if (node.flags & 16384 /* AwaitContext */) { getNodeLinks(container).flags |= 8192 /* CaptureArguments */; } return getTypeOfSymbol(symbol); @@ -34604,7 +34631,7 @@ var ts; if (impliedProp) { prop.flags |= impliedProp.flags & 536870912 /* Optional */; } - else if (!compilerOptions.suppressExcessPropertyErrors) { + else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0 /* String */)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); } } @@ -34618,6 +34645,9 @@ var ts; member = prop; } else if (memberDecl.kind === 259 /* SpreadAssignment */) { + if (languageVersion < 5 /* ESNext */) { + checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); propertiesArray = []; @@ -34627,7 +34657,7 @@ var ts; typeFlags = 0; } var type = checkExpression(memberDecl.expression); - if (!(type.flags & (32768 /* Object */ | 1 /* Any */))) { + if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } @@ -34699,6 +34729,11 @@ var ts; return result; } } + function isValidSpreadType(type) { + return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */) || + type.flags & 32768 /* Object */ && !isGenericMappedType(type) || + type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); return jsxElementType || anyType; @@ -34788,6 +34823,9 @@ var ts; return exprType; } function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + if (compilerOptions.jsx === 2 /* React */) { + checkExternalEmitHelpers(node, 2 /* Assign */); + } var type = checkExpression(node.expression); var props = getPropertiesOfType(type); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { @@ -37085,7 +37123,7 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 524288 /* AwaitContext */)) { + if (!(node.flags & 16384 /* AwaitContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -37262,6 +37300,9 @@ var ts; } } else if (property.kind === 259 /* SpreadAssignment */) { + if (languageVersion < 5 /* ESNext */) { + checkExternalEmitHelpers(property, 4 /* Rest */); + } var nonRestNames = []; if (allProperties) { for (var i = 0; i < allProperties.length - 1; i++) { @@ -37658,7 +37699,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 131072 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -38088,6 +38129,12 @@ var ts; node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } + if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 64 /* Awaiter */); + if (languageVersion < 2 /* ES2015 */) { + checkExternalEmitHelpers(node, 128 /* Generator */); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -39088,7 +39135,13 @@ var ts; if (!compilerOptions.experimentalDecorators) { error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } + var firstDecorator = node.decorators[0]; + checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); + if (node.kind === 144 /* Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + } if (compilerOptions.emitDecoratorMetadata) { + checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { case 226 /* ClassDeclaration */: @@ -39441,7 +39494,7 @@ var ts; } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "Promise")) { + if (languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check @@ -39450,7 +39503,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192 /* HasAsyncFunctions */) { + if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39598,6 +39651,9 @@ var ts; } } if (node.kind === 174 /* BindingElement */) { + if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + checkExternalEmitHelpers(node, 4 /* Rest */); + } // check computed properties inside property names of binding elements if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); @@ -40136,7 +40192,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 524288 /* AwaitContext */) { + if (node.flags & 16384 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -40407,6 +40463,9 @@ var ts; checkClassForDuplicateDeclarations(node); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { + if (languageVersion < 2 /* ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + } var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; @@ -42606,8 +42665,6 @@ var ts; } // Initialize global symbol table var augmentations; - var requestedExternalEmitHelpers = 0; - var firstFileRequestingExternalHelpers; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; if (!ts.isExternalOrCommonJsModule(file)) { @@ -42628,15 +42685,6 @@ var ts; } } } - if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 64512 /* EmitHelperFlags */; - if (fileRequestedExternalEmitHelpers) { - requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; - if (firstFileRequestingExternalHelpers === undefined) { - firstFileRequestingExternalHelpers = file; - } - } - } } if (augmentations) { // merge module augmentations. @@ -42695,50 +42743,46 @@ var ts; var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; - // If we have specified that we are importing helpers, we should report global - // errors if we cannot resolve the helpers external module, or if it does not have - // the necessary helpers exported. - if (compilerOptions.importHelpers && firstFileRequestingExternalHelpers) { - // Find the first reference to the helpers module. - var helpersModule = resolveExternalModule(firstFileRequestingExternalHelpers, ts.externalHelpersModuleNameText, ts.Diagnostics.Cannot_find_module_0, - /*errorNode*/ undefined); - // If we found the module, report errors if it does not have the necessary exports. - if (helpersModule) { - var exports = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { - verifyHelperSymbol(exports, "__extends", 107455 /* Value */); - } - if (requestedExternalEmitHelpers & 16384 /* HasSpreadAttribute */ && - (languageVersion < 5 /* ESNext */ || compilerOptions.jsx === 2 /* React */)) { - verifyHelperSymbol(exports, "__assign", 107455 /* Value */); - } - if (languageVersion < 5 /* ESNext */ && requestedExternalEmitHelpers & 32768 /* HasRestAttribute */) { - verifyHelperSymbol(exports, "__rest", 107455 /* Value */); - } - if (requestedExternalEmitHelpers & 2048 /* HasDecorators */) { - verifyHelperSymbol(exports, "__decorate", 107455 /* Value */); - if (compilerOptions.emitDecoratorMetadata) { - verifyHelperSymbol(exports, "__metadata", 107455 /* Value */); - } - } - if (requestedExternalEmitHelpers & 4096 /* HasParamDecorators */) { - verifyHelperSymbol(exports, "__param", 107455 /* Value */); - } - if (requestedExternalEmitHelpers & 8192 /* HasAsyncFunctions */) { - verifyHelperSymbol(exports, "__awaiter", 107455 /* Value */); - if (languageVersion < 2 /* ES2015 */) { - verifyHelperSymbol(exports, "__generator", 107455 /* Value */); + } + function checkExternalEmitHelpers(location, helpers) { + if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { + var sourceFile = ts.getSourceFileOfNode(location); + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var helpersModule = resolveHelpersModule(sourceFile, location); + if (helpersModule !== unknownSymbol) { + var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; + for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { + if (uncheckedHelpers & helper) { + var name_27 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455 /* Value */); + if (!symbol) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + } + } } } + requestedExternalEmitHelpers |= helpers; } } } - function verifyHelperSymbol(symbols, name, meaning) { - var symbol = getSymbol(symbols, ts.escapeIdentifier(name), meaning); - if (!symbol) { - error(/*location*/ undefined, ts.Diagnostics.Module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + function getHelperName(helper) { + switch (helper) { + case 1 /* Extends */: return "__extends"; + case 2 /* Assign */: return "__assign"; + case 4 /* Rest */: return "__rest"; + case 8 /* Decorate */: return "__decorate"; + case 16 /* Metadata */: return "__metadata"; + case 32 /* Param */: return "__param"; + case 64 /* Awaiter */: return "__awaiter"; + case 128 /* Generator */: return "__generator"; } } + function resolveHelpersModule(node, errorNode) { + if (!externalHelpersModule) { + externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol; + } + return externalHelpersModule; + } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyGenericType) { @@ -43273,10 +43317,10 @@ var ts; if (prop.kind === 259 /* SpreadAssignment */) { continue; } - var name_27 = prop.name; - if (name_27.kind === 142 /* ComputedPropertyName */) { + var name_28 = prop.name; + if (name_28.kind === 142 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_27); + checkGrammarComputedPropertyName(name_28); } if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern @@ -43304,8 +43348,8 @@ var ts; if (prop.kind === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_27); + if (name_28.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_28); } currentKind = Property; } @@ -43321,7 +43365,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); if (effectiveName === undefined) { continue; } @@ -43331,18 +43375,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -43355,12 +43399,12 @@ var ts; continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_29 = jsxAttr.name; + if (!seen[name_29.text]) { + seen[name_29.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { @@ -44879,11 +44923,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_29 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_29, + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_30, /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); variable.original = original; - if (ts.isIdentifier(name_29)) { + if (ts.isIdentifier(name_30)) { ts.setEmitFlags(variable, 64 /* NoNestedSourceMaps */); } ts.aggregateTransformFlags(variable); @@ -45087,8 +45131,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_30 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_30); + var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_31); } } /** @@ -45141,7 +45185,7 @@ var ts; var restHelper = { name: "typescript:rest", scoped: false, - text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" + text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ @@ -46712,14 +46756,14 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_31 = ts.getMutableClone(node); - name_31.flags &= ~8 /* Synthesized */; - name_31.original = undefined; - name_31.parent = currentScope; + var name_32 = ts.getMutableClone(node); + name_32.flags &= ~8 /* Synthesized */; + name_32.original = undefined; + name_32.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_31), ts.createLiteral("undefined")), name_31); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); } - return name_31; + return name_32; case 141 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -46766,7 +46810,7 @@ var ts; : name.expression; } else if (ts.isIdentifier(name)) { - return ts.createLiteral(name.text); + return ts.createLiteral(ts.unescapeIdentifier(name.text)); } else { return ts.getSynthesizedClone(name); @@ -47245,9 +47289,9 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_32 = node.symbol && node.symbol.name; - if (name_32) { - return currentScopeFirstDeclarationsOfName[name_32] === node; + var name_33 = node.symbol && node.symbol.name; + if (name_33) { + return currentScopeFirstDeclarationsOfName[name_33] === node; } } return false; @@ -47755,16 +47799,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_34 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_34); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, /*location*/ node); + return ts.createPropertyAssignment(name_34, initializer, /*location*/ node); } - return ts.createPropertyAssignment(name_33, exportedName, /*location*/ node); + return ts.createPropertyAssignment(name_34, exportedName, /*location*/ node); } } return node; @@ -48379,12 +48423,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_35 = node.tagName; + if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { + return ts.createLiteral(name_35.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_35); } } } @@ -49920,17 +49964,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); + if (ts.isBindingPattern(name_36)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); } } } @@ -53204,9 +53248,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_6 = ts.getMutableClone(name_36); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_6 = ts.getMutableClone(name_37); ts.setSourceMapRange(clone_6, node); ts.setCommentRange(clone_6, node); return clone_6; @@ -56755,8 +56799,8 @@ var ts; /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_37 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_37), + var name_38 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), /*location*/ node); } } @@ -58297,9 +58341,9 @@ var ts; var count = 0; while (true) { count++; - var name_38 = baseName + "_" + count; - if (!(name_38 in currentIdentifiers)) { - return name_38; + var name_39 = baseName + "_" + count; + if (!(name_39 in currentIdentifiers)) { + return name_39; } } } @@ -59247,6 +59291,11 @@ var ts; return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 155 /* IndexSignature */: + // Interfaces cannot have parameter types that cannot be named + return symbolAccessibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { @@ -61607,10 +61656,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_39 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_39)) { + var name_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_40)) { tempFlags |= flags; - return name_39; + return name_40; } } while (true) { @@ -61618,11 +61667,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_40 = count < 26 + var name_41 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_40)) { - return name_40; + if (isUniqueName(name_41)) { + return name_41; } } } @@ -62073,10 +62122,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_41 = names_1[_i]; - var result = name_41 in cache - ? cache[name_41] - : cache[name_41] = loader(name_41, containingFile); + var name_42 = names_1[_i]; + var result = name_42 in cache + ? cache[name_42] + : cache[name_42] = loader(name_42, containingFile); resolutions.push(result); } return resolutions; @@ -64125,11 +64174,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_42 in options) { - if (ts.hasProperty(options, name_42)) { + for (var name_43 in options) { + if (ts.hasProperty(options, name_43)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_42) { + switch (name_43) { case "init": case "watch": case "version": @@ -64137,14 +64186,14 @@ var ts; case "project": break; default: - var value = options[name_42]; - var optionDefinition = optionsNameMap[name_42.toLowerCase()]; + var value = options[name_43]; + var optionDefinition = optionsNameMap[name_43.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_42] = value; + result[name_43] = value; } else { if (optionDefinition.type === "list") { @@ -64153,11 +64202,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_42] = convertedValue; + result[name_43] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_42] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -67190,14 +67239,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_43 in nameTable) { + for (var name_44 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_43] === position) { + if (nameTable[name_44] === position) { continue; } - if (!uniqueNames[name_43]) { - uniqueNames[name_43] = name_43; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_43), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_44]) { + uniqueNames[name_44] = name_44; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -68502,8 +68551,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_44 = element.propertyName || element.name; - existingImportsOrExports[name_44.text] = true; + var name_45 = element.propertyName || element.name; + existingImportsOrExports[name_45.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -71120,9 +71169,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_45 in packageNameToTypingLocation) { - if (name_45 in inferredTypings && !inferredTypings[name_45]) { - inferredTypings[name_45] = packageNameToTypingLocation[name_45]; + for (var name_46 in packageNameToTypingLocation) { + if (name_46 in inferredTypings && !inferredTypings[name_46]) { + inferredTypings[name_46] = packageNameToTypingLocation[name_46]; } } // Remove typings that the user has added to the exclude list @@ -71260,12 +71309,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_46 in nameToDeclarations) { - var declarations = nameToDeclarations[name_46]; + for (var name_47 in nameToDeclarations) { + var declarations = nameToDeclarations[name_47]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_46); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); if (!matches) { continue; } @@ -71278,14 +71327,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_46); + matches = patternMatcher.getMatches(containers, name_47); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_46, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -71574,9 +71623,9 @@ var ts; case 174 /* BindingElement */: case 223 /* VariableDeclaration */: var decl = node; - var name_47 = decl.name; - if (ts.isBindingPattern(name_47)) { - addChildrenRecursively(name_47); + var name_48 = decl.name; + if (ts.isBindingPattern(name_48)) { + addChildrenRecursively(name_48); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -75075,9 +75124,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_48 in o) { - if (o[name_48] === rule) { - return name_48; + for (var name_49 in o) { + if (o[name_49] === rule) { + return name_49; } } throw new Error("Unknown rule"); diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index e15772fb840..dd305a97a9d 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -378,26 +378,20 @@ declare namespace ts { HasImplicitReturn = 128, HasExplicitReturn = 256, GlobalAugmentation = 512, - HasClassExtends = 1024, - HasDecorators = 2048, - HasParamDecorators = 4096, - HasAsyncFunctions = 8192, - HasSpreadAttribute = 16384, - HasRestAttribute = 32768, - DisallowInContext = 65536, - YieldContext = 131072, - DecoratorContext = 262144, - AwaitContext = 524288, - ThisNodeHasError = 1048576, - JavaScriptFile = 2097152, - ThisNodeOrAnySubNodesHasError = 4194304, - HasAggregatedChildData = 8388608, + HasAsyncFunctions = 1024, + DisallowInContext = 2048, + YieldContext = 4096, + DecoratorContext = 8192, + AwaitContext = 16384, + ThisNodeHasError = 32768, + JavaScriptFile = 65536, + ThisNodeOrAnySubNodesHasError = 131072, + HasAggregatedChildData = 262144, BlockScoped = 3, ReachabilityCheckFlags = 384, - EmitHelperFlags = 64512, - ReachabilityAndEmitFlags = 64896, - ContextFlags = 3080192, - TypeExcludesFlags = 655360, + ReachabilityAndEmitFlags = 1408, + ContextFlags = 96256, + TypeExcludesFlags = 20480, } enum ModifierFlags { None = 0, @@ -2145,7 +2139,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.1.3"; + const version = "2.1.4"; } declare namespace ts { type FileWatcherCallback = (fileName: string, removed?: boolean) => void; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 29a7baad1a1..cf735e4a3bc 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -399,28 +399,22 @@ var ts; NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasClassExtends"] = 1024] = "HasClassExtends"; - NodeFlags[NodeFlags["HasDecorators"] = 2048] = "HasDecorators"; - NodeFlags[NodeFlags["HasParamDecorators"] = 4096] = "HasParamDecorators"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 8192] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["HasSpreadAttribute"] = 16384] = "HasSpreadAttribute"; - NodeFlags[NodeFlags["HasRestAttribute"] = 32768] = "HasRestAttribute"; - NodeFlags[NodeFlags["DisallowInContext"] = 65536] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 131072] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 262144] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 524288] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 1048576] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 2097152] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 4194304] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 8388608] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["EmitHelperFlags"] = 64512] = "EmitHelperFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 64896] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 3080192] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 96256] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 655360] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -1066,6 +1060,24 @@ var ts; EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); + /** + * Used by the checker, this enum keeps track of external emit helpers that should be type + * checked. + */ + /* @internal */ + var ExternalEmitHelpers; + (function (ExternalEmitHelpers) { + ExternalEmitHelpers[ExternalEmitHelpers["Extends"] = 1] = "Extends"; + ExternalEmitHelpers[ExternalEmitHelpers["Assign"] = 2] = "Assign"; + ExternalEmitHelpers[ExternalEmitHelpers["Rest"] = 4] = "Rest"; + ExternalEmitHelpers[ExternalEmitHelpers["Decorate"] = 8] = "Decorate"; + ExternalEmitHelpers[ExternalEmitHelpers["Metadata"] = 16] = "Metadata"; + ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; + ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; + ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); /* @internal */ var EmitContext; (function (EmitContext) { @@ -1174,7 +1186,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.1.3"; + ts.version = "2.1.4"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -4110,6 +4122,7 @@ var ts; 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_2340", message: "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_2341", message: "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_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { code: 2343, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", message: "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "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_2345", message: "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_2346", message: "Supplied parameters do not match any signature of call target." }, @@ -4120,6 +4133,7 @@ var ts; Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Type_0_cannot_be_converted_to_type_1: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_converted_to_type_1_2352", message: "Type '{0}' cannot be converted to type '{1}'." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { code: 2354, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", message: "This syntax requires an imported helper but module '{0}' cannot be found." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, @@ -4426,6 +4440,8 @@ var ts; Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { code: 4083, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", message: "Type parameter '{0}' of exported type alias has or is using private name '{1}'." }, Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, @@ -6492,24 +6508,24 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 4194304 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 8388608 /* HasAggregatedChildData */)) { + if (!(node.flags & 262144 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 1048576 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 4194304 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 8388608 /* HasAggregatedChildData */; + node.flags |= 262144 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { @@ -6774,6 +6790,10 @@ var ts; return false; } ts.isExternalModuleAugmentation = isExternalModuleAugmentation; + function isEffectiveExternalModule(node, compilerOptions) { + return ts.isExternalModule(node) || compilerOptions.isolatedModules; + } + ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { case 261 /* SourceFile */: @@ -7601,7 +7621,7 @@ var ts; } ts.isSourceFileJavaScript = isSourceFileJavaScript; function isInJavaScriptFile(node) { - return node && !!(node.flags & 2097152 /* JavaScriptFile */); + return node && !!(node.flags & 65536 /* JavaScriptFile */); } ts.isInJavaScriptFile = isInJavaScriptFile; /** @@ -7867,7 +7887,7 @@ var ts; } ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { - if (node && (node.flags & 2097152 /* JavaScriptFile */)) { + if (node && (node.flags & 65536 /* JavaScriptFile */)) { if (node.type && node.type.kind === 275 /* JSDocVariadicType */ || ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275 /* JSDocVariadicType */; })) { return true; @@ -14335,7 +14355,7 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 65536 /* DisallowInContext */ | 262144 /* DecoratorContext */; + var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks var NodeConstructor; var TokenConstructor; @@ -14459,7 +14479,7 @@ var ts; identifiers = ts.createMap(); identifierCount = 0; nodeCount = 0; - contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 2097152 /* JavaScriptFile */ : 0 /* None */; + contextFlags = scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */ ? 65536 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); @@ -14567,16 +14587,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 65536 /* DisallowInContext */); + setContextFlag(val, 2048 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 131072 /* YieldContext */); + setContextFlag(val, 4096 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 262144 /* DecoratorContext */); + setContextFlag(val, 8192 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 524288 /* AwaitContext */); + setContextFlag(val, 16384 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -14617,40 +14637,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(65536 /* DisallowInContext */, func); + return doOutsideOfContext(2048 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(65536 /* DisallowInContext */, func); + return doInsideOfContext(2048 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(131072 /* YieldContext */, func); + return doInsideOfContext(4096 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(262144 /* DecoratorContext */, func); + return doInsideOfContext(8192 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(524288 /* AwaitContext */, func); + return doInsideOfContext(16384 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(524288 /* AwaitContext */, func); + return doOutsideOfContext(16384 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(131072 /* YieldContext */ | 524288 /* AwaitContext */, func); + return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(131072 /* YieldContext */); + return inContext(4096 /* YieldContext */); } function inDisallowInContext() { - return inContext(65536 /* DisallowInContext */); + return inContext(2048 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(262144 /* DecoratorContext */); + return inContext(8192 /* DecoratorContext */); } function inAwaitContext() { - return inContext(524288 /* AwaitContext */); + return inContext(16384 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -14854,7 +14874,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 1048576 /* ThisNodeHasError */; + node.flags |= 32768 /* ThisNodeHasError */; } return node; } @@ -15248,7 +15268,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 3080192 /* ContextFlags */; + var nodeContextFlags = node.flags & 96256 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -16253,7 +16273,7 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(655360 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { @@ -18363,7 +18383,7 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = ts.hasModifier(property, 32 /* Static */) ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(131072 /* YieldContext */ | 65536 /* DisallowInContext */, parseNonParameterInitializer); + : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseNonParameterInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); } @@ -20844,8 +20864,7 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - // Reset all emit helper flags on node (for incremental scenarios) - node.flags &= ~64896 /* ReachabilityAndEmitFlags */; + node.flags &= ~1408 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { node.flags |= 128 /* HasImplicitReturn */; if (hasExplicitReturn) @@ -22158,9 +22177,6 @@ var ts; return bindParameter(node); case 223 /* VariableDeclaration */: case 174 /* BindingElement */: - if (node.dotDotDotToken && node.parent.kind === 172 /* ObjectBindingPattern */) { - emitFlags |= 32768 /* HasRestAttribute */; - } return bindVariableDeclarationOrBindingElement(node); case 147 /* PropertyDeclaration */: case 146 /* PropertySignature */: @@ -22187,7 +22203,6 @@ var ts; } root = root.parent; } - emitFlags |= hasRest ? 32768 /* HasRestAttribute */ : 16384 /* HasSpreadAttribute */; return; case 153 /* CallSignature */: case 154 /* ConstructSignature */: @@ -22413,14 +22428,6 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.getClassExtendsHeritageClauseElement(node) !== undefined) { - emitFlags |= 1024 /* HasClassExtends */; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048 /* HasDecorators */; - } - } if (node.kind === 226 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } @@ -22483,11 +22490,6 @@ var ts; } } function bindParameter(node) { - if (!ts.isDeclarationFile(file) && - !ts.isInAmbientContext(node) && - ts.nodeIsDecorated(node)) { - emitFlags |= (2048 /* HasDecorators */ | 4096 /* HasParamDecorators */); - } if (inStrictMode) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) @@ -22509,7 +22511,7 @@ var ts; function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192 /* HasAsyncFunctions */; + emitFlags |= 1024 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); @@ -22524,7 +22526,7 @@ var ts; function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192 /* HasAsyncFunctions */; + emitFlags |= 1024 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -22537,10 +22539,7 @@ var ts; function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { if (ts.isAsyncFunctionLike(node)) { - emitFlags |= 8192 /* HasAsyncFunctions */; - } - if (ts.nodeIsDecorated(node)) { - emitFlags |= 2048 /* HasDecorators */; + emitFlags |= 1024 /* HasAsyncFunctions */; } } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { @@ -24132,6 +24131,8 @@ var ts; // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if // they no longer need the information (for example, if the user started editing again). var cancellationToken; + var requestedExternalEmitHelpers; + var externalHelpersModule; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -26872,7 +26873,13 @@ var ts; return name.kind === 142 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { - ts.Debug.assert(!!(source.flags & 32768 /* Object */), "Rest types only support object types right now."); + source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); + if (source.flags & 8192 /* Never */) { + return emptyObjectType; + } + if (source.flags & 65536 /* Union */) { + return mapType(source, function (t) { return getRestType(t, properties, symbol); }); + } var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { @@ -26913,7 +26920,7 @@ var ts; var type; if (pattern.kind === 172 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { - if (!(parentType.flags & 32768 /* Object */)) { + if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return unknownType; } @@ -27003,7 +27010,7 @@ var ts; } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { // If this is a variable in a JavaScript file, then use the JSDoc type (if it has // one as its type), otherwise fallback to the below standard TS codepaths to // try to figure it out. @@ -27032,7 +27039,7 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), /*optional*/ declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 2097152 /* JavaScriptFile */) && + if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && declaration.kind === 223 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, @@ -27109,14 +27116,19 @@ var ts; // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createMap(); + var stringIndexInfo; var hasComputedProperties = false; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; - if (isComputedNonLiteralName(name) || e.dotDotDotToken) { - // do not include computed properties or rests in the implied type + if (isComputedNonLiteralName(name)) { + // do not include computed properties in the implied type hasComputedProperties = true; return; } + if (e.dotDotDotToken) { + stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + return; + } var text = ts.getTextOfPropertyName(name); var flags = 4 /* Property */ | 67108864 /* Transient */ | (e.initializer ? 536870912 /* Optional */ : 0); var symbol = createSymbol(flags, text); @@ -27124,7 +27136,7 @@ var ts; symbol.bindingElement = e; members[symbol.name] = symbol; }); - var result = createAnonymousType(undefined, members, emptyArray, emptyArray, undefined, undefined); + var result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); if (includePatternInType) { result.pattern = pattern; } @@ -27215,7 +27227,7 @@ var ts; if (declaration.kind === 240 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 2097152 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 286 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27231,7 +27243,7 @@ var ts; if (declaration.kind === 192 /* BinaryExpression */ || declaration.kind === 177 /* PropertyAccessExpression */ && declaration.parent.kind === 192 /* BinaryExpression */) { // Use JS Doc type if present on parent expression statement - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { var jsdocType = ts.getJSDocType(declaration.parent); if (jsdocType) { return links.type = getTypeFromTypeNode(jsdocType); @@ -27287,7 +27299,7 @@ var ts; if (!links.type) { var getter = ts.getDeclarationOfKind(symbol, 151 /* GetAccessor */); var setter = ts.getDeclarationOfKind(symbol, 152 /* SetAccessor */); - if (getter && getter.flags & 2097152 /* JavaScriptFile */) { + if (getter && getter.flags & 65536 /* JavaScriptFile */) { var jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -28252,7 +28264,7 @@ var ts; var isomorphicProp = isomorphicType && getPropertyOfType(isomorphicType, propName); var isOptional = templateOptional || !!(isomorphicProp && isomorphicProp.flags & 536870912 /* Optional */); var prop = createSymbol(4 /* Property */ | 67108864 /* Transient */ | (isOptional ? 536870912 /* Optional */ : 0), propName); - prop.type = addOptionality(propType, isOptional); + prop.type = propType; prop.isReadonly = templateReadonly || isomorphicProp && isReadonlySymbol(isomorphicProp); members[propName] = prop; } @@ -28273,7 +28285,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!type.declaration.questionToken), type.mapper || identityMapper) : unknownType); } function getIsomorphicTypeFromMappedType(type) { @@ -28563,7 +28575,7 @@ var ts; return undefined; } function getTypeParametersFromJSDocTemplate(declaration) { - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { var templateTag = ts.getJSDocTemplateTag(declaration); if (templateTag) { return getTypeParametersFromDeclaration(templateTag.typeParameters); @@ -28593,7 +28605,7 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - if (node.flags & 2097152 /* JavaScriptFile */) { + if (node.flags & 65536 /* JavaScriptFile */) { if (node.type && node.type.kind === 273 /* JSDocOptionalType */) { return true; } @@ -28729,7 +28741,7 @@ var ts; else if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.flags & 2097152 /* JavaScriptFile */) { + if (declaration.flags & 65536 /* JavaScriptFile */) { var type = getReturnTypeFromJSDocComment(declaration); if (type && type !== unknownType) { return type; @@ -29611,7 +29623,7 @@ var ts; } var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return addOptionality(instantiateType(getTemplateTypeFromMappedType(type), templateMapper), !!type.declaration.questionToken); + return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); } function getIndexedAccessType(objectType, indexType, accessNode) { if (indexType.flags & 16384 /* TypeParameter */ || @@ -29703,10 +29715,23 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, isFromObjectLiteral) { - ts.Debug.assert(!!(left.flags & (32768 /* Object */ | 1 /* Any */)) && !!(right.flags & (32768 /* Object */ | 1 /* Any */)), "Only object types may be spread."); if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { return anyType; } + left = filterType(left, function (t) { return !(t.flags & 6144 /* Nullable */); }); + if (left.flags & 8192 /* Never */) { + return right; + } + right = filterType(right, function (t) { return !(t.flags & 6144 /* Nullable */); }); + if (right.flags & 8192 /* Never */) { + return left; + } + if (left.flags & 65536 /* Union */) { + return mapType(left, function (t) { return getSpreadType(t, right, isFromObjectLiteral); }); + } + if (right.flags & 65536 /* Union */) { + return mapType(right, function (t) { return getSpreadType(left, t, isFromObjectLiteral); }); + } var members = ts.createMap(); var skippedPrivateMembers = ts.createMap(); var stringIndexInfo; @@ -31872,6 +31897,8 @@ var ts; var typeInferences = createTypeInferencesObject(); var typeInferencesArray = [typeInferences]; var templateType = getTemplateTypeFromMappedType(target); + var readonlyMask = target.declaration.readonlyToken ? false : true; + var optionalMask = target.declaration.questionToken ? 0 : 536870912 /* Optional */; var properties = getPropertiesOfType(source); var members = createSymbolTable(properties); var hasInferredTypes = false; @@ -31879,10 +31906,10 @@ var ts; var prop = properties_4[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (inferredPropType) { - var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & 536870912 /* Optional */, prop.name); + var inferredProp = createSymbol(4 /* Property */ | 67108864 /* Transient */ | prop.flags & optionalMask, prop.name); inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; - inferredProp.isReadonly = isReadonlySymbol(prop); + inferredProp.isReadonly = readonlyMask && isReadonlySymbol(prop); members[prop.name] = inferredProp; hasInferredTypes = true; } @@ -31891,7 +31918,7 @@ var ts; if (indexInfo) { var inferredIndexType = inferTargetType(indexInfo.type); if (inferredIndexType) { - indexInfo = createIndexInfo(inferredIndexType, indexInfo.isReadonly); + indexInfo = createIndexInfo(inferredIndexType, readonlyMask && indexInfo.isReadonly); hasInferredTypes = true; } } @@ -33414,7 +33441,7 @@ var ts; error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 524288 /* AwaitContext */) { + if (node.flags & 16384 /* AwaitContext */) { getNodeLinks(container).flags |= 8192 /* CaptureArguments */; } return getTypeOfSymbol(symbol); @@ -34604,7 +34631,7 @@ var ts; if (impliedProp) { prop.flags |= impliedProp.flags & 536870912 /* Optional */; } - else if (!compilerOptions.suppressExcessPropertyErrors) { + else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0 /* String */)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); } } @@ -34618,6 +34645,9 @@ var ts; member = prop; } else if (memberDecl.kind === 259 /* SpreadAssignment */) { + if (languageVersion < 5 /* ESNext */) { + checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), /*isFromObjectLiteral*/ true); propertiesArray = []; @@ -34627,7 +34657,7 @@ var ts; typeFlags = 0; } var type = checkExpression(memberDecl.expression); - if (!(type.flags & (32768 /* Object */ | 1 /* Any */))) { + if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return unknownType; } @@ -34699,6 +34729,11 @@ var ts; return result; } } + function isValidSpreadType(type) { + return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */) || + type.flags & 32768 /* Object */ && !isGenericMappedType(type) || + type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); + } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); return jsxElementType || anyType; @@ -34788,6 +34823,9 @@ var ts; return exprType; } function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + if (compilerOptions.jsx === 2 /* React */) { + checkExternalEmitHelpers(node, 2 /* Assign */); + } var type = checkExpression(node.expression); var props = getPropertiesOfType(type); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { @@ -37085,7 +37123,7 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 524288 /* AwaitContext */)) { + if (!(node.flags & 16384 /* AwaitContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -37262,6 +37300,9 @@ var ts; } } else if (property.kind === 259 /* SpreadAssignment */) { + if (languageVersion < 5 /* ESNext */) { + checkExternalEmitHelpers(property, 4 /* Rest */); + } var nonRestNames = []; if (allProperties) { for (var i = 0; i < allProperties.length - 1; i++) { @@ -37658,7 +37699,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 131072 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -38088,6 +38129,12 @@ var ts; node.kind === 154 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } + if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 64 /* Awaiter */); + if (languageVersion < 2 /* ES2015 */) { + checkExternalEmitHelpers(node, 128 /* Generator */); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -39088,7 +39135,13 @@ var ts; if (!compilerOptions.experimentalDecorators) { error(node, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_to_remove_this_warning); } + var firstDecorator = node.decorators[0]; + checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); + if (node.kind === 144 /* Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + } if (compilerOptions.emitDecoratorMetadata) { + checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { case 226 /* ClassDeclaration */: @@ -39441,7 +39494,7 @@ var ts; } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!needCollisionCheckForIdentifier(node, name, "Promise")) { + if (languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check @@ -39450,7 +39503,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 8192 /* HasAsyncFunctions */) { + if (parent.kind === 261 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -39598,6 +39651,9 @@ var ts; } } if (node.kind === 174 /* BindingElement */) { + if (node.parent.kind === 172 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { + checkExternalEmitHelpers(node, 4 /* Rest */); + } // check computed properties inside property names of binding elements if (node.propertyName && node.propertyName.kind === 142 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); @@ -40136,7 +40192,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 524288 /* AwaitContext */) { + if (node.flags & 16384 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -40407,6 +40463,9 @@ var ts; checkClassForDuplicateDeclarations(node); var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { + if (languageVersion < 2 /* ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + } var baseTypes = getBaseTypes(type); if (baseTypes.length && produceDiagnostics) { var baseType_1 = baseTypes[0]; @@ -42606,8 +42665,6 @@ var ts; } // Initialize global symbol table var augmentations; - var requestedExternalEmitHelpers = 0; - var firstFileRequestingExternalHelpers; for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) { var file = _c[_b]; if (!ts.isExternalOrCommonJsModule(file)) { @@ -42628,15 +42685,6 @@ var ts; } } } - if ((compilerOptions.isolatedModules || ts.isExternalModule(file)) && !file.isDeclarationFile) { - var fileRequestedExternalEmitHelpers = file.flags & 64512 /* EmitHelperFlags */; - if (fileRequestedExternalEmitHelpers) { - requestedExternalEmitHelpers |= fileRequestedExternalEmitHelpers; - if (firstFileRequestingExternalHelpers === undefined) { - firstFileRequestingExternalHelpers = file; - } - } - } } if (augmentations) { // merge module augmentations. @@ -42695,50 +42743,46 @@ var ts; var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; - // If we have specified that we are importing helpers, we should report global - // errors if we cannot resolve the helpers external module, or if it does not have - // the necessary helpers exported. - if (compilerOptions.importHelpers && firstFileRequestingExternalHelpers) { - // Find the first reference to the helpers module. - var helpersModule = resolveExternalModule(firstFileRequestingExternalHelpers, ts.externalHelpersModuleNameText, ts.Diagnostics.Cannot_find_module_0, - /*errorNode*/ undefined); - // If we found the module, report errors if it does not have the necessary exports. - if (helpersModule) { - var exports = helpersModule.exports; - if (requestedExternalEmitHelpers & 1024 /* HasClassExtends */ && languageVersion < 2 /* ES2015 */) { - verifyHelperSymbol(exports, "__extends", 107455 /* Value */); - } - if (requestedExternalEmitHelpers & 16384 /* HasSpreadAttribute */ && - (languageVersion < 5 /* ESNext */ || compilerOptions.jsx === 2 /* React */)) { - verifyHelperSymbol(exports, "__assign", 107455 /* Value */); - } - if (languageVersion < 5 /* ESNext */ && requestedExternalEmitHelpers & 32768 /* HasRestAttribute */) { - verifyHelperSymbol(exports, "__rest", 107455 /* Value */); - } - if (requestedExternalEmitHelpers & 2048 /* HasDecorators */) { - verifyHelperSymbol(exports, "__decorate", 107455 /* Value */); - if (compilerOptions.emitDecoratorMetadata) { - verifyHelperSymbol(exports, "__metadata", 107455 /* Value */); - } - } - if (requestedExternalEmitHelpers & 4096 /* HasParamDecorators */) { - verifyHelperSymbol(exports, "__param", 107455 /* Value */); - } - if (requestedExternalEmitHelpers & 8192 /* HasAsyncFunctions */) { - verifyHelperSymbol(exports, "__awaiter", 107455 /* Value */); - if (languageVersion < 2 /* ES2015 */) { - verifyHelperSymbol(exports, "__generator", 107455 /* Value */); + } + function checkExternalEmitHelpers(location, helpers) { + if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { + var sourceFile = ts.getSourceFileOfNode(location); + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + var helpersModule = resolveHelpersModule(sourceFile, location); + if (helpersModule !== unknownSymbol) { + var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; + for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { + if (uncheckedHelpers & helper) { + var name_27 = getHelperName(helper); + var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name_27), 107455 /* Value */); + if (!symbol) { + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name_27); + } + } } } + requestedExternalEmitHelpers |= helpers; } } } - function verifyHelperSymbol(symbols, name, meaning) { - var symbol = getSymbol(symbols, ts.escapeIdentifier(name), meaning); - if (!symbol) { - error(/*location*/ undefined, ts.Diagnostics.Module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + function getHelperName(helper) { + switch (helper) { + case 1 /* Extends */: return "__extends"; + case 2 /* Assign */: return "__assign"; + case 4 /* Rest */: return "__rest"; + case 8 /* Decorate */: return "__decorate"; + case 16 /* Metadata */: return "__metadata"; + case 32 /* Param */: return "__param"; + case 64 /* Awaiter */: return "__awaiter"; + case 128 /* Generator */: return "__generator"; } } + function resolveHelpersModule(node, errorNode) { + if (!externalHelpersModule) { + externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol; + } + return externalHelpersModule; + } function createInstantiatedPromiseLikeType() { var promiseLikeType = getGlobalPromiseLikeType(); if (promiseLikeType !== emptyGenericType) { @@ -43273,10 +43317,10 @@ var ts; if (prop.kind === 259 /* SpreadAssignment */) { continue; } - var name_27 = prop.name; - if (name_27.kind === 142 /* ComputedPropertyName */) { + var name_28 = prop.name; + if (name_28.kind === 142 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_27); + checkGrammarComputedPropertyName(name_28); } if (prop.kind === 258 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern @@ -43304,8 +43348,8 @@ var ts; if (prop.kind === 257 /* PropertyAssignment */ || prop.kind === 258 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_27.kind === 8 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_27); + if (name_28.kind === 8 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_28); } currentKind = Property; } @@ -43321,7 +43365,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_27); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_28); if (effectiveName === undefined) { continue; } @@ -43331,18 +43375,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_27, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_27)); + grammarErrorOnNode(name_28, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_28)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_27, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_28, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -43355,12 +43399,12 @@ var ts; continue; } var jsxAttr = attr; - var name_28 = jsxAttr.name; - if (!seen[name_28.text]) { - seen[name_28.text] = true; + var name_29 = jsxAttr.name; + if (!seen[name_29.text]) { + seen[name_29.text] = true; } else { - return grammarErrorOnNode(name_28, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 252 /* JsxExpression */ && !initializer.expression) { @@ -44879,11 +44923,11 @@ var ts; } } for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) { - var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_29 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; - var variable = ts.createVariableDeclaration(name_29, + var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name_30 = _a.name, value = _a.value, location_2 = _a.location, original = _a.original; + var variable = ts.createVariableDeclaration(name_30, /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value, location_2); variable.original = original; - if (ts.isIdentifier(name_29)) { + if (ts.isIdentifier(name_30)) { ts.setEmitFlags(variable, 64 /* NoNestedSourceMaps */); } ts.aggregateTransformFlags(variable); @@ -45087,8 +45131,8 @@ var ts; return ts.createElementAccess(value, argumentExpression); } else { - var name_30 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); - return ts.createPropertyAccess(value, name_30); + var name_31 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_31); } } /** @@ -45141,7 +45185,7 @@ var ts; var restHelper = { name: "typescript:rest", scoped: false, - text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" + text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ @@ -46712,14 +46756,14 @@ var ts; case 70 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. - var name_31 = ts.getMutableClone(node); - name_31.flags &= ~8 /* Synthesized */; - name_31.original = undefined; - name_31.parent = currentScope; + var name_32 = ts.getMutableClone(node); + name_32.flags &= ~8 /* Synthesized */; + name_32.original = undefined; + name_32.parent = currentScope; if (useFallback) { - return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_31), ts.createLiteral("undefined")), name_31); + return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_32), ts.createLiteral("undefined")), name_32); } - return name_31; + return name_32; case 141 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } @@ -46766,7 +46810,7 @@ var ts; : name.expression; } else if (ts.isIdentifier(name)) { - return ts.createLiteral(name.text); + return ts.createLiteral(ts.unescapeIdentifier(name.text)); } else { return ts.getSynthesizedClone(name); @@ -47245,9 +47289,9 @@ var ts; */ function isFirstEmittedDeclarationInScope(node) { if (currentScopeFirstDeclarationsOfName) { - var name_32 = node.symbol && node.symbol.name; - if (name_32) { - return currentScopeFirstDeclarationsOfName[name_32] === node; + var name_33 = node.symbol && node.symbol.name; + if (name_33) { + return currentScopeFirstDeclarationsOfName[name_33] === node; } } return false; @@ -47755,16 +47799,16 @@ var ts; } function substituteShorthandPropertyAssignment(node) { if (enabledSubstitutions & 2 /* NamespaceExports */) { - var name_33 = node.name; - var exportedName = trySubstituteNamespaceExportedName(name_33); + var name_34 = node.name; + var exportedName = trySubstituteNamespaceExportedName(name_34); if (exportedName) { // A shorthand property with an assignment initializer is probably part of a // destructuring assignment if (node.objectAssignmentInitializer) { var initializer = ts.createAssignment(exportedName, node.objectAssignmentInitializer); - return ts.createPropertyAssignment(name_33, initializer, /*location*/ node); + return ts.createPropertyAssignment(name_34, initializer, /*location*/ node); } - return ts.createPropertyAssignment(name_33, exportedName, /*location*/ node); + return ts.createPropertyAssignment(name_34, exportedName, /*location*/ node); } } return node; @@ -48379,12 +48423,12 @@ var ts; return getTagName(node.openingElement); } else { - var name_34 = node.tagName; - if (ts.isIdentifier(name_34) && ts.isIntrinsicJsxName(name_34.text)) { - return ts.createLiteral(name_34.text); + var name_35 = node.tagName; + if (ts.isIdentifier(name_35) && ts.isIntrinsicJsxName(name_35.text)) { + return ts.createLiteral(name_35.text); } else { - return ts.createExpressionFromEntityName(name_34); + return ts.createExpressionFromEntityName(name_35); } } } @@ -49920,17 +49964,17 @@ var ts; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; - var name_35 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; + var name_36 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. if (dotDotDotToken) { continue; } - if (ts.isBindingPattern(name_35)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_35, initializer); + if (ts.isBindingPattern(name_36)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_36, initializer); } else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_35, initializer); + addDefaultValueAssignmentForInitializer(statements, parameter, name_36, initializer); } } } @@ -53204,9 +53248,9 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_36 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_36) { - var clone_6 = ts.getMutableClone(name_36); + var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_37) { + var clone_6 = ts.getMutableClone(name_37); ts.setSourceMapRange(clone_6, node); ts.setCommentRange(clone_6, node); return clone_6; @@ -56755,8 +56799,8 @@ var ts; /*location*/ node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_37 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_37), + var name_38 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), /*location*/ node); } } @@ -58297,9 +58341,9 @@ var ts; var count = 0; while (true) { count++; - var name_38 = baseName + "_" + count; - if (!(name_38 in currentIdentifiers)) { - return name_38; + var name_39 = baseName + "_" + count; + if (!(name_39 in currentIdentifiers)) { + return name_39; } } } @@ -59247,6 +59291,11 @@ var ts; return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; + case 155 /* IndexSignature */: + // Interfaces cannot have parameter types that cannot be named + return symbolAccessibilityResult.errorModuleName ? + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; case 149 /* MethodDeclaration */: case 148 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { @@ -61607,10 +61656,10 @@ var ts; */ function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_39 = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name_39)) { + var name_40 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_40)) { tempFlags |= flags; - return name_39; + return name_40; } } while (true) { @@ -61618,11 +61667,11 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_40 = count < 26 + var name_41 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_40)) { - return name_40; + if (isUniqueName(name_41)) { + return name_41; } } } @@ -62073,10 +62122,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_41 = names_1[_i]; - var result = name_41 in cache - ? cache[name_41] - : cache[name_41] = loader(name_41, containingFile); + var name_42 = names_1[_i]; + var result = name_42 in cache + ? cache[name_42] + : cache[name_42] = loader(name_42, containingFile); resolutions.push(result); } return resolutions; @@ -64125,11 +64174,11 @@ var ts; function serializeCompilerOptions(options) { var result = ts.createMap(); var optionsNameMap = getOptionNameMap().optionNameMap; - for (var name_42 in options) { - if (ts.hasProperty(options, name_42)) { + for (var name_43 in options) { + if (ts.hasProperty(options, name_43)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name_42) { + switch (name_43) { case "init": case "watch": case "version": @@ -64137,14 +64186,14 @@ var ts; case "project": break; default: - var value = options[name_42]; - var optionDefinition = optionsNameMap[name_42.toLowerCase()]; + var value = options[name_43]; + var optionDefinition = optionsNameMap[name_43.toLowerCase()]; if (optionDefinition) { var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); if (!customTypeMap) { // There is no map associated with this compiler option then use the value as-is // This is the case if the value is expect to be string, number, boolean or list of string - result[name_42] = value; + result[name_43] = value; } else { if (optionDefinition.type === "list") { @@ -64153,11 +64202,11 @@ var ts; var element = _a[_i]; convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } - result[name_42] = convertedValue; + result[name_43] = convertedValue; } else { // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name_42] = getNameOfCompilerOptionValue(value, customTypeMap); + result[name_43] = getNameOfCompilerOptionValue(value, customTypeMap); } } } @@ -67190,14 +67239,14 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_43 in nameTable) { + for (var name_44 in nameTable) { // Skip identifiers produced only from the current location - if (nameTable[name_43] === position) { + if (nameTable[name_44] === position) { continue; } - if (!uniqueNames[name_43]) { - uniqueNames[name_43] = name_43; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_43), compilerOptions.target, /*performCharacterChecks*/ true); + if (!uniqueNames[name_44]) { + uniqueNames[name_44] = name_44; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, /*performCharacterChecks*/ true); if (displayName) { var entry = { name: displayName, @@ -68502,8 +68551,8 @@ var ts; if (element.getStart() <= position && position <= element.getEnd()) { continue; } - var name_44 = element.propertyName || element.name; - existingImportsOrExports[name_44.text] = true; + var name_45 = element.propertyName || element.name; + existingImportsOrExports[name_45.text] = true; } if (!ts.someProperties(existingImportsOrExports)) { return ts.filter(exportsOfModule, function (e) { return e.name !== "default"; }); @@ -71120,9 +71169,9 @@ var ts; } } // Add the cached typing locations for inferred typings that are already installed - for (var name_45 in packageNameToTypingLocation) { - if (name_45 in inferredTypings && !inferredTypings[name_45]) { - inferredTypings[name_45] = packageNameToTypingLocation[name_45]; + for (var name_46 in packageNameToTypingLocation) { + if (name_46 in inferredTypings && !inferredTypings[name_46]) { + inferredTypings[name_46] = packageNameToTypingLocation[name_46]; } } // Remove typings that the user has added to the exclude list @@ -71260,12 +71309,12 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_46 in nameToDeclarations) { - var declarations = nameToDeclarations[name_46]; + for (var name_47 in nameToDeclarations) { + var declarations = nameToDeclarations[name_47]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_46); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_47); if (!matches) { continue; } @@ -71278,14 +71327,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_46); + matches = patternMatcher.getMatches(containers, name_47); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_46, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_47, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -71574,9 +71623,9 @@ var ts; case 174 /* BindingElement */: case 223 /* VariableDeclaration */: var decl = node; - var name_47 = decl.name; - if (ts.isBindingPattern(name_47)) { - addChildrenRecursively(name_47); + var name_48 = decl.name; + if (ts.isBindingPattern(name_48)) { + addChildrenRecursively(name_48); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { // For `const x = function() {}`, just use the function node, not the const. @@ -75075,9 +75124,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_48 in o) { - if (o[name_48] === rule) { - return name_48; + for (var name_49 in o) { + if (o[name_49] === rule) { + return name_49; } } throw new Error("Unknown rule"); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 1d9e78f7228..25933d96042 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -137,7 +137,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.1.3"; + ts.version = "2.1.4"; })(ts || (ts = {})); (function (ts) { var createObject = Object.create; @@ -2673,6 +2673,7 @@ var ts; 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_2340", message: "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_2341", message: "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_2342", message: "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'." }, + This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: { code: 2343, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", message: "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type_0_does_not_satisfy_the_constraint_1_2344", message: "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_2345", message: "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_2346", message: "Supplied parameters do not match any signature of call target." }, @@ -2683,6 +2684,7 @@ var ts; Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature: { code: 2351, category: ts.DiagnosticCategory.Error, key: "Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature_2351", message: "Cannot use 'new' with an expression whose type lacks a call or construct signature." }, Type_0_cannot_be_converted_to_type_1: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_converted_to_type_1_2352", message: "Type '{0}' cannot be converted to type '{1}'." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: { code: 2354, category: ts.DiagnosticCategory.Error, key: "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", message: "This syntax requires an imported helper but module '{0}' cannot be found." }, A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", message: "The operand of an increment or decrement operator must be a variable or a property access." }, @@ -2989,6 +2991,8 @@ var ts; Default_export_of_the_module_has_or_is_using_private_name_0: { code: 4082, category: ts.DiagnosticCategory.Error, key: "Default_export_of_the_module_has_or_is_using_private_name_0_4082", message: "Default export of the module has or is using private name '{0}'." }, Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: { code: 4083, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", message: "Type parameter '{0}' of exported type alias has or is using private name '{1}'." }, Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: { code: 4090, category: ts.DiagnosticCategory.Message, key: "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", message: "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 4091, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", message: "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'." }, + Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 4092, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", message: "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: ts.DiagnosticCategory.Error, key: "The_current_host_does_not_support_the_0_option_5001", message: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." },