diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-27 22:08:28 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-27 22:08:28 +0100 |
commit | f72af162a00d1d0eb9dced873fd1fbdf4d0975a2 (patch) | |
tree | c8ebe0b5fbf2c75b6da728cb0021b905e33f3ffb /node_modules/typescript/lib/tsserverlibrary.js | |
parent | b7f4ecc76a1dd751fd579bb92b5aff49780ec27d (diff) | |
download | wallet-core-f72af162a00d1d0eb9dced873fd1fbdf4d0975a2.tar.xz |
node_modules
Diffstat (limited to 'node_modules/typescript/lib/tsserverlibrary.js')
-rw-r--r-- | node_modules/typescript/lib/tsserverlibrary.js | 7105 |
1 files changed, 4141 insertions, 2964 deletions
diff --git a/node_modules/typescript/lib/tsserverlibrary.js b/node_modules/typescript/lib/tsserverlibrary.js index 04f56d015..4ed37099e 100644 --- a/node_modules/typescript/lib/tsserverlibrary.js +++ b/node_modules/typescript/lib/tsserverlibrary.js @@ -137,6 +137,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + ts.version = "2.2.0-dev.20161127"; +})(ts || (ts = {})); +(function (ts) { var createObject = Object.create; ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator() : undefined; function createMap(template) { @@ -606,7 +609,7 @@ var ts; if (value === undefined) return to; if (to === undefined) - to = []; + return [value]; to.push(value); return to; } @@ -621,6 +624,14 @@ var ts; return to; } ts.addRange = addRange; + function stableSort(array, comparer) { + if (comparer === void 0) { comparer = compareValues; } + return array + .map(function (_, i) { return i; }) + .sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); }) + .map(function (i) { return array[i]; }); + } + ts.stableSort = stableSort; function rangeEquals(array1, array2, pos, end) { while (pos < end) { if (array1[pos] !== array2[pos]) { @@ -775,6 +786,15 @@ var ts; } } ts.copyProperties = copyProperties; + function appendProperty(map, key, value) { + if (key === undefined || value === undefined) + return map; + if (map === undefined) + map = createMap(); + map[key] = value; + return map; + } + ts.appendProperty = appendProperty; function assign(t) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -1227,6 +1247,14 @@ var ts; getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; + function getEmitModuleResolutionKind(compilerOptions) { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; + } + return moduleResolution; + } + ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { @@ -1777,6 +1805,16 @@ var ts; } Debug.fail = fail; })(Debug = ts.Debug || (ts.Debug = {})); + function orderedRemoveItem(array, item) { + for (var i = 0; i < array.length; i++) { + if (array[i] === item) { + orderedRemoveItemAt(array, i); + return true; + } + } + return false; + } + ts.orderedRemoveItem = orderedRemoveItem; function orderedRemoveItemAt(array, index) { for (var i = index; i < array.length - 1; i++) { array[i] = array[i + 1]; @@ -2811,7 +2849,7 @@ var ts; Object_is_possibly_null_or_undefined: { code: 2533, category: ts.DiagnosticCategory.Error, key: "Object_is_possibly_null_or_undefined_2533", message: "Object is possibly 'null' or 'undefined'." }, A_function_returning_never_cannot_have_a_reachable_end_point: { code: 2534, category: ts.DiagnosticCategory.Error, key: "A_function_returning_never_cannot_have_a_reachable_end_point_2534", message: "A function returning 'never' cannot have a reachable end point." }, Enum_type_0_has_members_with_initializers_that_are_not_literals: { code: 2535, category: ts.DiagnosticCategory.Error, key: "Enum_type_0_has_members_with_initializers_that_are_not_literals_2535", message: "Enum type '{0}' has members with initializers that are not literals." }, - Type_0_is_not_constrained_to_keyof_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_constrained_to_keyof_1_2536", message: "Type '{0}' is not constrained to 'keyof {1}'." }, + Type_0_cannot_be_used_to_index_type_1: { code: 2536, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_to_index_type_1_2536", message: "Type '{0}' cannot be used to index type '{1}'." }, Type_0_has_no_matching_index_signature_for_type_1: { code: 2537, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_matching_index_signature_for_type_1_2537", message: "Type '{0}' has no matching index signature for type '{1}'." }, Type_0_cannot_be_used_as_an_index_type: { code: 2538, category: ts.DiagnosticCategory.Error, key: "Type_0_cannot_be_used_as_an_index_type_2538", message: "Type '{0}' cannot be used as an index type." }, Cannot_assign_to_0_because_it_is_not_a_variable: { code: 2539, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_to_0_because_it_is_not_a_variable_2539", message: "Cannot assign to '{0}' because it is not a variable." }, @@ -2876,7 +2914,8 @@ var ts; An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: { code: 2697, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_in_2697", message: "An async function or method must return a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option." }, Spread_types_may_only_be_created_from_object_types: { code: 2698, category: ts.DiagnosticCategory.Error, key: "Spread_types_may_only_be_created_from_object_types_2698", message: "Spread types may only be created from object types." }, Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, - An_object_rest_element_must_be_an_identifier: { code: 2701, category: ts.DiagnosticCategory.Error, key: "An_object_rest_element_must_be_an_identifier_2701", message: "An object rest element must be an identifier." }, + The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, + _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -2947,6 +2986,7 @@ var ts; Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: ts.DiagnosticCategory.Error, key: "Parameter_0_of_exported_function_has_or_is_using_private_name_1_4078", message: "Parameter '{0}' of exported function has or is using private name '{1}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: ts.DiagnosticCategory.Error, key: "Exported_type_alias_0_has_or_is_using_private_name_1_4081", message: "Exported type alias '{0}' has or is using private name '{1}'." }, 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." }, 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." }, @@ -3161,9 +3201,9 @@ var ts; A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses: { code: 17007, category: ts.DiagnosticCategory.Error, key: "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007", message: "A type assertion expression is not allowed in the left-hand side of an exponentiation expression. Consider enclosing the expression in parentheses." }, JSX_element_0_has_no_corresponding_closing_tag: { code: 17008, category: ts.DiagnosticCategory.Error, key: "JSX_element_0_has_no_corresponding_closing_tag_17008", message: "JSX element '{0}' has no corresponding closing tag." }, super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class: { code: 17009, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class_17009", message: "'super' must be called before accessing 'this' in the constructor of a derived class." }, - Unknown_typing_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_typing_option_0_17010", message: "Unknown typing option '{0}'." }, + Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, - The_path_in_an_extends_options_must_be_relative_or_rooted: { code: 18001, category: ts.DiagnosticCategory.Error, key: "The_path_in_an_extends_options_must_be_relative_or_rooted_18001", message: "The path in an 'extends' options must be relative or rooted." }, + A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, The_files_list_in_config_file_0_is_empty: { code: 18002, category: ts.DiagnosticCategory.Error, key: "The_files_list_in_config_file_0_is_empty_18002", message: "The 'files' list in config file '{0}' is empty." }, No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2: { code: 18003, category: ts.DiagnosticCategory.Error, key: "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003", message: "No inputs were found in config file '{0}'. Specified 'include' paths were '{1}' and 'exclude' paths were '{2}'." }, Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, @@ -3175,6 +3215,9 @@ var ts; Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class" }, Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, + Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, + Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, + Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, }; })(ts || (ts = {})); var ts; @@ -5176,12 +5219,16 @@ var ts; description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file } ]; - ts.typingOptionDeclarations = [ + ts.typeAcquisitionDeclarations = [ { name: "enableAutoDiscovery", type: "boolean", }, { + name: "enable", + type: "boolean", + }, + { name: "include", type: "list", element: { @@ -5205,6 +5252,18 @@ var ts; sourceMap: false, }; var optionNameMapCache; + function convertEnableAutoDiscoveryToEnable(typeAcquisition) { + if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) { + var result = { + enable: typeAcquisition.enableAutoDiscovery, + include: typeAcquisition.include || [], + exclude: typeAcquisition.exclude || [] + }; + return result; + } + return typeAcquisition; + } + ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable; function getOptionNameMap() { if (optionNameMapCache) { return optionNameMapCache; @@ -5484,14 +5543,15 @@ var ts; return { options: {}, fileNames: [], - typingOptions: {}, + typeAcquisition: {}, raw: json, errors: [ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, resolutionStack.concat([resolvedPath]).join(" -> "))], wildcardDirectories: {} }; } var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - var typingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; + var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { @@ -5518,7 +5578,7 @@ var ts; return { options: options, fileNames: fileNames, - typingOptions: typingOptions, + typeAcquisition: typeAcquisition, raw: json, errors: errors, wildcardDirectories: wildcardDirectories, @@ -5526,7 +5586,7 @@ var ts; }; function tryExtendsName(extendedConfig) { if (!(ts.isRootedDiskPath(extendedConfig) || ts.startsWith(ts.normalizeSlashes(extendedConfig), "./") || ts.startsWith(ts.normalizeSlashes(extendedConfig), "../"))) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); return; } var extendedConfigPath = ts.toPath(extendedConfig, basePath, getCanonicalFileName); @@ -5589,7 +5649,7 @@ var ts; errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); } else { - excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; + excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; var outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; if (outDir) { excludeSpecs.push(outDir); @@ -5624,12 +5684,12 @@ var ts; return { options: options, errors: errors }; } ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson; - function convertTypingOptionsFromJson(jsonOptions, basePath, configFileName) { + function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) { var errors = []; - var options = convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); return { options: options, errors: errors }; } - ts.convertTypingOptionsFromJson = convertTypingOptionsFromJson; + ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson; function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { var options = ts.getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true } @@ -5637,9 +5697,10 @@ var ts; convertOptionsFromJson(ts.optionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_compiler_option_0, errors); return options; } - function convertTypingOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) { - var options = { enableAutoDiscovery: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; - convertOptionsFromJson(ts.typingOptionDeclarations, jsonOptions, basePath, options, ts.Diagnostics.Unknown_typing_option_0, errors); + function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) { + var options = { enable: ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] }; + var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions); + convertOptionsFromJson(ts.typeAcquisitionDeclarations, typeAcquisition, basePath, options, ts.Diagnostics.Unknown_type_acquisition_option_0, errors); return options; } function convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, defaultOptions, diagnosticMessage, errors) { @@ -5858,9 +5919,9 @@ var ts; "constants", "process", "v8", "timers", "console" ]; var nodeCoreModules = ts.arrayToMap(JsTyping.nodeCoreModuleList, function (x) { return x; }); - function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typingOptions, unresolvedImports) { + function discoverTypings(host, fileNames, projectRootPath, safeListPath, packageNameToTypingLocation, typeAcquisition, unresolvedImports) { var inferredTypings = ts.createMap(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { + if (!typeAcquisition || !typeAcquisition.enable) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; } fileNames = ts.filter(ts.map(fileNames, ts.normalizePath), function (f) { @@ -5874,8 +5935,8 @@ var ts; var filesToWatch = []; var searchDirs = []; var exclude = []; - mergeTypings(typingOptions.include); - exclude = typingOptions.exclude || []; + mergeTypings(typeAcquisition.include); + exclude = typeAcquisition.exclude || []; var possibleSearchDirs = ts.map(fileNames, ts.getDirectoryPath); if (projectRootPath) { possibleSearchDirs.push(projectRootPath); @@ -6057,12 +6118,12 @@ var ts; return project.projectService.host.fileExists(projectName) ? ts.getDirectoryPath(projectName) : projectName; } } - function createInstallTypingsRequest(project, typingOptions, unresolvedImports, cachePath) { + function createInstallTypingsRequest(project, typeAcquisition, unresolvedImports, cachePath) { return { projectName: project.getProjectName(), fileNames: project.getFileNames(true), compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, + typeAcquisition: typeAcquisition, unresolvedImports: unresolvedImports, projectRootPath: getProjectRootPath(project), cachePath: cachePath, @@ -6249,6 +6310,7 @@ var ts; function moduleHasNonRelativeName(moduleName) { return !(ts.isRootedDiskPath(moduleName) || ts.isExternalModuleNameRelative(moduleName)); } + ts.moduleHasNonRelativeName = moduleHasNonRelativeName; function tryReadTypesSection(extensions, packageJsonPath, baseDirectory, state) { var jsonContent = readJson(packageJsonPath, state.host); switch (extensions) { @@ -6982,28 +7044,28 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; - function getTokenPosOfNode(node, sourceFile, includeJsDocComment) { + function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; } if (isJSDocNode(node)) { return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); } - if (includeJsDocComment && node.jsDocComments && node.jsDocComments.length > 0) { - return getTokenPosOfNode(node.jsDocComments[0]); + if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 291 && node._children.length > 0) { - return getTokenPosOfNode(node._children[0], sourceFile, includeJsDocComment); + if (node.kind === 292 && node._children.length > 0) { + return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 262 && node.kind <= 287; + return node.kind >= 262 && node.kind <= 288; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 278 && node.kind <= 290; + return node.kind >= 278 && node.kind <= 291; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -7180,7 +7242,7 @@ var ts; case 8: return name.text; case 142: - if (isStringOrNumericLiteral(name.expression.kind)) { + if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } } @@ -7302,7 +7364,8 @@ var ts; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 207 && node.expression.kind === 9; + return node.kind === 207 + && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { @@ -7313,25 +7376,20 @@ var ts; return ts.getLeadingCommentRanges(text, node.pos); } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; - function getJsDocComments(node, sourceFileOfNode) { - return getJsDocCommentsFromText(node, sourceFileOfNode.text); - } - ts.getJsDocComments = getJsDocComments; - function getJsDocCommentsFromText(node, text) { + function getJSDocCommentRanges(node, text) { var commentRanges = (node.kind === 144 || node.kind === 143 || node.kind === 184 || node.kind === 185) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); - return ts.filter(commentRanges, isJsDocComment); - function isJsDocComment(comment) { + return ts.filter(commentRanges, function (comment) { return text.charCodeAt(comment.pos + 1) === 42 && text.charCodeAt(comment.pos + 2) === 42 && text.charCodeAt(comment.pos + 3) !== 47; - } + }); } - ts.getJsDocCommentsFromText = getJsDocCommentsFromText; + ts.getJSDocCommentRanges = getJSDocCommentRanges; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/; @@ -7857,6 +7915,7 @@ var ts; case 145: case 252: case 251: + case 259: return true; case 199: return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); @@ -8011,152 +8070,118 @@ var ts; node.parameters[0].type.kind === 276; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function getJSDocTag(node, kind, checkParentVariableStatement) { - if (!node) { - return undefined; - } - var jsDocTags = getJSDocTags(node, checkParentVariableStatement); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_1 = jsDocTags; _i < jsDocTags_1.length; _i++) { - var tag = jsDocTags_1[_i]; - if (tag.kind === kind) { - return tag; - } - } + function getCommentsFromJSDoc(node) { + return ts.map(getJSDocs(node), function (doc) { return doc.comment; }); } - function append(previous, additional) { - if (additional) { - if (!previous) { - previous = []; - } - for (var _i = 0, additional_1 = additional; _i < additional_1.length; _i++) { - var x = additional_1[_i]; - previous.push(x); - } - } - return previous; - } - function getJSDocComments(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { return ts.map(docs, function (doc) { return doc.comment; }); }, function (tags) { return ts.map(tags, function (tag) { return tag.comment; }); }); - } - ts.getJSDocComments = getJSDocComments; - function getJSDocTags(node, checkParentVariableStatement) { - return getJSDocs(node, checkParentVariableStatement, function (docs) { + ts.getCommentsFromJSDoc = getCommentsFromJSDoc; + function getJSDocTags(node, kind) { + var docs = getJSDocs(node); + if (docs) { var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.tags) { - result.push.apply(result, doc.tags); + if (doc.kind === 281) { + if (doc.kind === kind) { + result.push(doc); + } + } + else { + result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); } } return result; - }, function (tags) { return tags; }); - } - function getJSDocs(node, checkParentVariableStatement, getDocs, getTags) { - var result = undefined; - if (checkParentVariableStatement) { - var isInitializerOfVariableDeclarationInStatement = isVariableLike(node.parent) && - (node.parent).initializer === node && - node.parent.parent.parent.kind === 205; + } + } + function getFirstJSDocTag(node, kind) { + return node && ts.firstOrUndefined(getJSDocTags(node, kind)); + } + function getJSDocs(node) { + var cache = node.jsDocCache; + if (!cache) { + getJSDocsWorker(node); + node.jsDocCache = cache; + } + return cache; + function getJSDocsWorker(node) { + var parent = node.parent; + var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && + parent.initializer === node && + parent.parent.parent.kind === 205; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - node.parent.parent.kind === 205; - var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : - isVariableOfVariableDeclarationStatement ? node.parent.parent : + parent.parent.kind === 205; + var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : + isVariableOfVariableDeclarationStatement ? parent.parent : undefined; if (variableStatementNode) { - result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); - } - if (node.kind === 230 && - node.parent && node.parent.kind === 230) { - result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); + getJSDocsWorker(variableStatementNode); } - var parent_4 = node.parent; - var isSourceOfAssignmentExpressionStatement = parent_4 && parent_4.parent && - parent_4.kind === 192 && - parent_4.operatorToken.kind === 57 && - parent_4.parent.kind === 207; + var isSourceOfAssignmentExpressionStatement = parent && parent.parent && + parent.kind === 192 && + parent.operatorToken.kind === 57 && + parent.parent.kind === 207; if (isSourceOfAssignmentExpressionStatement) { - result = append(result, getJSDocs(parent_4.parent, checkParentVariableStatement, getDocs, getTags)); + getJSDocsWorker(parent.parent); } - var isPropertyAssignmentExpression = parent_4 && parent_4.kind === 257; - if (isPropertyAssignmentExpression) { - result = append(result, getJSDocs(parent_4, checkParentVariableStatement, getDocs, getTags)); + var isModuleDeclaration = node.kind === 230 && + parent && parent.kind === 230; + var isPropertyAssignmentExpression = parent && parent.kind === 257; + if (isModuleDeclaration || isPropertyAssignmentExpression) { + getJSDocsWorker(parent); } if (node.kind === 144) { - var paramTags = getJSDocParameterTag(node, checkParentVariableStatement); - if (paramTags) { - result = append(result, getTags(paramTags)); - } - } - } - if (isVariableLike(node) && node.initializer) { - result = append(result, getJSDocs(node.initializer, false, getDocs, getTags)); - } - if (node.jsDocComments) { - if (result) { - result = append(result, getDocs(node.jsDocComments)); + cache = ts.concatenate(cache, getJSDocParameterTags(node)); } - else { - return getDocs(node.jsDocComments); + if (isVariableLike(node) && node.initializer) { + cache = ts.concatenate(cache, node.initializer.jsDoc); } + cache = ts.concatenate(cache, node.jsDoc); } - return result; } - function getJSDocParameterTag(param, checkParentVariableStatement) { + function getJSDocParameterTags(param) { + if (!isParameter(param)) { + return undefined; + } var func = param.parent; - var tags = getJSDocTags(func, checkParentVariableStatement); + var tags = getJSDocTags(func, 281); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 280; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 281; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } else if (param.name.kind === 70) { var name_8 = param.name.text; - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 280 && tag.parameterName.text === name_8; }); - if (paramTags) { - return paramTags; - } + return ts.filter(tags, function (tag) { return tag.kind === 281 && tag.parameterName.text === name_8; }); } else { return undefined; } } - function getJSDocTypeTag(node) { - return getJSDocTag(node, 282, false); + ts.getJSDocParameterTags = getJSDocParameterTags; + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 283); + if (!tag && node.kind === 144) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 280); } - ts.getJSDocTypeTag = getJSDocTypeTag; + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 281, true); + return getFirstJSDocTag(node, 282); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 283, false); + return getFirstJSDocTag(node, 284); } ts.getJSDocTemplateTag = getJSDocTemplateTag; - function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 70) { - var parameterName = parameter.name.text; - var jsDocTags = getJSDocTags(parameter.parent, true); - if (!jsDocTags) { - return undefined; - } - for (var _i = 0, jsDocTags_2 = jsDocTags; _i < jsDocTags_2.length; _i++) { - var tag = jsDocTags_2[_i]; - if (tag.kind === 280) { - var parameterTag = tag; - if (parameterTag.parameterName.text === parameterName) { - return parameterTag; - } - } - } - } - return undefined; - } - ts.getCorrespondingJSDocParameterTag = getCorrespondingJSDocParameterTag; function hasRestParameter(s) { return isRestParameter(ts.lastOrUndefined(s.parameters)); } @@ -8167,13 +8192,10 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 2097152)) { - if (node.type && node.type.kind === 275) { + if (node.type && node.type.kind === 275 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 275; })) { return true; } - var paramTag = getCorrespondingJSDocParameterTag(node); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 275; - } } return isDeclaredRestParam(node); } @@ -8396,8 +8418,10 @@ var ts; return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; - function isStringOrNumericLiteral(kind) { - return kind === 9 || kind === 8; + function isStringOrNumericLiteral(node) { + var kind = node.kind; + return kind === 9 + || kind === 8; } ts.isStringOrNumericLiteral = isStringOrNumericLiteral; function hasDynamicName(declaration) { @@ -8406,7 +8430,7 @@ var ts; ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { return name.kind === 142 && - !isStringOrNumericLiteral(name.expression.kind) && + !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } ts.isDynamicName = isDynamicName; @@ -8612,6 +8636,7 @@ var ts; case 194: case 183: case 198: + case 297: return 19; case 181: case 177: @@ -9373,19 +9398,19 @@ var ts; } } ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments; - function isAssignmentExpression(node) { + function isAssignmentExpression(node, excludeCompoundAssignment) { return isBinaryExpression(node) - && isAssignmentOperator(node.operatorToken.kind) + && (excludeCompoundAssignment + ? node.operatorToken.kind === 57 + : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left); } ts.isAssignmentExpression = isAssignmentExpression; function isDestructuringAssignment(node) { - if (isBinaryExpression(node)) { - if (node.operatorToken.kind === 57) { - var kind = node.left.kind; - return kind === 176 - || kind === 175; - } + if (isAssignmentExpression(node, true)) { + var kind = node.left.kind; + return kind === 176 + || kind === 175; } return false; } @@ -9696,122 +9721,6 @@ var ts; return ts.positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); } ts.getStartPositionOfRange = getStartPositionOfRange; - function collectExternalModuleInfo(sourceFile, resolver) { - var externalImports = []; - var exportSpecifiers = ts.createMap(); - var exportedBindings = ts.createMap(); - var uniqueExports = ts.createMap(); - var hasExportDefault = false; - var exportEquals = undefined; - var hasExportStarsToExportValues = false; - for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { - var node = _a[_i]; - switch (node.kind) { - case 235: - externalImports.push(node); - break; - case 234: - if (node.moduleReference.kind === 245) { - externalImports.push(node); - } - break; - case 241: - if (node.moduleSpecifier) { - if (!node.exportClause) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } - else { - externalImports.push(node); - } - } - else { - for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { - var specifier = _c[_b]; - if (!uniqueExports[specifier.name.text]) { - var name_10 = specifier.propertyName || specifier.name; - ts.multiMapAdd(exportSpecifiers, name_10.text, specifier); - var decl = resolver.getReferencedImportDeclaration(name_10) - || resolver.getReferencedValueDeclaration(name_10); - if (decl) { - ts.multiMapAdd(exportedBindings, getOriginalNodeId(decl), specifier.name); - } - uniqueExports[specifier.name.text] = specifier.name; - } - } - } - break; - case 240: - if (node.isExportEquals && !exportEquals) { - exportEquals = node; - } - break; - case 205: - if (hasModifier(node, 1)) { - for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { - var decl = _e[_d]; - collectExportedVariableInfo(decl, uniqueExports); - } - } - break; - case 225: - if (hasModifier(node, 1)) { - if (hasModifier(node, 512)) { - if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); - hasExportDefault = true; - } - } - else { - var name_11 = node.name; - if (!uniqueExports[name_11.text]) { - ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_11); - uniqueExports[name_11.text] = name_11; - } - } - } - break; - case 226: - if (hasModifier(node, 1)) { - if (hasModifier(node, 512)) { - if (!hasExportDefault) { - ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), ts.getDeclarationName(node)); - hasExportDefault = true; - } - } - else { - var name_12 = node.name; - if (!uniqueExports[name_12.text]) { - ts.multiMapAdd(exportedBindings, getOriginalNodeId(node), name_12); - uniqueExports[name_12.text] = name_12; - } - } - } - break; - } - } - var exportedNames; - for (var key in uniqueExports) { - exportedNames = ts.append(exportedNames, uniqueExports[key]); - } - return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames }; - } - ts.collectExternalModuleInfo = collectExternalModuleInfo; - function collectExportedVariableInfo(decl, uniqueExports) { - if (isBindingPattern(decl.name)) { - for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { - var element = _a[_i]; - if (!isOmittedExpression(element)) { - collectExportedVariableInfo(element, uniqueExports); - } - } - } - else if (!isGeneratedIdentifier(decl.name)) { - if (!uniqueExports[decl.name.text]) { - uniqueExports[decl.name.text] = decl.name; - } - } - } function isDeclarationNameOfEnumOrNamespace(node) { var parseNode = getParseTreeNode(node); if (parseNode) { @@ -9982,6 +9891,14 @@ var ts; return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; + function isArrayBindingPattern(node) { + return node.kind === 173; + } + ts.isArrayBindingPattern = isArrayBindingPattern; + function isObjectBindingPattern(node) { + return node.kind === 172; + } + ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; @@ -9991,6 +9908,12 @@ var ts; return false; } ts.isBindingPattern = isBindingPattern; + function isAssignmentPattern(node) { + var kind = node.kind; + return kind === 175 + || kind === 176; + } + ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { return node.kind === 174; } @@ -10001,6 +9924,39 @@ var ts; || kind === 198; } ts.isArrayBindingElement = isArrayBindingElement; + function isDeclarationBindingElement(bindingElement) { + switch (bindingElement.kind) { + case 223: + case 144: + case 174: + return true; + } + return false; + } + ts.isDeclarationBindingElement = isDeclarationBindingElement; + function isBindingOrAssignmentPattern(node) { + return isObjectBindingOrAssignmentPattern(node) + || isArrayBindingOrAssignmentPattern(node); + } + ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; + function isObjectBindingOrAssignmentPattern(node) { + switch (node.kind) { + case 172: + case 176: + return true; + } + return false; + } + ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; + function isArrayBindingOrAssignmentPattern(node) { + switch (node.kind) { + case 173: + case 175: + return true; + } + return false; + } + ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { return node.kind === 175; } @@ -10067,7 +10023,8 @@ var ts; || kind === 98 || kind === 100 || kind === 96 - || kind === 201; + || kind === 201 + || kind === 297; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); @@ -10095,6 +10052,7 @@ var ts; || kind === 196 || kind === 200 || kind === 198 + || kind === 297 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10108,11 +10066,11 @@ var ts; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 293; + return node.kind === 294; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 292; + return node.kind === 293; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10224,7 +10182,7 @@ var ts; || kind === 228 || kind === 143 || kind === 223 - || kind === 284; + || kind === 285; } function isDeclarationStatementKind(kind) { return kind === 225 @@ -10259,9 +10217,9 @@ var ts; || kind === 205 || kind === 210 || kind === 217 - || kind === 292 - || kind === 295 - || kind === 294; + || kind === 293 + || kind === 296 + || kind === 295; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10549,6 +10507,53 @@ var ts; return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; + function validateLocaleAndSetLanguage(locale, sys, errors) { + var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); + if (!matchResult) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp")); + } + return; + } + var language = matchResult[1]; + var territory = matchResult[3]; + if (!trySetLanguageAndTerritory(language, territory, errors)) { + trySetLanguageAndTerritory(language, undefined, errors); + } + function trySetLanguageAndTerritory(language, territory, errors) { + var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath()); + var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath); + var filePath = ts.combinePaths(containingDirectoryPath, language); + if (territory) { + filePath = filePath + "-" + territory; + } + filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json")); + if (!sys.fileExists(filePath)) { + return false; + } + var fileContents = ""; + try { + fileContents = sys.readFile(filePath); + } + catch (e) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); + } + return false; + } + try { + ts.localizedDiagnosticMessages = JSON.parse(fileContents); + } + catch (e) { + if (errors) { + errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath)); + } + return false; + } + return true; + } + } + ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage; })(ts || (ts = {})); var ts; (function (ts) { @@ -10749,9 +10754,9 @@ var ts; return node; } ts.createParameter = createParameter; - function updateParameter(node, decorators, modifiers, name, type, initializer) { - if (node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name || node.type !== type || node.initializer !== initializer) { - return updateNode(createParameter(decorators, modifiers, node.dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); + function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { + if (node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.type !== type || node.initializer !== initializer) { + return updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer, node, node.flags), node); } return node; } @@ -10884,9 +10889,9 @@ var ts; return node; } ts.createBindingElement = createBindingElement; - function updateBindingElement(node, propertyName, name, initializer) { - if (node.propertyName !== propertyName || node.name !== name || node.initializer !== initializer) { - return updateNode(createBindingElement(propertyName, node.dotDotDotToken, name, initializer, node), node); + function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) { + if (node.propertyName !== propertyName || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer) { + return updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer, node), node); } return node; } @@ -10926,7 +10931,7 @@ var ts; function createPropertyAccess(expression, name, location, flags) { var node = createNode(177, location, flags); node.expression = parenthesizeForAccess(expression); - (node.emitNode || (node.emitNode = {})).flags |= 1048576; + (node.emitNode || (node.emitNode = {})).flags |= 65536; node.name = typeof name === "string" ? createIdentifier(name) : name; return node; } @@ -11147,13 +11152,21 @@ var ts; return node; } ts.updateBinary = updateBinary; - function createConditional(condition, questionToken, whenTrue, colonToken, whenFalse, location) { - var node = createNode(193, location); - node.condition = condition; - node.questionToken = questionToken; - node.whenTrue = whenTrue; - node.colonToken = colonToken; - node.whenFalse = whenFalse; + function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonTokenOrLocation, whenFalse, location) { + var node = createNode(193, whenFalse ? location : colonTokenOrLocation); + node.condition = parenthesizeForConditionalHead(condition); + if (whenFalse) { + node.questionToken = questionTokenOrWhenTrue; + node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); + node.colonToken = colonTokenOrLocation; + node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenFalse); + } + else { + node.questionToken = createToken(54); + node.whenTrue = parenthesizeSubexpressionOfConditionalExpression(questionTokenOrWhenTrue); + node.colonToken = createToken(55); + node.whenFalse = parenthesizeSubexpressionOfConditionalExpression(whenTrueOrWhenFalse); + } return node; } ts.createConditional = createConditional; @@ -11963,35 +11976,33 @@ var ts; updated.imports = node.imports; if (node.moduleAugmentations !== undefined) updated.moduleAugmentations = node.moduleAugmentations; - if (node.externalHelpersModuleName !== undefined) - updated.externalHelpersModuleName = node.externalHelpersModuleName; return updateNode(updated, node); } return node; } ts.updateSourceFileNode = updateSourceFileNode; function createNotEmittedStatement(original) { - var node = createNode(292, original); + var node = createNode(293, original); node.original = original; return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createNode(295); + var node = createNode(296); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createNode(294); + var node = createNode(295); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original, location) { - var node = createNode(293, location || original); + var node = createNode(294, location || original); node.expression = expression; node.original = original; return node; @@ -12004,6 +12015,12 @@ var ts; return node; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; + function createRawExpression(text) { + var node = createNode(297); + node.text = text; + return node; + } + ts.createRawExpression = createRawExpression; function createComma(left, right) { return createBinary(left, 25, right); } @@ -12052,13 +12069,19 @@ var ts; return createVoid(createLiteral(0)); } ts.createVoidZero = createVoidZero; + function createTypeCheck(value, tag) { + return tag === "undefined" + ? createStrictEquality(value, createVoidZero()) + : createStrictEquality(createTypeOf(value), createLiteral(tag)); + } + ts.createTypeCheck = createTypeCheck; function createMemberAccessForPropertyName(target, memberName, location) { if (ts.isComputedPropertyName(memberName)) { return createElementAccess(target, memberName.expression, location); } else { var expression = ts.isIdentifier(memberName) ? createPropertyAccess(target, memberName, location) : createElementAccess(target, memberName, location); - (expression.emitNode || (expression.emitNode = {})).flags |= 2048; + (expression.emitNode || (expression.emitNode = {})).flags |= 64; return expression; } } @@ -12100,7 +12123,10 @@ var ts; } function createJsxFactoryExpressionFromEntityName(jsxFactory, parent) { if (ts.isQualifiedName(jsxFactory)) { - return createPropertyAccess(createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent), setEmitFlags(getMutableClone(jsxFactory.right), 1536)); + var left = createJsxFactoryExpressionFromEntityName(jsxFactory.left, parent); + var right = createSynthesizedNode(70); + right.text = jsxFactory.right.text; + return createPropertyAccess(left, right); } else { return createReactNamespace(jsxFactory.text, parent); @@ -12154,114 +12180,10 @@ var ts; return createVariableDeclarationList(declarations, location, 2); } ts.createConstDeclarationList = createConstDeclarationList; - function createHelperName(externalHelpersModuleName, name) { - return externalHelpersModuleName - ? createPropertyAccess(externalHelpersModuleName, name) - : createIdentifier(name); - } - ts.createHelperName = createHelperName; - function createExtendsHelper(externalHelpersModuleName, name) { - return createCall(createHelperName(externalHelpersModuleName, "__extends"), undefined, [ - name, - createIdentifier("_super") - ]); - } - ts.createExtendsHelper = createExtendsHelper; - function createAssignHelper(externalHelpersModuleName, attributesSegments) { - return createCall(createHelperName(externalHelpersModuleName, "__assign"), undefined, attributesSegments); - } - ts.createAssignHelper = createAssignHelper; - function createParamHelper(externalHelpersModuleName, expression, parameterOffset, location) { - return createCall(createHelperName(externalHelpersModuleName, "__param"), undefined, [ - createLiteral(parameterOffset), - expression - ], location); - } - ts.createParamHelper = createParamHelper; - function createMetadataHelper(externalHelpersModuleName, metadataKey, metadataValue) { - return createCall(createHelperName(externalHelpersModuleName, "__metadata"), undefined, [ - createLiteral(metadataKey), - metadataValue - ]); - } - ts.createMetadataHelper = createMetadataHelper; - function createDecorateHelper(externalHelpersModuleName, decoratorExpressions, target, memberName, descriptor, location) { - var argumentsArray = []; - argumentsArray.push(createArrayLiteral(decoratorExpressions, undefined, true)); - argumentsArray.push(target); - if (memberName) { - argumentsArray.push(memberName); - if (descriptor) { - argumentsArray.push(descriptor); - } - } - return createCall(createHelperName(externalHelpersModuleName, "__decorate"), undefined, argumentsArray, location); + function getHelperName(name) { + return setEmitFlags(createIdentifier(name), 4096 | 2); } - ts.createDecorateHelper = createDecorateHelper; - function createAwaiterHelper(externalHelpersModuleName, hasLexicalArguments, promiseConstructor, body) { - var generatorFunc = createFunctionExpression(undefined, createToken(38), undefined, undefined, [], undefined, body); - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 2097152; - return createCall(createHelperName(externalHelpersModuleName, "__awaiter"), undefined, [ - createThis(), - hasLexicalArguments ? createIdentifier("arguments") : createVoidZero(), - promiseConstructor ? createExpressionFromEntityName(promiseConstructor) : createVoidZero(), - generatorFunc - ]); - } - ts.createAwaiterHelper = createAwaiterHelper; - function createHasOwnProperty(target, propertyName) { - return createCall(createPropertyAccess(target, "hasOwnProperty"), undefined, [propertyName]); - } - ts.createHasOwnProperty = createHasOwnProperty; - function createObjectCreate(prototype) { - return createCall(createPropertyAccess(createIdentifier("Object"), "create"), undefined, [prototype]); - } - function createGeti(target) { - return createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createElementAccess(target, createIdentifier("name"))); - } - function createSeti(target) { - return createArrowFunction(undefined, undefined, [ - createParameter(undefined, undefined, undefined, "name"), - createParameter(undefined, undefined, undefined, "value") - ], undefined, createToken(35), createAssignment(createElementAccess(target, createIdentifier("name")), createIdentifier("value"))); - } - function createAdvancedAsyncSuperHelper() { - var createCache = createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("cache", undefined, createObjectCreate(createNull())) - ])); - var getter = createGetAccessor(undefined, undefined, "value", [], undefined, createBlock([ - createReturn(createCall(createIdentifier("geti"), undefined, [createIdentifier("name")])) - ])); - var setter = createSetAccessor(undefined, undefined, "value", [createParameter(undefined, undefined, undefined, "v")], createBlock([ - createStatement(createCall(createIdentifier("seti"), undefined, [ - createIdentifier("name"), - createIdentifier("v") - ])) - ])); - var getOrCreateAccessorsForName = createReturn(createArrowFunction(undefined, undefined, [createParameter(undefined, undefined, undefined, "name")], undefined, createToken(35), createLogicalOr(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createParen(createAssignment(createElementAccess(createIdentifier("cache"), createIdentifier("name")), createObjectLiteral([ - getter, - setter - ])))))); - return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createCall(createParen(createFunctionExpression(undefined, undefined, undefined, undefined, [ - createParameter(undefined, undefined, undefined, "geti"), - createParameter(undefined, undefined, undefined, "seti") - ], undefined, createBlock([ - createCache, - getOrCreateAccessorsForName - ]))), undefined, [ - createGeti(createSuper()), - createSeti(createSuper()) - ])) - ])); - } - ts.createAdvancedAsyncSuperHelper = createAdvancedAsyncSuperHelper; - function createSimpleAsyncSuperHelper() { - return createVariableStatement(undefined, createConstDeclarationList([ - createVariableDeclaration("_super", undefined, createGeti(createSuper())) - ])); - } - ts.createSimpleAsyncSuperHelper = createSimpleAsyncSuperHelper; + ts.getHelperName = getHelperName; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { @@ -12407,19 +12329,19 @@ var ts; return ts.aggregateTransformFlags(setOriginalNode(createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), setOriginalNode(createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body, method), method), method), method)); } function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 262144); + return getName(node, allowComments, allowSourceMaps, 16384); } ts.getLocalName = getLocalName; function isLocalName(node) { - return (getEmitFlags(node) & 262144) !== 0; + return (getEmitFlags(node) & 16384) !== 0; } ts.isLocalName = isLocalName; function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 131072); + return getName(node, allowComments, allowSourceMaps, 8192); } ts.getExportName = getExportName; function isExportName(node) { - return (getEmitFlags(node) & 131072) !== 0; + return (getEmitFlags(node) & 8192) !== 0; } ts.isExportName = isExportName; function getDeclarationName(node, allowComments, allowSourceMaps) { @@ -12428,15 +12350,15 @@ var ts; ts.getDeclarationName = getDeclarationName; function getName(node, allowComments, allowSourceMaps, emitFlags) { if (node.name && ts.isIdentifier(node.name) && !ts.isGeneratedIdentifier(node.name)) { - var name_13 = getMutableClone(node.name); + var name_10 = getMutableClone(node.name); emitFlags |= getEmitFlags(node.name); if (!allowSourceMaps) - emitFlags |= 1536; + emitFlags |= 48; if (!allowComments) - emitFlags |= 49152; + emitFlags |= 1536; if (emitFlags) - setEmitFlags(name_13, emitFlags); - return name_13; + setEmitFlags(name_10, emitFlags); + return name_10; } return getGeneratedNameForNode(node); } @@ -12451,14 +12373,18 @@ var ts; var qualifiedName = createPropertyAccess(ns, ts.nodeIsSynthesized(name) ? name : getSynthesizedClone(name), name); var emitFlags; if (!allowSourceMaps) - emitFlags |= 1536; + emitFlags |= 48; if (!allowComments) - emitFlags |= 49152; + emitFlags |= 1536; if (emitFlags) setEmitFlags(qualifiedName, emitFlags); return qualifiedName; } ts.getNamespaceMemberName = getNamespaceMemberName; + function convertToFunctionBody(node, multiLine) { + return ts.isBlock(node) ? node : createBlock([createReturn(node, node)], node, multiLine); + } + ts.convertToFunctionBody = convertToFunctionBody; function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } @@ -12485,7 +12411,7 @@ var ts; } while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (getEmitFlags(statement) & 8388608) { + if (getEmitFlags(statement) & 524288) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -12496,10 +12422,17 @@ var ts; return statementOffset; } ts.addPrologueDirectives = addPrologueDirectives; - function ensureUseStrict(node) { + function startsWithUseStrict(statements) { + var firstStatement = ts.firstOrUndefined(statements); + return firstStatement !== undefined + && ts.isPrologueDirective(firstStatement) + && isUseStrictPrologue(firstStatement); + } + ts.startsWithUseStrict = startsWithUseStrict; + function ensureUseStrict(statements) { var foundUseStrict = false; - for (var _i = 0, _a = node.statements; _i < _a.length; _i++) { - var statement = _a[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { foundUseStrict = true; @@ -12511,11 +12444,11 @@ var ts; } } if (!foundUseStrict) { - var statements = []; - statements.push(startOnNewLine(createStatement(createLiteral("use strict")))); - return updateSourceFileNode(node, statements.concat(node.statements)); + return createNodeArray([ + startOnNewLine(createStatement(createLiteral("use strict"))) + ].concat(statements), statements); } - return node; + return statements; } ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { @@ -12590,6 +12523,21 @@ var ts; } return 0; } + function parenthesizeForConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(193, 54); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return createParen(condition); + } + return condition; + } + ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; + function parenthesizeSubexpressionOfConditionalExpression(e) { + return e.kind === 192 && e.operatorToken.kind === 25 + ? createParen(e) + : e; + } function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { @@ -12695,7 +12643,7 @@ var ts; case 177: node = node.expression; continue; - case 293: + case 294: node = node.expression; continue; } @@ -12743,7 +12691,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 293) { + while (node.kind === 294) { node = node.expression; } return node; @@ -12765,8 +12713,8 @@ var ts; } ts.setOriginalNode = setOriginalNode; function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges; - if (!destEmitNode && (flags || commentRange || sourceMapRange || tokenSourceMapRanges)) + var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + if (!destEmitNode) destEmitNode = {}; if (flags) destEmitNode.flags = flags; @@ -12776,6 +12724,10 @@ var ts; destEmitNode.sourceMapRange = sourceMapRange; if (tokenSourceMapRanges) destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges); + if (constantValue !== undefined) + destEmitNode.constantValue = constantValue; + if (helpers) + destEmitNode.helpers = ts.addRange(destEmitNode.helpers, helpers); return destEmitNode; } function mergeTokenSourceMapRanges(sourceRanges, destRanges) { @@ -12809,6 +12761,7 @@ var ts; } return node.emitNode; } + ts.getOrCreateEmitNode = getOrCreateEmitNode; function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -12819,11 +12772,22 @@ var ts; return node; } ts.setEmitFlags = setEmitFlags; + function getSourceMapRange(node) { + var emitNode = node.emitNode; + return (emitNode && emitNode.sourceMapRange) || node; + } + ts.getSourceMapRange = getSourceMapRange; function setSourceMapRange(node, range) { getOrCreateEmitNode(node).sourceMapRange = range; return node; } ts.setSourceMapRange = setSourceMapRange; + function getTokenSourceMapRange(node, token) { + var emitNode = node.emitNode; + var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; + return tokenSourceMapRanges && tokenSourceMapRanges[token]; + } + ts.getTokenSourceMapRange = getTokenSourceMapRange; function setTokenSourceMapRange(node, token, range) { var emitNode = getOrCreateEmitNode(node); var tokenSourceMapRanges = emitNode.tokenSourceMapRanges || (emitNode.tokenSourceMapRanges = ts.createMap()); @@ -12831,27 +12795,16 @@ var ts; return node; } ts.setTokenSourceMapRange = setTokenSourceMapRange; - function setCommentRange(node, range) { - getOrCreateEmitNode(node).commentRange = range; - return node; - } - ts.setCommentRange = setCommentRange; function getCommentRange(node) { var emitNode = node.emitNode; return (emitNode && emitNode.commentRange) || node; } ts.getCommentRange = getCommentRange; - function getSourceMapRange(node) { - var emitNode = node.emitNode; - return (emitNode && emitNode.sourceMapRange) || node; - } - ts.getSourceMapRange = getSourceMapRange; - function getTokenSourceMapRange(node, token) { - var emitNode = node.emitNode; - var tokenSourceMapRanges = emitNode && emitNode.tokenSourceMapRanges; - return tokenSourceMapRanges && tokenSourceMapRanges[token]; + function setCommentRange(node, range) { + getOrCreateEmitNode(node).commentRange = range; + return node; } - ts.getTokenSourceMapRange = getTokenSourceMapRange; + ts.setCommentRange = setCommentRange; function getConstantValue(node) { var emitNode = node.emitNode; return emitNode && emitNode.constantValue; @@ -12863,6 +12816,103 @@ var ts; return node; } ts.setConstantValue = setConstantValue; + function getExternalHelpersModuleName(node) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = parseNode && parseNode.emitNode; + return emitNode && emitNode.externalHelpersModuleName; + } + ts.getExternalHelpersModuleName = getExternalHelpersModuleName; + function getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions) { + if (compilerOptions.importHelpers && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { + var externalHelpersModuleName = getExternalHelpersModuleName(node); + if (externalHelpersModuleName) { + return externalHelpersModuleName; + } + var helpers = getEmitHelpers(node); + if (helpers) { + for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { + var helper = helpers_1[_i]; + if (!helper.scoped) { + var parseNode = ts.getOriginalNode(node, ts.isSourceFile); + var emitNode = getOrCreateEmitNode(parseNode); + return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = createUniqueName(ts.externalHelpersModuleNameText)); + } + } + } + } + } + ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded; + function addEmitHelper(node, helper) { + var emitNode = getOrCreateEmitNode(node); + emitNode.helpers = ts.append(emitNode.helpers, helper); + return node; + } + ts.addEmitHelper = addEmitHelper; + function addEmitHelpers(node, helpers) { + if (ts.some(helpers)) { + var emitNode = getOrCreateEmitNode(node); + for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) { + var helper = helpers_2[_i]; + if (!ts.contains(emitNode.helpers, helper)) { + emitNode.helpers = ts.append(emitNode.helpers, helper); + } + } + } + return node; + } + ts.addEmitHelpers = addEmitHelpers; + function removeEmitHelper(node, helper) { + var emitNode = node.emitNode; + if (emitNode) { + var helpers = emitNode.helpers; + if (helpers) { + return ts.orderedRemoveItem(helpers, helper); + } + } + return false; + } + ts.removeEmitHelper = removeEmitHelper; + function getEmitHelpers(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.helpers; + } + ts.getEmitHelpers = getEmitHelpers; + function moveEmitHelpers(source, target, predicate) { + var sourceEmitNode = source.emitNode; + var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers; + if (!ts.some(sourceEmitHelpers)) + return; + var targetEmitNode = getOrCreateEmitNode(target); + var helpersRemoved = 0; + for (var i = 0; i < sourceEmitHelpers.length; i++) { + var helper = sourceEmitHelpers[i]; + if (predicate(helper)) { + helpersRemoved++; + if (!ts.contains(targetEmitNode.helpers, helper)) { + targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); + } + } + else if (helpersRemoved > 0) { + sourceEmitHelpers[i - helpersRemoved] = helper; + } + } + if (helpersRemoved > 0) { + sourceEmitHelpers.length -= helpersRemoved; + } + } + ts.moveEmitHelpers = moveEmitHelpers; + function compareEmitHelpers(x, y) { + if (x === y) + return 0; + if (x.priority === y.priority) + return 0; + if (x.priority === undefined) + return 1; + if (y.priority === undefined) + return -1; + return ts.compareValues(x.priority, y.priority); + } + ts.compareEmitHelpers = compareEmitHelpers; function setTextRange(node, location) { if (location) { node.pos = location.pos; @@ -12889,8 +12939,8 @@ var ts; function getLocalNameForExternalImport(node, sourceFile) { var namespaceDeclaration = ts.getNamespaceDeclarationNode(node); if (namespaceDeclaration && !ts.isDefaultImport(node)) { - var name_14 = namespaceDeclaration.name; - return ts.isGeneratedIdentifier(name_14) ? name_14 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + var name_11 = namespaceDeclaration.name; + return ts.isGeneratedIdentifier(name_11) ? name_11 : createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } if (node.kind === 235 && node.importClause) { return getGeneratedNameForNode(node); @@ -12933,221 +12983,291 @@ var ts; function tryGetModuleNameFromDeclaration(declaration, host, resolver, compilerOptions) { return tryGetModuleNameFromFile(resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions); } - function transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis, convertObjectRest) { - var multiLine = false; - var singleLine = false; - var statementsLocation; - var closeBraceLocation; - var statements = []; - var body = node.body; - var statementOffset; - context.startLexicalEnvironment(); - if (ts.isBlock(body)) { - statementOffset = addPrologueDirectives(statements, body.statements, false, visitor); - } - addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); - addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest); - addRestParameterIfNeeded(statements, node, false); - if (!multiLine && statements.length > 0) { - multiLine = true; - } - if (ts.isBlock(body)) { - statementsLocation = body.statements; - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); - if (!multiLine && body.multiLine) { - multiLine = true; - } + function getInitializerOfBindingOrAssignmentElement(bindingElement) { + if (ts.isDeclarationBindingElement(bindingElement)) { + return bindingElement.initializer; } - else { - ts.Debug.assert(node.kind === 185); - statementsLocation = ts.moveRangeEnd(body, -1); - var equalsGreaterThanToken = node.equalsGreaterThanToken; - if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { - if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { - singleLine = true; - } - else { - multiLine = true; - } - } - var expression = ts.visitNode(body, visitor, ts.isExpression); - var returnStatement = createReturn(expression, body); - setEmitFlags(returnStatement, 12288 | 1024 | 32768); - statements.push(returnStatement); - closeBraceLocation = body; + if (ts.isPropertyAssignment(bindingElement)) { + return ts.isAssignmentExpression(bindingElement.initializer, true) + ? bindingElement.initializer.right + : undefined; } - var lexicalEnvironment = context.endLexicalEnvironment(); - ts.addRange(statements, lexicalEnvironment); - if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { - multiLine = true; + if (ts.isShorthandPropertyAssignment(bindingElement)) { + return bindingElement.objectAssignmentInitializer; } - var block = createBlock(createNodeArray(statements, statementsLocation), node.body, multiLine); - if (!multiLine && singleLine) { - setEmitFlags(block, 32); + if (ts.isAssignmentExpression(bindingElement, true)) { + return bindingElement.right; } - if (closeBraceLocation) { - setTokenSourceMapRange(block, 17, closeBraceLocation); + if (ts.isSpreadExpression(bindingElement)) { + return getInitializerOfBindingOrAssignmentElement(bindingElement.expression); } - setOriginalNode(block, node.body); - return block; } - ts.transformFunctionBody = transformFunctionBody; - function addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis) { - if (node.transformFlags & 524288 && node.kind !== 185) { - captureThisForNode(statements, node, createThis(), enableSubstitutionsForCapturedThis); + ts.getInitializerOfBindingOrAssignmentElement = getInitializerOfBindingOrAssignmentElement; + function getTargetOfBindingOrAssignmentElement(bindingElement) { + if (ts.isDeclarationBindingElement(bindingElement)) { + return bindingElement.name; + } + if (ts.isObjectLiteralElementLike(bindingElement)) { + switch (bindingElement.kind) { + case 257: + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); + case 258: + return bindingElement.name; + case 259: + return getTargetOfBindingOrAssignmentElement(bindingElement.expression); + } + return undefined; } + if (ts.isAssignmentExpression(bindingElement, true)) { + return getTargetOfBindingOrAssignmentElement(bindingElement.left); + } + if (ts.isSpreadExpression(bindingElement)) { + return getTargetOfBindingOrAssignmentElement(bindingElement.expression); + } + return bindingElement; } - ts.addCaptureThisForNodeIfNeeded = addCaptureThisForNodeIfNeeded; - function captureThisForNode(statements, node, initializer, enableSubstitutionsForCapturedThis, originalStatement) { - enableSubstitutionsForCapturedThis(); - var captureThisStatement = createVariableStatement(undefined, createVariableDeclarationList([ - createVariableDeclaration("_this", undefined, initializer) - ]), originalStatement); - setEmitFlags(captureThisStatement, 49152 | 8388608); - setSourceMapRange(captureThisStatement, node); - statements.push(captureThisStatement); + ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; + function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { + switch (bindingElement.kind) { + case 144: + case 174: + return bindingElement.dotDotDotToken; + case 196: + case 259: + return bindingElement; + } + return undefined; } - ts.captureThisForNode = captureThisForNode; - function shouldAddDefaultValueAssignments(node) { - return (node.transformFlags & 2097152) !== 0; + ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; + function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { + switch (bindingElement.kind) { + case 174: + if (bindingElement.propertyName) { + var propertyName = bindingElement.propertyName; + return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) + ? propertyName.expression + : propertyName; + } + break; + case 257: + if (bindingElement.name) { + var propertyName = bindingElement.name; + return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) + ? propertyName.expression + : propertyName; + } + break; + case 259: + return bindingElement.name; + } + var target = getTargetOfBindingOrAssignmentElement(bindingElement); + if (target && ts.isPropertyName(target)) { + return ts.isComputedPropertyName(target) && ts.isStringOrNumericLiteral(target.expression) + ? target.expression + : target; + } + ts.Debug.fail("Invalid property name for binding element."); } - function addDefaultValueAssignmentsIfNeeded(statements, node, visitor, convertObjectRest) { - if (!shouldAddDefaultValueAssignments(node)) { - return; + ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; + function getElementsOfBindingOrAssignmentPattern(name) { + switch (name.kind) { + case 172: + case 173: + case 175: + return name.elements; + case 176: + return name.properties; } - for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { - var parameter = _a[_i]; - var name_15 = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken; - if (dotDotDotToken) { - continue; + } + ts.getElementsOfBindingOrAssignmentPattern = getElementsOfBindingOrAssignmentPattern; + function convertToArrayAssignmentElement(element) { + if (ts.isBindingElement(element)) { + if (element.dotDotDotToken) { + ts.Debug.assertNode(element.name, ts.isIdentifier); + return setOriginalNode(createSpread(element.name, element), element); } - if (ts.isBindingPattern(name_15)) { - addDefaultValueAssignmentForBindingPattern(statements, parameter, name_15, initializer, visitor, convertObjectRest); + var expression = convertToAssignmentElementTarget(element.name); + return element.initializer ? setOriginalNode(createAssignment(expression, element.initializer, element), element) : expression; + } + ts.Debug.assertNode(element, ts.isExpression); + return element; + } + ts.convertToArrayAssignmentElement = convertToArrayAssignmentElement; + function convertToObjectAssignmentElement(element) { + if (ts.isBindingElement(element)) { + if (element.dotDotDotToken) { + ts.Debug.assertNode(element.name, ts.isIdentifier); + return setOriginalNode(createSpreadAssignment(element.name, element), element); } - else if (initializer) { - addDefaultValueAssignmentForInitializer(statements, parameter, name_15, initializer, visitor); + if (element.propertyName) { + var expression = convertToAssignmentElementTarget(element.name); + return setOriginalNode(createPropertyAssignment(element.propertyName, element.initializer ? createAssignment(expression, element.initializer) : expression, element), element); } + ts.Debug.assertNode(element.name, ts.isIdentifier); + return setOriginalNode(createShorthandPropertyAssignment(element.name, element.initializer, element), element); } + ts.Debug.assertNode(element, ts.isObjectLiteralElementLike); + return element; } - ts.addDefaultValueAssignmentsIfNeeded = addDefaultValueAssignmentsIfNeeded; - function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer, visitor, convertObjectRest) { - var temp = getGeneratedNameForNode(parameter); - if (name.elements.length > 0) { - statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList(ts.flattenParameterDestructuring(parameter, temp, visitor, convertObjectRest))), 8388608)); + ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; + function convertToAssignmentPattern(node) { + switch (node.kind) { + case 173: + case 175: + return convertToArrayAssignmentPattern(node); + case 172: + case 176: + return convertToObjectAssignmentPattern(node); } - else if (initializer) { - statements.push(setEmitFlags(createStatement(createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 8388608)); + } + ts.convertToAssignmentPattern = convertToAssignmentPattern; + function convertToObjectAssignmentPattern(node) { + if (ts.isObjectBindingPattern(node)) { + return setOriginalNode(createObjectLiteral(ts.map(node.elements, convertToObjectAssignmentElement), node), node); } + ts.Debug.assertNode(node, ts.isObjectLiteralExpression); + return node; } - function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer, visitor) { - initializer = ts.visitNode(initializer, visitor, ts.isExpression); - var statement = createIf(createStrictEquality(getSynthesizedClone(name), createVoidZero()), setEmitFlags(createBlock([ - createStatement(createAssignment(setEmitFlags(getMutableClone(name), 1536), setEmitFlags(initializer, 1536 | getEmitFlags(initializer)), parameter)) - ], parameter), 32 | 1024 | 12288), undefined, parameter); - statement.startsOnNewLine = true; - setEmitFlags(statement, 12288 | 1024 | 8388608); - statements.push(statement); + ts.convertToObjectAssignmentPattern = convertToObjectAssignmentPattern; + function convertToArrayAssignmentPattern(node) { + if (ts.isArrayBindingPattern(node)) { + return setOriginalNode(createArrayLiteral(ts.map(node.elements, convertToArrayAssignmentElement), node), node); + } + ts.Debug.assertNode(node, ts.isArrayLiteralExpression); + return node; } - function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + ts.convertToArrayAssignmentPattern = convertToArrayAssignmentPattern; + function convertToAssignmentElementTarget(node) { + if (ts.isBindingPattern(node)) { + return convertToAssignmentPattern(node); + } + ts.Debug.assertNode(node, ts.isExpression); + return node; } - function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { - var parameter = ts.lastOrUndefined(node.parameters); - if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { - return; + ts.convertToAssignmentElementTarget = convertToAssignmentElementTarget; + function collectExternalModuleInfo(sourceFile, resolver, compilerOptions) { + var externalImports = []; + var exportSpecifiers = ts.createMap(); + var exportedBindings = ts.createMap(); + var uniqueExports = ts.createMap(); + var exportedNames; + var hasExportDefault = false; + var exportEquals = undefined; + var hasExportStarsToExportValues = false; + var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(sourceFile, compilerOptions); + var externalHelpersImportDeclaration = externalHelpersModuleName && createImportDeclaration(undefined, undefined, createImportClause(undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(ts.externalHelpersModuleNameText)); + if (externalHelpersImportDeclaration) { + externalImports.push(externalHelpersImportDeclaration); } - var declarationName = getMutableClone(parameter.name); - setEmitFlags(declarationName, 1536); - var expressionName = getSynthesizedClone(parameter.name); - var restIndex = node.parameters.length - 1; - var temp = createLoopVariable(); - statements.push(setEmitFlags(createVariableStatement(undefined, createVariableDeclarationList([ - createVariableDeclaration(declarationName, undefined, createArrayLiteral([])) - ]), parameter), 8388608)); - var forStatement = createFor(createVariableDeclarationList([ - createVariableDeclaration(temp, undefined, createLiteral(restIndex)) - ], parameter), createLessThan(temp, createPropertyAccess(createIdentifier("arguments"), "length"), parameter), createPostfixIncrement(temp, parameter), createBlock([ - startOnNewLine(createStatement(createAssignment(createElementAccess(expressionName, createSubtract(temp, createLiteral(restIndex))), createElementAccess(createIdentifier("arguments"), temp)), parameter)) - ])); - setEmitFlags(forStatement, 8388608); - startOnNewLine(forStatement); - statements.push(forStatement); - } - ts.addRestParameterIfNeeded = addRestParameterIfNeeded; - function convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, convertObjectRest) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; - var counter = convertObjectRest ? undefined : createLoopVariable(); - var rhsReference = expression.kind === 70 - ? createUniqueName(expression.text) - : createTempVariable(undefined); - var elementAccess = convertObjectRest ? rhsReference : createElementAccess(rhsReference, counter); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenVariableDestructuring(firstOriginalDeclaration, elementAccess, visitor, undefined, convertObjectRest); - var declarationList = createVariableDeclarationList(declarations, initializer); - setOriginalNode(declarationList, initializer); - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(createVariableStatement(undefined, declarationList)); - } - else { - statements.push(createVariableStatement(undefined, setOriginalNode(createVariableDeclarationList([ - createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : createTempVariable(undefined), undefined, createElementAccess(rhsReference, counter)) - ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { + var node = _a[_i]; + switch (node.kind) { + case 235: + externalImports.push(node); + break; + case 234: + if (node.moduleReference.kind === 245) { + externalImports.push(node); + } + break; + case 241: + if (node.moduleSpecifier) { + if (!node.exportClause) { + externalImports.push(node); + hasExportStarsToExportValues = true; + } + else { + externalImports.push(node); + } + } + else { + for (var _b = 0, _c = node.exportClause.elements; _b < _c.length; _b++) { + var specifier = _c[_b]; + if (!uniqueExports[specifier.name.text]) { + var name_12 = specifier.propertyName || specifier.name; + ts.multiMapAdd(exportSpecifiers, name_12.text, specifier); + var decl = resolver.getReferencedImportDeclaration(name_12) + || resolver.getReferencedValueDeclaration(name_12); + if (decl) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(decl), specifier.name); + } + uniqueExports[specifier.name.text] = true; + exportedNames = ts.append(exportedNames, specifier.name); + } + } + } + break; + case 240: + if (node.isExportEquals && !exportEquals) { + exportEquals = node; + } + break; + case 205: + if (ts.hasModifier(node, 1)) { + for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { + var decl = _e[_d]; + exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); + } + } + break; + case 225: + if (ts.hasModifier(node, 1)) { + if (ts.hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_13 = node.name; + if (!uniqueExports[name_13.text]) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_13); + uniqueExports[name_13.text] = true; + exportedNames = ts.append(exportedNames, name_13); + } + } + } + break; + case 226: + if (ts.hasModifier(node, 1)) { + if (ts.hasModifier(node, 512)) { + if (!hasExportDefault) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), getDeclarationName(node)); + hasExportDefault = true; + } + } + else { + var name_14 = node.name; + if (!uniqueExports[name_14.text]) { + ts.multiMapAdd(exportedBindings, ts.getOriginalNodeId(node), name_14); + uniqueExports[name_14.text] = true; + exportedNames = ts.append(exportedNames, name_14); + } + } + } + break; } } - else { - var assignment = createAssignment(initializer, elementAccess); - if (ts.isDestructuringAssignment(assignment)) { - statements.push(createStatement(ts.flattenDestructuringAssignment(context, assignment, false, context.hoistVariableDeclaration, visitor, convertObjectRest))); - } - else { - assignment.end = initializer.end; - statements.push(createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration }; + } + ts.collectExternalModuleInfo = collectExternalModuleInfo; + function collectExportedVariableInfo(decl, uniqueExports, exportedNames) { + if (ts.isBindingPattern(decl.name)) { + for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) { + var element = _a[_i]; + if (!ts.isOmittedExpression(element)) { + exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames); + } } } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); + else if (!ts.isGeneratedIdentifier(decl.name)) { + if (!uniqueExports[decl.name.text]) { + uniqueExports[decl.name.text] = true; + exportedNames = ts.append(exportedNames, decl.name); } } - setEmitFlags(expression, 1536 | getEmitFlags(expression)); - var body = createBlock(createNodeArray(statements, statementsLocation), bodyLocation); - setEmitFlags(body, 1536 | 12288); - var forStatement; - if (convertObjectRest) { - forStatement = createForOf(createVariableDeclarationList([ - createVariableDeclaration(rhsReference, undefined, undefined, node.expression) - ], node.expression), node.expression, body, node); - } - else { - forStatement = createFor(setEmitFlags(createVariableDeclarationList([ - createVariableDeclaration(counter, undefined, createLiteral(0), ts.moveRangePos(node.expression, -1)), - createVariableDeclaration(rhsReference, undefined, expression, node.expression) - ], node.expression), 16777216), createLessThan(counter, createPropertyAccess(rhsReference, "length"), node.expression), createPostfixIncrement(counter, node.expression), body, node); - } - setEmitFlags(forStatement, 8192); - return forStatement; + return exportedNames; } - ts.convertForOf = convertForOf; })(ts || (ts = {})); var ts; (function (ts) { @@ -13545,29 +13665,31 @@ var ts; visitNode(cbNode, node.type); case 278: return visitNodes(cbNodes, node.tags); - case 280: + case 281: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 281: - return visitNode(cbNode, node.typeExpression); case 282: return visitNode(cbNode, node.typeExpression); case 283: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 280: + return visitNode(cbNode, node.typeExpression); case 284: + return visitNodes(cbNodes, node.typeParameters); + case 285: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 286: + case 287: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 285: + case 286: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 293: + case 294: return visitNode(cbNode, node.expression); - case 287: + case 288: return visitNode(cbNode, node.literal); } } @@ -13691,7 +13813,7 @@ var ts; return sourceFile; } function addJSDocComment(node) { - var comments = ts.getJsDocCommentsFromText(node, sourceFile.text); + var comments = ts.getJSDocCommentRanges(node, sourceFile.text); if (comments) { for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { var comment = comments_2[_i]; @@ -13699,10 +13821,10 @@ var ts; if (!jsDoc) { continue; } - if (!node.jsDocComments) { - node.jsDocComments = []; + if (!node.jsDoc) { + node.jsDoc = []; } - node.jsDocComments.push(jsDoc); + node.jsDoc.push(jsDoc); } } return node; @@ -13717,12 +13839,12 @@ var ts; var saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDocComments) { - for (var _i = 0, _a = n.jsDocComments; _i < _a.length; _i++) { - var jsDocComment = _a[_i]; - jsDocComment.parent = n; - parent = jsDocComment; - forEachChild(jsDocComment, visitNode); + if (n.jsDoc) { + for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + jsDoc.parent = n; + parent = jsDoc; + forEachChild(jsDoc, visitNode); } } parent = saveParent; @@ -16899,8 +17021,8 @@ var ts; return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_16 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_16, undefined); + var name_15 = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_15, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } @@ -17547,7 +17669,7 @@ var ts; return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(287); + var result = createNode(288); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -17727,6 +17849,9 @@ var ts; var tag; if (tagName) { switch (tagName.text) { + case "augments": + tag = parseAugmentsTag(atToken, tagName); + break; case "param": tag = parseParamTag(atToken, tagName); break; @@ -17866,7 +17991,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(280, atToken.pos); + var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -17877,20 +18002,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 281; })) { + if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(281, atToken.pos); + var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 282; })) { + if (ts.forEach(tags, function (t) { return t.kind === 283; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(282, atToken.pos); + var result = createNode(283, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -17905,17 +18030,25 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(285, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; result.typeExpression = typeExpression; return finishNode(result); } + function parseAugmentsTag(atToken, tagName) { + var typeExpression = tryParseTypeExpression(); + var result = createNode(280, atToken.pos); + result.atToken = atToken; + result.tagName = tagName; + result.typeExpression = typeExpression; + return finishNode(result); + } function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(284, atToken.pos); + var typedefTag = createNode(285, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); @@ -17932,8 +18065,8 @@ var ts; if (typeExpression.type.kind === 272) { var jsDocTypeReference = typeExpression.type; if (jsDocTypeReference.name.kind === 70) { - var name_17 = jsDocTypeReference.name; - if (name_17.text === "Object") { + var name_16 = jsDocTypeReference.name; + if (name_16.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); } } @@ -17947,7 +18080,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(286, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(287, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18032,19 +18165,19 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 283; })) { + if (ts.forEach(tags, function (t) { return t.kind === 284; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); while (true) { - var name_18 = parseJSDocIdentifierName(); + var name_17 = parseJSDocIdentifierName(); skipWhitespace(); - if (!name_18) { + if (!name_17) { parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(143, name_18.pos); - typeParameter.name = name_18; + var typeParameter = createNode(143, name_17.pos); + typeParameter.name = name_17; finishNode(typeParameter); typeParameters.push(typeParameter); if (token() === 25) { @@ -18055,7 +18188,7 @@ var ts; break; } } - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18135,8 +18268,8 @@ var ts; ts.Debug.assert(text === newText.substring(node.pos, node.end)); } forEachChild(node, visitNode, visitArray); - if (node.jsDocComments) { - for (var _i = 0, _a = node.jsDocComments; _i < _a.length; _i++) { + if (node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; forEachChild(jsDocComment, visitNode, visitArray); } @@ -18520,7 +18653,7 @@ var ts; } if (node.name.kind === 142) { var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression.kind)) { + if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; } ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); @@ -18565,7 +18698,7 @@ var ts; var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 284: + case 285: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; if (parentNode && parentNode.kind === 205) { @@ -18640,7 +18773,7 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 284 && + var isJSDocTypedefInJSDocNamespace = node.kind === 285 && node.name && node.name.kind === 70 && node.name.isInJSDocNamespace; @@ -18745,12 +18878,35 @@ var ts; subtreeTransformFlags = savedSubtreeTransformFlags | computeTransformFlagsForNode(node, subtreeTransformFlags); } } + function bindEach(nodes) { + if (nodes === undefined) { + return; + } + if (skipTransformFlagAggregation) { + ts.forEach(nodes, bind); + } + else { + var savedSubtreeTransformFlags = subtreeTransformFlags; + subtreeTransformFlags = 0; + var nodeArrayFlags = 0; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; + bind(node); + nodeArrayFlags |= node.transformFlags & ~536870912; + } + nodes.transformFlags = nodeArrayFlags | 536870912; + subtreeTransformFlags |= savedSubtreeTransformFlags; + } + } + function bindEachChild(node) { + ts.forEachChild(node, bind, bindEach); + } function bindChildrenWorker(node) { - if (ts.isInJavaScriptFile(node) && node.jsDocComments) { - ts.forEach(node.jsDocComments, bind); + if (ts.isInJavaScriptFile(node) && node.jsDoc) { + ts.forEach(node.jsDoc, bind); } if (checkUnreachable(node)) { - ts.forEachChild(node, bind); + bindEachChild(node); return; } switch (node.kind) { @@ -18815,7 +18971,7 @@ var ts; bindCallExpressionFlow(node); break; default: - ts.forEachChild(node, bind); + bindEachChild(node); break; } } @@ -19118,7 +19274,7 @@ var ts; } return undefined; } - function bindbreakOrContinueFlow(node, breakTarget, continueTarget) { + function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { var flowLabel = node.kind === 215 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); @@ -19131,11 +19287,11 @@ var ts; var activeLabel = findActiveLabel(node.label.text); if (activeLabel) { activeLabel.referenced = true; - bindbreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget); + bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget); } } else { - bindbreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget); + bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget); } } function bindTryStatement(node) { @@ -19186,6 +19342,8 @@ var ts; currentFlow = finishFlowLabel(postSwitchLabel); } function bindCaseBlock(node) { + var savedSubtreeTransformFlags = subtreeTransformFlags; + subtreeTransformFlags = 0; var clauses = node.clauses; var fallthroughFlow = unreachableFlow; for (var i = 0; i < clauses.length; i++) { @@ -19205,13 +19363,15 @@ var ts; errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); } } + clauses.transformFlags = subtreeTransformFlags | 536870912; + subtreeTransformFlags |= savedSubtreeTransformFlags; } function bindCaseClause(node) { var saveCurrentFlow = currentFlow; currentFlow = preSwitchCaseFlow; bind(node.expression); currentFlow = saveCurrentFlow; - ts.forEach(node.statements, bind); + bindEach(node.statements); } function pushActiveLabel(name, breakTarget, continueTarget) { var activeLabel = { @@ -19297,19 +19457,19 @@ var ts; var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; - ts.forEachChild(node, bind); + bindEachChild(node); currentFalseTarget = currentTrueTarget; currentTrueTarget = saveTrueTarget; } else { - ts.forEachChild(node, bind); + bindEachChild(node); if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { - ts.forEachChild(node, bind); + bindEachChild(node); if (node.operator === 42 || node.operator === 43) { bindAssignmentTargetFlow(node.operand); } @@ -19327,7 +19487,7 @@ var ts; } } else { - ts.forEachChild(node, bind); + bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); if (operator === 57 && node.left.kind === 178) { @@ -19340,7 +19500,7 @@ var ts; } } function bindDeleteExpressionFlow(node) { - ts.forEachChild(node, bind); + bindEachChild(node); if (node.expression.kind === 177) { bindAssignmentTargetFlow(node.expression); } @@ -19373,7 +19533,7 @@ var ts; } } function bindVariableDeclarationFlow(node) { - ts.forEachChild(node, bind); + bindEachChild(node); if (node.initializer || node.parent.parent.kind === 212 || node.parent.parent.kind === 213) { bindInitializedVariableFlow(node); } @@ -19384,12 +19544,12 @@ var ts; expr = expr.expression; } if (expr.kind === 184 || expr.kind === 185) { - ts.forEach(node.typeArguments, bind); - ts.forEach(node.arguments, bind); + bindEach(node.typeArguments); + bindEach(node.arguments); bind(node.expression); } else { - ts.forEachChild(node, bind); + bindEachChild(node); } if (node.expression.kind === 177) { var propertyAccess = node.expression; @@ -19405,7 +19565,7 @@ var ts; case 229: case 176: case 161: - case 286: + case 287: case 270: return 1; case 227: @@ -19474,7 +19634,7 @@ var ts; case 176: case 227: case 270: - case 286: + case 287: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); case 158: case 159: @@ -19768,8 +19928,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -19789,7 +19949,7 @@ var ts; case 70: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 284) { + while (parentNode && parentNode.kind !== 285) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); @@ -19859,7 +20019,7 @@ var ts; case 146: case 271: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0); - case 285: + case 286: return bindJSDocProperty(node); case 257: case 258: @@ -19903,7 +20063,7 @@ var ts; return bindFunctionOrConstructorType(node); case 161: case 170: - case 286: + case 287: case 270: return bindAnonymousDeclaration(node, 2048, "__type"); case 176: @@ -19922,7 +20082,7 @@ var ts; return bindClassLikeDeclaration(node); case 227: return bindBlockScopedDeclaration(node, 64, 792968); - case 284: + case 285: if (!node.fullName || node.fullName.kind === 70) { return bindBlockScopedDeclaration(node, 524288, 793064); } @@ -19996,12 +20156,12 @@ var ts; return; } else { - var parent_5 = node.parent; - if (!ts.isExternalModule(parent_5)) { + var parent_4 = node.parent; + if (!ts.isExternalModule(parent_4)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_5.isDeclarationFile) { + if (!parent_4.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -20287,12 +20447,12 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 8388608 + if (subtreeFlags & 524288 || isSuperOrSuperProperty(expression, expressionKind)) { - transformFlags |= 3072; + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545281365; + return transformFlags & ~537396545; } function isSuperOrSuperProperty(node, kind) { switch (kind) { @@ -20311,28 +20471,28 @@ var ts; if (node.typeArguments) { transformFlags |= 3; } - if (subtreeFlags & 8388608) { - transformFlags |= 3072; + if (subtreeFlags & 524288) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~545281365; + return transformFlags & ~537396545; } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; if (operatorTokenKind === 57 && leftKind === 176) { - transformFlags |= 48 | 3072 | 49152; + transformFlags |= 8 | 192 | 3072; } else if (operatorTokenKind === 57 && leftKind === 175) { - transformFlags |= 3072 | 49152; + transformFlags |= 192 | 3072; } else if (operatorTokenKind === 39 || operatorTokenKind === 61) { - transformFlags |= 768; + transformFlags |= 32; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeParameter(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -20342,21 +20502,21 @@ var ts; var dotDotDotToken = node.dotDotDotToken; if (node.questionToken || node.type - || subtreeFlags & 65536 + || subtreeFlags & 4096 || ts.isThisIdentifier(name)) { transformFlags |= 3; } if (modifierFlags & 92) { - transformFlags |= 3 | 4194304; + transformFlags |= 3 | 262144; } - if (subtreeFlags & 8388608) { - transformFlags |= 48; + if (subtreeFlags & 1048576) { + transformFlags |= 8; } - if (subtreeFlags & 67108864 || initializer || dotDotDotToken) { - transformFlags |= 3072 | 2097152; + if (subtreeFlags & 8388608 || initializer || dotDotDotToken) { + transformFlags |= 192 | 131072; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~604001621; + return transformFlags & ~536872257; } function computeParenthesizedExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -20367,11 +20527,11 @@ var ts; || expressionKind === 182) { transformFlags |= 3; } - if (expressionTransformFlags & 16384) { - transformFlags |= 16384; + if (expressionTransformFlags & 1024) { + transformFlags |= 1024; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeClassDeclaration(node, subtreeFlags) { var transformFlags; @@ -20380,35 +20540,35 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 3072; - if ((subtreeFlags & 4390912) + transformFlags = subtreeFlags | 192; + if ((subtreeFlags & 274432) || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 1048576) { - transformFlags |= 262144; + if (subtreeFlags & 65536) { + transformFlags |= 16384; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~559895893; + return transformFlags & ~539358529; } function computeClassExpression(node, subtreeFlags) { - var transformFlags = subtreeFlags | 3072; - if (subtreeFlags & 4390912 + var transformFlags = subtreeFlags | 192; + if (subtreeFlags & 274432 || node.typeParameters) { transformFlags |= 3; } - if (subtreeFlags & 1048576) { - transformFlags |= 262144; + if (subtreeFlags & 65536) { + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~559895893; + return transformFlags & ~539358529; } function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { case 84: - transformFlags |= 3072; + transformFlags |= 192; break; case 107: transformFlags |= 3; @@ -20418,23 +20578,23 @@ var ts; break; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeCatchClause(node, subtreeFlags) { var transformFlags = subtreeFlags; if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name)) { - transformFlags |= 3072; + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~537920833; } function computeExpressionWithTypeArguments(node, subtreeFlags) { - var transformFlags = subtreeFlags | 3072; + var transformFlags = subtreeFlags | 192; if (node.typeArguments) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeConstructor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -20442,11 +20602,14 @@ var ts; || !node.body) { transformFlags |= 3; } + if (subtreeFlags & 1048576) { + transformFlags |= 8; + } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~975983957; + return transformFlags & ~601015617; } function computeMethod(node, subtreeFlags) { - var transformFlags = subtreeFlags | 3072; + var transformFlags = subtreeFlags | 192; if (node.decorators || ts.hasModifier(node, 2270) || node.typeParameters @@ -20454,14 +20617,17 @@ var ts; || !node.body) { transformFlags |= 3; } + if (subtreeFlags & 1048576) { + transformFlags |= 8; + } if (ts.hasModifier(node, 256)) { - transformFlags |= 192; + transformFlags |= 16; } - if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 12288; + if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~975983957; + return transformFlags & ~601015617; } function computeAccessor(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -20471,16 +20637,19 @@ var ts; || !node.body) { transformFlags |= 3; } + if (subtreeFlags & 1048576) { + transformFlags |= 8; + } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~975983957; + return transformFlags & ~601015617; } function computePropertyDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags | 3; if (node.initializer) { - transformFlags |= 131072; + transformFlags |= 8192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeFunctionDeclaration(node, subtreeFlags) { var transformFlags; @@ -20490,27 +20659,27 @@ var ts; transformFlags = 3; } else { - transformFlags = subtreeFlags | 268435456; + transformFlags = subtreeFlags | 33554432; if (modifierFlags & 2270 || node.typeParameters || node.type) { transformFlags |= 3; } if (modifierFlags & 256) { - transformFlags |= 192; + transformFlags |= 16; } - if (subtreeFlags & 8388608) { - transformFlags |= 48; + if (subtreeFlags & 1048576) { + transformFlags |= 8; } - if (subtreeFlags & 2621440) { - transformFlags |= 3072; + if (subtreeFlags & 163840) { + transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 12288; + if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + transformFlags |= 768; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~980243797; + return transformFlags & ~601281857; } function computeFunctionExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -20520,63 +20689,60 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 192; + transformFlags |= 16; } - if (subtreeFlags & 8388608) { - transformFlags |= 48; + if (subtreeFlags & 1048576) { + transformFlags |= 8; } - if (subtreeFlags & 2621440) { - transformFlags |= 3072; + if (subtreeFlags & 163840) { + transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - transformFlags |= 12288; + if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~980243797; + return transformFlags & ~601281857; } function computeArrowFunction(node, subtreeFlags) { - var transformFlags = subtreeFlags | 3072; + var transformFlags = subtreeFlags | 192; if (ts.hasModifier(node, 2270) || node.typeParameters || node.type) { transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 192; + transformFlags |= 16; } - if (subtreeFlags & 8388608) { - transformFlags |= 48; + if (subtreeFlags & 1048576) { + transformFlags |= 8; } - if (subtreeFlags & 262144) { - transformFlags |= 524288; + if (subtreeFlags & 16384) { + transformFlags |= 32768; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~979719509; + return transformFlags & ~601249089; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; if (expressionKind === 96) { - transformFlags |= 262144; + transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeVariableDeclaration(node, subtreeFlags) { var transformFlags = subtreeFlags; - var nameKind = node.name.kind; - if (nameKind === 172) { - transformFlags |= 48 | 3072 | 67108864; - } - else if (nameKind === 173) { - transformFlags |= 3072 | 67108864; + transformFlags |= 192 | 8388608; + if (subtreeFlags & 1048576) { + transformFlags |= 8; } if (node.type) { transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeVariableStatement(node, subtreeFlags) { var transformFlags; @@ -20587,21 +20753,21 @@ var ts; } else { transformFlags = subtreeFlags; - if (declarationListTransformFlags & 67108864) { - transformFlags |= 3072; + if (declarationListTransformFlags & 8388608) { + transformFlags |= 192; } } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeLabeledStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (subtreeFlags & 33554432 + if (subtreeFlags & 4194304 && ts.isIterationStatement(node, true)) { - transformFlags |= 3072; + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeImportEquals(node, subtreeFlags) { var transformFlags = subtreeFlags; @@ -20609,15 +20775,15 @@ var ts; transformFlags |= 3; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeExpressionStatement(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.transformFlags & 16384) { - transformFlags |= 3072; + if (node.expression.transformFlags & 1024) { + transformFlags |= 192; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~536892757; + return transformFlags & ~536872257; } function computeModuleDeclaration(node, subtreeFlags) { var transformFlags = 3; @@ -20626,26 +20792,26 @@ var ts; transformFlags |= subtreeFlags; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~839734613; + return transformFlags & ~574674241; } function computeVariableDeclarationList(node, subtreeFlags) { - var transformFlags = subtreeFlags | 268435456; - if (subtreeFlags & 67108864) { - transformFlags |= 3072; + var transformFlags = subtreeFlags | 33554432; + if (subtreeFlags & 8388608) { + transformFlags |= 192; } if (node.flags & 3) { - transformFlags |= 3072 | 33554432; + transformFlags |= 192 | 4194304; } node.transformFlags = transformFlags | 536870912; - return transformFlags & ~604001621; + return transformFlags & ~546309441; } function computeOther(node, kind, subtreeFlags) { var transformFlags = subtreeFlags; - var excludeFlags = 536892757; + var excludeFlags = 536872257; switch (kind) { case 119: case 189: - transformFlags |= 192; + transformFlags |= 16; break; case 113: case 111: @@ -20669,10 +20835,10 @@ var ts; case 250: case 251: case 252: - transformFlags |= 12; + transformFlags |= 4; break; case 213: - transformFlags |= 48; + transformFlags |= 8; case 12: case 13: case 14: @@ -20681,10 +20847,10 @@ var ts; case 181: case 258: case 114: - transformFlags |= 3072; + transformFlags |= 192; break; case 195: - transformFlags |= 3072 | 134217728; + transformFlags |= 192 | 16777216; break; case 118: case 132: @@ -20721,73 +20887,79 @@ var ts; excludeFlags = -3; break; case 142: - transformFlags |= 16777216; - if (subtreeFlags & 262144) { - transformFlags |= 1048576; + transformFlags |= 2097152; + if (subtreeFlags & 16384) { + transformFlags |= 65536; } break; case 196: + transformFlags |= 192 | 524288; + break; case 259: - transformFlags |= 8388608; + transformFlags |= 8 | 1048576; break; - case 174: - if (node.dotDotDotToken) { - transformFlags |= 8388608; - } case 96: - transformFlags |= 3072; + transformFlags |= 192; break; case 98: - transformFlags |= 262144; + transformFlags |= 16384; break; case 172: - case 173: - if (subtreeFlags & 8388608) { - transformFlags |= 48 | 67108864; + transformFlags |= 192 | 8388608; + if (subtreeFlags & 524288) { + transformFlags |= 8 | 1048576; } - else { - transformFlags |= 3072 | 67108864; + excludeFlags = 537396545; + break; + case 173: + transformFlags |= 192 | 8388608; + excludeFlags = 537396545; + break; + case 174: + transformFlags |= 192; + if (node.dotDotDotToken) { + transformFlags |= 524288; } break; case 145: - transformFlags |= 3 | 65536; + transformFlags |= 3 | 4096; break; case 176: - excludeFlags = 554784085; - if (subtreeFlags & 16777216) { - transformFlags |= 3072; + excludeFlags = 540087617; + if (subtreeFlags & 2097152) { + transformFlags |= 192; } - if (subtreeFlags & 1048576) { - transformFlags |= 262144; + if (subtreeFlags & 65536) { + transformFlags |= 16384; } - if (subtreeFlags & 8388608) { - transformFlags |= 48; + if (subtreeFlags & 1048576) { + transformFlags |= 8; } break; case 175: case 180: - excludeFlags = 545281365; - if (subtreeFlags & 8388608) { - transformFlags |= 3072; + excludeFlags = 537396545; + if (subtreeFlags & 524288) { + transformFlags |= 192; } break; case 209: case 210: case 211: case 212: - if (subtreeFlags & 33554432) { - transformFlags |= 3072; + if (subtreeFlags & 4194304) { + transformFlags |= 192; } break; case 261: - if (subtreeFlags & 524288) { - transformFlags |= 3072; + if (subtreeFlags & 32768) { + transformFlags |= 192; } break; case 216: case 214: case 215: - transformFlags |= 268435456; + transformFlags |= 33554432; break; } node.transformFlags = transformFlags | 536870912; @@ -20801,27 +20973,27 @@ var ts; case 179: case 180: case 175: - return 545281365; + return 537396545; case 230: - return 839734613; + return 574674241; case 144: - return 604001621; + return 536872257; case 185: - return 979719509; + return 601249089; case 184: case 225: - return 980243797; + return 601281857; case 224: - return 604001621; + return 546309441; case 226: case 197: - return 559895893; + return 539358529; case 150: - return 975983957; + return 601015617; case 149: case 151: case 152: - return 975983957; + return 601015617; case 118: case 132: case 129: @@ -20839,9 +21011,14 @@ var ts; case 228: return -3; case 176: - return 554784085; + return 540087617; + case 256: + return 537920833; + case 172: + case 173: + return 537396545; default: - return 536892757; + return 536872257; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -20933,6 +21110,7 @@ var ts; getJsxElementAttributesType: getJsxElementAttributesType, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, isOptionalParameter: isOptionalParameter, + tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); } @@ -20942,6 +21120,7 @@ var ts; var intersectionTypes = ts.createMap(); var stringLiteralTypes = ts.createMap(); var numericLiteralTypes = ts.createMap(); + var indexedAccessTypes = ts.createMap(); var evolvingArrayTypes = []; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -20961,7 +21140,6 @@ var ts; var voidType = createIntrinsicType(1024, "void"); var neverType = createIntrinsicType(8192, "never"); var silentNeverType = createIntrinsicType(8192, "never"); - var stringOrNumberType = getUnionType([stringType, numberType]); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); var emptyTypeLiteralSymbol = createSymbol(2048 | 67108864, "__type"); emptyTypeLiteralSymbol.members = ts.createMap(); @@ -21511,6 +21689,7 @@ var ts; if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation) && + !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); } @@ -21587,6 +21766,16 @@ var ts; return undefined; } } + function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { + if (meaning === 1920) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, name); + return true; + } + } + return false; + } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { if (meaning & (107455 & ~1024)) { var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); @@ -21692,28 +21881,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_19 = specifier.propertyName || specifier.name; - if (name_19.text) { + var name_18 = specifier.propertyName || specifier.name; + if (name_18.text) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports["export="]) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_19.text); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_18.text); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_19.text); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_18.text); } symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name_19.text); - if (!symbolFromModule && allowSyntheticDefaultImports && name_19.text === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_18.text); + if (!symbolFromModule && allowSyntheticDefaultImports && name_18.text === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_19, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_19)); + error(name_18, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_18)); } return symbol; } @@ -21938,6 +22127,12 @@ var ts; function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); } + function tryGetMemberInModuleExports(memberName, moduleSymbol) { + var symbolTable = getExportsOfModule(moduleSymbol); + if (symbolTable) { + return symbolTable[memberName]; + } + } function getExportsOfSymbol(symbol) { return symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -22453,9 +22648,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_6 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_6) { - walkSymbol(parent_6, getQualifiedLeftMeaning(meaning), false); + var parent_5 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_5) { + walkSymbol(parent_5, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -22588,12 +22783,12 @@ var ts; var length_1 = outerTypeParameters.length; while (i < length_1) { var start = i; - var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_7, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_6, typeArguments, start, i, flags); writePunctuation(writer, 22); } } @@ -23017,12 +23212,12 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_8 = getDeclarationContainer(node); + var parent_7 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 234 && parent_8.kind !== 261 && ts.isInAmbientContext(parent_8))) { - return isGlobalSourceFile(parent_8); + !(node.kind !== 234 && parent_7.kind !== 261 && ts.isInAmbientContext(parent_7))) { + return isGlobalSourceFile(parent_7); } - return isDeclarationVisible(parent_8); + return isDeclarationVisible(parent_7); case 147: case 146: case 151: @@ -23178,15 +23373,15 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 142 && !ts.isStringOrNumericLiteral(name.expression.kind); + 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."); var members = ts.createMap(); var names = ts.createMap(); for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name_20 = properties_2[_i]; - names[ts.getTextOfPropertyName(name_20)] = true; + var name_19 = properties_2[_i]; + names[ts.getTextOfPropertyName(name_19)] = true; } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; @@ -23224,26 +23419,26 @@ var ts; var literalMembers = []; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 198 && !element.dotDotDotToken) { + if (!element.dotDotDotToken) { literalMembers.push(element.propertyName || element.name); } } type = getRestType(parentType, literalMembers, declaration.symbol); } else { - var name_21 = declaration.propertyName || declaration.name; - if (isComputedNonLiteralName(name_21)) { + var name_20 = declaration.propertyName || declaration.name; + if (isComputedNonLiteralName(name_20)) { return anyType; } if (declaration.initializer) { getContextualType(declaration.initializer); } - var text = ts.getTextOfPropertyName(name_21); + var text = ts.getTextOfPropertyName(name_20); type = getTypeOfPropertyOfType(parentType, text) || isNumericLiteralName(text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_21, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_21)); + error(name_20, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_20)); return unknownType; } } @@ -23277,29 +23472,9 @@ var ts; type; } function getTypeForVariableLikeDeclarationFromJSDocComment(declaration) { - var jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration); - if (jsDocType) { - return getTypeFromTypeNode(jsDocType); - } - } - function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration) { - var typeTag = ts.getJSDocTypeTag(declaration); - if (typeTag && typeTag.typeExpression) { - return typeTag.typeExpression.type; - } - if (declaration.kind === 223 && - declaration.parent.kind === 224 && - declaration.parent.parent.kind === 205) { - var annotation = ts.getJSDocTypeTag(declaration.parent.parent); - if (annotation && annotation.typeExpression) { - return annotation.typeExpression.type; - } - } - else if (declaration.kind === 144) { - var paramTag = ts.getCorrespondingJSDocParameterTag(declaration); - if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type; - } + var jsdocType = ts.getJSDocType(declaration); + if (jsdocType) { + return getTypeFromTypeNode(jsdocType); } return undefined; } @@ -23322,7 +23497,8 @@ var ts; } } if (declaration.parent.parent.kind === 212) { - return stringType; + var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); + return indexType.flags & (16384 | 262144) ? indexType : stringType; } if (declaration.parent.parent.kind === 213) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; @@ -23333,7 +23509,8 @@ var ts; if (declaration.type) { return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality); } - if (declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && + if ((compilerOptions.noImplicitAny || declaration.flags & 2097152) && + declaration.kind === 223 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23472,7 +23649,7 @@ var ts; if (declaration.kind === 240) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 2097152 && declaration.kind === 285 && declaration.typeExpression) { + if (declaration.flags & 2097152 && declaration.kind === 286 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { @@ -23482,9 +23659,9 @@ var ts; if (declaration.kind === 192 || declaration.kind === 177 && declaration.parent.kind === 192) { if (declaration.flags & 2097152) { - var typeTag = ts.getJSDocTypeTag(declaration.parent); - if (typeTag && typeTag.typeExpression) { - return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); + var jsdocType = ts.getJSDocType(declaration.parent); + if (jsdocType) { + return links.type = getTypeFromTypeNode(jsdocType); } } var declaredTypes = ts.map(symbol.declarations, function (decl) { return decl.kind === 192 ? @@ -23785,6 +23962,13 @@ var ts; } baseType = getReturnTypeOfSignature(constructors[0]); } + var valueDecl = type.symbol.valueDeclaration; + if (valueDecl && ts.isInJavaScriptFile(valueDecl)) { + var augTag = ts.getJSDocAugmentsTag(type.symbol.valueDeclaration); + if (augTag) { + baseType = getTypeFromTypeNode(augTag.typeExpression.type); + } + } if (baseType === unknownType) { return; } @@ -23793,7 +23977,7 @@ var ts; return; } if (type === baseType || hasBaseType(baseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); + error(valueDecl, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 1)); return; } if (type.resolvedBaseTypes === emptyArray) { @@ -23895,7 +24079,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 284); + var declaration = ts.getDeclarationOfKind(symbol, 285); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24382,6 +24566,7 @@ var ts; var members = ts.createMap(); var stringIndexInfo; var numberIndexInfo; + setStructuredTypeMembers(type, emptySymbols, emptyArray, emptyArray, undefined, undefined); var typeParameter = getTypeParameterFromMappedType(type); var constraintType = getConstraintTypeFromMappedType(type); var templateType = getTemplateTypeFromMappedType(type); @@ -24426,6 +24611,9 @@ var ts; instantiateType(getTypeFromTypeNode(type.declaration.type), type.mapper || identityMapper) : unknownType); } + function getErasedTemplateTypeFromMappedType(type) { + return instantiateType(getTemplateTypeFromMappedType(type), createUnaryTypeMapper(getTypeParameterFromMappedType(type), anyType)); + } function isGenericMappedType(type) { if (getObjectFlags(type) & 32) { var constraintType = getConstraintTypeFromMappedType(type); @@ -24513,14 +24701,18 @@ var ts; } return type.resolvedApparentType; } + function getApparentTypeOfIndexedAccess(type) { + return getIndexTypeOfType(getApparentType(type.objectType), 0) || type; + } function getApparentType(type) { - var t = type.flags & 16384 ? getApparentTypeOfTypeParameter(type) : type; - return t.flags & 34 ? globalStringType : + var t = type.flags & 16384 ? getApparentTypeOfTypeParameter(type) : + type.flags & 524288 ? getApparentTypeOfIndexedAccess(type) : + type; + return t.flags & 262178 ? globalStringType : t.flags & 340 ? globalNumberType : t.flags & 136 ? globalBooleanType : t.flags & 512 ? getGlobalESSymbolType() : - t.flags & 262144 ? stringOrNumberType : - t; + t; } function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; @@ -24693,13 +24885,16 @@ var ts; if (node.type && node.type.kind === 273) { return true; } - var paramTag = ts.getCorrespondingJSDocParameterTag(node); - if (paramTag) { - if (paramTag.isBracketed) { - return true; - } - if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 273; + var paramTags = ts.getJSDocParameterTags(node); + if (paramTags) { + for (var _i = 0, paramTags_1 = paramTags; _i < paramTags_1.length; _i++) { + var paramTag = paramTags_1[_i]; + if (paramTag.isBracketed) { + return true; + } + if (paramTag.typeExpression) { + return paramTag.typeExpression.type.kind === 273; + } } } } @@ -25534,10 +25729,14 @@ var ts; } function getIndexType(type) { return type.flags & 16384 ? getIndexTypeForTypeParameter(type) : - type.flags & 1 || getIndexInfoOfType(type, 0) ? stringOrNumberType : - getIndexInfoOfType(type, 1) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) : + getObjectFlags(type) & 32 ? getConstraintTypeFromMappedType(type) : + type.flags & 1 || getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromPropertyNames(type); } + function getIndexTypeOrString(type) { + var indexType = getIndexType(type); + return indexType !== neverType ? indexType : stringType; + } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -25551,10 +25750,6 @@ var ts; type.indexType = indexType; return type; } - function getIndexedAccessTypeForTypeParameter(objectType, indexType) { - var indexedAccessTypes = indexType.resolvedIndexedAccessTypes || (indexType.resolvedIndexedAccessTypes = []); - return indexedAccessTypes[objectType.id] || (indexedAccessTypes[objectType.id] = createIndexedAccessType(objectType, indexType)); - } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? @@ -25577,7 +25772,7 @@ var ts; return getTypeOfSymbol(prop); } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 34 | 340 | 512)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 262178 | 340 | 512)) { if (isTypeAny(objectType)) { return anyType; } @@ -25617,20 +25812,38 @@ var ts; } return unknownType; } + function getIndexedAccessForMappedType(type, indexType, accessNode) { + var accessExpression = accessNode && accessNode.kind === 178 ? accessNode : undefined; + if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { + error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); + return unknownType; + } + var mapper = createUnaryTypeMapper(getTypeParameterFromMappedType(type), indexType); + var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + return addOptionality(instantiateType(getTemplateTypeFromMappedType(type), templateMapper), !!type.declaration.questionToken); + } function getIndexedAccessType(objectType, indexType, accessNode) { - if (indexType.flags & 16384) { - if (accessNode && !isTypeAssignableTo(getConstraintOfTypeParameter(indexType) || emptyObjectType, getIndexType(objectType))) { - error(accessNode, ts.Diagnostics.Type_0_is_not_constrained_to_keyof_1, typeToString(indexType), typeToString(objectType)); - return unknownType; + if (indexType.flags & 16384 || + objectType.flags & 16384 && indexType.flags & 262144 || + isGenericMappedType(objectType)) { + if (accessNode) { + if (!isTypeAssignableTo(indexType, getIndexType(objectType))) { + error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType)); + return unknownType; + } + } + if (isGenericMappedType(objectType)) { + return getIndexedAccessForMappedType(objectType, indexType, accessNode); } - return getIndexedAccessTypeForTypeParameter(objectType, indexType); + var id = objectType.id + "," + indexType.id; + return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType)); } - var apparentType = getApparentType(objectType); + var apparentObjectType = getApparentType(objectType); if (indexType.flags & 65536 && !(indexType.flags & 8190)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(apparentType, t, accessNode, false); + var propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, false); if (propType === unknownType) { return unknownType; } @@ -25638,7 +25851,7 @@ var ts; } return getUnionType(propTypes); } - return getPropertyTypeForIndexType(apparentType, indexType, accessNode, true); + return getPropertyTypeForIndexType(apparentObjectType, indexType, accessNode, true); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -25655,6 +25868,7 @@ var ts; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getAliasTypeArgumentsForTypeNode(node); links.resolvedType = type; + getConstraintTypeFromMappedType(type); } return links.resolvedType; } @@ -25823,18 +26037,18 @@ var ts; return nullType; case 129: return neverType; - case 288: - return nullType; case 289: - return undefinedType; + return nullType; case 290: + return undefinedType; + case 291: return neverType; case 167: case 98: return getTypeFromThisTypeNode(node); case 171: return getTypeFromLiteralTypeNode(node); - case 287: + case 288: return getTypeFromLiteralTypeNode(node.literal); case 157: case 272: @@ -25867,7 +26081,7 @@ var ts; case 158: case 159: case 161: - case 286: + case 287: case 274: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 168: @@ -26028,6 +26242,28 @@ var ts; return result; } function instantiateMappedType(type, mapper) { + var constraintType = getConstraintTypeFromMappedType(type); + if (constraintType.flags & 262144) { + var typeParameter_1 = constraintType.type; + var mappedTypeParameter = mapper(typeParameter_1); + if (typeParameter_1 !== mappedTypeParameter) { + return mapType(mappedTypeParameter, function (t) { + if (isMappableType(t)) { + var replacementMapper = createUnaryTypeMapper(typeParameter_1, t); + var combinedMapper = mapper.mappedTypes && mapper.mappedTypes.length === 1 ? replacementMapper : combineTypeMappers(replacementMapper, mapper); + combinedMapper.mappedTypes = mapper.mappedTypes; + return instantiateMappedObjectType(type, combinedMapper); + } + return t; + }); + } + } + return instantiateMappedObjectType(type, mapper); + } + function isMappableType(type) { + return type.flags & (16384 | 32768 | 131072 | 524288); + } + function instantiateMappedObjectType(type, mapper) { var result = createObjectType(32 | 64, type.symbol); result.declaration = type.declaration; result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; @@ -26386,7 +26622,7 @@ var ts; return false; if (target.flags & 1 || source.flags & 8192) return true; - if (source.flags & 34 && target.flags & 2) + if (source.flags & 262178 && target.flags & 2) return true; if (source.flags & 340 && target.flags & 4) return true; @@ -26510,11 +26746,6 @@ var ts; } if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1; - if (source.flags & 262144) { - if (maybeTypeOfKind(target, 2) && maybeTypeOfKind(target, 4)) { - return -1; - } - } if (getObjectFlags(source) & 128 && source.flags & 1048576) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { @@ -26554,10 +26785,21 @@ var ts; } } if (target.flags & 16384) { - var constraint = getConstraintOfTypeParameter(target); - if (constraint && constraint.flags & 262144) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - return result; + if (getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (!source.declaration.questionToken) { + var templateType = getTemplateTypeFromMappedType(source); + var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); + if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + return result; + } + } + } + else { + var constraint = getConstraintOfTypeParameter(target); + if (constraint && constraint.flags & 262144) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + return result; + } } } } @@ -26574,16 +26816,32 @@ var ts; } } } + else if (target.flags & 524288) { + if (source.flags & 524288 && source.indexType === target.indexType) { + if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { + return result; + } + } + } if (source.flags & 16384) { - var constraint = getConstraintOfTypeParameter(source); - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; + if (getObjectFlags(target) & 32 && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); + var templateType = getTemplateTypeFromMappedType(target); + if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + return result; + } + } + else { + var constraint = getConstraintOfTypeParameter(source); + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } } } else { @@ -26592,22 +26850,12 @@ var ts; return result; } } - if (isGenericMappedType(target)) { - if (isGenericMappedType(source)) { - if ((result = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) && - (result = isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors))) { - return result; - } - } - } - else { - var apparentSource = getApparentType(source); - if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { - errorInfo = saveErrorInfo; - return result; - } + var apparentSource = getApparentType(source); + if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); + if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + errorInfo = saveErrorInfo; + return result; } } } @@ -26814,6 +27062,9 @@ var ts; if (expandingFlags === 3) { result = 1; } + else if (isGenericMappedType(source) || isGenericMappedType(target)) { + result = mappedTypeRelatedTo(source, target, reportErrors); + } else { result = propertiesRelatedTo(source, target, reportErrors); if (result) { @@ -26841,6 +27092,33 @@ var ts; } return result; } + function mappedTypeRelatedTo(source, target, reportErrors) { + if (isGenericMappedType(target)) { + if (isGenericMappedType(source)) { + var result_2; + if (relation === identityRelation) { + var readonlyMatches = !source.declaration.readonlyToken === !target.declaration.readonlyToken; + var optionalMatches = !source.declaration.questionToken === !target.declaration.questionToken; + if (readonlyMatches && optionalMatches) { + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + return result_2 & isRelatedTo(getErasedTemplateTypeFromMappedType(source), getErasedTemplateTypeFromMappedType(target), reportErrors); + } + } + } + else { + if (relation === comparableRelation || !source.declaration.questionToken || target.declaration.questionToken) { + if (result_2 = isRelatedTo(getConstraintTypeFromMappedType(target), getConstraintTypeFromMappedType(source), reportErrors)) { + return result_2 & isRelatedTo(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target), reportErrors); + } + } + } + } + } + else if (relation !== identityRelation && isEmptyObjectType(resolveStructuredTypeMembers(target))) { + return -1; + } + return 0; + } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { return propertiesIdenticalTo(source, target); @@ -27316,7 +27594,7 @@ var ts; return type; } var types = [type]; - if (flags & 34) + if (flags & 262178) types.push(emptyStringType); if (flags & 340) types.push(zeroType); @@ -27651,19 +27929,6 @@ var ts; } } else { - if (getObjectFlags(target) & 32) { - var constraintType = getConstraintTypeFromMappedType(target); - if (getObjectFlags(source) & 32) { - inferFromTypes(getConstraintTypeFromMappedType(source), constraintType); - inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); - return; - } - if (constraintType.flags & 16384) { - inferFromTypes(getIndexType(source), constraintType); - inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); - return; - } - } source = getApparentType(source); if (source.flags & 32768) { if (isInProcess(source, target)) { @@ -27684,14 +27949,30 @@ var ts; sourceStack[depth] = source; targetStack[depth] = target; depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, 0); - inferFromSignatures(source, target, 1); - inferFromIndexTypes(source, target); + inferFromObjectTypes(source, target); depth--; } } } + function inferFromObjectTypes(source, target) { + if (getObjectFlags(target) & 32) { + var constraintType = getConstraintTypeFromMappedType(target); + if (getObjectFlags(source) & 32) { + inferFromTypes(getConstraintTypeFromMappedType(source), constraintType); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + return; + } + if (constraintType.flags & 16384) { + inferFromTypes(getIndexType(source), constraintType); + inferFromTypes(getUnionType(ts.map(getPropertiesOfType(source), getTypeOfSymbol)), getTemplateTypeFromMappedType(target)); + return; + } + } + inferFromProperties(source, target); + inferFromSignatures(source, target, 0); + inferFromSignatures(source, target, 1); + inferFromIndexTypes(source, target); + } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { @@ -28026,7 +28307,7 @@ var ts; } function getTypeWithDefault(type, defaultExpression) { if (defaultExpression) { - var defaultType = checkExpression(defaultExpression); + var defaultType = getTypeOfExpression(defaultExpression); return getUnionType([getTypeWithFacts(type, 131072), defaultType]); } return type; @@ -28049,7 +28330,7 @@ var ts; function getAssignedTypeOfBinaryExpression(node) { return node.parent.kind === 175 || node.parent.kind === 257 ? getTypeWithDefault(getAssignedType(node), node.right) : - checkExpression(node.right); + getTypeOfExpression(node.right); } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); @@ -28097,7 +28378,7 @@ var ts; } function getTypeOfInitializer(node) { var links = getNodeLinks(node); - return links.resolvedType || checkExpression(node); + return links.resolvedType || getTypeOfExpression(node); } function getInitialTypeOfVariableDeclaration(node) { if (node.initializer) { @@ -28150,7 +28431,7 @@ var ts; } function getTypeOfSwitchClause(clause) { if (clause.kind === 253) { - var caseType = getRegularTypeOfLiteralType(checkExpression(clause.expression)); + var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } return neverType; @@ -28230,7 +28511,7 @@ var ts; return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); } function addEvolvingArrayElementType(evolvingArrayType, node) { - var elementType = getBaseTypeOfLiteralType(checkExpression(node)); + var elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { @@ -28278,7 +28559,7 @@ var ts; parent.parent.operatorToken.kind === 57 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAnyOrAllConstituentTypesHaveKind(checkExpression(parent.argumentExpression), 340 | 2048); + isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 340 | 2048); return isLengthPushOrUnshift || isElementAssignment; } function maybeTypePredicateCall(node) { @@ -28416,7 +28697,7 @@ var ts; } } else { - var indexType = checkExpression(node.left.argumentExpression); + var indexType = getTypeOfExpression(node.left.argumentExpression); if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 340 | 2048)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } @@ -28597,7 +28878,7 @@ var ts; if (operator === 32 || operator === 34) { assumeTrue = !assumeTrue; } - var valueType = checkExpression(value); + var valueType = getTypeOfExpression(value); if (valueType.flags & 6144) { if (!strictNullChecks) { return type; @@ -28669,7 +28950,7 @@ var ts; } return type; } - var rightType = checkExpression(expr.right); + var rightType = getTypeOfExpression(expr.right); if (!isTypeSubtypeOf(rightType, globalFunctionType)) { return type; } @@ -28697,16 +28978,16 @@ var ts; } } if (targetType) { - return getNarrowedType(type, targetType, assumeTrue); + return getNarrowedType(type, targetType, assumeTrue, isTypeInstanceOf); } return type; } - function getNarrowedType(type, candidate, assumeTrue) { + function getNarrowedType(type, candidate, assumeTrue, isRelated) { if (!assumeTrue) { - return filterType(type, function (t) { return !isTypeInstanceOf(t, candidate); }); + return filterType(type, function (t) { return !isRelated(t, candidate); }); } if (type.flags & 65536) { - var assignableType = filterType(type, function (t) { return isTypeInstanceOf(t, candidate); }); + var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); if (!(assignableType.flags & 8192)) { return assignableType; } @@ -28733,7 +29014,7 @@ var ts; var predicateArgument = callExpression.arguments[predicate.parameterIndex]; if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue); + return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } if (containsMatchingReference(reference, predicateArgument)) { return declaredType; @@ -28746,7 +29027,7 @@ var ts; var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue); + return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } if (containsMatchingReference(reference, possibleReference)) { return declaredType; @@ -28782,7 +29063,7 @@ var ts; location = location.parent; } if (ts.isPartOfExpression(location) && !ts.isAssignmentTarget(location)) { - var type = checkExpression(location); + var type = getTypeOfExpression(location); if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) { return type; } @@ -29117,9 +29398,9 @@ var ts; return anyType; } function getTypeForThisExpressionFromJSDoc(node) { - var typeTag = ts.getJSDocTypeTag(node); - if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type.kind === 274) { - var jsDocFunctionType = typeTag.typeExpression.type; + var jsdocType = ts.getJSDocType(node); + if (jsdocType && jsdocType.kind === 274) { + var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 277) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } @@ -29304,11 +29585,11 @@ var ts; } if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; - var name_22 = declaration.propertyName || declaration.name; + var name_21 = declaration.propertyName || declaration.name; if (ts.isVariableLike(parentDeclaration) && parentDeclaration.type && - !ts.isBindingPattern(name_22)) { - var text = ts.getTextOfPropertyName(name_22); + !ts.isBindingPattern(name_21)) { + var text = ts.getTextOfPropertyName(name_21); if (text) { return getTypeOfPropertyOfType(getTypeFromTypeNode(parentDeclaration.type), text); } @@ -29387,13 +29668,13 @@ var ts; return undefined; } if (node === binaryExpression.right) { - return checkExpression(binaryExpression.left); + return getTypeOfExpression(binaryExpression.left); } } else if (operator === 53) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { - type = checkExpression(binaryExpression.left); + type = getTypeOfExpression(binaryExpression.left); } return type; } @@ -29699,7 +29980,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 340 | 34 | 512)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 340 | 262178 | 512)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -29708,10 +29989,10 @@ var ts; } return links.resolvedType; } - function getObjectLiteralIndexInfo(node, properties, kind) { + function getObjectLiteralIndexInfo(propertyNodes, offset, properties, kind) { var propTypes = []; for (var i = 0; i < properties.length; i++) { - if (kind === 0 || isNumericName(node.properties[i].name)) { + if (kind === 0 || isNumericName(propertyNodes[i + offset].name)) { propTypes.push(getTypeOfSymbol(properties[i])); } } @@ -29732,8 +30013,9 @@ var ts; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var memberDecl = _a[_i]; + var offset = 0; + for (var i = 0; i < node.properties.length; i++) { + var memberDecl = node.properties[i]; var member = memberDecl.symbol; if (memberDecl.kind === 257 || memberDecl.kind === 258 || @@ -29794,6 +30076,7 @@ var ts; return unknownType; } spread = getSpreadType(spread, type, false); + offset = i + 1; continue; } else { @@ -29814,8 +30097,8 @@ var ts; propertiesArray.push(member); } if (contextualTypeHasPattern) { - for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { - var prop = _c[_b]; + for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { + var prop = _a[_i]; if (!propertiesTable[prop.name]) { if (!(prop.flags & 536870912)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); @@ -29835,8 +30118,8 @@ var ts; } return createObjectLiteralType(); function createObjectLiteralType() { - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 0) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, propertiesArray, 1) : undefined; + var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); @@ -30378,7 +30661,7 @@ var ts; if (node.kind === 212 && child === node.statement && getForInVariableSymbol(node) === symbol && - hasNumericPropertyNames(checkExpression(node.expression))) { + hasNumericPropertyNames(getTypeOfExpression(node.expression))) { return true; } child = node; @@ -30471,19 +30754,19 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var signature = signatures_2[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent_9 = signature.declaration && signature.declaration.parent; + var parent_8 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent_9 === lastParent) { + if (lastParent && parent_8 === lastParent) { index++; } else { - lastParent = parent_9; + lastParent = parent_8; index = cutoffIndex; } } else { index = cutoffIndex = result.length; - lastParent = parent_9; + lastParent = parent_8; } lastSymbol = symbol; if (signature.hasLiteralTypes) { @@ -31451,7 +31734,7 @@ var ts; if (!node.possiblyExhaustive) { return false; } - var type = checkExpression(node.expression); + var type = getTypeOfExpression(node.expression); if (!isLiteralType(type)) { return false; } @@ -31787,10 +32070,10 @@ var ts; if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34 | 340 | 512)) { + if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; @@ -31799,20 +32082,20 @@ var ts; var properties = node.properties; for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var p = properties_5[_i]; - checkObjectLiteralDestructuringPropertyAssignment(sourceType, p); + checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; } - function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property) { + function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { if (property.kind === 257 || property.kind === 258) { - var name_23 = property.name; - if (name_23.kind === 142) { - checkComputedPropertyName(name_23); + var name_22 = property.name; + if (name_22.kind === 142) { + checkComputedPropertyName(name_22); } - if (isComputedNonLiteralName(name_23)) { + if (isComputedNonLiteralName(name_22)) { return undefined; } - var text = ts.getTextOfPropertyName(name_23); + var text = ts.getTextOfPropertyName(name_22); var type = isTypeAny(objectLiteralType) ? objectLiteralType : getTypeOfPropertyOfType(objectLiteralType, text) || @@ -31827,13 +32110,18 @@ var ts; } } else { - error(name_23, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_23)); + error(name_22, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name_22)); } } else if (property.kind === 259) { - if (property.expression.kind !== 70) { - error(property.expression, ts.Diagnostics.An_object_rest_element_must_be_an_identifier); + var nonRestNames = []; + if (allProperties) { + for (var i = 0; i < allProperties.length - 1; i++) { + nonRestNames.push(allProperties[i].name); + } } + var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol); + return checkDestructuringAssignment(property.expression, type); } else { error(property, ts.Diagnostics.Property_assignment_expected); @@ -31918,7 +32206,10 @@ var ts; } function checkReferenceAssignment(target, sourceType, contextualMapper) { var targetType = checkExpression(target, contextualMapper); - if (checkReferenceExpression(target, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { + var error = target.parent.kind === 259 ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; + if (checkReferenceExpression(target, error)) { checkTypeAssignableTo(sourceType, targetType, target, undefined); } return sourceType; @@ -32055,7 +32346,7 @@ var ts; resultType = numberType; } else { - if (isTypeOfKind(leftType, 34) || isTypeOfKind(rightType, 34)) { + if (isTypeOfKind(leftType, 262178) || isTypeOfKind(rightType, 262178)) { resultType = stringType; } else if (isTypeAny(leftType) || isTypeAny(rightType)) { @@ -32078,6 +32369,8 @@ var ts; case 29: case 30: if (checkForDisallowedESSymbolOperand(operator)) { + leftType = getBaseTypeOfLiteralType(leftType); + rightType = getBaseTypeOfLiteralType(rightType); if (!isTypeComparableTo(leftType, rightType) && !isTypeComparableTo(rightType, leftType)) { reportOperatorError(); } @@ -32251,7 +32544,7 @@ var ts; function checkDeclarationInitializer(declaration) { var type = checkExpressionCached(declaration.initializer); return ts.getCombinedNodeFlags(declaration) & 2 || - ts.getCombinedModifierFlags(declaration) & 64 || + ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); } function isLiteralContextualType(contextualType) { @@ -32263,7 +32556,7 @@ var ts; } contextualType = apparentType; } - return maybeTypeOfKind(contextualType, 480); + return maybeTypeOfKind(contextualType, (480 | 262144)); } return false; } @@ -32300,6 +32593,16 @@ var ts; } return type; } + function getTypeOfExpression(node) { + if (node.kind === 179 && node.expression.kind !== 96) { + var funcType = checkNonNullExpression(node.expression); + var signature = getSingleCallSignature(funcType); + if (signature && !signature.typeParameters) { + return getReturnTypeOfSignature(signature); + } + } + return checkExpression(node); + } function checkExpression(node, contextualMapper) { var type; if (node.kind === 141) { @@ -32480,9 +32783,9 @@ var ts; else if (parameterName) { var hasReportedError = false; for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) { - var name_24 = _a[_i].name; - if (ts.isBindingPattern(name_24) && - checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, parameterName, typePredicate.parameterName)) { + var name_23 = _a[_i].name; + if (ts.isBindingPattern(name_23) && + checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_23, parameterName, typePredicate.parameterName)) { hasReportedError = true; break; } @@ -32502,9 +32805,9 @@ var ts; case 158: case 149: case 148: - var parent_10 = node.parent; - if (node === parent_10.type) { - return parent_10; + var parent_9 = node.parent; + if (node === parent_9.type) { + return parent_9; } } } @@ -32514,15 +32817,15 @@ var ts; if (ts.isOmittedExpression(element)) { continue; } - var name_25 = element.name; - if (name_25.kind === 70 && - name_25.text === predicateVariableName) { + var name_24 = element.name; + if (name_24.kind === 70 && + name_24.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name_25.kind === 173 || - name_25.kind === 172) { - if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_25, predicateVariableNode, predicateVariableName)) { + else if (name_24.kind === 173 || + name_24.kind === 172) { + if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name_24, predicateVariableNode, predicateVariableName)) { return true; } } @@ -32753,8 +33056,8 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; if (statement.kind === 207 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; @@ -32897,7 +33200,7 @@ var ts; var type = getTypeFromMappedTypeNode(node); var constraintType = getConstraintTypeFromMappedType(type); var keyType = constraintType.flags & 16384 ? getApparentTypeOfTypeParameter(constraintType) : constraintType; - checkTypeAssignableTo(keyType, stringOrNumberType, node.typeParameter.constraint); + checkTypeAssignableTo(keyType, stringType, node.typeParameter.constraint); } function isPrivateWithinAmbient(node) { return (ts.getModifierFlags(node) & 8) && ts.isInAmbientContext(node); @@ -33141,10 +33444,10 @@ var ts; case 229: return 2097152 | 1048576; case 234: - var result_2 = 0; + var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_2 |= getDeclarationSpaces(d); }); - return result_2; + ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); + return result_3; default: return 1048576; } @@ -33683,8 +33986,8 @@ var ts; container.kind === 230 || container.kind === 261); if (!namesShareScope) { - var name_26 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_26, name_26); + var name_25 = symbolToString(localDeclarationSymbol); + error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_25, name_25); } } } @@ -33755,13 +34058,13 @@ var ts; if (node.propertyName && node.propertyName.kind === 142) { checkComputedPropertyName(node.propertyName); } - var parent_11 = node.parent.parent; - var parentType = getTypeForBindingElementParent(parent_11); - var name_27 = node.propertyName || node.name; - var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_27)); + var parent_10 = node.parent.parent; + var parentType = getTypeForBindingElementParent(parent_10); + var name_26 = node.propertyName || node.name; + var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_26)); markPropertyAsReferenced(property); - if (parent_11.initializer && property && getParentOfSymbol(property)) { - checkClassPropertyAccess(parent_11, parent_11.initializer, parentType, property); + if (parent_10.initializer && property && getParentOfSymbol(property)) { + checkClassPropertyAccess(parent_10, parent_10.initializer, parentType, property); } } if (ts.isBindingPattern(node.name)) { @@ -33922,6 +34225,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); + var rightType = checkNonNullExpression(node.expression); if (node.initializer.kind === 224) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { @@ -33935,15 +34239,14 @@ var ts; if (varExpr.kind === 175 || varExpr.kind === 176) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } - else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 34)) { + else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - var rightType = checkNonNullExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 16384 | 524288)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -34068,12 +34371,12 @@ var ts; var arrayType = arrayOrStringType; if (arrayOrStringType.flags & 65536) { var arrayTypes = arrayOrStringType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 34); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178); }); if (filteredTypes !== arrayTypes) { arrayType = getUnionType(filteredTypes, true); } } - else if (arrayOrStringType.flags & 34) { + else if (arrayOrStringType.flags & 262178) { arrayType = neverType; } var hasStringConstituent = arrayOrStringType !== arrayType; @@ -34098,7 +34401,7 @@ var ts; } var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; if (hasStringConstituent) { - if (arrayElementType.flags & 34) { + if (arrayElementType.flags & 262178) { return stringType; } return getUnionType([arrayElementType, stringType], true); @@ -34782,7 +35085,7 @@ var ts; return undefined; } } - enumType_1 = checkExpression(expression); + enumType_1 = getTypeOfExpression(expression); if (!(enumType_1.symbol && (enumType_1.symbol.flags & 384))) { return undefined; } @@ -34977,9 +35280,9 @@ var ts; break; case 174: case 223: - var name_28 = node.name; - if (ts.isBindingPattern(name_28)) { - for (var _b = 0, _c = name_28.elements; _b < _c.length; _b++) { + var name_27 = node.name; + if (ts.isBindingPattern(name_27)) { + for (var _b = 0, _c = name_27.elements; _b < _c.length; _b++) { var el = _c[_b]; checkModuleAugmentationElement(el, isGlobalAugmentation); } @@ -35717,7 +36020,7 @@ var ts; } } case 96: - var type = ts.isPartOfExpression(node) ? checkExpression(node) : getTypeFromTypeNode(node); + var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; case 167: return getTypeFromTypeNode(node).symbol; @@ -35739,7 +36042,7 @@ var ts; } case 8: if (node.parent.kind === 178 && node.parent.argumentExpression === node) { - var objectType = checkExpression(node.parent.expression); + var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; var apparentType = getApparentType(objectType); @@ -35770,7 +36073,7 @@ var ts; return getTypeFromTypeNode(node); } if (ts.isPartOfExpression(node)) { - return getTypeOfExpression(node); + return getRegularTypeOfExpression(node); } if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; @@ -35808,7 +36111,7 @@ var ts; return checkDestructuringAssignment(expr, iteratedType || unknownType); } if (expr.parent.kind === 192) { - var iteratedType = checkExpression(expr.parent.right); + var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } if (expr.parent.kind === 257) { @@ -35824,11 +36127,11 @@ var ts; var typeOfObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(location.parent.parent); return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.text); } - function getTypeOfExpression(expr) { + function getRegularTypeOfExpression(expr) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) { expr = expr.parent; } - return getRegularTypeOfLiteralType(checkExpression(expr)); + return getRegularTypeOfLiteralType(getTypeOfExpression(expr)); } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); @@ -35851,9 +36154,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols_3 = []; - var name_29 = symbol.name; + var name_28 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_29); + var symbol = getPropertyOfType(t, name_28); if (symbol) { symbols_3.push(symbol); } @@ -35906,7 +36209,7 @@ var ts; } function isNameOfModuleOrEnumDeclaration(node) { var parent = node.parent; - return ts.isModuleOrEnumDeclaration(parent) && node === parent.name; + return parent && ts.isModuleOrEnumDeclaration(parent) && node === parent.name; } function getReferencedExportContainer(node, prefixLocals) { node = ts.getParseTreeNode(node, ts.isIdentifier); @@ -36114,7 +36417,7 @@ var ts; else if (isTypeOfKind(type, 340)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeOfKind(type, 34)) { + else if (isTypeOfKind(type, 262178)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { @@ -36145,7 +36448,7 @@ var ts; getSymbolDisplayBuilder().buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags); } function writeTypeOfExpression(expr, enclosingDeclaration, flags, writer) { - var type = getWidenedType(getTypeOfExpression(expr)); + var type = getWidenedType(getRegularTypeOfExpression(expr)); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeBaseConstructorTypeOfClass(node, enclosingDeclaration, flags, writer) { @@ -36164,9 +36467,9 @@ var ts; } var location = reference; if (startInDeclarationContainer) { - var parent_12 = reference.parent; - if (ts.isDeclaration(parent_12) && reference === parent_12.name) { - location = getDeclarationContainer(parent_12); + var parent_11 = reference.parent; + if (ts.isDeclaration(parent_11) && reference === parent_11.name) { + location = getDeclarationContainer(parent_11); } } return resolveName(location, reference.text, 107455 | 1048576 | 8388608, undefined, undefined); @@ -36279,9 +36582,9 @@ var ts; } var current = symbol; while (true) { - var parent_13 = getParentOfSymbol(current); - if (parent_13) { - current = parent_13; + var parent_12 = getParentOfSymbol(current); + if (parent_12) { + current = parent_12; } else { break; @@ -36958,9 +37261,9 @@ var ts; if (prop.kind === 259) { continue; } - var name_30 = prop.name; - if (name_30.kind === 142) { - checkGrammarComputedPropertyName(name_30); + var name_29 = prop.name; + if (name_29.kind === 142) { + checkGrammarComputedPropertyName(name_29); } 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); @@ -36976,8 +37279,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_30.kind === 8) { - checkGrammarNumericLiteral(name_30); + if (name_29.kind === 8) { + checkGrammarNumericLiteral(name_29); } currentKind = Property; } @@ -36993,7 +37296,7 @@ var ts; else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - var effectiveName = ts.getPropertyNameForPropertyNameNode(name_30); + var effectiveName = ts.getPropertyNameForPropertyNameNode(name_29); if (effectiveName === undefined) { continue; } @@ -37003,18 +37306,18 @@ var ts; else { var existingKind = seen[effectiveName]; if (currentKind === Property && existingKind === Property) { - grammarErrorOnNode(name_30, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_30)); + grammarErrorOnNode(name_29, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_29)); } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { seen[effectiveName] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_30, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_29, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } @@ -37027,12 +37330,12 @@ var ts; continue; } var jsxAttr = attr; - var name_31 = jsxAttr.name; - if (!seen[name_31.text]) { - seen[name_31.text] = true; + var name_30 = jsxAttr.name; + if (!seen[name_30.text]) { + seen[name_30.text] = true; } else { - return grammarErrorOnNode(name_31, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + return grammarErrorOnNode(name_30, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; if (initializer && initializer.kind === 252 && !initializer.expression) { @@ -37480,10 +37783,15 @@ var ts; function reduceNode(node, f, initial) { return node ? f(initial, node) : initial; } - function reduceEachChild(node, f, initial) { + function reduceNodeArray(nodes, f, initial) { + return nodes ? f(initial, nodes) : initial; + } + function reduceEachChild(node, initial, cbNode, cbNodeArray) { if (node === undefined) { return initial; } + var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; + var cbNodes = cbNodeArray || cbNode; var kind = node.kind; if ((kind > 0 && kind <= 140)) { return initial; @@ -37497,108 +37805,108 @@ var ts; case 206: case 198: case 222: - case 292: + case 293: break; case 142: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 144: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 145: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 147: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 149: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; case 150: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); break; case 151: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; case 152: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.body, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); break; case 172: case 173: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNodes(node.elements, cbNodes, result); break; case 174: - result = reduceNode(node.propertyName, f, result); - result = reduceNode(node.name, f, result); - result = reduceNode(node.initializer, f, result); + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 175: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNodes(node.elements, cbNodes, result); break; case 176: - result = ts.reduceLeft(node.properties, f, result); + result = reduceNodes(node.properties, cbNodes, result); break; case 177: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.name, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 178: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.argumentExpression, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); break; case 179: - result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); break; case 180: - result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); - result = ts.reduceLeft(node.arguments, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); break; case 181: - result = reduceNode(node.tag, f, result); - result = reduceNode(node.template, f, result); + result = reduceNode(node.tag, cbNode, result); + result = reduceNode(node.template, cbNode, result); break; case 184: - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; case 185: - result = ts.reduceLeft(node.modifiers, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; case 183: case 186: @@ -37608,205 +37916,205 @@ var ts; case 195: case 196: case 201: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 190: case 191: - result = reduceNode(node.operand, f, result); + result = reduceNode(node.operand, cbNode, result); break; case 192: - result = reduceNode(node.left, f, result); - result = reduceNode(node.right, f, result); + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); break; case 193: - result = reduceNode(node.condition, f, result); - result = reduceNode(node.whenTrue, f, result); - result = reduceNode(node.whenFalse, f, result); + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.whenTrue, cbNode, result); + result = reduceNode(node.whenFalse, cbNode, result); break; case 194: - result = reduceNode(node.head, f, result); - result = ts.reduceLeft(node.templateSpans, f, result); + result = reduceNode(node.head, cbNode, result); + result = reduceNodes(node.templateSpans, cbNodes, result); break; case 197: - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.heritageClauses, f, result); - result = ts.reduceLeft(node.members, f, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); break; case 199: - result = reduceNode(node.expression, f, result); - result = ts.reduceLeft(node.typeArguments, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); break; case 202: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.literal, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.literal, cbNode, result); break; case 204: - result = ts.reduceLeft(node.statements, f, result); + result = reduceNodes(node.statements, cbNodes, result); break; case 205: - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.declarationList, f, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.declarationList, cbNode, result); break; case 207: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 208: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.thenStatement, f, result); - result = reduceNode(node.elseStatement, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.thenStatement, cbNode, result); + result = reduceNode(node.elseStatement, cbNode, result); break; case 209: - result = reduceNode(node.statement, f, result); - result = reduceNode(node.expression, f, result); + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 210: case 217: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.statement, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); break; case 211: - result = reduceNode(node.initializer, f, result); - result = reduceNode(node.condition, f, result); - result = reduceNode(node.incrementor, f, result); - result = reduceNode(node.statement, f, result); + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.incrementor, cbNode, result); + result = reduceNode(node.statement, cbNode, result); break; case 212: case 213: - result = reduceNode(node.initializer, f, result); - result = reduceNode(node.expression, f, result); - result = reduceNode(node.statement, f, result); + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); break; case 216: case 220: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 218: - result = reduceNode(node.expression, f, result); - result = reduceNode(node.caseBlock, f, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.caseBlock, cbNode, result); break; case 219: - result = reduceNode(node.label, f, result); - result = reduceNode(node.statement, f, result); + result = reduceNode(node.label, cbNode, result); + result = reduceNode(node.statement, cbNode, result); break; case 221: - result = reduceNode(node.tryBlock, f, result); - result = reduceNode(node.catchClause, f, result); - result = reduceNode(node.finallyBlock, f, result); + result = reduceNode(node.tryBlock, cbNode, result); + result = reduceNode(node.catchClause, cbNode, result); + result = reduceNode(node.finallyBlock, cbNode, result); break; case 223: - result = reduceNode(node.name, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.initializer, f, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 224: - result = ts.reduceLeft(node.declarations, f, result); + result = reduceNodes(node.declarations, cbNodes, result); break; case 225: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.parameters, f, result); - result = reduceNode(node.type, f, result); - result = reduceNode(node.body, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); break; case 226: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.name, f, result); - result = ts.reduceLeft(node.typeParameters, f, result); - result = ts.reduceLeft(node.heritageClauses, f, result); - result = ts.reduceLeft(node.members, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); break; case 232: - result = ts.reduceLeft(node.clauses, f, result); + result = reduceNodes(node.clauses, cbNodes, result); break; case 235: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.importClause, f, result); - result = reduceNode(node.moduleSpecifier, f, result); + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.importClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); break; case 236: - result = reduceNode(node.name, f, result); - result = reduceNode(node.namedBindings, f, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.namedBindings, cbNode, result); break; case 237: - result = reduceNode(node.name, f, result); + result = reduceNode(node.name, cbNode, result); break; case 238: case 242: - result = ts.reduceLeft(node.elements, f, result); + result = reduceNodes(node.elements, cbNodes, result); break; case 239: case 243: - result = reduceNode(node.propertyName, f, result); - result = reduceNode(node.name, f, result); + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); break; case 240: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.expression, f, result); + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.expression, cbNode, result); break; case 241: - result = ts.reduceLeft(node.decorators, f, result); - result = ts.reduceLeft(node.modifiers, f, result); - result = reduceNode(node.exportClause, f, result); - result = reduceNode(node.moduleSpecifier, f, result); + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.exportClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); break; case 246: - result = reduceNode(node.openingElement, f, result); - result = ts.reduceLeft(node.children, f, result); - result = reduceNode(node.closingElement, f, result); + result = reduceNode(node.openingElement, cbNode, result); + result = ts.reduceLeft(node.children, cbNode, result); + result = reduceNode(node.closingElement, cbNode, result); break; case 247: case 248: - result = reduceNode(node.tagName, f, result); - result = ts.reduceLeft(node.attributes, f, result); + result = reduceNode(node.tagName, cbNode, result); + result = reduceNodes(node.attributes, cbNodes, result); break; case 249: - result = reduceNode(node.tagName, f, result); + result = reduceNode(node.tagName, cbNode, result); break; case 250: - result = reduceNode(node.name, f, result); - result = reduceNode(node.initializer, f, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 251: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 252: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 253: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); case 254: - result = ts.reduceLeft(node.statements, f, result); + result = reduceNodes(node.statements, cbNodes, result); break; case 255: - result = ts.reduceLeft(node.types, f, result); + result = reduceNodes(node.types, cbNodes, result); break; case 256: - result = reduceNode(node.variableDeclaration, f, result); - result = reduceNode(node.block, f, result); + result = reduceNode(node.variableDeclaration, cbNode, result); + result = reduceNode(node.block, cbNode, result); break; case 257: - result = reduceNode(node.name, f, result); - result = reduceNode(node.initializer, f, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); break; case 258: - result = reduceNode(node.name, f, result); - result = reduceNode(node.objectAssignmentInitializer, f, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; case 259: - result = reduceNode(node.expression, f, result); + result = reduceNode(node.expression, cbNode, result); break; case 261: - result = ts.reduceLeft(node.statements, f, result); + result = reduceNodes(node.statements, cbNodes, result); break; - case 293: - result = reduceNode(node.expression, f, result); + case 294: + result = reduceNode(node.expression, cbNode, result); break; default: var edgeTraversalPath = nodeEdgeTraversalMap[kind]; @@ -37816,8 +38124,8 @@ var ts; var value = node[edge.name]; if (value !== undefined) { result = ts.isArray(value) - ? ts.reduceLeft(value, f, result) - : f(result, value); + ? reduceNodes(value, cbNodes, result) + : cbNode(result, value); } } } @@ -37827,8 +38135,8 @@ var ts; } ts.reduceEachChild = reduceEachChild; function visitNode(node, visitor, test, optional, lift, parenthesize, parentNode) { - if (node === undefined) { - return undefined; + if (node === undefined || visitor === undefined) { + return node; } aggregateTransformFlags(node); var visited = visitor(node); @@ -37905,6 +38213,35 @@ var ts; return updated || nodes; } ts.visitNodes = visitNodes; + function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict) { + context.startLexicalEnvironment(); + statements = visitNodes(statements, visitor, ts.isStatement, start); + if (ensureUseStrict && !ts.startsWithUseStrict(statements)) { + statements = ts.createNodeArray([ts.createStatement(ts.createLiteral("use strict"))].concat(statements), statements); + } + var declarations = context.endLexicalEnvironment(); + return ts.createNodeArray(ts.concatenate(statements, declarations), statements); + } + ts.visitLexicalEnvironment = visitLexicalEnvironment; + function visitParameterList(nodes, visitor, context) { + context.startLexicalEnvironment(); + var updated = visitNodes(nodes, visitor, ts.isParameterDeclaration); + context.suspendLexicalEnvironment(); + return updated; + } + ts.visitParameterList = visitParameterList; + function visitFunctionBody(node, visitor, context) { + context.resumeLexicalEnvironment(); + var updated = visitNode(node, visitor, ts.isConciseBody); + var declarations = context.endLexicalEnvironment(); + if (ts.some(declarations)) { + var block = ts.convertToFunctionBody(updated); + var statements = mergeLexicalEnvironment(block.statements, declarations); + return ts.updateBlock(block, statements); + } + return updated; + } + ts.visitFunctionBody = visitFunctionBody; function visitEachChild(node, visitor, context) { if (node === undefined) { return undefined; @@ -37925,23 +38262,23 @@ var ts; case 142: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); case 144: - return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 147: return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); case 149: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 150: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 151: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 152: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); case 172: return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); case 173: return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); case 174: - return ts.updateBindingElement(node, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); + return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); case 175: return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); case 176: @@ -37959,9 +38296,9 @@ var ts; case 183: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); case 184: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 185: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isConciseBody, true), context.endLexicalEnvironment())); + return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 186: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 187: @@ -38029,7 +38366,7 @@ var ts; case 224: return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); case 225: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), (context.startLexicalEnvironment(), visitNodes(node.parameters, visitor, ts.isParameter)), visitNode(node.type, visitor, ts.isTypeNode, true), mergeFunctionBodyLexicalEnvironment(visitNode(node.body, visitor, ts.isFunctionBody, true), context.endLexicalEnvironment())); + return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); case 226: return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); case 232: @@ -38081,9 +38418,8 @@ var ts; case 259: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); case 261: - context.startLexicalEnvironment(); - return ts.updateSourceFileNode(node, ts.createNodeArray(ts.concatenate(visitNodes(node.statements, visitor, ts.isStatement), context.endLexicalEnvironment()), node.statements)); - case 293: + return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); + case 294: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: var updated = void 0; @@ -38111,6 +38447,15 @@ var ts; } } ts.visitEachChild = visitEachChild; + function mergeLexicalEnvironment(statements, declarations) { + if (!ts.some(declarations)) { + return statements; + } + return ts.isNodeArray(statements) + ? ts.createNodeArray(ts.concatenate(statements, declarations), statements) + : ts.addRange(statements, declarations); + } + ts.mergeLexicalEnvironment = mergeLexicalEnvironment; function mergeFunctionBodyLexicalEnvironment(body, declarations) { if (body && declarations !== undefined && declarations.length > 0) { if (ts.isBlock(body)) { @@ -38141,22 +38486,37 @@ var ts; if (node === undefined) { return 0; } - else if (node.transformFlags & 536870912) { + if (node.transformFlags & 536870912) { return node.transformFlags & ~ts.getTransformFlagsSubtreeExclusions(node.kind); } - else { - var subtreeFlags = aggregateTransformFlagsForSubtree(node); - return ts.computeTransformFlagsForNode(node, subtreeFlags); + var subtreeFlags = aggregateTransformFlagsForSubtree(node); + return ts.computeTransformFlagsForNode(node, subtreeFlags); + } + function aggregateTransformFlagsForNodeArray(nodes) { + if (nodes === undefined) { + return 0; } + var subtreeFlags = 0; + var nodeArrayFlags = 0; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; + subtreeFlags |= aggregateTransformFlagsForNode(node); + nodeArrayFlags |= node.transformFlags & ~536870912; + } + nodes.transformFlags = nodeArrayFlags | 536870912; + return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { if (ts.hasModifier(node, 2) || ts.isTypeNode(node)) { return 0; } - return reduceEachChild(node, aggregateTransformFlagsForChildNode, 0); + return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); + } + function aggregateTransformFlagsForChildNode(transformFlags, node) { + return transformFlags | aggregateTransformFlagsForNode(node); } - function aggregateTransformFlagsForChildNode(transformFlags, child) { - return transformFlags | aggregateTransformFlagsForNode(child); + function aggregateTransformFlagsForChildNodes(transformFlags, nodes) { + return transformFlags | aggregateTransformFlagsForNodeArray(nodes); } var Debug; (function (Debug) { @@ -38166,9 +38526,21 @@ var ts; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } : ts.noop; + Debug.assertEachNode = Debug.shouldAssert(1) + ? function (nodes, test, message) { return Debug.assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }); } + : ts.noop; Debug.assertNode = Debug.shouldAssert(1) ? function (node, test, message) { return Debug.assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } : ts.noop; + Debug.assertOptionalNode = Debug.shouldAssert(1) + ? function (node, test, message) { return Debug.assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }); } + : ts.noop; + Debug.assertOptionalToken = Debug.shouldAssert(1) + ? function (node, kind, message) { return Debug.assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was not a '" + ts.formatSyntaxKind(kind) + "' token."; }); } + : ts.noop; + Debug.assertMissingNode = Debug.shouldAssert(1) + ? function (node, message) { return Debug.assert(node === undefined, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected'."; }); } + : ts.noop; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -38187,440 +38559,316 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function flattenDestructuringAssignment(context, node, needsValue, recordTempVariable, visitor, transformRest) { - if (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { - var right = node.right; - if (ts.isDestructuringAssignment(right)) { - return flattenDestructuringAssignment(context, right, needsValue, recordTempVariable, visitor); - } - else { - return node.right; - } - } + function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) { var location = node; - var value = node.right; - var expressions = []; - if (needsValue) { - value = ensureIdentifier(value, true, location, emitTempVariableAssignment, visitor); + var value; + if (ts.isDestructuringAssignment(node)) { + value = node.right; + while (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { + if (ts.isDestructuringAssignment(value)) { + location = node = value; + value = node.right; + } + else { + return value; + } + } } - else if (ts.nodeIsSynthesized(node)) { - location = value; + var expressions; + var flattenContext = { + context: context, + level: level, + hoistTempVariables: true, + emitExpression: emitExpression, + emitBindingOrAssignment: emitBindingOrAssignment, + createArrayBindingOrAssignmentPattern: makeArrayAssignmentPattern, + createObjectBindingOrAssignmentPattern: makeObjectAssignmentPattern, + createArrayBindingOrAssignmentElement: makeAssignmentElement, + visitor: visitor + }; + if (value) { + value = ts.visitNode(value, visitor, ts.isExpression); + if (needsValue) { + value = ensureIdentifier(flattenContext, value, true, location); + } + else if (ts.nodeIsSynthesized(node)) { + location = value; + } } - flattenDestructuring(node, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); - if (needsValue) { + flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node)); + if (value && needsValue) { + if (!ts.some(expressions)) { + return value; + } expressions.push(value); } - var expression = ts.inlineExpressions(expressions); - ts.aggregateTransformFlags(expression); - return expression; - function emitAssignment(name, value, location) { - var expression = ts.createAssignment(name, value, location); - ts.setEmitFlags(expression, 2048); + return ts.aggregateTransformFlags(ts.inlineExpressions(expressions)) || ts.createOmittedExpression(); + function emitExpression(expression) { + ts.setEmitFlags(expression, 64); ts.aggregateTransformFlags(expression); - expressions.push(expression); - } - function emitTempVariableAssignment(value, location) { - var name = ts.createTempVariable(recordTempVariable); - emitAssignment(name, value, location); - return name; + expressions = ts.append(expressions, expression); } - function emitRestAssignment(elements, value, location) { - emitAssignment(ts.createObjectLiteral(elements), value, location); + function emitBindingOrAssignment(target, value, location, original) { + ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression); + var expression = createAssignmentCallback + ? createAssignmentCallback(target, value, location) + : ts.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value, location); + expression.original = original; + emitExpression(expression); } } ts.flattenDestructuringAssignment = flattenDestructuringAssignment; - function flattenParameterDestructuring(node, value, visitor, transformRest) { + function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) { + var pendingExpressions; + var pendingDeclarations = []; var declarations = []; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, transformRest, visitor); - return declarations; - function emitAssignment(name, value, location) { - var declaration = ts.createVariableDeclaration(name, undefined, value, location); - ts.setEmitFlags(declaration, 2048); - ts.aggregateTransformFlags(declaration); - declarations.push(declaration); - } - function emitTempVariableAssignment(value, location) { - var name = ts.createTempVariable(undefined); - emitAssignment(name, value, location); - return name; - } - function emitRestAssignment(elements, value, location) { - emitAssignment(ts.createObjectBindingPattern(elements), value, location); - } - } - ts.flattenParameterDestructuring = flattenParameterDestructuring; - function flattenVariableDestructuring(node, value, visitor, recordTempVariable, transformRest) { - var declarations = []; - var pendingAssignments; - flattenDestructuring(node, value, node, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor); - return declarations; - function emitAssignment(name, value, location, original) { - if (pendingAssignments) { - pendingAssignments.push(value); - value = ts.inlineExpressions(pendingAssignments); - pendingAssignments = undefined; - } - var declaration = ts.createVariableDeclaration(name, undefined, value, location); - declaration.original = original; - ts.setEmitFlags(declaration, 2048); - declarations.push(declaration); - ts.aggregateTransformFlags(declaration); - } - function emitTempVariableAssignment(value, location) { - var name = ts.createTempVariable(recordTempVariable); - if (recordTempVariable) { - var assignment = ts.createAssignment(name, value, location); - if (pendingAssignments) { - pendingAssignments.push(assignment); - } - else { - pendingAssignments = [assignment]; - } + var flattenContext = { + context: context, + level: level, + hoistTempVariables: hoistTempVariables, + emitExpression: emitExpression, + emitBindingOrAssignment: emitBindingOrAssignment, + createArrayBindingOrAssignmentPattern: makeArrayBindingPattern, + createObjectBindingOrAssignmentPattern: makeObjectBindingPattern, + createArrayBindingOrAssignmentElement: makeBindingElement, + visitor: visitor + }; + flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer); + if (pendingExpressions) { + var temp = ts.createTempVariable(undefined); + if (hoistTempVariables) { + var value = ts.inlineExpressions(pendingExpressions); + pendingExpressions = undefined; + emitBindingOrAssignment(temp, value, undefined, undefined); } else { - emitAssignment(name, value, location, undefined); + context.hoistVariableDeclaration(temp); + var pendingDeclaration = ts.lastOrUndefined(pendingDeclarations); + pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, ts.createAssignment(temp, pendingDeclaration.value)); + ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions); + pendingDeclaration.value = temp; } - return name; - } - function emitRestAssignment(elements, value, location, original) { - emitAssignment(ts.createObjectBindingPattern(elements), value, location, original); - } - } - ts.flattenVariableDestructuring = flattenVariableDestructuring; - function flattenVariableDestructuringToExpression(node, recordTempVariable, createAssignmentCallback, visitor) { - var pendingAssignments = []; - flattenDestructuring(node, undefined, node, emitAssignment, emitTempVariableAssignment, ts.noop, emitRestAssignment, false, visitor); - var expression = ts.inlineExpressions(pendingAssignments); - ts.aggregateTransformFlags(expression); - return expression; - function emitAssignment(name, value, location, original) { - var expression = createAssignmentCallback - ? createAssignmentCallback(name.kind === 70 ? name : emitTempVariableAssignment(name, location), value, location) - : ts.createAssignment(name, value, location); - emitPendingAssignment(expression, original); } - function emitTempVariableAssignment(value, location) { - var name = ts.createTempVariable(recordTempVariable); - emitPendingAssignment(ts.createAssignment(name, value, location), undefined); - return name; + 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); + variable.original = original; + if (ts.isIdentifier(name_31)) { + ts.setEmitFlags(variable, 64); + } + ts.aggregateTransformFlags(variable); + declarations.push(variable); } - function emitRestAssignment(elements, value, location, original) { - emitAssignment(ts.createObjectLiteral(elements), value, location, original); + return declarations; + function emitExpression(value) { + pendingExpressions = ts.append(pendingExpressions, value); } - function emitPendingAssignment(expression, original) { - expression.original = original; - ts.setEmitFlags(expression, 2048); - pendingAssignments.push(expression); + function emitBindingOrAssignment(target, value, location, original) { + ts.Debug.assertNode(target, ts.isBindingName); + if (pendingExpressions) { + value = ts.inlineExpressions(ts.append(pendingExpressions, value)); + pendingExpressions = undefined; + } + pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original }); } } - ts.flattenVariableDestructuringToExpression = flattenVariableDestructuringToExpression; - function flattenDestructuring(root, value, location, emitAssignment, emitTempVariableAssignment, recordTempVariable, emitRestAssignment, transformRest, visitor) { - if (value && visitor) { - value = ts.visitNode(value, visitor, ts.isExpression); - } - if (ts.isBinaryExpression(root)) { - emitDestructuringAssignment(root.left, value, location); - } - else { - emitBindingElement(root, value); - } - function emitDestructuringAssignment(bindingTarget, value, location) { - var target; - if (ts.isShorthandPropertyAssignment(bindingTarget)) { - var initializer = visitor - ? ts.visitNode(bindingTarget.objectAssignmentInitializer, visitor, ts.isExpression) - : bindingTarget.objectAssignmentInitializer; - if (initializer) { - value = createDefaultValueCheck(value, initializer, location); - } - target = bindingTarget.name; - } - else if (ts.isBinaryExpression(bindingTarget) && bindingTarget.operatorToken.kind === 57) { - var initializer = visitor - ? ts.visitNode(bindingTarget.right, visitor, ts.isExpression) - : bindingTarget.right; - value = createDefaultValueCheck(value, initializer, location); - target = bindingTarget.left; - } - else { - target = bindingTarget; + ts.flattenDestructuringBinding = flattenDestructuringBinding; + function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) { + if (!skipInitializer) { + var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression); + if (initializer) { + value = value ? createDefaultValueCheck(flattenContext, value, initializer, location) : initializer; } - if (target.kind === 176) { - emitObjectLiteralAssignment(target, value, location); - } - else if (target.kind === 175) { - emitArrayLiteralAssignment(target, value, location); - } - else { - var name_32 = ts.getMutableClone(target); - ts.setSourceMapRange(name_32, target); - ts.setCommentRange(name_32, target); - emitAssignment(name_32, value, location, undefined); + else if (!value) { + value = ts.createVoidZero(); } } - function emitObjectLiteralAssignment(target, value, location) { - var properties = target.properties; - if (properties.length !== 1) { - value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - } - var bindingElements = []; - for (var i = 0; i < properties.length; i++) { - var p = properties[i]; - if (p.kind === 257 || p.kind === 258) { - if (!transformRest || - p.transformFlags & 8388608 || - (p.kind === 257 && p.initializer.transformFlags & 8388608)) { - if (bindingElements.length) { - emitRestAssignment(bindingElements, value, location, target); - bindingElements = []; - } - var propName = p.name; - var bindingTarget = p.kind === 258 ? p : p.initializer || propName; - emitDestructuringAssignment(bindingTarget, createDestructuringPropertyAccess(value, propName), p); - } - else { - bindingElements.push(p); - } - } - else if (i === properties.length - 1 && - p.kind === 259 && - p.expression.kind === 70) { - if (bindingElements.length) { - emitRestAssignment(bindingElements, value, location, target); - bindingElements = []; - } - var propName = p.expression; - var restCall = createRestCall(value, target.properties, function (p) { return p.name; }, target); - emitDestructuringAssignment(propName, restCall, p); - } - } - if (bindingElements.length) { - emitRestAssignment(bindingElements, value, location, target); - bindingElements = []; - } + var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element); + if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) { + flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } - function emitArrayLiteralAssignment(target, value, location) { - if (transformRest) { - emitESNextArrayLiteralAssignment(target, value, location); - } - else { - emitES2015ArrayLiteralAssignment(target, value, location); - } + else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) { + flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location); } - function emitESNextArrayLiteralAssignment(target, value, location) { - var elements = target.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - } - var expressions = []; - var spreadContainingExpressions = []; - for (var i = 0; i < numElements; i++) { - var e = elements[i]; - if (e.kind === 198) { - continue; - } - if (e.transformFlags & 8388608 && i < numElements - 1) { - var tmp = ts.createTempVariable(recordTempVariable); - spreadContainingExpressions.push([e, tmp]); - expressions.push(tmp); + else { + flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element); + } + } + function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { + var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); + var numElements = elements.length; + if (numElements !== 1) { + var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; + value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); + } + var bindingElements; + var computedTempVariables; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { + var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); + if (flattenContext.level >= 1 + && !(element.transformFlags & (524288 | 1048576)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (524288 | 1048576)) + && !ts.isComputedPropertyName(propertyName)) { + bindingElements = ts.append(bindingElements, element); } else { - expressions.push(e); - } - } - emitAssignment(ts.updateArrayLiteral(target, expressions), value, undefined, undefined); - for (var _i = 0, spreadContainingExpressions_1 = spreadContainingExpressions; _i < spreadContainingExpressions_1.length; _i++) { - var _a = spreadContainingExpressions_1[_i], e = _a[0], tmp = _a[1]; - emitDestructuringAssignment(e, tmp, e); - } - } - function emitES2015ArrayLiteralAssignment(target, value, location) { - var elements = target.elements; - var numElements = elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - } - for (var i = 0; i < numElements; i++) { - var e = elements[i]; - if (e.kind !== 198) { - if (e.kind !== 196) { - emitDestructuringAssignment(e, ts.createElementAccess(value, ts.createLiteral(i)), e); + if (bindingElements) { + flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern); + bindingElements = undefined; } - else if (i === numElements - 1) { - emitDestructuringAssignment(e.expression, ts.createArraySlice(value, i), e); + var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName); + if (ts.isComputedPropertyName(propertyName)) { + computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression); } + flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element); } } - } - function createRestCall(value, elements, getPropertyName, location) { - var propertyNames = []; - for (var i = 0; i < elements.length - 1; i++) { - if (ts.isOmittedExpression(elements[i])) { - continue; + else if (i === numElements - 1) { + if (bindingElements) { + flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern); + bindingElements = undefined; } - var str = ts.createSynthesizedNode(9); - str.pos = location.pos; - str.end = location.end; - str.text = ts.getTextOfPropertyName(getPropertyName(elements[i])); - propertyNames.push(str); + var rhsValue = createRestCall(flattenContext.context, value, elements, computedTempVariables, pattern); + flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element); } - var args = ts.createSynthesizedNodeArray([value, ts.createArrayLiteral(propertyNames, location)]); - return ts.createCall(ts.createIdentifier("__rest"), undefined, args); } - function emitBindingElement(target, value) { - var initializer = visitor ? ts.visitNode(target.initializer, visitor, ts.isExpression) : target.initializer; - if (transformRest) { - value = value || initializer; - } - else if (initializer) { - value = value ? createDefaultValueCheck(value, initializer, target) : initializer; - } - else if (!value) { - value = ts.createVoidZero(); - } - var name = target.name; - if (!ts.isBindingPattern(name)) { - emitAssignment(name, value, target, target); - } - else { - var numElements = name.elements.length; - if (numElements !== 1) { - value = ensureIdentifier(value, numElements !== 0, target, emitTempVariableAssignment); - } - if (name.kind === 173) { - emitArrayBindingElement(name, value); - } - else { - emitObjectBindingElement(target, value); - } - } + if (bindingElements) { + flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern); } - function emitArrayBindingElement(name, value) { - if (transformRest) { - emitESNextArrayBindingElement(name, value); - } - else { - emitES2015ArrayBindingElement(name, value); - } - } - function emitES2015ArrayBindingElement(name, value) { - var elements = name.elements; - var numElements = elements.length; - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - if (!element.dotDotDotToken) { - emitBindingElement(element, ts.createElementAccess(value, i)); - } - else if (i === numElements - 1) { - emitBindingElement(element, ts.createArraySlice(value, i)); - } - } + } + function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { + var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); + var numElements = elements.length; + if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { + var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; + value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } - function emitESNextArrayBindingElement(name, value) { - var elements = name.elements; - var numElements = elements.length; - var bindingElements = []; - var spreadContainingElements = []; - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - if (element.transformFlags & 8388608 && i < numElements - 1) { - spreadContainingElements.push(element); - bindingElements.push(ts.createBindingElement(undefined, undefined, ts.getGeneratedNameForNode(element), undefined, value)); + var bindingElements; + var restContainingElements; + for (var i = 0; i < numElements; i++) { + var element = elements[i]; + if (flattenContext.level >= 1) { + if (element.transformFlags & 1048576) { + var temp = ts.createTempVariable(undefined); + if (flattenContext.hoistTempVariables) { + flattenContext.context.hoistVariableDeclaration(temp); + } + restContainingElements = ts.append(restContainingElements, [temp, element]); + bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp)); } else { - bindingElements.push(element); + bindingElements = ts.append(bindingElements, element); } } - emitAssignment(ts.updateArrayBindingPattern(name, bindingElements), value, undefined, undefined); - for (var _i = 0, spreadContainingElements_1 = spreadContainingElements; _i < spreadContainingElements_1.length; _i++) { - var element = spreadContainingElements_1[_i]; - emitBindingElement(element, ts.getGeneratedNameForNode(element)); + else if (ts.isOmittedExpression(element)) { + continue; } - } - function emitObjectBindingElement(target, value) { - var name = target.name; - var elements = name.elements; - var numElements = elements.length; - var bindingElements = []; - for (var i = 0; i < numElements; i++) { - var element = elements[i]; - if (ts.isOmittedExpression(element)) { - continue; - } - if (i === numElements - 1 && element.dotDotDotToken) { - if (bindingElements.length) { - emitRestAssignment(bindingElements, value, target, target); - bindingElements = []; - } - var restCall = createRestCall(value, name.elements, function (element) { return element.propertyName || element.name; }, name); - emitBindingElement(element, restCall); - } - else if (transformRest && !(element.transformFlags & 8388608)) { - bindingElements.push(element); - } - else { - if (bindingElements.length) { - emitRestAssignment(bindingElements, value, target, target); - bindingElements = []; - } - var propName = element.propertyName || element.name; - emitBindingElement(element, createDestructuringPropertyAccess(value, propName)); - } + else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { + var rhsValue = ts.createElementAccess(value, i); + flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element); } - if (bindingElements.length) { - emitRestAssignment(bindingElements, value, target, target); - bindingElements = []; + else if (i === numElements - 1) { + var rhsValue = ts.createArraySlice(value, i); + flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element); } } - function createDefaultValueCheck(value, defaultValue, location) { - value = ensureIdentifier(value, true, location, emitTempVariableAssignment); - return ts.createConditional(ts.createStrictEquality(value, ts.createVoidZero()), ts.createToken(54), defaultValue, ts.createToken(55), value); + if (bindingElements) { + flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern); } - function createDestructuringPropertyAccess(expression, propertyName) { - if (ts.isComputedPropertyName(propertyName)) { - return ts.createElementAccess(expression, ensureIdentifier(propertyName.expression, false, propertyName, emitTempVariableAssignment)); - } - else if (ts.isLiteralExpression(propertyName)) { - var clone_2 = ts.getSynthesizedClone(propertyName); - clone_2.text = ts.unescapeIdentifier(clone_2.text); - return ts.createElementAccess(expression, clone_2); - } - else { - if (ts.isGeneratedIdentifier(propertyName)) { - var clone_3 = ts.getSynthesizedClone(propertyName); - clone_3.text = ts.unescapeIdentifier(clone_3.text); - return ts.createPropertyAccess(expression, clone_3); - } - else { - return ts.createPropertyAccess(expression, ts.createIdentifier(ts.unescapeIdentifier(propertyName.text))); - } + if (restContainingElements) { + for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) { + var _a = restContainingElements_1[_i], id = _a[0], element = _a[1]; + flattenBindingOrAssignmentElement(flattenContext, element, id, element); } } } - function ensureIdentifier(value, reuseIdentifierExpressions, location, emitTempVariableAssignment, visitor) { + function createDefaultValueCheck(flattenContext, value, defaultValue, location) { + value = ensureIdentifier(flattenContext, value, true, location); + return ts.createConditional(ts.createTypeCheck(value, "undefined"), defaultValue, value); + } + function createDestructuringPropertyAccess(flattenContext, value, propertyName) { + if (ts.isComputedPropertyName(propertyName)) { + var argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, false, propertyName); + return ts.createElementAccess(value, argumentExpression); + } + else if (ts.isStringOrNumericLiteral(propertyName)) { + var argumentExpression = ts.getSynthesizedClone(propertyName); + argumentExpression.text = ts.unescapeIdentifier(argumentExpression.text); + return ts.createElementAccess(value, argumentExpression); + } + else { + var name_32 = ts.createIdentifier(ts.unescapeIdentifier(propertyName.text)); + return ts.createPropertyAccess(value, name_32); + } + } + function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) { if (ts.isIdentifier(value) && reuseIdentifierExpressions) { return value; } else { - if (visitor) { - value = ts.visitNode(value, visitor, ts.isExpression); + var temp = ts.createTempVariable(undefined); + if (flattenContext.hoistTempVariables) { + flattenContext.context.hoistVariableDeclaration(temp); + flattenContext.emitExpression(ts.createAssignment(temp, value, location)); } - return emitTempVariableAssignment(value, location); + else { + flattenContext.emitBindingOrAssignment(temp, value, location, undefined); + } + return temp; } } + function makeArrayBindingPattern(elements) { + ts.Debug.assertEachNode(elements, ts.isArrayBindingElement); + return ts.createArrayBindingPattern(elements); + } + function makeArrayAssignmentPattern(elements) { + return ts.createArrayLiteral(ts.map(elements, ts.convertToArrayAssignmentElement)); + } + function makeObjectBindingPattern(elements) { + ts.Debug.assertEachNode(elements, ts.isBindingElement); + return ts.createObjectBindingPattern(elements); + } + function makeObjectAssignmentPattern(elements) { + return ts.createObjectLiteral(ts.map(elements, ts.convertToObjectAssignmentElement)); + } + function makeBindingElement(name) { + return ts.createBindingElement(undefined, undefined, name); + } + function makeAssignmentElement(name) { + return name; + } + 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 };" + }; + function createRestCall(context, value, elements, computedTempVariables, location) { + context.requestEmitHelper(restHelper); + var propertyNames = []; + var computedTempVariableOffset = 0; + for (var i = 0; i < elements.length - 1; i++) { + var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(elements[i]); + if (propertyName) { + if (ts.isComputedPropertyName(propertyName)) { + var temp = computedTempVariables[computedTempVariableOffset]; + computedTempVariableOffset++; + propertyNames.push(ts.createConditional(ts.createTypeCheck(temp, "symbol"), temp, ts.createAdd(temp, ts.createLiteral("")))); + } + else { + propertyNames.push(ts.createLiteral(propertyName)); + } + } + } + return ts.createCall(ts.getHelperName("__rest"), undefined, [value, ts.createArrayLiteral(propertyNames, location)]); + } })(ts || (ts = {})); var ts; (function (ts) { var USE_NEW_TYPE_METADATA_FORMAT = false; function transformTypeScript(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -38636,7 +38884,6 @@ var ts; var currentNamespaceContainerName; var currentScope; var currentScopeFirstDeclarationsOfName; - var currentExternalHelpersModuleName; var enabledSubstitutions; var classAliases; var applicableSubstitutions; @@ -38645,7 +38892,11 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - return ts.visitNode(node, visitor, ts.isSourceFile); + currentSourceFile = node; + var visited = saveStateAndInvoke(node, visitSourceFile); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; } function saveStateAndInvoke(node, f) { var savedCurrentScope = currentScope; @@ -38658,14 +38909,29 @@ var ts; currentScope = savedCurrentScope; return visited; } + function onBeforeVisitNode(node) { + switch (node.kind) { + case 261: + case 232: + case 231: + case 204: + currentScope = node; + currentScopeFirstDeclarationsOfName = undefined; + break; + case 226: + case 225: + if (ts.hasModifier(node, 2)) { + break; + } + recordEmittedDeclarationInScope(node); + break; + } + } function visitor(node) { return saveStateAndInvoke(node, visitorWorker); } function visitorWorker(node) { - if (node.kind === 261) { - return visitSourceFile(node); - } - else if (node.transformFlags & 1) { + if (node.transformFlags & 1) { return visitTypeScript(node); } else if (node.transformFlags & 2) { @@ -38833,53 +39099,9 @@ var ts; return ts.visitEachChild(node, visitor, context); } } - function onBeforeVisitNode(node) { - switch (node.kind) { - case 261: - case 232: - case 231: - case 204: - currentScope = node; - currentScopeFirstDeclarationsOfName = undefined; - break; - case 226: - case 225: - if (ts.hasModifier(node, 2)) { - break; - } - recordEmittedDeclarationInScope(node); - break; - } - } function visitSourceFile(node) { - currentSourceFile = node; - if (compilerOptions.alwaysStrict && - !(ts.isExternalModule(node) && (compilerOptions.target >= 2 || compilerOptions.module === ts.ModuleKind.ES2015))) { - node = ts.ensureUseStrict(node); - } - if (node.flags & 64512 - && compilerOptions.importHelpers - && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - startLexicalEnvironment(); - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); - var externalHelpersModuleName = ts.createUniqueName(ts.externalHelpersModuleNameText); - var externalHelpersModuleImport = ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText)); - externalHelpersModuleImport.parent = node; - externalHelpersModuleImport.flags &= ~8; - statements.push(externalHelpersModuleImport); - currentExternalHelpersModuleName = externalHelpersModuleName; - ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); - currentExternalHelpersModuleName = undefined; - node = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); - node.externalHelpersModuleName = externalHelpersModuleName; - } - else { - node = ts.visitEachChild(node, sourceElementVisitor, context); - } - ts.setEmitFlags(node, 1 | ts.getEmitFlags(node)); - return node; + var alwaysStrict = compilerOptions.alwaysStrict && !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { if (node.decorators && node.decorators.length > 0) { @@ -38925,7 +39147,7 @@ var ts; } if (statements.length > 1) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 33554432); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 2097152); } return ts.singleOrMany(statements); } @@ -38933,7 +39155,7 @@ var ts; var classDeclaration = ts.createClassDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, hasExtendsClause), node); var emitFlags = ts.getEmitFlags(node); if (hasStaticProperties) { - emitFlags |= 1024; + emitFlags |= 32; } ts.setOriginalNode(classDeclaration, node); ts.setEmitFlags(classDeclaration, emitFlags); @@ -38964,7 +39186,7 @@ var ts; enableSubstitutionForClassAliases(); classAliases[ts.getOriginalNodeId(node)] = ts.getSynthesizedClone(temp); } - ts.setEmitFlags(classExpression, 524288 | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 32768 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -38983,7 +39205,7 @@ var ts; } function transformConstructor(node, hasExtendsClause) { var hasInstancePropertyWithInitializer = ts.forEach(node.members, isInstanceInitializedProperty); - var hasParameterPropertyAssignments = node.transformFlags & 4194304; + var hasParameterPropertyAssignments = node.transformFlags & 262144; var constructor = ts.getFirstConstructorWithBody(node); if (!hasInstancePropertyWithInitializer && !hasParameterPropertyAssignments) { return ts.visitEachChild(constructor, visitor, context); @@ -38993,14 +39215,13 @@ var ts; return ts.startOnNewLine(ts.setOriginalNode(ts.createConstructor(undefined, undefined, parameters, body, constructor || node), constructor)); } function transformConstructorParameters(constructor) { - return constructor - ? ts.visitNodes(constructor.parameters, visitor, ts.isParameter) - : []; + return ts.visitParameterList(constructor && constructor.parameters, visitor, context) + || []; } function transformConstructorBody(node, constructor, hasExtendsClause) { var statements = []; var indexOfFirstStatement = 0; - startLexicalEnvironment(); + resumeLexicalEnvironment(); if (constructor) { indexOfFirstStatement = addPrologueDirectivesAndInitialSuperCall(constructor, statements); var propertyAssignments = getParametersWithPropertyAssignments(constructor); @@ -39015,7 +39236,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } ts.addRange(statements, endLexicalEnvironment()); - return ts.setMultiLine(ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined), true); + return ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : undefined, true); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { @@ -39044,9 +39265,9 @@ var ts; ts.Debug.assert(ts.isIdentifier(node.name)); var name = node.name; var propertyName = ts.getMutableClone(name); - ts.setEmitFlags(propertyName, 49152 | 1536); + ts.setEmitFlags(propertyName, 1536 | 48); var localName = ts.getMutableClone(name); - ts.setEmitFlags(localName, 49152); + ts.setEmitFlags(localName, 1536); return ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), propertyName, node.name), localName), ts.moveRangePos(node, -1))); } function getInitializedProperties(node, isStatic) { @@ -39219,8 +39440,8 @@ var ts; ? ts.createVoidZero() : ts.createNull() : undefined; - var helper = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); - ts.setEmitFlags(helper, 49152); + var helper = createDecorateHelper(context, decoratorExpressions, prefix, memberName, descriptor, ts.moveRangePastDecorators(member)); + ts.setEmitFlags(helper, 1536); return helper; } function addConstructorDecorationStatement(statements, node) { @@ -39237,9 +39458,9 @@ var ts; } var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; var localName = ts.getLocalName(node, false, true); - var decorate = ts.createDecorateHelper(currentExternalHelpersModuleName, decoratorExpressions, localName); + var decorate = createDecorateHelper(context, decoratorExpressions, localName); var expression = ts.createAssignment(localName, classAlias ? ts.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 49152); + ts.setEmitFlags(expression, 1536); ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node)); return expression; } @@ -39252,8 +39473,8 @@ var ts; expressions = []; for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) { var decorator = decorators_1[_i]; - var helper = ts.createParamHelper(currentExternalHelpersModuleName, transformDecorator(decorator), parameterOffset, decorator.expression); - ts.setEmitFlags(helper, 49152); + var helper = createParamHelper(context, transformDecorator(decorator), parameterOffset, decorator.expression); + ts.setEmitFlags(helper, 1536); expressions.push(helper); } } @@ -39270,13 +39491,13 @@ var ts; function addOldTypeMetadata(node, decoratorExpressions) { if (compilerOptions.emitDecoratorMetadata) { if (shouldAddTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:type", serializeTypeOfNode(node))); + decoratorExpressions.push(createMetadataHelper(context, "design:type", serializeTypeOfNode(node))); } if (shouldAddParamTypesMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:paramtypes", serializeParameterTypesOfNode(node))); + decoratorExpressions.push(createMetadataHelper(context, "design:paramtypes", serializeParameterTypesOfNode(node))); } if (shouldAddReturnTypeMetadata(node)) { - decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:returntype", serializeReturnTypeOfNode(node))); + decoratorExpressions.push(createMetadataHelper(context, "design:returntype", serializeReturnTypeOfNode(node))); } } } @@ -39293,7 +39514,7 @@ var ts; (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); } if (properties) { - decoratorExpressions.push(ts.createMetadataHelper(currentExternalHelpersModuleName, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); + decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, undefined, true))); } } } @@ -39462,7 +39683,7 @@ var ts; case ts.TypeReferenceSerializationKind.Unknown: var serialized = serializeEntityNameAsExpression(node.typeName, true); var temp = ts.createTempVariable(hoistVariableDeclaration); - return ts.createLogicalOr(ts.createLogicalAnd(ts.createStrictEquality(ts.createTypeOf(ts.createAssignment(temp, serialized)), ts.createLiteral("function")), temp), ts.createIdentifier("Object")); + return ts.createLogicalOr(ts.createLogicalAnd(ts.createTypeCheck(ts.createAssignment(temp, serialized), "function"), temp), ts.createIdentifier("Object")); case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: return serializeEntityNameAsExpression(node.typeName, false); case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: @@ -39518,7 +39739,7 @@ var ts; return ts.createPropertyAccess(left, node.right); } function getGlobalSymbolNameWithFallback() { - return ts.createConditional(ts.createStrictEquality(ts.createTypeOf(ts.createIdentifier("Symbol")), ts.createLiteral("function")), ts.createToken(54), ts.createIdentifier("Symbol"), ts.createToken(55), ts.createIdentifier("Object")); + return ts.createConditional(ts.createTypeCheck(ts.createIdentifier("Symbol"), "function"), ts.createIdentifier("Symbol"), ts.createIdentifier("Object")); } function getExpressionForPropertyName(member, generateNameForComputedPropertyName) { var name = member.name; @@ -39573,11 +39794,12 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - ts.setCommentRange(method, node); - ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(method, node); - return method; + var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + if (updated !== node) { + ts.setCommentRange(updated, node); + ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); + } + return updated; } function shouldEmitAccessorDeclaration(node) { return !(ts.nodeIsMissing(node.body) && ts.hasModifier(node, 128)); @@ -39586,86 +39808,46 @@ var ts; if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createGetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - ts.setOriginalNode(accessor, node); - ts.setCommentRange(accessor, node); - ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - return accessor; + var updated = ts.updateGetAccessor(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); + if (updated !== node) { + ts.setCommentRange(updated, node); + ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); + } + return updated; } function visitSetAccessor(node) { if (!shouldEmitAccessorDeclaration(node)) { return undefined; } - var accessor = ts.createSetAccessor(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitNodes(node.parameters, visitor, ts.isParameter), node.body ? ts.visitEachChild(node.body, visitor, context) : ts.createBlock([]), node); - ts.setOriginalNode(accessor, node); - ts.setCommentRange(accessor, node); - ts.setSourceMapRange(accessor, ts.moveRangePastDecorators(node)); - return accessor; + var updated = ts.updateSetAccessor(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); + if (updated !== node) { + ts.setCommentRange(updated, node); + ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); + } + return updated; } function visitFunctionDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createNotEmittedStatement(node); } - var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - ts.setOriginalNode(func, node); + var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); if (isNamespaceExport(node)) { - var statements = [func]; + var statements = [updated]; addExportMemberAssignment(statements, node); return statements; } - return func; + return updated; } function visitFunctionExpression(node) { if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - ts.setOriginalNode(func, node); - return func; + var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + return updated; } function visitArrowFunction(node) { - var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); - ts.setOriginalNode(func, node); - return func; - } - function transformFunctionBody(node) { - return transformFunctionBodyWorker(node.body); - } - function transformFunctionBodyWorker(body, start) { - if (start === void 0) { start = 0; } - var savedCurrentScope = currentScope; - var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName; - currentScope = body; - currentScopeFirstDeclarationsOfName = ts.createMap(); - startLexicalEnvironment(); - var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); - var visited = ts.updateBlock(body, statements); - var declarations = endLexicalEnvironment(); - currentScope = savedCurrentScope; - currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; - return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); - } - function transformConciseBody(node) { - return transformConciseBodyWorker(node.body, false); - } - function transformConciseBodyWorker(body, forceBlockFunctionBody) { - if (ts.isBlock(body)) { - return transformFunctionBodyWorker(body); - } - else { - startLexicalEnvironment(); - var visited = ts.visitNode(body, visitor, ts.isConciseBody); - var declarations = endLexicalEnvironment(); - var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); - if (forceBlockFunctionBody && !ts.isBlock(merged)) { - return ts.createBlock([ - ts.createReturn(merged) - ]); - } - else { - return merged; - } - } + var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + return updated; } function visitParameter(node) { if (ts.parameterIsThisKeyword(node)) { @@ -39675,7 +39857,7 @@ var ts; ts.setOriginalNode(parameter, node); ts.setCommentRange(parameter, node); ts.setSourceMapRange(parameter, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(parameter.name, 1024); + ts.setEmitFlags(parameter.name, 32); return parameter; } function visitVariableStatement(node) { @@ -39693,7 +39875,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createNamespaceExportExpression, visitor); + return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression); } else { return ts.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression), node); @@ -39734,10 +39916,10 @@ var ts; return undefined; } var statements = []; - var emitFlags = 64; + var emitFlags = 2; if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { - emitFlags |= 16384; + emitFlags |= 512; } } var parameterName = getNamespaceParameterName(node); @@ -39829,13 +40011,13 @@ var ts; ts.setSourceMapRange(statement, node); } ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 32768 | 33554432); + ts.setEmitFlags(statement, 1024 | 2097152); statements.push(statement); return true; } else { var mergeMarker = ts.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 49152 | 33554432); + ts.setEmitFlags(mergeMarker, 1536 | 2097152); statements.push(mergeMarker); return false; } @@ -39847,10 +40029,10 @@ var ts; ts.Debug.assert(ts.isIdentifier(node.name), "TypeScript module should have an Identifier name."); enableSubstitutionForNamespaceExports(); var statements = []; - var emitFlags = 64; + var emitFlags = 2; if (addVarForEnumOrModuleDeclaration(statements, node)) { if (moduleKind !== ts.ModuleKind.System || currentScope !== currentSourceFile) { - emitFlags |= 16384; + emitFlags |= 512; } } var parameterName = getNamespaceParameterName(node); @@ -39906,7 +40088,7 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), blockLocation, true); if (body.kind !== 231) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 49152); + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } @@ -39981,7 +40163,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(node.moduleReference); - ts.setEmitFlags(moduleReference, 49152 | 65536); + ts.setEmitFlags(moduleReference, 1536 | 2048); if (isNamedExternalModuleExport(node) || !isNamespaceExport(node)) { return ts.setOriginalNode(ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.setOriginalNode(ts.createVariableDeclaration(node.name, undefined, moduleReference), node) @@ -40134,10 +40316,10 @@ var ts; if (declaration) { var classAlias = classAliases[declaration.id]; if (classAlias) { - var clone_4 = ts.getSynthesizedClone(classAlias); - ts.setSourceMapRange(clone_4, node); - ts.setCommentRange(clone_4, node); - return clone_4; + var clone_2 = ts.getSynthesizedClone(classAlias); + ts.setSourceMapRange(clone_2, node); + ts.setCommentRange(clone_2, node); + return clone_2; } } } @@ -40145,7 +40327,7 @@ var ts; return undefined; } function trySubstituteNamespaceExportedName(node) { - if (enabledSubstitutions & applicableSubstitutions && !ts.isLocalName(node)) { + if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); if (container && container.kind !== 261) { var substitute = (applicableSubstitutions & 2 && container.kind === 230) || @@ -40190,10 +40372,278 @@ var ts; } } ts.transformTypeScript = transformTypeScript; + var paramHelper = { + name: "typescript:param", + scoped: false, + priority: 4, + text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" + }; + function createParamHelper(context, expression, parameterOffset, location) { + context.requestEmitHelper(paramHelper); + return ts.createCall(ts.getHelperName("__param"), undefined, [ + ts.createLiteral(parameterOffset), + expression + ], location); + } + var metadataHelper = { + name: "typescript:metadata", + scoped: false, + priority: 3, + text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" + }; + function createMetadataHelper(context, metadataKey, metadataValue) { + context.requestEmitHelper(metadataHelper); + return ts.createCall(ts.getHelperName("__metadata"), undefined, [ + ts.createLiteral(metadataKey), + metadataValue + ]); + } + var decorateHelper = { + name: "typescript:decorate", + scoped: false, + priority: 2, + text: "\n var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n };" + }; + function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { + context.requestEmitHelper(decorateHelper); + var argumentsArray = []; + argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, undefined, true)); + argumentsArray.push(target); + if (memberName) { + argumentsArray.push(memberName); + if (descriptor) { + argumentsArray.push(descriptor); + } + } + return ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray, location); + } +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformESNext(context) { + var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + return visited; + } + function visitor(node) { + return visitorWorker(node, false); + } + function visitorNoDestructuringValue(node) { + return visitorWorker(node, true); + } + function visitorWorker(node, noDestructuringValue) { + if ((node.transformFlags & 8) === 0) { + return node; + } + switch (node.kind) { + case 176: + return visitObjectLiteralExpression(node); + case 192: + return visitBinaryExpression(node, noDestructuringValue); + case 223: + return visitVariableDeclaration(node); + case 213: + return visitForOfStatement(node); + case 211: + return visitForStatement(node); + case 188: + return visitVoidExpression(node); + case 150: + return visitConstructorDeclaration(node); + case 149: + return visitMethodDeclaration(node); + case 151: + return visitGetAccessorDeclaration(node); + case 152: + return visitSetAccessorDeclaration(node); + case 225: + return visitFunctionDeclaration(node); + case 184: + return visitFunctionExpression(node); + case 185: + return visitArrowFunction(node); + case 144: + return visitParameter(node); + case 207: + return visitExpressionStatement(node); + case 183: + return visitParenthesizedExpression(node, noDestructuringValue); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function chunkObjectLiteralElements(elements) { + var chunkObject; + var objects = []; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; + if (e.kind === 259) { + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + chunkObject = undefined; + } + var target = e.expression; + objects.push(ts.visitNode(target, visitor, ts.isExpression)); + } + else { + if (!chunkObject) { + chunkObject = []; + } + if (e.kind === 257) { + var p = e; + chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); + } + else { + chunkObject.push(e); + } + } + } + if (chunkObject) { + objects.push(ts.createObjectLiteral(chunkObject)); + } + return objects; + } + function visitObjectLiteralExpression(node) { + if (node.transformFlags & 1048576) { + var objects = chunkObjectLiteralElements(node.properties); + if (objects.length && objects[0].kind !== 176) { + objects.unshift(ts.createObjectLiteral()); + } + return createAssignHelper(context, objects); + } + return ts.visitEachChild(node, visitor, context); + } + function visitExpressionStatement(node) { + return ts.visitEachChild(node, visitorNoDestructuringValue, context); + } + function visitParenthesizedExpression(node, noDestructuringValue) { + return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); + } + function visitBinaryExpression(node, noDestructuringValue) { + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); + } + else if (node.operatorToken.kind === 25) { + return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); + } + return ts.visitEachChild(node, visitor, context); + } + function visitVariableDeclaration(node) { + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 1048576) { + return ts.flattenDestructuringBinding(node, visitor, context, 1); + } + return ts.visitEachChild(node, visitor, context); + } + function visitForStatement(node) { + return ts.updateFor(node, ts.visitNode(node.initializer, visitorNoDestructuringValue, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement)); + } + function visitVoidExpression(node) { + return ts.visitEachChild(node, visitorNoDestructuringValue, context); + } + function visitForOfStatement(node) { + var leadingStatements; + var temp; + var initializer = ts.skipParentheses(node.initializer); + if (initializer.transformFlags & 1048576) { + if (ts.isVariableDeclarationList(initializer)) { + temp = ts.createTempVariable(undefined); + var firstDeclaration = ts.firstOrUndefined(initializer.declarations); + var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); + if (ts.some(declarations)) { + var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations), initializer); + leadingStatements = ts.append(leadingStatements, statement); + } + } + else if (ts.isAssignmentPattern(initializer)) { + temp = ts.createTempVariable(undefined); + var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.createAssignment(initializer, temp, node.initializer)), visitor, context, 1); + leadingStatements = ts.append(leadingStatements, ts.createStatement(expression, node.initializer)); + } + } + if (temp) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + var block = ts.isBlock(statement) + ? ts.updateBlock(statement, ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements), statement.statements)) + : ts.createBlock(ts.append(leadingStatements, statement), statement, true); + return ts.updateForOf(node, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, undefined, undefined, node.initializer) + ], node.initializer, 1), expression, block); + } + return ts.visitEachChild(node, visitor, context); + } + function visitParameter(node) { + if (node.transformFlags & 1048576) { + return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); + } + return ts.visitEachChild(node, visitor, context); + } + function visitConstructorDeclaration(node) { + return ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + } + function visitGetAccessorDeclaration(node) { + return ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + } + function visitSetAccessorDeclaration(node) { + return ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + } + function visitMethodDeclaration(node) { + return ts.updateMethod(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + } + function visitFunctionDeclaration(node) { + return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + } + function visitArrowFunction(node) { + return ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + } + function visitFunctionExpression(node) { + return ts.updateFunctionExpression(node, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + } + function transformFunctionBody(node) { + resumeLexicalEnvironment(); + var leadingStatements; + for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { + var parameter = _a[_i]; + if (parameter.transformFlags & 1048576) { + var temp = ts.getGeneratedNameForNode(parameter); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true); + if (ts.some(declarations)) { + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations)); + ts.setEmitFlags(statement, 524288); + leadingStatements = ts.append(leadingStatements, statement); + } + } + } + var body = ts.visitNode(node.body, visitor, ts.isConciseBody); + var trailingStatements = endLexicalEnvironment(); + if (ts.some(leadingStatements) || ts.some(trailingStatements)) { + var block = ts.convertToFunctionBody(body, true); + return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements), block.statements)); + } + return body; + } + } + ts.transformESNext = transformESNext; + var assignHelper = { + name: "typescript:assign", + scoped: false, + priority: 1, + text: "\n var __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };" + }; + function createAssignHelper(context, attributesSegments) { + context.requestEmitHelper(assignHelper); + return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); + } + ts.createAssignHelper = createAssignHelper; })(ts || (ts = {})); var ts; (function (ts) { - var entities = createEntitiesMap(); function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); var currentSourceFile; @@ -40203,17 +40653,15 @@ var ts; return node; } currentSourceFile = node; - node = ts.visitEachChild(node, visitor, context); + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); currentSourceFile = undefined; - return node; + return visited; } function visitor(node) { if (node.transformFlags & 4) { return visitorWorker(node); } - else if (node.transformFlags & 8) { - return ts.visitEachChild(node, visitor, context); - } else { return node; } @@ -40227,8 +40675,7 @@ var ts; case 252: return visitJsxExpression(node); default: - ts.Debug.failBadSyntaxKind(node); - return undefined; + return ts.visitEachChild(node, visitor, context); } } function transformJsxChildToExpression(node) { @@ -40266,8 +40713,10 @@ var ts; if (ts.isJsxSpreadAttribute(attrs[0])) { segments.unshift(ts.createObjectLiteral()); } - objectProperties = ts.singleOrUndefined(segments) - || ts.createAssignHelper(currentSourceFile.externalHelpersModuleName, segments); + objectProperties = ts.singleOrUndefined(segments); + if (!objectProperties) { + objectProperties = ts.createAssignHelper(context, segments); + } } var element = ts.createExpressionForJsxElement(context.getEmitResolver().getJsxFactoryEntity(), compilerOptions.reactNamespace, tagName, objectProperties, ts.filter(ts.map(children, transformJsxChildToExpression), ts.isDefined), node, location); if (isChild) { @@ -40383,458 +40832,291 @@ var ts; } } ts.transformJsx = transformJsx; - function createEntitiesMap() { - return ts.createMap({ - "quot": 0x0022, - "amp": 0x0026, - "apos": 0x0027, - "lt": 0x003C, - "gt": 0x003E, - "nbsp": 0x00A0, - "iexcl": 0x00A1, - "cent": 0x00A2, - "pound": 0x00A3, - "curren": 0x00A4, - "yen": 0x00A5, - "brvbar": 0x00A6, - "sect": 0x00A7, - "uml": 0x00A8, - "copy": 0x00A9, - "ordf": 0x00AA, - "laquo": 0x00AB, - "not": 0x00AC, - "shy": 0x00AD, - "reg": 0x00AE, - "macr": 0x00AF, - "deg": 0x00B0, - "plusmn": 0x00B1, - "sup2": 0x00B2, - "sup3": 0x00B3, - "acute": 0x00B4, - "micro": 0x00B5, - "para": 0x00B6, - "middot": 0x00B7, - "cedil": 0x00B8, - "sup1": 0x00B9, - "ordm": 0x00BA, - "raquo": 0x00BB, - "frac14": 0x00BC, - "frac12": 0x00BD, - "frac34": 0x00BE, - "iquest": 0x00BF, - "Agrave": 0x00C0, - "Aacute": 0x00C1, - "Acirc": 0x00C2, - "Atilde": 0x00C3, - "Auml": 0x00C4, - "Aring": 0x00C5, - "AElig": 0x00C6, - "Ccedil": 0x00C7, - "Egrave": 0x00C8, - "Eacute": 0x00C9, - "Ecirc": 0x00CA, - "Euml": 0x00CB, - "Igrave": 0x00CC, - "Iacute": 0x00CD, - "Icirc": 0x00CE, - "Iuml": 0x00CF, - "ETH": 0x00D0, - "Ntilde": 0x00D1, - "Ograve": 0x00D2, - "Oacute": 0x00D3, - "Ocirc": 0x00D4, - "Otilde": 0x00D5, - "Ouml": 0x00D6, - "times": 0x00D7, - "Oslash": 0x00D8, - "Ugrave": 0x00D9, - "Uacute": 0x00DA, - "Ucirc": 0x00DB, - "Uuml": 0x00DC, - "Yacute": 0x00DD, - "THORN": 0x00DE, - "szlig": 0x00DF, - "agrave": 0x00E0, - "aacute": 0x00E1, - "acirc": 0x00E2, - "atilde": 0x00E3, - "auml": 0x00E4, - "aring": 0x00E5, - "aelig": 0x00E6, - "ccedil": 0x00E7, - "egrave": 0x00E8, - "eacute": 0x00E9, - "ecirc": 0x00EA, - "euml": 0x00EB, - "igrave": 0x00EC, - "iacute": 0x00ED, - "icirc": 0x00EE, - "iuml": 0x00EF, - "eth": 0x00F0, - "ntilde": 0x00F1, - "ograve": 0x00F2, - "oacute": 0x00F3, - "ocirc": 0x00F4, - "otilde": 0x00F5, - "ouml": 0x00F6, - "divide": 0x00F7, - "oslash": 0x00F8, - "ugrave": 0x00F9, - "uacute": 0x00FA, - "ucirc": 0x00FB, - "uuml": 0x00FC, - "yacute": 0x00FD, - "thorn": 0x00FE, - "yuml": 0x00FF, - "OElig": 0x0152, - "oelig": 0x0153, - "Scaron": 0x0160, - "scaron": 0x0161, - "Yuml": 0x0178, - "fnof": 0x0192, - "circ": 0x02C6, - "tilde": 0x02DC, - "Alpha": 0x0391, - "Beta": 0x0392, - "Gamma": 0x0393, - "Delta": 0x0394, - "Epsilon": 0x0395, - "Zeta": 0x0396, - "Eta": 0x0397, - "Theta": 0x0398, - "Iota": 0x0399, - "Kappa": 0x039A, - "Lambda": 0x039B, - "Mu": 0x039C, - "Nu": 0x039D, - "Xi": 0x039E, - "Omicron": 0x039F, - "Pi": 0x03A0, - "Rho": 0x03A1, - "Sigma": 0x03A3, - "Tau": 0x03A4, - "Upsilon": 0x03A5, - "Phi": 0x03A6, - "Chi": 0x03A7, - "Psi": 0x03A8, - "Omega": 0x03A9, - "alpha": 0x03B1, - "beta": 0x03B2, - "gamma": 0x03B3, - "delta": 0x03B4, - "epsilon": 0x03B5, - "zeta": 0x03B6, - "eta": 0x03B7, - "theta": 0x03B8, - "iota": 0x03B9, - "kappa": 0x03BA, - "lambda": 0x03BB, - "mu": 0x03BC, - "nu": 0x03BD, - "xi": 0x03BE, - "omicron": 0x03BF, - "pi": 0x03C0, - "rho": 0x03C1, - "sigmaf": 0x03C2, - "sigma": 0x03C3, - "tau": 0x03C4, - "upsilon": 0x03C5, - "phi": 0x03C6, - "chi": 0x03C7, - "psi": 0x03C8, - "omega": 0x03C9, - "thetasym": 0x03D1, - "upsih": 0x03D2, - "piv": 0x03D6, - "ensp": 0x2002, - "emsp": 0x2003, - "thinsp": 0x2009, - "zwnj": 0x200C, - "zwj": 0x200D, - "lrm": 0x200E, - "rlm": 0x200F, - "ndash": 0x2013, - "mdash": 0x2014, - "lsquo": 0x2018, - "rsquo": 0x2019, - "sbquo": 0x201A, - "ldquo": 0x201C, - "rdquo": 0x201D, - "bdquo": 0x201E, - "dagger": 0x2020, - "Dagger": 0x2021, - "bull": 0x2022, - "hellip": 0x2026, - "permil": 0x2030, - "prime": 0x2032, - "Prime": 0x2033, - "lsaquo": 0x2039, - "rsaquo": 0x203A, - "oline": 0x203E, - "frasl": 0x2044, - "euro": 0x20AC, - "image": 0x2111, - "weierp": 0x2118, - "real": 0x211C, - "trade": 0x2122, - "alefsym": 0x2135, - "larr": 0x2190, - "uarr": 0x2191, - "rarr": 0x2192, - "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }); - } -})(ts || (ts = {})); -var ts; -(function (ts) { - function transformESNext(context) { - var hoistVariableDeclaration = context.hoistVariableDeclaration; - var currentSourceFile; - return transformSourceFile; - function transformSourceFile(node) { - currentSourceFile = node; - return ts.visitEachChild(node, visitor, context); - } - function visitor(node) { - if (node.transformFlags & 16) { - return visitorWorker(node); - } - else if (node.transformFlags & 32) { - return ts.visitEachChild(node, visitor, context); - } - else { - return node; - } - } - function visitorWorker(node) { - switch (node.kind) { - case 176: - return visitObjectLiteralExpression(node); - case 192: - return visitBinaryExpression(node); - case 223: - return visitVariableDeclaration(node); - case 213: - return visitForOfStatement(node); - case 172: - case 173: - return node; - case 225: - return visitFunctionDeclaration(node); - case 184: - return visitFunctionExpression(node); - case 185: - return visitArrowFunction(node); - case 144: - return visitParameter(node); - default: - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); - } - } - function chunkObjectLiteralElements(elements) { - var chunkObject; - var objects = []; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var e = elements_3[_i]; - if (e.kind === 259) { - if (chunkObject) { - objects.push(ts.createObjectLiteral(chunkObject)); - chunkObject = undefined; - } - var target = e.expression; - objects.push(ts.visitNode(target, visitor, ts.isExpression)); - } - else { - if (!chunkObject) { - chunkObject = []; - } - if (e.kind === 257) { - var p = e; - chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); - } - else { - chunkObject.push(e); - } - } - } - if (chunkObject) { - objects.push(ts.createObjectLiteral(chunkObject)); - } - return objects; - } - function visitObjectLiteralExpression(node) { - if (ts.forEach(node.properties, function (p) { return p.kind === 259; })) { - var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 176) { - objects.unshift(ts.createObjectLiteral()); - } - return ts.aggregateTransformFlags(ts.createCall(ts.createIdentifier("__assign"), undefined, objects)); - } - return ts.visitEachChild(node, visitor, context); - } - function visitBinaryExpression(node) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 48) { - return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, visitor, true); - } - return ts.visitEachChild(node, visitor, context); - } - function visitVariableDeclaration(node) { - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 48) { - var result = ts.flattenVariableDestructuring(node, undefined, visitor, undefined, true); - return result; - } - return ts.visitEachChild(node, visitor, context); - } - function visitForOfStatement(node) { - var initializer = node.initializer; - if (!isRestBindingPattern(initializer) && !isRestAssignment(initializer)) { - return ts.visitEachChild(node, visitor, context); - } - return ts.convertForOf(node, undefined, visitor, ts.noop, context, true); - } - function isRestBindingPattern(initializer) { - if (ts.isVariableDeclarationList(initializer)) { - var declaration = ts.firstOrUndefined(initializer.declarations); - return declaration && declaration.name && - declaration.name.kind === 172 && - !!(declaration.name.transformFlags & 8388608); - } - return false; - } - function isRestAssignment(initializer) { - return initializer.kind === 176 && - initializer.transformFlags & 8388608; - } - function visitParameter(node) { - if (isObjectRestParameter(node)) { - return ts.setOriginalNode(ts.createParameter(undefined, undefined, undefined, ts.getGeneratedNameForNode(node), undefined, undefined, node.initializer, node), node); - } - else { - return node; - } - } - function isObjectRestParameter(node) { - return node.name && - node.name.kind === 172 && - !!(node.name.transformFlags & 8388608); - } - function visitFunctionDeclaration(node) { - var hasRest = ts.forEach(node.parameters, isObjectRestParameter); - var body = hasRest ? - ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : - ts.visitEachChild(node.body, visitor, context); - return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); - } - function visitArrowFunction(node) { - var hasRest = ts.forEach(node.parameters, isObjectRestParameter); - var body = hasRest ? - ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : - ts.visitEachChild(node.body, visitor, context); - var func = ts.setOriginalNode(ts.createArrowFunction(node.modifiers, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, body, node), node); - ts.setEmitFlags(func, 256); - return func; - } - function visitFunctionExpression(node) { - var hasRest = ts.forEach(node.parameters, isObjectRestParameter); - var body = hasRest ? - ts.transformFunctionBody(node, visitor, currentSourceFile, context, ts.noop, true) : - ts.visitEachChild(node.body, visitor, context); - return ts.setOriginalNode(ts.createFunctionExpression(node.modifiers, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, body, node), node); - } - } - ts.transformESNext = transformESNext; + var entities = ts.createMap({ + "quot": 0x0022, + "amp": 0x0026, + "apos": 0x0027, + "lt": 0x003C, + "gt": 0x003E, + "nbsp": 0x00A0, + "iexcl": 0x00A1, + "cent": 0x00A2, + "pound": 0x00A3, + "curren": 0x00A4, + "yen": 0x00A5, + "brvbar": 0x00A6, + "sect": 0x00A7, + "uml": 0x00A8, + "copy": 0x00A9, + "ordf": 0x00AA, + "laquo": 0x00AB, + "not": 0x00AC, + "shy": 0x00AD, + "reg": 0x00AE, + "macr": 0x00AF, + "deg": 0x00B0, + "plusmn": 0x00B1, + "sup2": 0x00B2, + "sup3": 0x00B3, + "acute": 0x00B4, + "micro": 0x00B5, + "para": 0x00B6, + "middot": 0x00B7, + "cedil": 0x00B8, + "sup1": 0x00B9, + "ordm": 0x00BA, + "raquo": 0x00BB, + "frac14": 0x00BC, + "frac12": 0x00BD, + "frac34": 0x00BE, + "iquest": 0x00BF, + "Agrave": 0x00C0, + "Aacute": 0x00C1, + "Acirc": 0x00C2, + "Atilde": 0x00C3, + "Auml": 0x00C4, + "Aring": 0x00C5, + "AElig": 0x00C6, + "Ccedil": 0x00C7, + "Egrave": 0x00C8, + "Eacute": 0x00C9, + "Ecirc": 0x00CA, + "Euml": 0x00CB, + "Igrave": 0x00CC, + "Iacute": 0x00CD, + "Icirc": 0x00CE, + "Iuml": 0x00CF, + "ETH": 0x00D0, + "Ntilde": 0x00D1, + "Ograve": 0x00D2, + "Oacute": 0x00D3, + "Ocirc": 0x00D4, + "Otilde": 0x00D5, + "Ouml": 0x00D6, + "times": 0x00D7, + "Oslash": 0x00D8, + "Ugrave": 0x00D9, + "Uacute": 0x00DA, + "Ucirc": 0x00DB, + "Uuml": 0x00DC, + "Yacute": 0x00DD, + "THORN": 0x00DE, + "szlig": 0x00DF, + "agrave": 0x00E0, + "aacute": 0x00E1, + "acirc": 0x00E2, + "atilde": 0x00E3, + "auml": 0x00E4, + "aring": 0x00E5, + "aelig": 0x00E6, + "ccedil": 0x00E7, + "egrave": 0x00E8, + "eacute": 0x00E9, + "ecirc": 0x00EA, + "euml": 0x00EB, + "igrave": 0x00EC, + "iacute": 0x00ED, + "icirc": 0x00EE, + "iuml": 0x00EF, + "eth": 0x00F0, + "ntilde": 0x00F1, + "ograve": 0x00F2, + "oacute": 0x00F3, + "ocirc": 0x00F4, + "otilde": 0x00F5, + "ouml": 0x00F6, + "divide": 0x00F7, + "oslash": 0x00F8, + "ugrave": 0x00F9, + "uacute": 0x00FA, + "ucirc": 0x00FB, + "uuml": 0x00FC, + "yacute": 0x00FD, + "thorn": 0x00FE, + "yuml": 0x00FF, + "OElig": 0x0152, + "oelig": 0x0153, + "Scaron": 0x0160, + "scaron": 0x0161, + "Yuml": 0x0178, + "fnof": 0x0192, + "circ": 0x02C6, + "tilde": 0x02DC, + "Alpha": 0x0391, + "Beta": 0x0392, + "Gamma": 0x0393, + "Delta": 0x0394, + "Epsilon": 0x0395, + "Zeta": 0x0396, + "Eta": 0x0397, + "Theta": 0x0398, + "Iota": 0x0399, + "Kappa": 0x039A, + "Lambda": 0x039B, + "Mu": 0x039C, + "Nu": 0x039D, + "Xi": 0x039E, + "Omicron": 0x039F, + "Pi": 0x03A0, + "Rho": 0x03A1, + "Sigma": 0x03A3, + "Tau": 0x03A4, + "Upsilon": 0x03A5, + "Phi": 0x03A6, + "Chi": 0x03A7, + "Psi": 0x03A8, + "Omega": 0x03A9, + "alpha": 0x03B1, + "beta": 0x03B2, + "gamma": 0x03B3, + "delta": 0x03B4, + "epsilon": 0x03B5, + "zeta": 0x03B6, + "eta": 0x03B7, + "theta": 0x03B8, + "iota": 0x03B9, + "kappa": 0x03BA, + "lambda": 0x03BB, + "mu": 0x03BC, + "nu": 0x03BD, + "xi": 0x03BE, + "omicron": 0x03BF, + "pi": 0x03C0, + "rho": 0x03C1, + "sigmaf": 0x03C2, + "sigma": 0x03C3, + "tau": 0x03C4, + "upsilon": 0x03C5, + "phi": 0x03C6, + "chi": 0x03C7, + "psi": 0x03C8, + "omega": 0x03C9, + "thetasym": 0x03D1, + "upsih": 0x03D2, + "piv": 0x03D6, + "ensp": 0x2002, + "emsp": 0x2003, + "thinsp": 0x2009, + "zwnj": 0x200C, + "zwj": 0x200D, + "lrm": 0x200E, + "rlm": 0x200F, + "ndash": 0x2013, + "mdash": 0x2014, + "lsquo": 0x2018, + "rsquo": 0x2019, + "sbquo": 0x201A, + "ldquo": 0x201C, + "rdquo": 0x201D, + "bdquo": 0x201E, + "dagger": 0x2020, + "Dagger": 0x2021, + "bull": 0x2022, + "hellip": 0x2026, + "permil": 0x2030, + "prime": 0x2032, + "Prime": 0x2033, + "lsaquo": 0x2039, + "rsaquo": 0x203A, + "oline": 0x203E, + "frasl": 0x2044, + "euro": 0x20AC, + "image": 0x2111, + "weierp": 0x2118, + "real": 0x211C, + "trade": 0x2122, + "alefsym": 0x2135, + "larr": 0x2190, + "uarr": 0x2191, + "rarr": 0x2192, + "darr": 0x2193, + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }); })(ts || (ts = {})); var ts; (function (ts) { function transformES2017(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var currentSourceFileExternalHelpersModuleName; + var currentSourceFile; var enabledSubstitutions; - var applicableSubstitutions; var currentSuperContainer; var previousOnEmitNode = context.onEmitNode; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - var currentScope; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - currentSourceFileExternalHelpersModuleName = node.externalHelpersModuleName; - return ts.visitEachChild(node, visitor, context); + currentSourceFile = node; + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; } function visitor(node) { - if (node.transformFlags & 64) { - return visitorWorker(node); - } - else if (node.transformFlags & 128) { - return ts.visitEachChild(node, visitor, context); + if ((node.transformFlags & 16) === 0) { + return node; } - return node; - } - function visitorWorker(node) { switch (node.kind) { case 119: return undefined; @@ -40849,68 +41131,37 @@ var ts; case 185: return visitArrowFunction(node); default: - ts.Debug.failBadSyntaxKind(node); - return node; + return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { return ts.setOriginalNode(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression), node), node); } function visitMethodDeclaration(node) { - if (!ts.isAsyncFunctionLike(node)) { - return node; - } - var method = ts.createMethod(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - ts.setCommentRange(method, node); - ts.setSourceMapRange(method, ts.moveRangePastDecorators(node)); - ts.setOriginalNode(method, node); - return method; + return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); } function visitFunctionDeclaration(node) { - if (!ts.isAsyncFunctionLike(node)) { - return node; - } - var func = ts.createFunctionDeclaration(undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - ts.setOriginalNode(func, node); - return func; + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); } function visitFunctionExpression(node) { - if (!ts.isAsyncFunctionLike(node)) { - return node; - } if (ts.nodeIsMissing(node.body)) { return ts.createOmittedExpression(); } - var func = ts.createFunctionExpression(undefined, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, transformFunctionBody(node), node); - ts.setOriginalNode(func, node); - return func; + return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); } function visitArrowFunction(node) { - if (!ts.isAsyncFunctionLike(node)) { - return node; - } - var func = ts.createArrowFunction(ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, node.equalsGreaterThanToken, transformConciseBody(node), node); - ts.setOriginalNode(func, node); - return func; - } - function transformFunctionBody(node) { - return transformAsyncFunctionBody(node); - } - function transformConciseBody(node) { - return transformAsyncFunctionBody(node); - } - function transformFunctionBodyWorker(body, start) { - if (start === void 0) { start = 0; } - var savedCurrentScope = currentScope; - currentScope = body; - startLexicalEnvironment(); - var statements = ts.visitNodes(body.statements, visitor, ts.isStatement, start); - var visited = ts.updateBlock(body, statements); - var declarations = endLexicalEnvironment(); - currentScope = savedCurrentScope; - return ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); } function transformAsyncFunctionBody(node) { + resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; @@ -40919,52 +41170,49 @@ var ts; if (!isArrowFunction) { var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(statements, node.body, true); if (languageVersion >= 2) { if (resolver.getNodeCheckFlags(node) & 4096) { enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 8); + ts.addEmitHelper(block, advancedAsyncSuperHelper); } else if (resolver.getNodeCheckFlags(node) & 2048) { enableSubstitutionForAsyncMethodsWithSuper(); - ts.setEmitFlags(block, 4); + ts.addEmitHelper(block, asyncSuperHelper); } } return block; } else { - return ts.createAwaiterHelper(currentSourceFileExternalHelpersModuleName, hasLexicalArguments, promiseConstructor, transformConciseBodyWorker(node.body, true)); + var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); + var declarations = endLexicalEnvironment(); + if (ts.some(declarations)) { + var block = ts.convertToFunctionBody(expression); + return ts.updateBlock(block, ts.createNodeArray(ts.concatenate(block.statements, declarations), block.statements)); + } + return expression; } } - function transformConciseBodyWorker(body, forceBlockFunctionBody) { + function transformFunctionBodyWorker(body, start) { if (ts.isBlock(body)) { - return transformFunctionBodyWorker(body); + return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); } else { startLexicalEnvironment(); - var visited = ts.visitNode(body, visitor, ts.isConciseBody); + var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); var declarations = endLexicalEnvironment(); - var merged = ts.mergeFunctionBodyLexicalEnvironment(visited, declarations); - if (forceBlockFunctionBody && !ts.isBlock(merged)) { - return ts.createBlock([ - ts.createReturn(merged) - ]); - } - else { - return merged; - } + return ts.updateBlock(visited, ts.createNodeArray(ts.concatenate(visited.statements, declarations), visited.statements)); } } function getPromiseConstructor(type) { - if (type) { - var typeName = ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } + var typeName = type && ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; } } return undefined; @@ -41038,14 +41286,15 @@ var ts; || kind === 152; } function onEmitNode(emitContext, node, emitCallback) { - var savedApplicableSubstitutions = applicableSubstitutions; - var savedCurrentSuperContainer = currentSuperContainer; if (enabledSubstitutions & 1 && isSuperContainer(node)) { + var savedCurrentSuperContainer = currentSuperContainer; currentSuperContainer = node; + previousOnEmitNode(emitContext, node, emitCallback); + currentSuperContainer = savedCurrentSuperContainer; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); } - previousOnEmitNode(emitContext, node, emitCallback); - applicableSubstitutions = savedApplicableSubstitutions; - currentSuperContainer = savedCurrentSuperContainer; } function onSubstituteNode(emitContext, node) { node = previousOnSubstituteNode(emitContext, node); @@ -41068,6 +41317,33 @@ var ts; } } ts.transformES2017 = transformES2017; + function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + context.requestEmitHelper(awaiterHelper); + var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(38), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 131072; + return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ + ts.createThis(), + hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), + promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), + generatorFunc + ]); + } + var awaiterHelper = { + name: "typescript:awaiter", + scoped: false, + priority: 5, + text: "\n var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n };" + }; + var asyncSuperHelper = { + name: "typescript:async-super", + scoped: true, + text: "\n const _super = name => super[name];" + }; + var advancedAsyncSuperHelper = { + name: "typescript:advanced-async-super", + scoped: true, + text: "\n const _super = (function (geti, seti) {\n const cache = Object.create(null);\n return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n })(name => super[name], (name, value) => super[name] = value);" + }; })(ts || (ts = {})); var ts; (function (ts) { @@ -41081,55 +41357,52 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if (node.transformFlags & 256) { - return visitorWorker(node); - } - else if (node.transformFlags & 512) { - return ts.visitEachChild(node, visitor, context); - } - else { + if ((node.transformFlags & 32) === 0) { return node; } - } - function visitorWorker(node) { switch (node.kind) { case 192: return visitBinaryExpression(node); default: - ts.Debug.failBadSyntaxKind(node); return ts.visitEachChild(node, visitor, context); } } function visitBinaryExpression(node) { + switch (node.operatorToken.kind) { + case 61: + return visitExponentiationAssignmentExpression(node); + case 39: + return visitExponentiationExpression(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitExponentiationAssignmentExpression(node) { + var target; + var value; var left = ts.visitNode(node.left, visitor, ts.isExpression); var right = ts.visitNode(node.right, visitor, ts.isExpression); - if (node.operatorToken.kind === 61) { - var target = void 0; - var value = void 0; - if (ts.isElementAccessExpression(left)) { - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); - value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); - } - else if (ts.isPropertyAccessExpression(left)) { - var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); - target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); - value = ts.createPropertyAccess(expressionTemp, left.name, left); - } - else { - target = left; - value = left; - } - return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + if (ts.isElementAccessExpression(left)) { + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + var argumentExpressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createElementAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), ts.createAssignment(argumentExpressionTemp, left.argumentExpression, left.argumentExpression), left); + value = ts.createElementAccess(expressionTemp, argumentExpressionTemp, left); } - else if (node.operatorToken.kind === 39) { - return ts.createMathPow(left, right, node); + else if (ts.isPropertyAccessExpression(left)) { + var expressionTemp = ts.createTempVariable(hoistVariableDeclaration); + target = ts.createPropertyAccess(ts.createAssignment(expressionTemp, left.expression, left.expression), left.name, left); + value = ts.createPropertyAccess(expressionTemp, left.name, left); } else { - ts.Debug.failBadSyntaxKind(node); - return ts.visitEachChild(node, visitor, context); + target = left; + value = left; } + return ts.createAssignment(target, ts.createMathPow(value, right, node), node); + } + function visitExponentiationExpression(node) { + var left = ts.visitNode(node.left, visitor, ts.isExpression); + var right = ts.visitNode(node.right, visitor, ts.isExpression); + return ts.createMathPow(left, right, node); } } ts.transformES2016 = transformES2016; @@ -41137,7 +41410,7 @@ var ts; var ts; (function (ts) { function transformES2015(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -41163,7 +41436,11 @@ var ts; } currentSourceFile = node; currentText = node.text; - return ts.visitNode(node, visitor, ts.isSourceFile); + var visited = saveStateAndInvoke(node, visitSourceFile); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + currentText = undefined; + return visited; } function visitor(node) { return saveStateAndInvoke(node, dispatcher); @@ -41202,6 +41479,38 @@ var ts; currentNode = savedCurrentNode; return visited; } + function onBeforeVisitNode(node) { + if (currentNode) { + if (ts.isBlockScope(currentNode, currentParent)) { + enclosingBlockScopeContainer = currentNode; + enclosingBlockScopeContainerParent = currentParent; + } + if (ts.isFunctionLike(currentNode)) { + enclosingFunction = currentNode; + if (currentNode.kind !== 185) { + enclosingNonArrowFunction = currentNode; + if (!(ts.getEmitFlags(currentNode) & 131072)) { + enclosingNonAsyncFunctionBody = currentNode; + } + } + } + switch (currentNode.kind) { + case 205: + enclosingVariableStatement = currentNode; + break; + case 224: + case 223: + case 174: + case 172: + case 173: + break; + default: + enclosingVariableStatement = undefined; + } + } + currentParent = currentNode; + currentNode = node; + } function returnCapturedThis(node) { return ts.setOriginalNode(ts.createReturn(ts.createIdentifier("_this")), node); } @@ -41209,7 +41518,7 @@ var ts; return isInConstructorWithCapturedSuper && node.kind === 216 && !node.expression; } function shouldCheckNode(node) { - return (node.transformFlags & 1024) !== 0 || + return (node.transformFlags & 64) !== 0 || node.kind === 219 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)); } @@ -41220,7 +41529,7 @@ var ts; else if (shouldCheckNode(node)) { return visitJavaScript(node); } - else if (node.transformFlags & 2048 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { + else if (node.transformFlags & 128 || (isInConstructorWithCapturedSuper && !ts.isExpression(node))) { return ts.visitEachChild(node, visitor, context); } else { @@ -41320,14 +41629,14 @@ var ts; return visitTemplateExpression(node); case 195: return visitYieldExpression(node); + case 196: + return visitSpreadElement(node); case 96: return visitSuperKeyword(); case 195: return ts.visitEachChild(node, visitor, context); case 149: return visitMethodDeclaration(node); - case 261: - return visitSourceFileNode(node); case 205: return visitVariableStatement(node); default: @@ -41335,37 +41644,14 @@ var ts; return ts.visitEachChild(node, visitor, context); } } - function onBeforeVisitNode(node) { - if (currentNode) { - if (ts.isBlockScope(currentNode, currentParent)) { - enclosingBlockScopeContainer = currentNode; - enclosingBlockScopeContainerParent = currentParent; - } - if (ts.isFunctionLike(currentNode)) { - enclosingFunction = currentNode; - if (currentNode.kind !== 185) { - enclosingNonArrowFunction = currentNode; - if (!(ts.getEmitFlags(currentNode) & 2097152)) { - enclosingNonAsyncFunctionBody = currentNode; - } - } - } - switch (currentNode.kind) { - case 205: - enclosingVariableStatement = currentNode; - break; - case 224: - case 223: - case 174: - case 172: - case 173: - break; - default: - enclosingVariableStatement = undefined; - } - } - currentParent = currentNode; - currentNode = node; + function visitSourceFile(node) { + var statements = []; + startLexicalEnvironment(); + var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); + addCaptureThisForNodeIfNeeded(statements, node); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + ts.addRange(statements, endLexicalEnvironment()); + return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); } function visitSwitchStatement(node) { ts.Debug.assert(convertedLoopState !== undefined); @@ -41467,9 +41753,9 @@ var ts; statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 33554432) === 0) { + if ((emitFlags & 2097152) === 0) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 33554432); + ts.setEmitFlags(statement, emitFlags | 2097152); } return ts.singleOrMany(statements); } @@ -41482,15 +41768,15 @@ var ts; } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, "_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (ts.getEmitFlags(node) & 524288) { - ts.setEmitFlags(classFunction, 524288); + if (ts.getEmitFlags(node) & 32768) { + ts.setEmitFlags(classFunction, 32768); } var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; - ts.setEmitFlags(inner, 49152); + ts.setEmitFlags(inner, 1536); var outer = ts.createPartiallyEmittedExpression(inner); outer.end = ts.skipTrivia(currentText, node.pos); - ts.setEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 1536); return ts.createParen(ts.createCall(outer, undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); @@ -41505,19 +41791,19 @@ var ts; var localName = ts.getLocalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; - ts.setEmitFlags(outer, 49152); + ts.setEmitFlags(outer, 1536); var statement = ts.createReturn(outer); statement.pos = closingBraceLocation.pos; - ts.setEmitFlags(statement, 49152 | 12288); + ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, node.members), undefined, true); - ts.setEmitFlags(block, 49152); + ts.setEmitFlags(block, 1536); return block; } function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) { if (extendsClauseElement) { - statements.push(ts.createStatement(ts.createExtendsHelper(currentSourceFile.externalHelpersModuleName, ts.getLocalName(node)), extendsClauseElement)); + statements.push(ts.createStatement(createExtendsHelper(context, ts.getLocalName(node)), extendsClauseElement)); } } function addConstructor(statements, node, extendsClauseElement) { @@ -41525,29 +41811,27 @@ var ts; var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 256); + ts.setEmitFlags(constructorFunction, 8); } statements.push(constructorFunction); } function transformConstructorParameters(constructor, hasSynthesizedSuper) { - if (constructor && !hasSynthesizedSuper) { - return ts.visitNodes(constructor.parameters, visitor, ts.isParameter); - } - return []; + return ts.visitParameterList(constructor && !hasSynthesizedSuper && constructor.parameters, visitor, context) + || []; } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { var statements = []; - startLexicalEnvironment(); + resumeLexicalEnvironment(); var statementOffset = -1; if (hasSynthesizedSuper) { - statementOffset = 1; + statementOffset = 0; } else if (constructor) { statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); } if (constructor) { - ts.addDefaultValueAssignmentsIfNeeded(statements, constructor, visitor, false); - ts.addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + addDefaultValueAssignmentsIfNeeded(statements, constructor); + addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, !!extendsClauseElement, hasSynthesizedSuper, statementOffset); @@ -41569,7 +41853,7 @@ var ts; ts.addRange(statements, endLexicalEnvironment()); var block = ts.createBlock(ts.createNodeArray(statements, constructor ? constructor.body.statements : node.members), constructor ? constructor.body : node, true); if (!constructor) { - ts.setEmitFlags(block, 49152); + ts.setEmitFlags(block, 1536); } return block; } @@ -41595,7 +41879,7 @@ var ts; function declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, ctor, hasExtendsClause, hasSynthesizedSuper, statementOffset) { if (!hasExtendsClause) { if (ctor) { - ts.addCaptureThisForNodeIfNeeded(statements, ctor, enableSubstitutionsForCapturedThis); + addCaptureThisForNodeIfNeeded(statements, ctor); } return 0; } @@ -41604,7 +41888,7 @@ var ts; return 2; } if (hasSynthesizedSuper) { - ts.captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); + captureThisForNode(statements, ctor, createDefaultSuperCallOrThis()); enableSubstitutionsForCapturedThis(); return 1; } @@ -41624,11 +41908,11 @@ var ts; || superCallExpression.left.kind !== 179) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } - ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 49152))); + ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); statements.push(returnStatement); return 2; } - ts.captureThisForNode(statements, ctor, superCallExpression, enableSubstitutionsForCapturedThis, firstStatement); + captureThisForNode(statements, ctor, superCallExpression, firstStatement); if (superCallExpression) { return 1; } @@ -41636,7 +41920,7 @@ var ts; } function createDefaultSuperCallOrThis() { var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128); + ts.setEmitFlags(actualThis, 4); var superCall = ts.createFunctionApply(ts.createIdentifier("_super"), actualThis, ts.createIdentifier("arguments")); return ts.createLogicalOr(superCall, actualThis); } @@ -41654,6 +41938,86 @@ var ts; return node; } } + function shouldAddDefaultValueAssignments(node) { + return (node.transformFlags & 131072) !== 0; + } + function addDefaultValueAssignmentsIfNeeded(statements, node) { + if (!shouldAddDefaultValueAssignments(node)) { + return; + } + 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; + if (dotDotDotToken) { + continue; + } + if (ts.isBindingPattern(name_37)) { + addDefaultValueAssignmentForBindingPattern(statements, parameter, name_37, initializer); + } + else if (initializer) { + addDefaultValueAssignmentForInitializer(statements, parameter, name_37, initializer); + } + } + } + function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { + var temp = ts.getGeneratedNameForNode(parameter); + if (name.elements.length > 0) { + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 524288)); + } + else if (initializer) { + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 524288)); + } + } + function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { + initializer = ts.visitNode(initializer, visitor, ts.isExpression); + var statement = ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer)), parameter)) + ], parameter), 1 | 32 | 384), undefined, parameter); + statement.startsOnNewLine = true; + ts.setEmitFlags(statement, 384 | 32 | 524288); + statements.push(statement); + } + function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { + return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + } + function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { + var parameter = ts.lastOrUndefined(node.parameters); + if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { + return; + } + var declarationName = ts.getMutableClone(parameter.name); + ts.setEmitFlags(declarationName, 48); + var expressionName = ts.getSynthesizedClone(parameter.name); + var restIndex = node.parameters.length - 1; + var temp = ts.createLoopVariable(); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) + ]), parameter), 524288)); + var forStatement = ts.createFor(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) + ], parameter), ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length"), parameter), ts.createPostfixIncrement(temp, parameter), ts.createBlock([ + ts.startOnNewLine(ts.createStatement(ts.createAssignment(ts.createElementAccess(expressionName, restIndex === 0 + ? temp + : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp)), parameter)) + ])); + ts.setEmitFlags(forStatement, 524288); + ts.startOnNewLine(forStatement); + statements.push(forStatement); + } + function addCaptureThisForNodeIfNeeded(statements, node) { + if (node.transformFlags & 32768 && node.kind !== 185) { + captureThisForNode(statements, node, ts.createThis()); + } + } + function captureThisForNode(statements, node, initializer, originalStatement) { + enableSubstitutionsForCapturedThis(); + var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration("_this", undefined, initializer) + ]), originalStatement); + ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setSourceMapRange(captureThisStatement, node); + statements.push(captureThisStatement); + } function addClassMembers(statements, node) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -41685,33 +42049,34 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var func = transformFunctionLikeToExpression(member, member, undefined); - ts.setEmitFlags(func, 49152); - ts.setSourceMapRange(func, sourceMapRange); - var statement = ts.createStatement(ts.createAssignment(ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name), func), member); + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); + var memberFunction = transformFunctionLikeToExpression(member, member, undefined); + ts.setEmitFlags(memberFunction, 1536); + ts.setSourceMapRange(memberFunction, sourceMapRange); + var statement = ts.createStatement(ts.createAssignment(memberName, memberFunction), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); - ts.setEmitFlags(statement, 1536); + ts.setEmitFlags(statement, 48); return statement; } function transformAccessorsToStatement(receiver, accessors) { var statement = ts.createStatement(transformAccessorsToExpression(receiver, accessors, false), ts.getSourceMapRange(accessors.firstAccessor)); - ts.setEmitFlags(statement, 49152); + ts.setEmitFlags(statement, 1536); return statement; } function transformAccessorsToExpression(receiver, _a, startsOnNewLine) { var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; var target = ts.getMutableClone(receiver); - ts.setEmitFlags(target, 49152 | 1024); + ts.setEmitFlags(target, 1536 | 32); ts.setSourceMapRange(target, firstAccessor.name); var propertyName = ts.createExpressionForPropertyName(ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName)); - ts.setEmitFlags(propertyName, 49152 | 512); + ts.setEmitFlags(propertyName, 1536 | 16); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 16384); + ts.setEmitFlags(getterFunction, 512); var getter = ts.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -41719,7 +42084,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 16384); + ts.setEmitFlags(setterFunction, 512); var setter = ts.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -41736,28 +42101,91 @@ var ts; return call; } function visitArrowFunction(node) { - if (node.transformFlags & 262144) { + if (node.transformFlags & 16384) { enableSubstitutionsForCapturedThis(); } - var func = transformFunctionLikeToExpression(node, node, undefined); - ts.setEmitFlags(func, 256); + var func = ts.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node), node); + ts.setOriginalNode(func, node); + ts.setEmitFlags(func, 8); return func; } function visitFunctionExpression(node) { - return transformFunctionLikeToExpression(node, node, node.name); + return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + ? transformFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); } function visitFunctionDeclaration(node) { - return ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, node.asteriskToken, node.name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis), node), node); + return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.transformFlags & 64 + ? transformFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); } function transformFunctionLikeToExpression(node, location, name) { var savedContainingNonArrowFunction = enclosingNonArrowFunction; if (node.kind !== 185) { enclosingNonArrowFunction = node; } - var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitNodes(node.parameters, visitor, ts.isParameter), undefined, saveStateAndInvoke(node, function (node) { return ts.transformFunctionBody(node, visitor, currentSourceFile, context, enableSubstitutionsForCapturedThis); }), location), node); + var expression = ts.setOriginalNode(ts.createFunctionExpression(undefined, node.asteriskToken, name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, saveStateAndInvoke(node, transformFunctionBody), location), node); enclosingNonArrowFunction = savedContainingNonArrowFunction; return expression; } + function transformFunctionBody(node) { + var multiLine = false; + var singleLine = false; + var statementsLocation; + var closeBraceLocation; + var statements = []; + var body = node.body; + var statementOffset; + resumeLexicalEnvironment(); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + } + addCaptureThisForNodeIfNeeded(statements, node); + addDefaultValueAssignmentsIfNeeded(statements, node); + addRestParameterIfNeeded(statements, node, false); + if (!multiLine && statements.length > 0) { + multiLine = true; + } + if (ts.isBlock(body)) { + statementsLocation = body.statements; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); + if (!multiLine && body.multiLine) { + multiLine = true; + } + } + else { + ts.Debug.assert(node.kind === 185); + statementsLocation = ts.moveRangeEnd(body, -1); + var equalsGreaterThanToken = node.equalsGreaterThanToken; + if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { + if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) { + singleLine = true; + } + else { + multiLine = true; + } + } + var expression = ts.visitNode(body, visitor, ts.isExpression); + var returnStatement = ts.createReturn(expression, body); + ts.setEmitFlags(returnStatement, 384 | 32 | 1024); + statements.push(returnStatement); + closeBraceLocation = body; + } + var lexicalEnvironment = context.endLexicalEnvironment(); + ts.addRange(statements, lexicalEnvironment); + if (!multiLine && lexicalEnvironment && lexicalEnvironment.length) { + multiLine = true; + } + var block = ts.createBlock(ts.createNodeArray(statements, statementsLocation), node.body, multiLine); + if (!multiLine && singleLine) { + ts.setEmitFlags(block, 1); + } + if (closeBraceLocation) { + ts.setTokenSourceMapRange(block, 17, closeBraceLocation); + } + ts.setOriginalNode(block, node.body); + return block; + } function visitExpressionStatement(node) { switch (node.expression.kind) { case 183: @@ -41768,19 +42196,20 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitParenthesizedExpression(node, needsDestructuringValue) { - if (needsDestructuringValue) { + if (!needsDestructuringValue) { switch (node.expression.kind) { case 183: - return ts.createParen(visitParenthesizedExpression(node.expression, true), node); + return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); case 192: - return ts.createParen(visitBinaryExpression(node.expression, true), node); + return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } return ts.visitEachChild(node, visitor, context); } function visitBinaryExpression(node, needsDestructuringValue) { - ts.Debug.assert(ts.isDestructuringAssignment(node)); - return ts.flattenDestructuringAssignment(context, node, needsDestructuringValue, hoistVariableDeclaration, visitor); + if (ts.isDestructuringAssignment(node)) { + return ts.flattenDestructuringAssignment(node, visitor, context, 0, needsDestructuringValue); + } } function visitVariableStatement(node) { if (convertedLoopState && (ts.getCombinedNodeFlags(node.declarationList) & 3) == 0) { @@ -41791,7 +42220,7 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenVariableDestructuringToExpression(decl, hoistVariableDeclaration, undefined, visitor); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); @@ -41818,7 +42247,7 @@ var ts; var declarationList = ts.createVariableDeclarationList(declarations, node); ts.setOriginalNode(declarationList, node); ts.setCommentRange(declarationList, node); - if (node.transformFlags & 67108864 + if (node.transformFlags & 8388608 && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.lastOrUndefined(node.declarations).name))) { var firstDeclaration = ts.firstOrUndefined(declarations); @@ -41851,17 +42280,17 @@ var ts; return visitVariableDeclaration(node); } if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) { - var clone_5 = ts.getMutableClone(node); - clone_5.initializer = ts.createVoidZero(); - return clone_5; + var clone_3 = ts.getMutableClone(node); + clone_3.initializer = ts.createVoidZero(); + return clone_3; } return ts.visitEachChild(node, visitor, context); } function visitVariableDeclaration(node) { if (ts.isBindingPattern(node.name)) { - var recordTempVariablesInLine = !enclosingVariableStatement - || !ts.hasModifier(enclosingVariableStatement, 1); - return ts.flattenVariableDestructuring(node, undefined, visitor, recordTempVariablesInLine ? undefined : hoistVariableDeclaration); + var hoistTempVariables = enclosingVariableStatement + && ts.hasModifier(enclosingVariableStatement, 1); + return ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, hoistTempVariables); } return ts.visitEachChild(node, visitor, context); } @@ -41900,7 +42329,69 @@ var ts; return convertIterationStatementBodyIfNecessary(node, convertForOfToFor); } function convertForOfToFor(node, convertedLoopBodyStatements) { - return ts.convertForOf(node, convertedLoopBodyStatements, visitor, enableSubstitutionsForBlockScopedBindings, context, false); + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var initializer = node.initializer; + var statements = []; + var counter = ts.createLoopVariable(); + var rhsReference = expression.kind === 70 + ? ts.createUniqueName(expression.text) + : ts.createTempVariable(undefined); + var elementAccess = ts.createElementAccess(rhsReference, counter); + if (ts.isVariableDeclarationList(initializer)) { + if (initializer.flags & 3) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); + var declarationList = ts.createVariableDeclarationList(declarations, initializer); + ts.setOriginalNode(declarationList, initializer); + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(ts.createVariableStatement(undefined, declarationList)); + } + else { + statements.push(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) + ], ts.moveRangePos(initializer, -1)), initializer), ts.moveRangeEnd(initializer, -1))); + } + } + else { + var assignment = ts.createAssignment(initializer, elementAccess); + if (ts.isDestructuringAssignment(assignment)) { + statements.push(ts.createStatement(ts.flattenDestructuringAssignment(assignment, visitor, context, 0))); + } + else { + assignment.end = initializer.end; + statements.push(ts.createStatement(assignment, ts.moveRangeEnd(initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); + var body = ts.createBlock(ts.createNodeArray(statements, statementsLocation), bodyLocation); + ts.setEmitFlags(body, 48 | 384); + var forStatement = ts.createFor(ts.setEmitFlags(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0), ts.moveRangePos(node.expression, -1)), + ts.createVariableDeclaration(rhsReference, undefined, expression, node.expression) + ], node.expression), 1048576), ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length"), node.expression), ts.createPostfixIncrement(counter, node.expression), body, node); + ts.setEmitFlags(forStatement, 256); + return forStatement; } function visitObjectLiteralExpression(node) { var properties = node.properties; @@ -41908,7 +42399,7 @@ var ts; var numInitialProperties = numProperties; for (var i = 0; i < numProperties; i++) { var property = properties[i]; - if (property.transformFlags & 134217728 + if (property.transformFlags & 16777216 || property.name.kind === 142) { numInitialProperties = i; break; @@ -41917,7 +42408,7 @@ var ts; ts.Debug.assert(numInitialProperties !== numProperties); var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 524288)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), undefined, node.multiLine), 32768)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -41998,26 +42489,26 @@ var ts; var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; if (loopOutParameters.length) { - var statements_3 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; - copyOutParameters(loopOutParameters, 1, statements_3); - loopBody = ts.createBlock(statements_3, undefined, true); + var statements_4 = ts.isBlock(loopBody) ? loopBody.statements.slice() : [loopBody]; + copyOutParameters(loopOutParameters, 1, statements_4); + loopBody = ts.createBlock(statements_4, undefined, true); } if (!ts.isBlock(loopBody)) { loopBody = ts.createBlock([loopBody], undefined, true); } var isAsyncBlockContainingAwait = enclosingNonArrowFunction - && (ts.getEmitFlags(enclosingNonArrowFunction) & 2097152) !== 0 - && (node.statement.transformFlags & 134217728) !== 0; + && (ts.getEmitFlags(enclosingNonArrowFunction) & 131072) !== 0 + && (node.statement.transformFlags & 16777216) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { - loopBodyFlags |= 256; + loopBodyFlags |= 8; } if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 2097152; + loopBodyFlags |= 131072; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ]), 16777216)); + ]), 1048576)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; if (currentState.argumentsName) { @@ -42234,7 +42725,7 @@ var ts; ts.Debug.assert(ts.isBindingPattern(node.variableDeclaration.name)); var temp = ts.createTempVariable(undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp, undefined, undefined, node.variableDeclaration); - var vars = ts.flattenVariableDestructuring(node.variableDeclaration, temp, visitor); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp); var list = ts.createVariableDeclarationList(vars, node.variableDeclaration, node.variableDeclaration.flags); var destructure = ts.createVariableStatement(undefined, list); return ts.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure)); @@ -42246,7 +42737,7 @@ var ts; function visitMethodDeclaration(node) { ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined); - ts.setEmitFlags(functionExpression, 16384 | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression)); return ts.createPropertyAssignment(node.name, functionExpression, node); } function visitShorthandPropertyAssignment(node) { @@ -42267,10 +42758,10 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; if (node.expression.kind === 96) { - ts.setEmitFlags(thisArg, 128); + ts.setEmitFlags(thisArg, 4); } var resultingCall; - if (node.transformFlags & 8388608) { + if (node.transformFlags & 524288) { resultingCall = ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { @@ -42278,7 +42769,7 @@ var ts; } if (node.expression.kind === 96) { var actualThis = ts.createThis(); - ts.setEmitFlags(actualThis, 128); + ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); return assignToCapturedThis ? ts.createAssignment(ts.createIdentifier("_this"), initializer) @@ -42287,7 +42778,7 @@ var ts; return resultingCall; } function visitNewExpression(node) { - ts.Debug.assert((node.transformFlags & 8388608) !== 0); + ts.Debug.assert((node.transformFlags & 524288) !== 0); var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; return ts.createNew(ts.createFunctionApply(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(ts.createNodeArray([ts.createVoidZero()].concat(node.arguments)), false, false, false)), undefined, []); } @@ -42315,6 +42806,9 @@ var ts; function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) { return ts.createArrayLiteral(ts.visitNodes(ts.createNodeArray(chunk, undefined, hasTrailingComma), visitor, ts.isExpression), undefined, multiLine); } + function visitSpreadElement(node) { + return ts.visitNode(node.expression, visitor, ts.isExpression); + } function visitExpressionOfSpread(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); } @@ -42392,18 +42886,6 @@ var ts; ? ts.createPropertyAccess(ts.createIdentifier("_super"), "prototype") : ts.createIdentifier("_super"); } - function visitSourceFileNode(node) { - var _a = ts.span(node.statements, ts.isPrologueDirective), prologue = _a[0], remaining = _a[1]; - var statements = []; - startLexicalEnvironment(); - ts.addRange(statements, prologue); - ts.addCaptureThisForNodeIfNeeded(statements, node, enableSubstitutionsForCapturedThis); - ts.addRange(statements, ts.visitNodes(ts.createNodeArray(remaining), visitor, ts.isStatement)); - ts.addRange(statements, endLexicalEnvironment()); - var clone = ts.getMutableClone(node); - clone.statements = ts.createNodeArray(statements, node.statements); - return clone; - } function onEmitNode(emitContext, node, emitCallback) { var savedEnclosingFunction = enclosingFunction; if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) { @@ -42483,7 +42965,7 @@ var ts; function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && enclosingFunction - && ts.getEmitFlags(enclosingFunction) & 256) { + && ts.getEmitFlags(enclosingFunction) & 8) { return ts.createIdentifier("_this", node); } return node; @@ -42496,8 +42978,7 @@ var ts; if (!constructor || !hasExtendsClause) { return false; } - var parameter = ts.singleOrUndefined(constructor.parameters); - if (!parameter || !ts.nodeIsSynthesized(parameter) || !parameter.dotDotDotToken) { + if (ts.some(constructor.parameters)) { return false; } var statement = ts.firstOrUndefined(constructor.body.statements); @@ -42517,10 +42998,23 @@ var ts; return false; } var expression = callArgument.expression; - return ts.isIdentifier(expression) && expression === parameter.name; + return ts.isIdentifier(expression) && expression.text === "arguments"; } } ts.transformES2015 = transformES2015; + function createExtendsHelper(context, name) { + context.requestEmitHelper(extendsHelper); + return ts.createCall(ts.getHelperName("__extends"), undefined, [ + name, + ts.createIdentifier("_super") + ]); + } + var extendsHelper = { + name: "typescript:extends", + scoped: false, + priority: 0, + text: "\n var __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };" + }; })(ts || (ts = {})); var ts; (function (ts) { @@ -42532,7 +43026,7 @@ var ts; _a[7] = "endfinally", _a)); function transformGenerators(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var resolver = context.getEmitResolver(); @@ -42566,15 +43060,15 @@ var ts; var withBlockStack; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { + if (ts.isDeclarationFile(node) + || (node.transformFlags & 512) === 0) { return node; } - if (node.transformFlags & 8192) { - currentSourceFile = node; - node = ts.visitEachChild(node, visitor, context); - currentSourceFile = undefined; - } - return node; + currentSourceFile = node; + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; } function visitor(node) { var transformFlags = node.transformFlags; @@ -42584,10 +43078,10 @@ var ts; else if (inGeneratorFunctionBody) { return visitJavaScriptInGeneratorFunctionBody(node); } - else if (transformFlags & 4096) { + else if (transformFlags & 256) { return visitGenerator(node); } - else if (transformFlags & 8192) { + else if (transformFlags & 512) { return ts.visitEachChild(node, visitor, context); } else { @@ -42630,10 +43124,10 @@ var ts; case 216: return visitReturnStatement(node); default: - if (node.transformFlags & 134217728) { + if (node.transformFlags & 16777216) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (8192 | 268435456)) { + else if (node.transformFlags & (512 | 33554432)) { return ts.visitEachChild(node, visitor, context); } else { @@ -42675,8 +43169,8 @@ var ts; } } function visitFunctionDeclaration(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + node = ts.setOriginalNode(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -42696,8 +43190,8 @@ var ts; } } function visitFunctionExpression(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 2097152) { - node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, node.parameters, undefined, transformGeneratorFunctionBody(node.body), node), node); + if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + node = ts.setOriginalNode(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body), node), node); } else { var savedInGeneratorFunctionBody = inGeneratorFunctionBody; @@ -42748,7 +43242,7 @@ var ts; operationArguments = undefined; operationLocations = undefined; state = ts.createTempVariable(undefined); - startLexicalEnvironment(); + resumeLexicalEnvironment(); var statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); @@ -42770,12 +43264,12 @@ var ts; return ts.createBlock(statements, body, body.multiLine); } function visitVariableStatement(node) { - if (node.transformFlags & 134217728) { + if (node.transformFlags & 16777216) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { - if (ts.getEmitFlags(node) & 8388608) { + if (ts.getEmitFlags(node) & 524288) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -42852,10 +43346,10 @@ var ts; else if (node.operatorToken.kind === 25) { return visitCommaExpression(node); } - var clone_6 = ts.getMutableClone(node); - clone_6.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); - clone_6.right = ts.visitNode(node.right, visitor, ts.isExpression); - return clone_6; + var clone_4 = ts.getMutableClone(node); + clone_4.left = cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)); + clone_4.right = ts.visitNode(node.right, visitor, ts.isExpression); + return clone_4; } return ts.visitEachChild(node, visitor, context); } @@ -42920,26 +43414,30 @@ var ts; return createGeneratorResume(); } function visitArrayLiteralExpression(node) { - return visitElements(node.elements, node.multiLine); + return visitElements(node.elements, undefined, undefined, node.multiLine); } - function visitElements(elements, _multiLine) { + function visitElements(elements, leadingElement, location, multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); var temp = declareLocal(); var hasAssignedTemp = false; if (numInitialElements > 0) { - emitAssignment(temp, ts.createArrayLiteral(ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements))); + var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); + emitAssignment(temp, ts.createArrayLiteral(leadingElement + ? [leadingElement].concat(initialElements) : initialElements)); + leadingElement = undefined; hasAssignedTemp = true; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); return hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions)]) - : ts.createArrayLiteral(expressions); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, location, multiLine); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { emitAssignment(temp, hasAssignedTemp - ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions)]) - : ts.createArrayLiteral(expressions)); + ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, undefined, multiLine)]) + : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, undefined, multiLine)); hasAssignedTemp = true; + leadingElement = undefined; expressions = []; } expressions.push(ts.visitNode(element, visitor, ts.isExpression)); @@ -42973,10 +43471,10 @@ var ts; } function visitElementAccessExpression(node) { if (containsYield(node.argumentExpression)) { - var clone_7 = ts.getMutableClone(node); - clone_7.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); - clone_7.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); - return clone_7; + var clone_5 = ts.getMutableClone(node); + clone_5.expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)); + clone_5.argumentExpression = ts.visitNode(node.argumentExpression, visitor, ts.isExpression); + return clone_5; } return ts.visitEachChild(node, visitor, context); } @@ -42990,7 +43488,7 @@ var ts; function visitNewExpression(node) { if (ts.forEach(node.arguments, containsYield)) { var _a = ts.createCallBinding(ts.createPropertyAccess(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments)), undefined, [], node), node); + return ts.setOriginalNode(ts.createNew(ts.createFunctionApply(cacheExpression(ts.visitNode(target, visitor, ts.isExpression)), thisArg, visitElements(node.arguments, ts.createVoidZero())), undefined, [], node), node); } return ts.visitEachChild(node, visitor, context); } @@ -43432,7 +43930,7 @@ var ts; } } function containsYield(node) { - return node && (node.transformFlags & 134217728) !== 0; + return node && (node.transformFlags & 16777216) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -43462,12 +43960,12 @@ var ts; if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); if (declaration) { - var name_37 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); - if (name_37) { - var clone_8 = ts.getMutableClone(name_37); - ts.setSourceMapRange(clone_8, node); - ts.setCommentRange(clone_8, node); - return clone_8; + var name_38 = ts.getProperty(renamedCatchVariableDeclarations, String(ts.getOriginalNodeId(declaration))); + if (name_38) { + var clone_6 = ts.getMutableClone(name_38); + ts.setSourceMapRange(clone_6, node); + ts.setCommentRange(clone_6, node); + return clone_6; } } } @@ -43858,10 +44356,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return ts.createCall(ts.createHelperName(currentSourceFile.externalHelpersModuleName, "__generator"), undefined, [ - ts.createThis(), - ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 4194304) - ]); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, undefined, buildResult.length > 0)), 262144)); } function buildStatements() { if (operations) { @@ -44124,6 +44619,16 @@ var ts; } } ts.transformGenerators = transformGenerators; + function createGeneratorHelper(context, body) { + context.requestEmitHelper(generatorHelper); + return ts.createCall(ts.getHelperName("__generator"), undefined, [ts.createThis(), body]); + } + var generatorHelper = { + name: "typescript:generator", + scoped: false, + priority: 6, + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + }; var _a; })(ts || (ts = {})); var ts; @@ -44180,7 +44685,7 @@ var ts; _a[ts.ModuleKind.AMD] = transformAMDModule, _a[ts.ModuleKind.UMD] = transformUMDModule, _a)); - var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var host = context.getEmitHost(); @@ -44209,7 +44714,7 @@ var ts; return node; } currentSourceFile = node; - currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver); + currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(node)] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); var transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ts.ModuleKind.None]; var updated = transformModule(node); currentSourceFile = undefined; @@ -44220,12 +44725,13 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); var updated = ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { - ts.setEmitFlags(updated, 2 | ts.getEmitFlags(node)); + ts.addEmitHelper(updated, exportStarHelper); } return updated; } @@ -44235,8 +44741,7 @@ var ts; return transformAsynchronousModule(node, define, moduleName, true); } function transformUMDModule(node) { - var define = ts.createIdentifier("define"); - ts.setEmitFlags(define, 16); + var define = ts.createRawExpression(umdHelper); return transformAsynchronousModule(node, define, undefined, false); } function transformAsynchronousModule(node, define, moduleName, includeNonAmdDependencies) { @@ -44273,7 +44778,7 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 128); + ts.setEmitFlags(importAliasName, 4); aliasedModuleNames.push(externalModuleName); importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); } @@ -44287,12 +44792,13 @@ var ts; startLexicalEnvironment(); var statements = []; var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); var body = ts.createBlock(statements, undefined, true); if (currentModuleInfo.hasExportStarsToExportValues) { - ts.setEmitFlags(body, 2); + ts.addEmitHelper(body, exportStarHelper); } return body; } @@ -44300,12 +44806,12 @@ var ts; if (currentModuleInfo.exportEquals) { if (emitAsReturn) { var statement = ts.createReturn(currentModuleInfo.exportEquals.expression, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 12288 | 49152); + ts.setEmitFlags(statement, 384 | 1536); statements.push(statement); } else { var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression), currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 49152); + ts.setEmitFlags(statement, 1536); statements.push(statement); } } @@ -44326,9 +44832,9 @@ var ts; return visitFunctionDeclaration(node); case 226: return visitClassDeclaration(node); - case 294: - return visitMergeDeclarationMarker(node); case 295: + return visitMergeDeclarationMarker(node); + case 296: return visitEndOfDeclarationMarker(node); default: return node; @@ -44519,7 +45025,7 @@ var ts; } function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { - return ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createExportExpression); + return ts.flattenDestructuringAssignment(node, undefined, context, 0, false, createExportExpression); } else { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name, node.name), node.initializer); @@ -44533,7 +45039,7 @@ var ts; return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 33554432) !== 0; + return (ts.getEmitFlags(node) & 2097152) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -44653,7 +45159,7 @@ var ts; var statement = ts.createStatement(createExportExpression(name, value), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 49152); + ts.setEmitFlags(statement, 1536); } return statement; } @@ -44720,6 +45226,13 @@ var ts; return node; } function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + return node; + } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); if (exportContainer && exportContainer.kind === 261) { @@ -44731,8 +45244,8 @@ var ts; return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent), ts.createIdentifier("default"), node); } else if (ts.isImportSpecifier(importDeclaration)) { - var name_38 = importDeclaration.propertyName || importDeclaration.name; - return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_38), node); + var name_39 = importDeclaration.propertyName || importDeclaration.name; + return ts.createPropertyAccess(ts.getGeneratedNameForNode(importDeclaration.parent.parent.parent), ts.getSynthesizedClone(name_39), node); } } } @@ -44791,6 +45304,12 @@ var ts; var _a; } ts.transformModule = transformModule; + var exportStarHelper = { + name: "typescript:export-star", + scoped: true, + text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + }; + var umdHelper = "\n (function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n })"; })(ts || (ts = {})); var ts; (function (ts) { @@ -44829,14 +45348,15 @@ var ts; var id = ts.getOriginalNodeId(node); currentSourceFile = node; enclosingBlockScopedContainer = node; - moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver); + moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(node, resolver, compilerOptions); exportFunction = exportFunctionsMap[id] = ts.createUniqueName("exports"); contextObject = ts.createUniqueName("context"); var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports); + var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups); var moduleBodyFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ ts.createParameter(undefined, undefined, undefined, exportFunction), ts.createParameter(undefined, undefined, undefined, contextObject) - ], undefined, createSystemModuleBody(node, dependencyGroups)); + ], undefined, moduleBodyBlock); var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var dependencies = ts.createArrayLiteral(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; })); var updated = ts.updateSourceFileNode(node, ts.createNodeArray([ @@ -44844,7 +45364,9 @@ var ts; ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) ], node.statements)); - ts.setEmitFlags(updated, ts.getEmitFlags(node) & ~1); + if (!(compilerOptions.outFile || compilerOptions.out)) { + ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); + } if (noSubstitution) { noSubstitutionMap[id] = noSubstitution; noSubstitution = undefined; @@ -44885,6 +45407,7 @@ var ts; statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) ]))); + ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true); var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); @@ -44893,9 +45416,7 @@ var ts; ts.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), ts.createPropertyAssignment("execute", ts.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, ts.createBlock(executeStatements, undefined, true))) ]), true))); - var body = ts.createBlock(statements, undefined, true); - ts.setEmitFlags(body, 1); - return body; + return ts.createBlock(statements, undefined, true); } function addExportStarIfNeeded(statements) { if (!moduleInfo.hasExportStarsToExportValues) { @@ -44955,7 +45476,7 @@ var ts; var exports = ts.createIdentifier("exports"); var condition = ts.createStrictInequality(n, ts.createLiteral("default")); if (localNames) { - condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createHasOwnProperty(localNames, n))); + condition = ts.createLogicalAnd(condition, ts.createLogicalNot(ts.createCall(ts.createPropertyAccess(localNames, "hasOwnProperty"), undefined, [n]))); } return ts.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [ts.createParameter(undefined, undefined, undefined, m)], undefined, ts.createBlock([ ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ @@ -44964,7 +45485,7 @@ var ts; ts.createForIn(ts.createVariableDeclarationList([ ts.createVariableDeclaration(n, undefined) ]), m, ts.createBlock([ - ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 32) + ts.setEmitFlags(ts.createIf(condition, ts.createStatement(ts.createAssignment(ts.createElementAccess(exports, n), ts.createElementAccess(m, n)))), 1) ])), ts.createStatement(ts.createCall(exportFunction, undefined, [exports])) ], undefined, true)); @@ -45136,14 +45657,14 @@ var ts; } } function shouldHoistVariableDeclarationList(node) { - return (ts.getEmitFlags(node) & 16777216) === 0 + return (ts.getEmitFlags(node) & 1048576) === 0 && (enclosingBlockScopedContainer.kind === 261 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenVariableDestructuringToExpression(node, hoistVariableDeclaration, createAssignment, destructuringVisitor) + ? ts.flattenDestructuringAssignment(node, destructuringVisitor, context, 0, false, createAssignment) : createAssignment(node.name, ts.visitNode(node.initializer, destructuringVisitor, ts.isExpression)); } function createExportedVariableAssignment(name, value, location) { @@ -45167,7 +45688,7 @@ var ts; return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 33554432) !== 0; + return (ts.getEmitFlags(node) & 2097152) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -45284,7 +45805,7 @@ var ts; var statement = ts.createStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 49152); + ts.setEmitFlags(statement, 1536); } return statement; } @@ -45328,9 +45849,9 @@ var ts; return visitCatchClause(node); case 204: return visitBlock(node); - case 294: - return visitMergeDeclarationMarker(node); case 295: + return visitMergeDeclarationMarker(node); + case 296: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -45420,11 +45941,11 @@ var ts; return node; } function destructuringVisitor(node) { - if (node.transformFlags & 16384 + if (node.transformFlags & 1024 && node.kind === 192) { return visitDestructuringAssignment(node); } - else if (node.transformFlags & 32768) { + else if (node.transformFlags & 2048) { return ts.visitEachChild(node, destructuringVisitor, context); } else { @@ -45433,7 +45954,7 @@ var ts; } function visitDestructuringAssignment(node) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(context, node, true, hoistVariableDeclaration, destructuringVisitor); + return ts.flattenDestructuringAssignment(node, destructuringVisitor, context, 0, true); } return ts.visitEachChild(node, destructuringVisitor, context); } @@ -45515,6 +46036,13 @@ var ts; return node; } function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + return node; + } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var importDeclaration = resolver.getReferencedImportDeclaration(node); if (importDeclaration) { @@ -45602,13 +46130,30 @@ var ts; (function (ts) { function transformES2015Module(context) { var compilerOptions = context.getCompilerOptions(); + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + context.enableEmitNotification(261); + context.enableSubstitution(70); + var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { - return ts.visitEachChild(node, visitor, context); + var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); + if (externalHelpersModuleName) { + var statements = []; + var statementOffset = ts.addPrologueDirectives(statements, node.statements); + ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); + ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); + return ts.updateSourceFileNode(node, ts.createNodeArray(statements, node.statements)); + } + else { + return ts.visitEachChild(node, visitor, context); + } } return node; } @@ -45624,6 +46169,32 @@ var ts; function visitExportAssignment(node) { return node.isExportEquals ? undefined : node; } + function onEmitNode(emitContext, node, emitCallback) { + if (ts.isSourceFile(node)) { + currentSourceFile = node; + previousOnEmitNode(emitContext, node, emitCallback); + currentSourceFile = undefined; + } + else { + previousOnEmitNode(emitContext, node, emitCallback); + } + } + function onSubstituteNode(emitContext, node) { + node = previousOnSubstituteNode(emitContext, node); + if (ts.isIdentifier(node) && emitContext === 1) { + return substituteExpressionIdentifier(node); + } + return node; + } + function substituteExpressionIdentifier(node) { + if (ts.getEmitFlags(node) & 4096) { + var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); + if (externalHelpersModuleName) { + return ts.createPropertyAccess(externalHelpersModuleName, node); + } + } + return node; + } } ts.transformES2015Module = transformES2015Module; })(ts || (ts = {})); @@ -45667,21 +46238,27 @@ var ts; } ts.getTransformers = getTransformers; function transformFiles(resolver, host, sourceFiles, transformers) { + var enabledSyntaxKindFeatures = new Array(298); + var lexicalEnvironmentDisabled = false; + var lexicalEnvironmentVariableDeclarations; + var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; - var enabledSyntaxKindFeatures = new Array(296); var lexicalEnvironmentStackOffset = 0; - var hoistedVariableDeclarations; - var hoistedFunctionDeclarations; - var lexicalEnvironmentDisabled; + var lexicalEnvironmentSuspended = false; + var emitHelpers; var context = { getCompilerOptions: function () { return host.getCompilerOptions(); }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, - hoistVariableDeclaration: hoistVariableDeclaration, - hoistFunctionDeclaration: hoistFunctionDeclaration, startLexicalEnvironment: startLexicalEnvironment, + suspendLexicalEnvironment: suspendLexicalEnvironment, + resumeLexicalEnvironment: resumeLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, + hoistVariableDeclaration: hoistVariableDeclaration, + hoistFunctionDeclaration: hoistFunctionDeclaration, + requestEmitHelper: requestEmitHelper, + readEmitHelpers: readEmitHelpers, onSubstituteNode: function (_emitContext, node) { return node; }, enableSubstitution: enableSubstitution, isSubstitutionEnabled: isSubstitutionEnabled, @@ -45708,7 +46285,7 @@ var ts; } function isSubstitutionEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 - && (ts.getEmitFlags(node) & 128) === 0; + && (ts.getEmitFlags(node) & 4) === 0; } function emitNodeWithSubstitution(emitContext, node, emitCallback) { if (node) { @@ -45727,7 +46304,7 @@ var ts; } function isEmitNotificationEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0 - || (ts.getEmitFlags(node) & 64) !== 0; + || (ts.getEmitFlags(node) & 2) !== 0; } function emitNodeWithNotification(emitContext, node, emitCallback) { if (node) { @@ -45742,39 +46319,51 @@ var ts; function hoistVariableDeclaration(name) { ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); var decl = ts.createVariableDeclaration(name); - if (!hoistedVariableDeclarations) { - hoistedVariableDeclarations = [decl]; + if (!lexicalEnvironmentVariableDeclarations) { + lexicalEnvironmentVariableDeclarations = [decl]; } else { - hoistedVariableDeclarations.push(decl); + lexicalEnvironmentVariableDeclarations.push(decl); } } function hoistFunctionDeclaration(func) { ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); - if (!hoistedFunctionDeclarations) { - hoistedFunctionDeclarations = [func]; + if (!lexicalEnvironmentFunctionDeclarations) { + lexicalEnvironmentFunctionDeclarations = [func]; } else { - hoistedFunctionDeclarations.push(func); + lexicalEnvironmentFunctionDeclarations.push(func); } } function startLexicalEnvironment() { ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase."); - lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = hoistedVariableDeclarations; - lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = hoistedFunctionDeclarations; + ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); + lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations; + lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations; lexicalEnvironmentStackOffset++; - hoistedVariableDeclarations = undefined; - hoistedFunctionDeclarations = undefined; + lexicalEnvironmentVariableDeclarations = undefined; + lexicalEnvironmentFunctionDeclarations = undefined; + } + function suspendLexicalEnvironment() { + ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase."); + ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); + lexicalEnvironmentSuspended = true; + } + function resumeLexicalEnvironment() { + ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase."); + ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); + lexicalEnvironmentSuspended = false; } function endLexicalEnvironment() { ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase."); + ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; - if (hoistedVariableDeclarations || hoistedFunctionDeclarations) { - if (hoistedFunctionDeclarations) { - statements = hoistedFunctionDeclarations.slice(); + if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { + if (lexicalEnvironmentFunctionDeclarations) { + statements = lexicalEnvironmentFunctionDeclarations.slice(); } - if (hoistedVariableDeclarations) { - var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(hoistedVariableDeclarations)); + if (lexicalEnvironmentVariableDeclarations) { + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); if (!statements) { statements = [statement]; } @@ -45784,10 +46373,25 @@ var ts; } } lexicalEnvironmentStackOffset--; - hoistedVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset]; - hoistedFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset]; + if (lexicalEnvironmentStackOffset === 0) { + lexicalEnvironmentVariableDeclarationsStack = []; + lexicalEnvironmentFunctionDeclarationsStack = []; + } return statements; } + function requestEmitHelper(helper) { + ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); + emitHelpers = ts.append(emitHelpers, helper); + } + function readEmitHelpers() { + ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + var helpers = emitHelpers; + emitHelpers = undefined; + return helpers; + } } ts.transformFiles = transformFiles; var _a; @@ -46042,15 +46646,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { - var node = nodes_2[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { - var node = nodes_3[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -46065,7 +46669,7 @@ var ts; } function writeJsDocComments(declaration) { if (declaration) { - var jsDocComments = ts.getJsDocCommentsFromText(declaration, currentText); + var jsDocComments = ts.getJSDocCommentRanges(declaration, currentText); ts.emitNewLineBeforeLeadingComments(currentLineMap, writer, declaration, jsDocComments); ts.emitComments(currentText, currentLineMap, writer, jsDocComments, false, true, newLine, ts.writeCommentRange); } @@ -46252,9 +46856,9 @@ var ts; var count = 0; while (true) { count++; - var name_39 = baseName + "_" + count; - if (!(name_39 in currentIdentifiers)) { - return name_39; + var name_40 = baseName + "_" + count; + if (!(name_40 in currentIdentifiers)) { + return name_40; } } } @@ -46648,6 +47252,9 @@ var ts; case 225: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; + case 228: + diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; + break; default: ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } @@ -46741,7 +47348,10 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - emitHeritageClause(ts.getInterfaceBaseTypeNodes(node), false); + var interfaceExtendsTypes = ts.filter(ts.getInterfaceBaseTypeNodes(node), function (base) { return ts.isEntityNameExpression(base.expression); }); + if (interfaceExtendsTypes && interfaceExtendsTypes.length) { + emitHeritageClause(interfaceExtendsTypes, false); + } write(" {"); writeLine(); increaseIndent(); @@ -47459,12 +48069,12 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 292 - && (emitFlags & 512) === 0 + if (node.kind !== 293 + && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); } - if (emitFlags & 2048) { + if (emitFlags & 64) { disabled = true; emitCallback(emitContext, node); disabled = false; @@ -47472,8 +48082,8 @@ var ts; else { emitCallback(emitContext, node); } - if (node.kind !== 292 - && (emitFlags & 1024) === 0 + if (node.kind !== 293 + && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); } @@ -47487,13 +48097,13 @@ var ts; var emitFlags = emitNode && emitNode.flags; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; tokenPos = ts.skipTrivia(currentSourceText, range ? range.pos : tokenPos); - if ((emitFlags & 4096) === 0 && tokenPos >= 0) { + if ((emitFlags & 128) === 0 && tokenPos >= 0) { emitPos(tokenPos); } tokenPos = emitCallback(token, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 8192) === 0 && tokenPos >= 0) { + if ((emitFlags & 256) === 0 && tokenPos >= 0) { emitPos(tokenPos); } return tokenPos; @@ -47603,7 +48213,7 @@ var ts; var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; var emitFlags = ts.getEmitFlags(node); if ((pos < 0 && end < 0) || (pos === end)) { - if (emitFlags & 65536) { + if (emitFlags & 2048) { disabled = true; emitCallback(emitContext, node); disabled = false; @@ -47616,9 +48226,9 @@ var ts; if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 292; - var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; - var skipTrailingComments = end < 0 || (emitFlags & 32768) !== 0; + var isEmittedNode = node.kind !== 293; + var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; + var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { emitLeadingComments(pos, isEmittedNode); } @@ -47637,7 +48247,7 @@ var ts; if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitNodeWithComment"); } - if (emitFlags & 65536) { + if (emitFlags & 2048) { disabled = true; emitCallback(emitContext, node); disabled = false; @@ -47666,15 +48276,15 @@ var ts; } var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 16384) !== 0; - var skipTrailingComments = disabled || end < 0 || (emitFlags & 32768) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; + var skipTrailingComments = disabled || end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitBodyWithDetachedComments"); } - if (emitFlags & 65536 && !disabled) { + if (emitFlags & 2048 && !disabled) { disabled = true; emitCallback(node); disabled = false; @@ -47835,18 +48445,6 @@ var ts; function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); - var extendsHelper = "\nvar __extends = (this && this.__extends) || function (d, b) {\n for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n};"; - var assignHelper = "\nvar __assign = (this && this.__assign) || Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n};"; - var restHelper = "\nvar __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))\n t[p] = s[p];\n return t;\n};"; - var decorateHelper = "\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};"; - var metadataHelper = "\nvar __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n};"; - var paramHelper = "\nvar __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n};"; - var awaiterHelper = "\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments)).next());\n });\n};"; - var generatorHelper = "\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};"; - var exportStarHelper = "\nfunction __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n}"; - var umdHelper = "\n(function (dependencies, factory) {\n if (typeof module === 'object' && typeof module.exports === 'object') {\n var v = factory(require, exports); if (v !== undefined) module.exports = v;\n }\n else if (typeof define === 'function' && define.amd) {\n define(dependencies, factory);\n }\n})"; - var superHelper = "\nconst _super = name => super[name];"; - var advancedSuperHelper = "\nconst _super = (function (geti, seti) {\n const cache = Object.create(null);\n return name => cache[name] || (cache[name] = { get value() { return geti(name); }, set value(v) { seti(name, v); } });\n})(name => super[name], (name, value) => super[name] = value);"; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -47868,12 +48466,7 @@ var ts; var currentSourceFile; var currentText; var currentFileIdentifiers; - var extendsEmitted; - var assignEmitted; - var restEmitted; - var decorateEmitted; - var paramEmitted; - var awaiterEmitted; + var bundledHelpers; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); @@ -47922,11 +48515,12 @@ var ts; nodeIdToGeneratedName = []; autoGeneratedIdToGeneratedName = []; generatedNameSet = ts.createMap(); + bundledHelpers = isBundledEmit ? ts.createMap() : undefined; isOwnFileEmit = !isBundledEmit; if (isBundledEmit && moduleKind) { for (var _a = 0, sourceFiles_5 = sourceFiles; _a < sourceFiles_5.length; _a++) { var sourceFile = sourceFiles_5[_a]; - emitEmitHelpers(sourceFile); + emitHelpers(sourceFile, true); } } ts.forEach(sourceFiles, printSourceFile); @@ -47936,23 +48530,18 @@ var ts; write("//# " + "sourceMappingURL" + "=" + sourceMappingURL); } if (compilerOptions.sourceMap && !compilerOptions.inlineSourceMap) { - ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false); + ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap.getText(), false, sourceFiles); } if (sourceMapDataList) { sourceMapDataList.push(sourceMap.getSourceMapData()); } - ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM); + ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), compilerOptions.emitBOM, sourceFiles); sourceMap.reset(); comments.reset(); writer.reset(); tempFlags = 0; currentSourceFile = undefined; currentText = undefined; - extendsEmitted = false; - assignEmitted = false; - decorateEmitted = false; - paramEmitted = false; - awaiterEmitted = false; isOwnFileEmit = false; } function printSourceFile(node) { @@ -48320,8 +48909,10 @@ var ts; return emitJsxElement(node); case 247: return emitJsxSelfClosingElement(node); - case 293: + case 294: return emitPartiallyEmittedExpression(node); + case 297: + return writeLines(node.text); } } function emitNumericLiteral(node) { @@ -48341,12 +48932,7 @@ var ts; } } function emitIdentifier(node) { - if (ts.getEmitFlags(node) & 16) { - writeLines(umdHelper); - } - else { - write(getTextOfNode(node, false)); - } + write(getTextOfNode(node, false)); } function emitQualifiedName(node) { emitEntityName(node.left); @@ -48589,7 +49175,7 @@ var ts; write("{}"); } else { - var indentedFlag = ts.getEmitFlags(node) & 524288; + var indentedFlag = ts.getEmitFlags(node) & 32768; if (indentedFlag) { increaseIndent(); } @@ -48604,7 +49190,7 @@ var ts; function emitPropertyAccessExpression(node) { var indentBeforeDot = false; var indentAfterDot = false; - if (!(ts.getEmitFlags(node) & 1048576)) { + if (!(ts.getEmitFlags(node) & 65536)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentText, node.expression.end) + 1; var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; @@ -48788,7 +49374,7 @@ var ts; } } function emitBlockStatements(node) { - if (ts.getEmitFlags(node) & 32) { + if (ts.getEmitFlags(node) & 1) { emitList(node, node.statements, 384); } else { @@ -48964,11 +49550,11 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 524288; + var indentedFlag = ts.getEmitFlags(node) & 32768; if (indentedFlag) { increaseIndent(); } - if (ts.getEmitFlags(node) & 4194304) { + if (ts.getEmitFlags(node) & 262144) { emitSignatureHead(node); emitBlockFunctionBody(body); } @@ -49000,7 +49586,7 @@ var ts; emitWithPrefix(": ", node.type); } function shouldEmitBlockFunctionBodyOnSingleLine(body) { - if (ts.getEmitFlags(body) & 32) { + if (ts.getEmitFlags(body) & 1) { return true; } if (body.multiLine) { @@ -49055,7 +49641,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = ts.getEmitFlags(node) & 524288; + var indentedFlag = ts.getEmitFlags(node) & 32768; if (indentedFlag) { increaseIndent(); } @@ -49314,7 +49900,7 @@ var ts; emit(node.name); write(": "); var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 16384) === 0) { + if ((ts.getEmitFlags(initializer) & 512) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -49368,71 +49954,31 @@ var ts; } return statements.length; } - function emitHelpers(node) { - var emitFlags = ts.getEmitFlags(node); + function emitHelpers(node, isBundle) { + var sourceFile = ts.isSourceFile(node) ? node : currentSourceFile; + var shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && ts.getExternalHelpersModuleName(sourceFile) !== undefined); + var shouldBundle = ts.isSourceFile(node) && !isOwnFileEmit; var helpersEmitted = false; - if (emitFlags & 1) { - helpersEmitted = emitEmitHelpers(currentSourceFile); - } - if (emitFlags & 2) { - writeLines(exportStarHelper); - helpersEmitted = true; - } - if (emitFlags & 4) { - writeLines(superHelper); - helpersEmitted = true; - } - if (emitFlags & 8) { - writeLines(advancedSuperHelper); - helpersEmitted = true; - } - return helpersEmitted; - } - function emitEmitHelpers(node) { - if (compilerOptions.noEmitHelpers) { - return false; - } - if (compilerOptions.importHelpers - && (ts.isExternalModule(node) || compilerOptions.isolatedModules)) { - return false; - } - var helpersEmitted = false; - if ((languageVersion < 2) && (!extendsEmitted && node.flags & 1024)) { - writeLines(extendsHelper); - extendsEmitted = true; - helpersEmitted = true; - } - if ((languageVersion < 5 || currentSourceFile.scriptKind === 2 || currentSourceFile.scriptKind === 4) && - compilerOptions.jsx !== 1 && - !assignEmitted && - node.flags & 16384) { - writeLines(assignHelper); - assignEmitted = true; - } - if (languageVersion < 5 && !restEmitted && node.flags & 32768) { - writeLines(restHelper); - restEmitted = true; - } - if (!decorateEmitted && node.flags & 2048) { - writeLines(decorateHelper); - if (compilerOptions.emitDecoratorMetadata) { - writeLines(metadataHelper); - } - decorateEmitted = true; - helpersEmitted = true; - } - if (!paramEmitted && node.flags & 4096) { - writeLines(paramHelper); - paramEmitted = true; - helpersEmitted = true; - } - if ((languageVersion < 4) && (!awaiterEmitted && node.flags & 8192)) { - writeLines(awaiterHelper); - if (languageVersion < 2) { - writeLines(generatorHelper); + var helpers = ts.getEmitHelpers(node); + if (helpers) { + for (var _a = 0, _b = ts.stableSort(helpers, ts.compareEmitHelpers); _a < _b.length; _a++) { + var helper = _b[_a]; + if (!helper.scoped) { + if (shouldSkip) + continue; + if (shouldBundle) { + if (bundledHelpers[helper.name]) { + continue; + } + bundledHelpers[helper.name] = true; + } + } + else if (isBundle) { + continue; + } + writeLines(helper.text); + helpersEmitted = true; } - awaiterEmitted = true; - helpersEmitted = true; } if (helpersEmitted) { writeLine(); @@ -49440,9 +49986,10 @@ var ts; return helpersEmitted; } function writeLines(text) { - var lines = text.split(/\r\n|\r|\n/g); + var lines = text.split(/\r\n?|\n/g); + var indentation = guessIndentation(lines); for (var i = 0; i < lines.length; i++) { - var line = lines[i]; + var line = indentation ? lines[i].slice(indentation) : lines[i]; if (line.length) { if (i > 0) { writeLine(); @@ -49451,6 +49998,21 @@ var ts; } } } + function guessIndentation(lines) { + var indentation; + for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { + var line = lines_1[_a]; + for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { + if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (indentation === undefined || i < indentation) { + indentation = i; + break; + } + } + } + } + return indentation; + } function emitShebang() { var shebang = ts.getShebang(currentText); if (shebang) { @@ -49792,21 +50354,21 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name_40 = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name_40)) { + var name_41 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_41)) { tempFlags |= flags; - return name_40; + return name_41; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_41 = count < 26 + var name_42 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_41)) { - return name_41; + if (isUniqueName(name_42)) { + return name_42; } } } @@ -49927,7 +50489,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.2.0-dev.20161115"; var emptyArray = []; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } @@ -50143,10 +50704,10 @@ var ts; var resolutions = []; var cache = ts.createMap(); for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { - var name_42 = names_1[_i]; - var result = name_42 in cache - ? cache[name_42] - : cache[name_42] = loader(name_42, containingFile); + var name_43 = names_1[_i]; + var result = name_43 in cache + ? cache[name_43] + : cache[name_43] = loader(name_43, containingFile); resolutions.push(result); } return resolutions; @@ -50200,7 +50761,8 @@ var ts; ts.forEach(rootNames, function (name) { return processRootFile(name, false); }); var typeReferences = ts.getAutomaticTypeDirectiveNames(options, host); if (typeReferences.length) { - var containingFilename = ts.combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); + var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); + var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -50680,8 +51242,8 @@ var ts; } break; } - for (var _b = 0, nodes_4 = nodes; _b < nodes_4.length; _b++) { - var node = nodes_4[_b]; + for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) { + var node = nodes_6[_b]; walk(node); } } @@ -51714,7 +52276,7 @@ var ts; case 243: case 237: return ts.ScriptElementKind.alias; - case 284: + case 285: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -51929,7 +52491,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 291 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 292 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -52165,11 +52727,11 @@ var ts; } } if (node) { - if (node.jsDocComments) { - for (var _i = 0, _a = node.jsDocComments; _i < _a.length; _i++) { - var jsDocComment = _a[_i]; - if (jsDocComment.tags) { - for (var _b = 0, _c = jsDocComment.tags; _b < _c.length; _b++) { + if (node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + if (jsDoc.tags) { + for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) { var tag = _c[_b]; if (tag.pos <= position && position <= tag.end) { return tag; @@ -52491,7 +53053,7 @@ var ts; if (isImportOrExportSpecifierName(location)) { return location.getText(); } - else if (ts.isStringOrNumericLiteral(location.kind) && + else if (ts.isStringOrNumericLiteral(location) && location.parent.kind === 142) { return location.text; } @@ -53574,16 +54136,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 280: + case 281: processJSDocParameterTag(tag); break; - case 283: + case 284: processJSDocTemplateTag(tag); break; - case 282: + case 283: processElement(tag.typeExpression); break; - case 281: + case 282: processElement(tag.typeExpression); break; } @@ -53835,13 +54397,13 @@ var ts; function getJavaScriptCompletionEntries(sourceFile, position, uniqueNames) { var entries = []; var nameTable = ts.getNameTable(sourceFile); - for (var name_43 in nameTable) { - if (nameTable[name_43] === position) { + for (var name_44 in nameTable) { + if (nameTable[name_44] === position) { continue; } - if (!uniqueNames[name_43]) { - uniqueNames[name_43] = name_43; - var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_43), compilerOptions.target, true); + if (!uniqueNames[name_44]) { + uniqueNames[name_44] = name_44; + var displayName = getCompletionEntryDisplayName(ts.unescapeIdentifier(name_44), compilerOptions.target, true); if (displayName) { var entry = { name: displayName, @@ -54263,11 +54825,11 @@ var ts; if (currentConfigPath) { paths.push(currentConfigPath); currentDir = ts.getDirectoryPath(currentConfigPath); - var parent_14 = ts.getDirectoryPath(currentDir); - if (currentDir === parent_14) { + var parent_13 = ts.getDirectoryPath(currentDir); + if (currentDir === parent_13) { break; } - currentDir = parent_14; + currentDir = parent_13; } else { break; @@ -54344,10 +54906,10 @@ var ts; function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_2 = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_2) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_3 = completionData.location; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_2, location_2, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), @@ -54373,8 +54935,8 @@ var ts; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; - return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_3) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_4 = completionData.location; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_4) === entryName ? s : undefined; }); } return undefined; } @@ -54399,9 +54961,9 @@ var ts; isJsDocTagName = true; } switch (tag.kind) { - case 282: - case 280: + case 283: case 281: + case 282: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -54436,13 +54998,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent_15 = contextToken.parent, kind = contextToken.kind; + var parent_14 = contextToken.parent, kind = contextToken.kind; if (kind === 22) { - if (parent_15.kind === 177) { + if (parent_14.kind === 177) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent_15.kind === 141) { + else if (parent_14.kind === 141) { node = contextToken.parent.left; isRightOfDot = true; } @@ -54739,9 +55301,9 @@ var ts; switch (contextToken.kind) { case 16: case 25: - var parent_16 = contextToken.parent; - if (parent_16 && (parent_16.kind === 176 || parent_16.kind === 172)) { - return parent_16; + var parent_15 = contextToken.parent; + if (parent_15 && (parent_15.kind === 176 || parent_15.kind === 172)) { + return parent_15; } break; } @@ -54764,34 +55326,34 @@ var ts; } function tryGetContainingJsxElement(contextToken) { if (contextToken) { - var parent_17 = contextToken.parent; + var parent_16 = contextToken.parent; switch (contextToken.kind) { case 27: case 40: case 70: case 250: case 251: - if (parent_17 && (parent_17.kind === 247 || parent_17.kind === 248)) { - return parent_17; + if (parent_16 && (parent_16.kind === 247 || parent_16.kind === 248)) { + return parent_16; } - else if (parent_17.kind === 250) { - return parent_17.parent; + else if (parent_16.kind === 250) { + return parent_16.parent; } break; case 9: - if (parent_17 && ((parent_17.kind === 250) || (parent_17.kind === 251))) { - return parent_17.parent; + if (parent_16 && ((parent_16.kind === 250) || (parent_16.kind === 251))) { + return parent_16.parent; } break; case 17: - if (parent_17 && - parent_17.kind === 252 && - parent_17.parent && - (parent_17.parent.kind === 250)) { - return parent_17.parent.parent; + if (parent_16 && + parent_16.kind === 252 && + parent_16.parent && + (parent_16.parent.kind === 250)) { + return parent_16.parent.parent; } - if (parent_17 && parent_17.kind === 251) { - return parent_17.parent; + if (parent_16 && parent_16.kind === 251) { + return parent_16.parent; } break; } @@ -54914,8 +55476,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"; }); @@ -55212,17 +55774,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_18 = child.parent; - if (ts.isFunctionBlock(parent_18) || parent_18.kind === 261) { - return parent_18; + var parent_17 = child.parent; + if (ts.isFunctionBlock(parent_17) || parent_17.kind === 261) { + return parent_17; } - if (parent_18.kind === 221) { - var tryStatement = parent_18; + if (parent_17.kind === 221) { + var tryStatement = parent_17; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_18; + child = parent_17; } return undefined; } @@ -56057,24 +56619,24 @@ var ts; } var containingTypeReference = getContainingTypeReference(refNode); if (containingTypeReference) { - var parent_19 = containingTypeReference.parent; - if (ts.isVariableLike(parent_19) && parent_19.type === containingTypeReference && parent_19.initializer && isImplementationExpression(parent_19.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent_19.initializer)); + var parent_18 = containingTypeReference.parent; + if (ts.isVariableLike(parent_18) && parent_18.type === containingTypeReference && parent_18.initializer && isImplementationExpression(parent_18.initializer)) { + maybeAdd(getReferenceEntryFromNode(parent_18.initializer)); } - else if (ts.isFunctionLike(parent_19) && parent_19.type === containingTypeReference && parent_19.body) { - if (parent_19.body.kind === 204) { - ts.forEachReturnStatement(parent_19.body, function (returnStatement) { + else if (ts.isFunctionLike(parent_18) && parent_18.type === containingTypeReference && parent_18.body) { + if (parent_18.body.kind === 204) { + ts.forEachReturnStatement(parent_18.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); } }); } - else if (isImplementationExpression(parent_19.body)) { - maybeAdd(getReferenceEntryFromNode(parent_19.body)); + else if (isImplementationExpression(parent_18.body)) { + maybeAdd(getReferenceEntryFromNode(parent_18.body)); } } - else if (ts.isAssertionExpression(parent_19) && isImplementationExpression(parent_19.expression)) { - maybeAdd(getReferenceEntryFromNode(parent_19.expression)); + else if (ts.isAssertionExpression(parent_18) && isImplementationExpression(parent_18.expression)) { + maybeAdd(getReferenceEntryFromNode(parent_18.expression)); } } } @@ -56450,9 +57012,9 @@ var ts; return undefined; } } - var result_3 = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_3, ts.createMap()); - return ts.forEach(result_3, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); + var result_4 = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result_4, ts.createMap()); + return ts.forEach(result_4, function (s) { return searchSymbols.indexOf(s) >= 0 ? s : undefined; }); } return undefined; }); @@ -56460,7 +57022,7 @@ var ts; function getNameFromObjectLiteralElement(node) { if (node.name.kind === 142) { var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression.kind)) { + if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; } return undefined; @@ -56472,20 +57034,20 @@ var ts; var contextualType = typeChecker.getContextualType(objectLiteral); var name = getNameFromObjectLiteralElement(node); if (name && contextualType) { - var result_4 = []; + var result_5 = []; var symbol_2 = contextualType.getProperty(name); if (symbol_2) { - result_4.push(symbol_2); + result_5.push(symbol_2); } if (contextualType.flags & 65536) { ts.forEach(contextualType.types, function (t) { var symbol = t.getProperty(name); if (symbol) { - result_4.push(symbol); + result_5.push(symbol); } }); } - return result_4; + return result_5; } return undefined; } @@ -56713,13 +57275,13 @@ var ts; return undefined; } if (type.flags & 65536 && !(type.flags & 16)) { - var result_5 = []; + var result_6 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(result_6, getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_5; + return result_6; } if (!type.symbol) { return undefined; @@ -56911,7 +57473,7 @@ var ts; function getJsDocCommentsFromDeclarations(declarations) { var documentationComment = []; forEachUnique(declarations, function (declaration) { - var comments = ts.getJSDocComments(declaration, true); + var comments = ts.getCommentsFromJSDoc(declaration); if (!comments) { return; } @@ -57050,10 +57612,10 @@ var ts; return; } var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_45 in nameToDeclarations) { - var declarations = nameToDeclarations[name_45]; + for (var name_46 in nameToDeclarations) { + var declarations = nameToDeclarations[name_46]; if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_45); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_46); if (!matches) { continue; } @@ -57064,14 +57626,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_45); + matches = patternMatcher.getMatches(containers, name_46); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_45, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_46, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -57324,9 +57886,9 @@ var ts; case 174: case 223: var decl = node; - var name_46 = decl.name; - if (ts.isBindingPattern(name_46)) { - addChildrenRecursively(name_46); + var name_47 = decl.name; + if (ts.isBindingPattern(name_47)) { + addChildrenRecursively(name_47); } else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { addChildrenRecursively(decl.initializer); @@ -57372,9 +57934,9 @@ var ts; addLeafNode(node); break; default: - ts.forEach(node.jsDocComments, function (jsDocComment) { - ts.forEach(jsDocComment.tags, function (tag) { - if (tag.kind === 284) { + ts.forEach(node.jsDoc, function (jsDoc) { + ts.forEach(jsDoc.tags, function (tag) { + if (tag.kind === 285) { addLeafNode(tag); } }); @@ -57490,7 +58052,7 @@ var ts; case 185: case 197: return getFunctionOrClassName(node); - case 284: + case 285: return getJSDocTypedefTagName(node); default: return undefined; @@ -57530,7 +58092,7 @@ var ts; return "()"; case 155: return "[]"; - case 284: + case 285: return getJSDocTypedefTagName(node); default: return "<unknown>"; @@ -57577,7 +58139,7 @@ var ts; case 230: case 261: case 228: - case 284: + case 285: return true; case 150: case 149: @@ -57790,24 +58352,24 @@ var ts; switch (n.kind) { case 204: if (!ts.isFunctionBlock(n)) { - var parent_20 = n.parent; + var parent_19 = n.parent; var openBrace = ts.findChildOfKind(n, 16, sourceFile); var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent_20.kind === 209 || - parent_20.kind === 212 || - parent_20.kind === 213 || - parent_20.kind === 211 || - parent_20.kind === 208 || - parent_20.kind === 210 || - parent_20.kind === 217 || - parent_20.kind === 256) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + if (parent_19.kind === 209 || + parent_19.kind === 212 || + parent_19.kind === 213 || + parent_19.kind === 211 || + parent_19.kind === 208 || + parent_19.kind === 210 || + parent_19.kind === 217 || + parent_19.kind === 256) { + addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_20.kind === 221) { - var tryStatement = parent_20; + if (parent_19.kind === 221) { + var tryStatement = parent_19; if (tryStatement.tryBlock === n) { - addOutliningSpan(parent_20, openBrace, closeBrace, autoCollapse(n)); + addOutliningSpan(parent_19, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { @@ -59421,8 +59983,8 @@ var ts; if (declaration.kind !== 223 && declaration.kind !== 225) { return false; } - for (var parent_21 = declaration.parent; !ts.isFunctionBlock(parent_21); parent_21 = parent_21.parent) { - if (parent_21.kind === 261 || parent_21.kind === 231) { + for (var parent_20 = declaration.parent; !ts.isFunctionBlock(parent_20); parent_20 = parent_20.parent) { + if (parent_20.kind === 261 || parent_20.kind === 231) { return false; } } @@ -59909,7 +60471,7 @@ var ts; function RuleOperationContext() { var funcs = []; for (var _i = 0; _i < arguments.length; _i++) { - funcs[_i - 0] = arguments[_i]; + funcs[_i] = arguments[_i]; } this.customContextChecks = funcs; } @@ -60116,9 +60678,9 @@ var ts; } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_47 in o) { - if (o[name_47] === rule) { - return name_47; + for (var name_48 in o) { + if (o[name_48] === rule) { + return name_48; } } throw new Error("Unknown rule"); @@ -61297,11 +61859,23 @@ var ts; else { var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos); var startLinePosition = ts.getStartPositionOfLine(tokenStart.line, sourceFile); - if (indentation !== tokenStart.character || indentationIsDifferent(indentationString, startLinePosition)) { + if (indentation !== characterToColumn(startLinePosition, tokenStart.character) || indentationIsDifferent(indentationString, startLinePosition)) { recordReplace(startLinePosition, tokenStart.character, indentationString); } } } + function characterToColumn(startLinePosition, characterInLine) { + var column = 0; + for (var i = 0; i < characterInLine; i++) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9) { + column += options.tabSize - column % options.tabSize; + } + else { + column++; + } + } + return column; + } function indentationIsDifferent(indentationString, startLinePosition) { return indentationString !== sourceFile.text.substr(startLinePosition, indentationString.length); } @@ -62007,6 +62581,579 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var codefix; + (function (codefix) { + var ModuleSpecifierComparison; + (function (ModuleSpecifierComparison) { + ModuleSpecifierComparison[ModuleSpecifierComparison["Better"] = 0] = "Better"; + ModuleSpecifierComparison[ModuleSpecifierComparison["Equal"] = 1] = "Equal"; + ModuleSpecifierComparison[ModuleSpecifierComparison["Worse"] = 2] = "Worse"; + })(ModuleSpecifierComparison || (ModuleSpecifierComparison = {})); + var ImportCodeActionMap = (function () { + function ImportCodeActionMap() { + this.symbolIdToActionMap = ts.createMap(); + } + ImportCodeActionMap.prototype.addAction = function (symbolId, newAction) { + if (!newAction) { + return; + } + if (!this.symbolIdToActionMap[symbolId]) { + this.symbolIdToActionMap[symbolId] = [newAction]; + return; + } + if (newAction.kind === "CodeChange") { + this.symbolIdToActionMap[symbolId].push(newAction); + return; + } + var updatedNewImports = []; + for (var _i = 0, _a = this.symbolIdToActionMap[symbolId]; _i < _a.length; _i++) { + var existingAction = _a[_i]; + if (existingAction.kind === "CodeChange") { + updatedNewImports.push(existingAction); + continue; + } + switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) { + case ModuleSpecifierComparison.Better: + if (newAction.kind === "NewImport") { + return; + } + case ModuleSpecifierComparison.Equal: + updatedNewImports.push(existingAction); + break; + case ModuleSpecifierComparison.Worse: + continue; + } + } + updatedNewImports.push(newAction); + this.symbolIdToActionMap[symbolId] = updatedNewImports; + }; + ImportCodeActionMap.prototype.addActions = function (symbolId, newActions) { + for (var _i = 0, newActions_1 = newActions; _i < newActions_1.length; _i++) { + var newAction = newActions_1[_i]; + this.addAction(symbolId, newAction); + } + }; + ImportCodeActionMap.prototype.getAllActions = function () { + var result = []; + for (var symbolId in this.symbolIdToActionMap) { + result = ts.concatenate(result, this.symbolIdToActionMap[symbolId]); + } + return result; + }; + ImportCodeActionMap.prototype.compareModuleSpecifiers = function (moduleSpecifier1, moduleSpecifier2) { + if (moduleSpecifier1 === moduleSpecifier2) { + return ModuleSpecifierComparison.Equal; + } + if (moduleSpecifier2.indexOf(moduleSpecifier1) === 0) { + return ModuleSpecifierComparison.Better; + } + if (moduleSpecifier1.indexOf(moduleSpecifier2) === 0) { + return ModuleSpecifierComparison.Worse; + } + if (ts.isExternalModuleNameRelative(moduleSpecifier1) && ts.isExternalModuleNameRelative(moduleSpecifier2)) { + var regex = new RegExp(ts.directorySeparator, "g"); + var moduleSpecifier1LevelCount = (moduleSpecifier1.match(regex) || []).length; + var moduleSpecifier2LevelCount = (moduleSpecifier2.match(regex) || []).length; + return moduleSpecifier1LevelCount < moduleSpecifier2LevelCount + ? ModuleSpecifierComparison.Better + : moduleSpecifier1LevelCount === moduleSpecifier2LevelCount + ? ModuleSpecifierComparison.Equal + : ModuleSpecifierComparison.Worse; + } + return ModuleSpecifierComparison.Equal; + }; + return ImportCodeActionMap; + }()); + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Cannot_find_name_0.code], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var checker = context.program.getTypeChecker(); + var allSourceFiles = context.program.getSourceFiles(); + var useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false; + var token = ts.getTokenAtPosition(sourceFile, context.span.start); + var name = token.getText(); + var symbolIdActionMap = new ImportCodeActionMap(); + var cachedImportDeclarations = ts.createMap(); + var cachedNewImportInsertPosition; + var allPotentialModules = checker.getAmbientModules(); + for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { + var otherSourceFile = allSourceFiles_1[_i]; + if (otherSourceFile !== sourceFile && ts.isExternalOrCommonJsModule(otherSourceFile)) { + allPotentialModules.push(otherSourceFile.symbol); + } + } + var currentTokenMeaning = ts.getMeaningFromLocation(token); + for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { + var moduleSymbol = allPotentialModules_1[_a]; + context.cancellationToken.throwIfCancellationRequested(); + var defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); + if (defaultExport) { + var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); + if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { + var symbolId = getUniqueSymbolId(localSymbol); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, true)); + } + } + var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol); + if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + var symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol)); + } + } + return symbolIdActionMap.getAllActions(); + function getImportDeclarations(moduleSymbol) { + var moduleSymbolId = getUniqueSymbolId(moduleSymbol); + if (cachedImportDeclarations[moduleSymbolId]) { + return cachedImportDeclarations[moduleSymbolId]; + } + var existingDeclarations = []; + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var importModuleSpecifier = _a[_i]; + var importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); + if (importSymbol === moduleSymbol) { + existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); + } + } + cachedImportDeclarations[moduleSymbolId] = existingDeclarations; + return existingDeclarations; + function getImportDeclaration(moduleSpecifier) { + var node = moduleSpecifier; + while (node) { + if (node.kind === 235) { + return node; + } + if (node.kind === 234) { + return node; + } + node = node.parent; + } + return undefined; + } + } + function getUniqueSymbolId(symbol) { + if (symbol.flags & 8388608) { + return ts.getSymbolId(checker.getAliasedSymbol(symbol)); + } + return ts.getSymbolId(symbol); + } + function checkSymbolHasMeaning(symbol, meaning) { + var declarations = symbol.getDeclarations(); + return declarations ? ts.some(symbol.declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }) : false; + } + function getCodeActionForImport(moduleSymbol, isDefault) { + var existingDeclarations = getImportDeclarations(moduleSymbol); + if (existingDeclarations.length > 0) { + return getCodeActionsForExistingImport(existingDeclarations); + } + else { + return [getCodeActionForNewImport()]; + } + function getCodeActionsForExistingImport(declarations) { + var actions = []; + var namespaceImportDeclaration; + var namedImportDeclaration; + var existingModuleSpecifier; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + if (declaration.kind === 235) { + var namedBindings = declaration.importClause && declaration.importClause.namedBindings; + if (namedBindings && namedBindings.kind === 237) { + namespaceImportDeclaration = declaration; + } + else { + namedImportDeclaration = declaration; + } + existingModuleSpecifier = declaration.moduleSpecifier.getText(); + } + else { + namespaceImportDeclaration = declaration; + existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration); + } + } + if (namespaceImportDeclaration) { + actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); + } + if (namedImportDeclaration && namedImportDeclaration.importClause && + (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { + var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); + actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], textChange.newText, textChange.span, sourceFile.fileName, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); + } + else { + actions.push(getCodeActionForNewImport(existingModuleSpecifier)); + } + return actions; + function getModuleSpecifierFromImportEqualsDeclaration(declaration) { + if (declaration.moduleReference && declaration.moduleReference.kind === 245) { + return declaration.moduleReference.expression.getText(); + } + return declaration.moduleReference.getText(); + } + function getTextChangeForImportClause(importClause) { + var newImportText = isDefault ? "default as " + name : name; + var importList = importClause.namedBindings; + if (!importList && importClause.name) { + var start = importClause.name.getEnd(); + return { + newText: ", { " + newImportText + " }", + span: { start: start, length: 0 } + }; + } + if (importList.elements.length === 0) { + var start = importList.getStart(); + return { + newText: "{ " + newImportText + " }", + span: { start: start, length: importList.getEnd() - start } + }; + } + var insertPoint = importList.elements[importList.elements.length - 1].getEnd(); + var startLine = ts.getLineOfLocalPosition(sourceFile, importList.getStart()); + var endLine = ts.getLineOfLocalPosition(sourceFile, importList.getEnd()); + var oneImportPerLine = endLine - startLine > importList.elements.length; + return { + newText: "," + (oneImportPerLine ? context.newLineCharacter : " ") + newImportText, + span: { start: insertPoint, length: 0 } + }; + } + function getCodeActionForNamespaceImport(declaration) { + var namespacePrefix; + if (declaration.kind === 235) { + namespacePrefix = declaration.importClause.namedBindings.name.getText(); + } + else { + namespacePrefix = declaration.name.getText(); + } + namespacePrefix = ts.stripQuotes(namespacePrefix); + return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], namespacePrefix + ".", { start: token.getStart(), length: 0 }, sourceFile.fileName, "CodeChange"); + } + } + function getCodeActionForNewImport(moduleSpecifier) { + if (!cachedNewImportInsertPosition) { + var lastModuleSpecifierEnd = -1; + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier_1 = _a[_i]; + var end = moduleSpecifier_1.getEnd(); + if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { + lastModuleSpecifierEnd = end; + } + } + cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); + } + var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); + var importStatementText = isDefault + ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + var newText = cachedNewImportInsertPosition === sourceFile.getStart() + ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter + : "" + context.newLineCharacter + importStatementText + ";"; + return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); + function getModuleSpecifierForNewImport() { + var fileName = sourceFile.path; + var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().path; + var sourceDirectory = ts.getDirectoryPath(fileName); + var options = context.program.getCompilerOptions(); + return tryGetModuleNameFromAmbientModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || + tryGetModuleNameFromTypeRoots() || + tryGetModuleNameAsNodeModule() || + ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); + function tryGetModuleNameFromAmbientModule() { + if (moduleSymbol.valueDeclaration.kind !== 261) { + return moduleSymbol.name; + } + } + function tryGetModuleNameFromBaseUrl() { + if (!options.baseUrl) { + return undefined; + } + var normalizedBaseUrl = ts.toPath(options.baseUrl, ts.getDirectoryPath(options.baseUrl), getCanonicalFileName); + var relativeName = tryRemoveParentDirectoryName(moduleFileName, normalizedBaseUrl); + if (!relativeName) { + return undefined; + } + relativeName = removeExtensionAndIndexPostFix(relativeName); + if (options.paths) { + for (var key in options.paths) { + for (var _i = 0, _a = options.paths[key]; _i < _a.length; _i++) { + var pattern = _a[_i]; + var indexOfStar = pattern.indexOf("*"); + if (indexOfStar === 0 && pattern.length === 1) { + continue; + } + else if (indexOfStar !== -1) { + var prefix = pattern.substr(0, indexOfStar); + var suffix = pattern.substr(indexOfStar + 1); + if (relativeName.length >= prefix.length + suffix.length && + ts.startsWith(relativeName, prefix) && + ts.endsWith(relativeName, suffix)) { + var matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length); + return key.replace("\*", matchedStar); + } + } + else if (pattern === relativeName) { + return key; + } + } + } + } + return relativeName; + } + function tryGetModuleNameFromRootDirs() { + if (options.rootDirs) { + var normalizedRootDirs = ts.map(options.rootDirs, function (rootDir) { return ts.toPath(rootDir, undefined, getCanonicalFileName); }); + var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, normalizedRootDirs); + var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, normalizedRootDirs); + if (normalizedTargetPath !== undefined) { + var relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; + return ts.removeFileExtension(relativePath); + } + } + return undefined; + } + function tryGetModuleNameFromTypeRoots() { + var typeRoots = ts.getEffectiveTypeRoots(options, context.host); + if (typeRoots) { + var normalizedTypeRoots = ts.map(typeRoots, function (typeRoot) { return ts.toPath(typeRoot, undefined, getCanonicalFileName); }); + for (var _i = 0, normalizedTypeRoots_1 = normalizedTypeRoots; _i < normalizedTypeRoots_1.length; _i++) { + var typeRoot = normalizedTypeRoots_1[_i]; + if (ts.startsWith(moduleFileName, typeRoot)) { + var relativeFileName = moduleFileName.substring(typeRoot.length + 1); + return removeExtensionAndIndexPostFix(relativeFileName); + } + } + } + } + function tryGetModuleNameAsNodeModule() { + if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) { + return undefined; + } + var indexOfNodeModules = moduleFileName.indexOf("node_modules"); + if (indexOfNodeModules < 0) { + return undefined; + } + var relativeFileName; + if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) { + relativeFileName = moduleFileName.substring(indexOfNodeModules + 13); + } + else { + relativeFileName = getRelativePath(moduleFileName, sourceDirectory); + } + relativeFileName = ts.removeFileExtension(relativeFileName); + if (ts.endsWith(relativeFileName, "/index")) { + relativeFileName = ts.getDirectoryPath(relativeFileName); + } + else { + try { + var moduleDirectory = ts.getDirectoryPath(moduleFileName); + var packageJsonContent = JSON.parse(context.host.readFile(ts.combinePaths(moduleDirectory, "package.json"))); + if (packageJsonContent) { + var mainFile = packageJsonContent.main || packageJsonContent.typings; + if (mainFile) { + var mainExportFile = ts.toPath(mainFile, moduleDirectory, getCanonicalFileName); + if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(moduleFileName)) { + relativeFileName = ts.getDirectoryPath(relativeFileName); + } + } + } + } + catch (e) { } + } + return relativeFileName; + } + } + function getPathRelativeToRootDirs(path, rootDirs) { + for (var _i = 0, rootDirs_2 = rootDirs; _i < rootDirs_2.length; _i++) { + var rootDir = rootDirs_2[_i]; + var relativeName = tryRemoveParentDirectoryName(path, rootDir); + if (relativeName !== undefined) { + return relativeName; + } + } + return undefined; + } + function removeExtensionAndIndexPostFix(fileName) { + fileName = ts.removeFileExtension(fileName); + if (ts.endsWith(fileName, "/index")) { + fileName = fileName.substr(0, fileName.length - 6); + } + return fileName; + } + function getRelativePath(path, directoryPath) { + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; + } + function tryRemoveParentDirectoryName(path, parentDirectory) { + var index = path.indexOf(parentDirectory); + if (index === 0) { + return ts.endsWith(parentDirectory, ts.directorySeparator) + ? path.substring(parentDirectory.length) + : path.substring(parentDirectory.length + 1); + } + return undefined; + } + } + } + function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { + return { + description: ts.formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), + changes: [{ fileName: fileName, textChanges: [{ newText: newText, span: span }] }], + kind: kind, + moduleSpecifier: moduleSpecifier + }; + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ + ts.Diagnostics._0_is_declared_but_never_used.code, + ts.Diagnostics.Property_0_is_declared_but_never_used.code + ], + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind === 20) { + token = ts.getTokenAtPosition(sourceFile, start + 1); + } + switch (token.kind) { + case 70: + switch (token.parent.kind) { + case 223: + switch (token.parent.parent.parent.kind) { + case 211: + var forStatement = token.parent.parent.parent; + var forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return createCodeFix("", forInitializer.pos, forInitializer.end - forInitializer.pos); + } + else { + return removeSingleItem(forInitializer.declarations, token); + } + case 213: + var forOfStatement = token.parent.parent.parent; + if (forOfStatement.initializer.kind === 224) { + var forOfInitializer = forOfStatement.initializer; + return createCodeFix("{}", forOfInitializer.declarations[0].pos, forOfInitializer.declarations[0].end - forOfInitializer.declarations[0].pos); + } + break; + case 212: + return undefined; + case 256: + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); + default: + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); + } + else { + var declarations = variableStatement.declarationList.declarations; + return removeSingleItem(declarations, token); + } + } + case 143: + var typeParameters = token.parent.parent.typeParameters; + if (typeParameters.length === 1) { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + } + else { + return removeSingleItem(typeParameters, token); + } + case 144: + var functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else { + return removeSingleItem(functionDeclaration.parameters, token); + } + case 234: + var importEquals = findImportDeclaration(token); + return createCodeFix("", importEquals.pos, importEquals.end - importEquals.pos); + case 239: + var namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + var importSpec = findImportDeclaration(token); + return createCodeFix("", importSpec.pos, importSpec.end - importSpec.pos); + } + else { + return removeSingleItem(namedImports.elements, token); + } + case 236: + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = findImportDeclaration(importClause); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + return createCodeFix("", importClause.name.pos, importClause.namedBindings.pos - importClause.name.pos); + } + case 237: + var namespaceImport = token.parent; + if (namespaceImport.name == token && !namespaceImport.parent.name) { + var importDecl = findImportDeclaration(namespaceImport); + return createCodeFix("", importDecl.pos, importDecl.end - importDecl.pos); + } + else { + var start_4 = namespaceImport.parent.name.end; + return createCodeFix("", start_4, namespaceImport.parent.namedBindings.end - start_4); + } + } + break; + case 147: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + case 237: + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + if (ts.isDeclarationName(token)) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); + } + else if (ts.isLiteralComputedPropertyDeclarationName(token)) { + return createCodeFix("", token.parent.parent.pos, token.parent.parent.end - token.parent.parent.pos); + } + else { + return undefined; + } + function findImportDeclaration(token) { + var importDecl = token; + while (importDecl.kind != 235 && importDecl.parent) { + importDecl = importDecl.parent; + } + return importDecl; + } + function createCodeFix(newText, start, length) { + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: newText, span: { start: start, length: length } }] + }] + }]; + } + function removeSingleItem(elements, token) { + if (elements[0] === token.parent) { + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); + } + else { + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); + } + } + } + }); + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { var node = kind >= 141 ? new NodeObject(kind, pos, end) : @@ -62067,11 +63214,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(291, nodes.pos, nodes.end, this); + var list = createNode(292, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { - var node = nodes_5[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -62090,7 +63237,7 @@ var ts; ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 290; + var useJSDocScanner_1 = this.kind >= 278 && this.kind <= 291; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -62108,8 +63255,8 @@ var ts; children.push(_this.createSyntaxList(nodes)); pos_3 = nodes.end; }; - if (this.jsDocComments) { - for (var _i = 0, _a = this.jsDocComments; _i < _a.length; _i++) { + if (this.jsDoc) { + for (var _i = 0, _a = this.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; processNode(jsDocComment); } @@ -62329,6 +63476,19 @@ var ts; SourceFileObject.prototype.getPositionOfLineAndCharacter = function (line, character) { return ts.getPositionOfLineAndCharacter(this, line, character); }; + SourceFileObject.prototype.getLineEndOfPosition = function (pos) { + var line = this.getLineAndCharacterOfPosition(pos).line; + var lineStarts = this.getLineStarts(); + var lastCharPos; + if (line + 1 >= lineStarts.length) { + lastCharPos = this.getEnd(); + } + if (!lastCharPos) { + lastCharPos = lineStarts[line + 1] - 1; + } + var fullText = this.getFullText(); + return fullText[lastCharPos] === "\n" && fullText[lastCharPos - 1] === "\r" ? lastCharPos - 1 : lastCharPos; + }; SourceFileObject.prototype.getNamedDeclarations = function () { if (!this.namedDeclarations) { this.namedDeclarations = this.computeNamedDeclarations(); @@ -62350,9 +63510,9 @@ var ts; } function getDeclarationName(declaration) { if (declaration.name) { - var result_6 = getTextOfIdentifierOrLiteral(declaration.name); - if (result_6 !== undefined) { - return result_6; + var result_7 = getTextOfIdentifierOrLiteral(declaration.name); + if (result_7 !== undefined) { + return result_7; } if (declaration.name.kind === 142) { var expr = declaration.name.expression; @@ -63179,7 +64339,9 @@ var ts; sourceFile: sourceFile, span: span, program: program, - newLineCharacter: newLineChar + newLineCharacter: newLineChar, + host: host, + cancellationToken: cancellationToken }; var fixes = ts.codefix.getFixes(context); if (fixes) { @@ -63344,10 +64506,10 @@ var ts; break; default: ts.forEachChild(node, walk); - if (node.jsDocComments) { - for (var _i = 0, _a = node.jsDocComments; _i < _a.length; _i++) { - var jsDocComment = _a[_i]; - ts.forEachChild(jsDocComment, walk); + if (node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + ts.forEachChild(jsDoc, walk); } } } @@ -63544,7 +64706,7 @@ var ts; this.trace = function (s) { return host.trace(s); }; } this.resolveModuleName = function (moduleName, containingFile, compilerOptions, host) { - var globalCache = _this.project.getTypingOptions().enableAutoDiscovery + var globalCache = _this.project.getTypeAcquisition().enable ? _this.project.projectService.typingsInstaller.globalTypingsCacheLocation : undefined; var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host); @@ -63576,15 +64738,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_48 = names_2[_i]; - var resolution = newResolutions[name_48]; + var name_49 = names_2[_i]; + var resolution = newResolutions[name_49]; if (!resolution) { - var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_48]; + var existingResolution = currentResolutionsInFile && currentResolutionsInFile[name_49]; if (moduleResolutionIsValid(existingResolution)) { resolution = existingResolution; } else { - newResolutions[name_48] = resolution = loader(name_48, containingFile, compilerOptions, this); + newResolutions[name_49] = resolution = loader(name_49, containingFile, compilerOptions, this); } if (logChanges && this.filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { this.filesWithChangedSetOfUnresolvedImports.push(path); @@ -63746,8 +64908,8 @@ var ts; } return unique === 0; } - function typingOptionsChanged(opt1, opt2) { - return opt1.enableAutoDiscovery !== opt2.enableAutoDiscovery || + function typeAcquisitionChanged(opt1, opt2) { + return opt1.enable !== opt2.enable || !setIsEqualTo(opt1.include, opt2.include) || !setIsEqualTo(opt1.exclude, opt2.exclude); } @@ -63766,32 +64928,32 @@ var ts; this.perProjectCache = ts.createMap(); } TypingsCache.prototype.getTypingsForProject = function (project, unresolvedImports, forceRefresh) { - var typingOptions = project.getTypingOptions(); - if (!typingOptions || !typingOptions.enableAutoDiscovery) { + var typeAcquisition = project.getTypeAcquisition(); + if (!typeAcquisition || !typeAcquisition.enable) { return server.emptyArray; } var entry = this.perProjectCache[project.getProjectName()]; var result = entry ? entry.typings : server.emptyArray; if (forceRefresh || !entry || - typingOptionsChanged(typingOptions, entry.typingOptions) || + typeAcquisitionChanged(typeAcquisition, entry.typeAcquisition) || compilerOptionsChanged(project.getCompilerOptions(), entry.compilerOptions) || unresolvedImportsChanged(unresolvedImports, entry.unresolvedImports)) { this.perProjectCache[project.getProjectName()] = { compilerOptions: project.getCompilerOptions(), - typingOptions: typingOptions, + typeAcquisition: typeAcquisition, typings: result, unresolvedImports: unresolvedImports, poisoned: true }; - this.installer.enqueueInstallTypingsRequest(project, typingOptions, unresolvedImports); + this.installer.enqueueInstallTypingsRequest(project, typeAcquisition, unresolvedImports); } return result; }; - TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typingOptions, unresolvedImports, newTypings) { + TypingsCache.prototype.updateTypingsForProject = function (projectName, compilerOptions, typeAcquisition, unresolvedImports, newTypings) { this.perProjectCache[projectName] = { compilerOptions: compilerOptions, - typingOptions: typingOptions, + typeAcquisition: typeAcquisition, typings: server.toSortedReadonlyArray(newTypings), unresolvedImports: unresolvedImports, poisoned: false @@ -64289,7 +65451,8 @@ var ts; } server.createNoSemanticFeaturesWrapper = createNoSemanticFeaturesWrapper; var Project = (function () { - function Project(projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + function Project(projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) { + this.projectName = projectName; this.projectKind = projectKind; this.projectService = projectService; this.documentRegistry = documentRegistry; @@ -64372,6 +65535,9 @@ var ts; this.languageServiceEnabled = false; this.projectService.onUpdateLanguageServiceStateForProject(this, false); }; + Project.prototype.getProjectName = function () { + return this.projectName; + }; Project.prototype.getSourceFile = function (path) { if (!this.program) { return undefined; @@ -64529,9 +65695,9 @@ var ts; } var unresolvedImports; if (file.resolvedModules) { - for (var name_49 in file.resolvedModules) { - if (!file.resolvedModules[name_49] && !ts.isExternalModuleNameRelative(name_49)) { - var trimmed = name_49.trim(); + for (var name_50 in file.resolvedModules) { + if (!file.resolvedModules[name_50] && !ts.isExternalModuleNameRelative(name_50)) { + var trimmed = name_50.trim(); var i = trimmed.indexOf("/"); if (i !== -1 && trimmed.charCodeAt(0) === 64) { i = trimmed.indexOf("/", i + 1); @@ -64753,15 +65919,10 @@ var ts; var InferredProject = (function (_super) { __extends(InferredProject, _super); function InferredProject(projectService, documentRegistry, compilerOptions) { - var _this = _super.call(this, ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; + var _this = _super.call(this, InferredProject.newName(), ProjectKind.Inferred, projectService, documentRegistry, undefined, true, compilerOptions, false) || this; _this.directoriesWatchedForTsconfig = []; - _this.inferredProjectName = server.makeInferredProjectName(InferredProject.NextId); - InferredProject.NextId++; return _this; } - InferredProject.prototype.getProjectName = function () { - return this.inferredProjectName; - }; InferredProject.prototype.getProjectRootPath = function () { if (this.projectService.useSingleInferredProject) { return undefined; @@ -64776,45 +65937,52 @@ var ts; this.projectService.stopWatchingDirectory(directory); } }; - InferredProject.prototype.getTypingOptions = function () { + InferredProject.prototype.getTypeAcquisition = function () { return { - enableAutoDiscovery: allRootFilesAreJsOrDts(this), + enable: allRootFilesAreJsOrDts(this), include: [], exclude: [] }; }; return InferredProject; }(Project)); - InferredProject.NextId = 1; + InferredProject.newName = (function () { + var nextId = 1; + return function () { + var id = nextId; + nextId++; + return server.makeInferredProjectName(id); + }; + })(); server.InferredProject = InferredProject; var ConfiguredProject = (function (_super) { __extends(ConfiguredProject, _super); function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { - var _this = _super.call(this, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.configFileName = configFileName; + var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; _this.wildcardDirectories = wildcardDirectories; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.openRefCount = 0; + _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } + ConfiguredProject.prototype.getConfigFilePath = function () { + return this.getProjectName(); + }; ConfiguredProject.prototype.getProjectRootPath = function () { - return ts.getDirectoryPath(this.configFileName); + return ts.getDirectoryPath(this.getConfigFilePath()); }; ConfiguredProject.prototype.setProjectErrors = function (projectErrors) { this.projectErrors = projectErrors; }; - ConfiguredProject.prototype.setTypingOptions = function (newTypingOptions) { - this.typingOptions = newTypingOptions; - }; - ConfiguredProject.prototype.getTypingOptions = function () { - return this.typingOptions; + ConfiguredProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { + this.typeAcquisition = newTypeAcquisition; }; - ConfiguredProject.prototype.getProjectName = function () { - return this.configFileName; + ConfiguredProject.prototype.getTypeAcquisition = function () { + return this.typeAcquisition; }; ConfiguredProject.prototype.watchConfigFile = function (callback) { var _this = this; - this.projectFileWatcher = this.projectService.host.watchFile(this.configFileName, function (_) { return callback(_this); }); + this.projectFileWatcher = this.projectService.host.watchFile(this.getConfigFilePath(), function (_) { return callback(_this); }); }; ConfiguredProject.prototype.watchTypeRoots = function (callback) { var _this = this; @@ -64832,7 +66000,7 @@ var ts; if (this.directoryWatcher) { return; } - var directoryToWatch = ts.getDirectoryPath(this.configFileName); + var directoryToWatch = ts.getDirectoryPath(this.getConfigFilePath()); this.projectService.logger.info("Add recursive watcher for: " + directoryToWatch); this.directoryWatcher = this.projectService.host.watchDirectory(directoryToWatch, function (path) { return callback(_this, path); }, true); }; @@ -64841,7 +66009,7 @@ var ts; if (!this.wildcardDirectories) { return; } - var configDirectoryPath = ts.getDirectoryPath(this.configFileName); + var configDirectoryPath = ts.getDirectoryPath(this.getConfigFilePath()); this.directoriesWatchedForWildcards = ts.reduceProperties(this.wildcardDirectories, function (watchers, flag, directory) { if (ts.comparePaths(configDirectoryPath, directory, ".", !_this.projectService.host.useCaseSensitiveFileNames) !== 0) { var recursive = (flag & 1) !== 0; @@ -64891,8 +66059,7 @@ var ts; var ExternalProject = (function (_super) { __extends(ExternalProject, _super); function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { - var _this = _super.call(this, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.externalProjectName = externalProjectName; + var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.projectFilePath = projectFilePath; return _this; @@ -64901,37 +66068,34 @@ var ts; if (this.projectFilePath) { return ts.getDirectoryPath(this.projectFilePath); } - return ts.getDirectoryPath(ts.normalizeSlashes(this.externalProjectName)); + return ts.getDirectoryPath(ts.normalizeSlashes(this.getProjectName())); }; - ExternalProject.prototype.getTypingOptions = function () { - return this.typingOptions; + ExternalProject.prototype.getTypeAcquisition = function () { + return this.typeAcquisition; }; ExternalProject.prototype.setProjectErrors = function (projectErrors) { this.projectErrors = projectErrors; }; - ExternalProject.prototype.setTypingOptions = function (newTypingOptions) { - if (!newTypingOptions) { - newTypingOptions = { - enableAutoDiscovery: allRootFilesAreJsOrDts(this), + ExternalProject.prototype.setTypeAcquisition = function (newTypeAcquisition) { + if (!newTypeAcquisition) { + newTypeAcquisition = { + enable: allRootFilesAreJsOrDts(this), include: [], exclude: [] }; } else { - if (newTypingOptions.enableAutoDiscovery === undefined) { - newTypingOptions.enableAutoDiscovery = allRootFilesAreJsOrDts(this); + if (newTypeAcquisition.enable === undefined) { + newTypeAcquisition.enable = allRootFilesAreJsOrDts(this); } - if (!newTypingOptions.include) { - newTypingOptions.include = []; + if (!newTypeAcquisition.include) { + newTypeAcquisition.include = []; } - if (!newTypingOptions.exclude) { - newTypingOptions.exclude = []; + if (!newTypeAcquisition.exclude) { + newTypeAcquisition.exclude = []; } } - this.typingOptions = newTypingOptions; - }; - ExternalProject.prototype.getProjectName = function () { - return this.externalProjectName; + this.typeAcquisition = newTypeAcquisition; }; return ExternalProject; }(Project)); @@ -65123,7 +66287,7 @@ var ts; } switch (response.kind) { case server.ActionSet: - this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typingOptions, response.unresolvedImports, response.typings); + this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings); break; case server.ActionInvalidate: this.typingsCache.deleteTypingsForProject(response.projectName); @@ -65252,7 +66416,7 @@ var ts; ProjectService.prototype.onTypeRootFileChanged = function (project, fileName) { var _this = this; this.logger.info("Type root file " + fileName + " changed"); - this.throttledOperations.schedule(project.configFileName + " * type root", 250, function () { + this.throttledOperations.schedule(project.getConfigFilePath() + " * type root", 250, function () { project.updateTypes(); _this.updateConfiguredProject(project); _this.refreshInferredProjects(); @@ -65264,11 +66428,11 @@ var ts; return; } this.logger.info("Detected source file changes: " + fileName); - this.throttledOperations.schedule(project.configFileName, 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); + this.throttledOperations.schedule(project.getConfigFilePath(), 250, function () { return _this.handleChangeInSourceFileForConfiguredProject(project, fileName); }); }; ProjectService.prototype.handleChangeInSourceFileForConfiguredProject = function (project, triggerFile) { var _this = this; - var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; this.reportConfigFileDiagnostics(project.getProjectName(), configFileErrors, triggerFile); var newRootFiles = projectOptions.files.map((function (f) { return _this.getCanonicalFileName(f); })); var currentRootFiles = project.getRootFiles().map((function (f) { return _this.getCanonicalFileName(f); })); @@ -65279,8 +66443,10 @@ var ts; } }; ProjectService.prototype.onConfigChangedForConfiguredProject = function (project) { - this.logger.info("Config file changed: " + project.configFileName); - this.updateConfiguredProject(project); + var configFileName = project.getConfigFilePath(); + this.logger.info("Config file changed: " + configFileName); + var configFileErrors = this.updateConfiguredProject(project); + this.reportConfigFileDiagnostics(configFileName, configFileErrors, configFileName); this.refreshInferredProjects(); }; ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { @@ -65466,7 +66632,13 @@ var ts; } }; ProjectService.prototype.findConfiguredProjectByProjectName = function (configFileName) { - return findProjectByName(configFileName, this.configuredProjects); + configFileName = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); + for (var _i = 0, _a = this.configuredProjects; _i < _a.length; _i++) { + var proj = _a[_i]; + if (proj.canonicalConfigFilePath === configFileName) { + return proj; + } + } }; ProjectService.prototype.findExternalProjectByProjectName = function (projectFileName) { return findProjectByName(projectFileName, this.externalProjects); @@ -65496,7 +66668,7 @@ var ts; compilerOptions: parsedCommandLine.options, configHasFilesProperty: config["files"] !== undefined, wildcardDirectories: ts.createMap(parsedCommandLine.wildcardDirectories), - typingOptions: parsedCommandLine.typingOptions, + typeAcquisition: parsedCommandLine.typeAcquisition, compileOnSave: parsedCommandLine.compileOnSave }; return { success: true, projectOptions: projectOptions, configFileErrors: errors }; @@ -65519,10 +66691,10 @@ var ts; } return false; }; - ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typingOptions) { + ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typeAcquisition) { var compilerOptions = convertCompilerOptions(options); var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typingOptions, undefined); + this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typeAcquisition, undefined); this.externalProjects.push(project); return project; }; @@ -65539,7 +66711,7 @@ var ts; var _this = this; var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typingOptions, configFileErrors); + this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); if (!sizeLimitExceeded) { this.watchConfigDirectoryForProject(project, projectOptions); @@ -65555,7 +66727,7 @@ var ts; project.watchConfigDirectory(function (project, path) { return _this.onSourceFileInDirectoryChangedForConfiguredProject(project, path); }); } }; - ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typingOptions, configFileErrors) { + ProjectService.prototype.addFilesToProjectAndUpdateGraph = function (project, files, propertyReader, clientFileName, typeAcquisition, configFileErrors) { var errors; for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { var f = files_4[_i]; @@ -65571,7 +66743,7 @@ var ts; } } project.setProjectErrors(ts.concatenate(configFileErrors, errors)); - project.setTypingOptions(typingOptions); + project.setTypeAcquisition(typeAcquisition); project.updateGraph(); }; ProjectService.prototype.openConfigFile = function (configFileName, clientFileName) { @@ -65586,7 +66758,7 @@ var ts; errors: project.getProjectErrors() }; }; - ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypingOptions, compileOnSave, configFileErrors) { + ProjectService.prototype.updateNonInferredProject = function (project, newUncheckedFiles, propertyReader, newOptions, newTypeAcquisition, compileOnSave, configFileErrors) { var oldRootScriptInfos = project.getRootScriptInfos(); var newRootScriptInfos = []; var newRootScriptInfoMap = server.createNormalizedPathMap(); @@ -65648,7 +66820,7 @@ var ts; } } project.setCompilerOptions(newOptions); - project.setTypingOptions(newTypingOptions); + project.setTypeAcquisition(newTypeAcquisition); if (compileOnSave !== undefined) { project.compileOnSaveEnabled = compileOnSave; } @@ -65656,12 +66828,12 @@ var ts; project.updateGraph(); }; ProjectService.prototype.updateConfiguredProject = function (project) { - if (!this.host.fileExists(project.configFileName)) { + if (!this.host.fileExists(project.getConfigFilePath())) { this.logger.info("Config file deleted"); this.removeProject(project); return; } - var _a = this.convertConfigFileContentToProjectOptions(project.configFileName), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; + var _a = this.convertConfigFileContentToProjectOptions(project.getConfigFilePath()), success = _a.success, projectOptions = _a.projectOptions, configFileErrors = _a.configFileErrors; if (!success) { this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); return configFileErrors; @@ -65669,7 +66841,7 @@ var ts; if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { project.setCompilerOptions(projectOptions.compilerOptions); if (!project.languageServiceEnabled) { - return; + return configFileErrors; } project.disableLanguageService(); project.stopWatchingDirectory(); @@ -65679,8 +66851,9 @@ var ts; project.enableLanguageService(); } this.watchConfigDirectoryForProject(project, projectOptions); - this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typingOptions, projectOptions.compileOnSave, configFileErrors); + this.updateNonInferredProject(project, projectOptions.files, fileNamePropertyReader, projectOptions.compilerOptions, projectOptions.typeAcquisition, projectOptions.compileOnSave, configFileErrors); } + return configFileErrors; }; ProjectService.prototype.createInferredProjectWithRootFileIfNecessary = function (root) { var _this = this; @@ -65910,6 +67083,10 @@ var ts; } }; ProjectService.prototype.openExternalProject = function (proj) { + if (proj.typingOptions && !proj.typeAcquisition) { + var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); + proj.typeAcquisition = typeAcquisition; + } var tsConfigFiles; var rootFiles = []; for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { @@ -65931,7 +67108,7 @@ var ts; var exisingConfigFiles; if (externalProject) { if (!tsConfigFiles) { - this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typingOptions, proj.options.compileOnSave, undefined); + this.updateNonInferredProject(externalProject, proj.rootFiles, externalFilePropertyReader, convertCompilerOptions(proj.options), proj.typeAcquisition, proj.options.compileOnSave, undefined); return; } this.closeExternalProject(proj.projectFileName, true); @@ -65981,7 +67158,7 @@ var ts; } else { delete this.externalProjectToConfiguredProjectMap[proj.projectFileName]; - this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typingOptions); + this.createAndAddExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); } this.refreshInferredProjects(); }; @@ -67059,9 +68236,9 @@ var ts; if (simplifiedResult) { return completions.entries.reduce(function (result, entry) { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - var name_50 = entry.name, kind = entry.kind, kindModifiers = entry.kindModifiers, sortText = entry.sortText, replacementSpan = entry.replacementSpan; + var name_51 = 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_50, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); + result.push({ name: name_51, kind: kind, kindModifiers: kindModifiers, sortText: sortText, replacementSpan: convertedSpan }); } return result; }, []).sort(function (a, b) { return ts.compareStrings(a.name, b.name); }); @@ -68902,7 +70079,7 @@ var ts; if (result.error) { return { options: {}, - typingOptions: {}, + typeAcquisition: {}, files: [], raw: {}, errors: [realizeDiagnostic(result.error, "\r\n")] @@ -68912,7 +70089,7 @@ var ts; var configFile = ts.parseJsonConfigFileContent(result.config, _this.host, ts.getDirectoryPath(normalizedFileName), {}, normalizedFileName); return { options: configFile.options, - typingOptions: configFile.typingOptions, + typeAcquisition: configFile.typeAcquisition, files: configFile.fileNames, raw: configFile.raw, errors: realizeDiagnostics(configFile.errors, "\r\n") @@ -68927,7 +70104,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(false); return this.forwardJSONCall("discoverTypings()", function () { var info = JSON.parse(discoverTypingsJson); - return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typingOptions, info.unresolvedImports); + return ts.JsTyping.discoverTypings(_this.host, info.fileNames, ts.toPath(info.projectRootPath, info.projectRootPath, getCanonicalFileName), ts.toPath(info.safeListPath, info.safeListPath, getCanonicalFileName), info.packageNameToTypingLocation, info.typeAcquisition, info.unresolvedImports); }); }; return CoreServicesShimObject; |