From fc51ca749ce987e0be53fb7c96577a3b82ab617e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 2 Nov 2015 16:41:13 -0800 Subject: [PATCH] Updated LKG. --- lib/tsc.js | 1660 ++++++++++++++++++----------- lib/tsserver.js | 1945 ++++++++++++++++++++-------------- lib/typescript.d.ts | 101 +- lib/typescript.js | 1992 +++++++++++++++++++++-------------- lib/typescriptServices.d.ts | 101 +- lib/typescriptServices.js | 1992 +++++++++++++++++++++-------------- 6 files changed, 4765 insertions(+), 3026 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 511fc67c0a..bbbcedf0f4 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -49,40 +49,49 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -97,8 +106,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -121,8 +130,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -135,8 +144,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -149,8 +158,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -169,8 +178,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -181,8 +190,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -190,8 +199,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -512,8 +521,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -661,8 +670,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -672,8 +681,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -747,8 +756,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -834,16 +843,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -894,6 +903,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); function createWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } @@ -1006,8 +1016,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1021,8 +1031,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1032,14 +1042,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -1306,6 +1309,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -1358,7 +1362,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -1379,7 +1383,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -1669,8 +1673,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -1678,7 +1680,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -1696,6 +1705,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -3082,6 +3095,13 @@ var ts; var ts; (function (ts) { ts.bindTime = 0; + function or(state1, state2) { + return (state1 | state2) & 2 + ? 2 + : (state1 & state2) & 8 + ? 8 + : 4; + } function getModuleInstanceState(node) { if (node.kind === 215 || node.kind === 216) { return 0; @@ -3089,7 +3109,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 2)) { return 0; } else if (node.kind === 219) { @@ -3116,28 +3136,52 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; - var inStrictMode = !!file.externalModuleIndicator; + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -3188,7 +3232,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213: case 214: - return node.flags & 1024 ? "default" : undefined; + return node.flags & 512 ? "default" : undefined; } } function getDisplayName(node) { @@ -3196,7 +3240,7 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024; + var isDefaultExport = node.flags & 512; var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { @@ -3214,7 +3258,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024) { + if (declaration.flags & 512) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -3233,7 +3277,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; if (symbolFlags & 8388608) { if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -3243,7 +3287,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 262144) { + if (hasExportModifier || container.flags & 131072) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -3274,18 +3318,202 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + flags &= ~1572864; + if (kind === 215) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 || kind === 219 || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288; + if (hasExplicitReturn) { + flags |= 1048576; + } + } + if (kind === 215) { + flags = seenThisKeyword ? flags | 262144 : flags & ~262144; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198: + bindWhileStatement(node); + break; + case 197: + bindDoStatement(node); + break; + case 199: + bindForStatement(node); + break; + case 200: + case 201: + bindForInOrForOfStatement(node); + break; + case 196: + bindIfStatement(node); + break; + case 204: + case 208: + bindReturnOrThrow(node); + break; + case 203: + case 202: + bindBreakOrContinueStatement(node); + break; + case 209: + bindTryStatement(node); + break; + case 206: + bindSwitchStatement(node); + break; + case 220: + bindCaseBlock(node); + break; + case 207: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var postWhileState = n.expression.kind === 99 ? 4 : currentReachabilityState; + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 ? 4 : preDoState; + popImplicitLabel(postDoLabel, postDoState); + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + var isInfiniteLoop = (!n.condition || n.condition.kind === 99); + var postForState = isInfiniteLoop ? 4 : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + var ifTrueState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var ifFalseState = n.expression.kind === 99 ? 4 : currentReachabilityState; + currentReachabilityState = ifTrueState; + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + bind(n.expression); + if (n.kind === 204) { + hasExplicitReturn = true; + } + currentReachabilityState = 4; + } + function bindBreakOrContinueStatement(n) { + bind(n.label); + var isValidJump = jumpToLabel(n.label, n.kind === 203 ? currentReachabilityState : 4); + if (isValidJump) { + currentReachabilityState = 4; + } + } + function bindTryStatement(n) { + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242; }); + var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186: @@ -3365,7 +3593,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 + return node.flags & 64 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -3374,15 +3602,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 ? node : node.body; if (body.kind === 248 || body.kind === 219) { @@ -3396,11 +3615,11 @@ var ts; return false; } function setExportContextFlag(node) { - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072; } else { - node.flags &= ~262144; + node.flags &= ~131072; } } function bindModuleDeclaration(node) { @@ -3551,7 +3770,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536) { + if (inStrictMode && node.flags & 32768) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -3569,10 +3788,10 @@ var ts; } function checkStrictModeWithStatement(node) { if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -3580,6 +3799,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -3607,8 +3829,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -3795,7 +4017,7 @@ var ts; else { declareSymbolAndAddToSymbolTable(node, 1, 107455); } - if (node.flags & 112 && + if (node.flags & 56 && node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -3807,6 +4029,95 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4: + var reportError = ts.isStatement(node) || + node.kind === 214 || + (node.kind === 218 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 217 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8; + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 || + ts.getCombinedNodeFlags(node.declarationList) & 24576 || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 || (instanceState === 2 && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); var ts; @@ -3814,8 +4125,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -3985,7 +4296,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -4086,7 +4397,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192) !== 0; + return (file.flags & 4096) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -4116,11 +4427,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768); + return !!(getCombinedNodeFlags(node) & 16384); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384); + return !!(getCombinedNodeFlags(node) & 8192); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -4299,27 +4610,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144: - case 173: - case 213: - case 174: - case 143: - case 142: - case 145: - case 146: - case 147: - case 148: - case 149: - case 152: - case 153: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144: + case 173: + case 213: + case 174: + case 143: + case 142: + case 145: + case 146: + case 147: + case 148: + case 149: + case 152: + case 153: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143: @@ -4783,9 +5095,18 @@ var ts; return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 | 8192)) { + if (node.flags & (4 | 4096)) { return true; } node = node.parent; @@ -4843,7 +5164,7 @@ var ts; case 207: case 204: case 206: - case 98: + case 208: case 209: case 193: case 198: @@ -4942,8 +5263,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -4955,7 +5276,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -5013,7 +5333,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { @@ -5371,7 +5691,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 || member.kind === 146) - && (member.flags & 128) === (accessor.flags & 128)) { + && (member.flags & 64) === (accessor.flags & 64)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -5426,6 +5746,49 @@ var ts; }); } ts.emitComments = emitComments; + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -5490,16 +5853,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113: return 128; - case 112: return 16; - case 111: return 64; - case 110: return 32; - case 115: return 256; - case 82: return 1; - case 122: return 2; - case 74: return 32768; - case 77: return 1024; - case 118: return 512; + case 113: return 64; + case 112: return 8; + case 111: return 32; + case 110: return 16; + case 115: return 128; + case 82: return 2; + case 122: return 4; + case 74: return 16384; + case 77: return 512; + case 118: return 256; } return 0; } @@ -5578,7 +5941,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -5642,6 +6005,12 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !ts.isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); + } + ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -5814,8 +6183,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -6276,8 +6645,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -6308,7 +6677,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; return sourceFile; } @@ -7144,7 +7513,7 @@ var ts; if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536; + node.flags |= 32768; } return node; } @@ -7713,7 +8082,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(arrowFunction.flags & 512); + var isAsync = !!(arrowFunction.flags & 256); var lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 34 || lastToken === 15) @@ -7805,7 +8174,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -8419,7 +8788,7 @@ var ts; var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048; + node.flags |= 1024; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(20); return finishNode(node); @@ -8474,7 +8843,7 @@ var ts; var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048; + node.flags |= 1024; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(16); @@ -8490,7 +8859,7 @@ var ts; parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -9028,10 +9397,10 @@ var ts; case 102: break; case 108: - node.flags |= 16384; + node.flags |= 8192; break; case 74: - node.flags |= 32768; + node.flags |= 16384; break; default: ts.Debug.fail(); @@ -9065,9 +9434,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87); node.asteriskToken = parseOptionalToken(37); - node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -9089,7 +9458,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512); + var isAsync = !!(method.flags & 256); fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -9101,7 +9470,7 @@ var ts; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 128 + property.initializer = modifiers && modifiers.flags & 64 ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 | 1, parseNonParameterInitializer); parseSemicolon(); @@ -9391,13 +9760,13 @@ var ts; } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { var node = createNode(218, fullStart); - var namespaceFlag = flags & 131072; + var namespaceFlag = flags & 65536; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 2 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -9412,7 +9781,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126)) { - flags |= 131072; + flags |= 65536; } else { parseExpected(125); @@ -9626,7 +9995,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 + return node.flags & 2 || node.kind === 221 && node.moduleReference.kind === 232 || node.kind === 222 || node.kind === 227 @@ -10200,8 +10569,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -10273,8 +10642,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -10547,6 +10916,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -10795,7 +11165,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 && - (current.parent.flags & 128) === 0 && + (current.parent.flags & 64) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -10854,7 +11224,7 @@ var ts; break; case 141: case 140: - if (ts.isClassLike(location.parent) && !(location.flags & 128)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -10867,7 +11237,7 @@ var ts; case 186: case 215: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 128) { + if (lastLocation && lastLocation.flags & 64) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } @@ -11301,8 +11671,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } @@ -11508,7 +11878,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1) && + !(anyImportSyntax.flags & 2) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -11638,8 +12008,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -11805,7 +12175,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -11911,8 +12281,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { writePunctuation(writer, 53); @@ -12115,7 +12485,7 @@ var ts; case 217: case 221: var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && + if (!(ts.getCombinedNodeFlags(node) & 2) && !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -12126,7 +12496,7 @@ var ts; case 146: case 143: case 142: - if (node.flags & (32 | 64)) { + if (node.flags & (16 | 32)) { return false; } case 144: @@ -12555,8 +12925,8 @@ var ts; } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -12737,13 +13107,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215) { - if (declaration.flags & 524288) { + if (declaration.flags & 262144) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056, true); if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -12911,23 +13281,23 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; } function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -12935,8 +13305,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -12979,8 +13349,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); @@ -13026,8 +13396,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -13055,8 +13425,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -13110,8 +13480,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -13275,12 +13645,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 | 32))) { if (!props) { props = [prop]; } @@ -13301,8 +13671,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -13635,8 +14005,8 @@ var ts; } function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064; @@ -13757,8 +14127,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214: case 215: @@ -13856,8 +14226,8 @@ var ts; } } function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -13879,8 +14249,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -13983,7 +14353,8 @@ var ts; var container = ts.getThisContainer(node, false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { - if (!(container.flags & 128)) { + if (!(container.flags & 64) && + (container.kind !== 144 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -14048,8 +14419,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -14088,8 +14459,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -14454,8 +14825,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0; @@ -14477,8 +14848,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -14500,8 +14871,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0; @@ -14614,8 +14985,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -14629,20 +15000,20 @@ var ts; else if (!(targetProp.flags & 134217728)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 || targetPropFlags & 32) { + if (sourcePropFlags & 16 || targetPropFlags & 16) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 && targetPropFlags & 32) { + if (sourcePropFlags & 16 && targetPropFlags & 16) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 ? source : target), typeToString(sourcePropFlags & 16 ? target : source)); } } return 0; } } - else if (targetPropFlags & 64) { + else if (targetPropFlags & 32) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -14653,7 +15024,7 @@ var ts; return 0; } } - else if (sourcePropFlags & 64) { + else if (sourcePropFlags & 32) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -14688,8 +15059,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -14721,13 +15092,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -14755,8 +15126,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); @@ -14957,8 +15328,8 @@ var ts; if (sourceProp === targetProp) { return -1; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 | 32); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 | 32); if (sourcePropAccessibility !== targetPropAccessibility) { return 0; } @@ -15024,8 +15395,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -15238,8 +15609,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -15305,8 +15676,8 @@ var ts; var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -15323,8 +15694,8 @@ var ts; } else if (source.flags & 49152) { var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -15357,8 +15728,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -15849,7 +16220,7 @@ var ts; break; case 141: case 140: - if (container.flags & 128) { + if (container.flags & 64) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -15862,7 +16233,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -15890,7 +16261,7 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (canUseSuperExpression) { - if ((container.flags & 128) || isCallExpression) { + if ((container.flags & 64) || isCallExpression) { nodeCheckFlag = 512; } else { @@ -15935,7 +16306,7 @@ var ts; } else { if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128) { + if (container.flags & 64) { return container.kind === 143 || container.kind === 142 || container.kind === 145 || @@ -16074,8 +16445,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -16239,8 +16610,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -16291,8 +16662,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || @@ -16551,8 +16922,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; if (!nameTable[prop.name]) { var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { @@ -16721,7 +17092,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -16788,7 +17158,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); @@ -16801,17 +17171,17 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256) { + if (flags & 128) { error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); return false; } } - if (!(flags & (32 | 64))) { + if (!(flags & (16 | 32))) { return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 32) { + if (flags & 16) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -16825,7 +17195,7 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); return false; } - if (flags & 128) { + if (flags & 64) { return true; } if (type.flags & 33554432) { @@ -17005,8 +17375,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -17417,8 +17787,8 @@ var ts; reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -17437,8 +17807,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -17541,7 +17911,7 @@ var ts; return resolveErrorCall(node); } var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256) { + if (valueDecl && valueDecl.flags & 128) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -17827,32 +18197,24 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208); - } - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 || !(func.flags & 524288)) { return; } - var bodyBlock = func.body; - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); @@ -17911,7 +18273,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -17970,7 +18332,7 @@ var ts; case 69: case 166: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; } case 167: { var index = n.argumentExpression; @@ -17978,7 +18340,7 @@ var ts; if (symbol && index && index.kind === 9) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384) !== 0; } return false; } @@ -18058,8 +18420,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -18074,8 +18436,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -18110,8 +18472,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 || p.kind === 246) { var name_13 = p.name; var type = isTypeAny(sourceType) @@ -18573,7 +18935,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112) { + if (node.flags & 56) { func = ts.getContainingFunction(node); if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -18754,7 +19116,7 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionLikeDeclaration(node); - if (node.flags & 256 && node.body) { + if (node.flags & 128 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -18801,7 +19163,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 && - !(n.flags & 128) && + !(n.flags & 64) && !!n.initializer; } var containingClassDecl = node.parent; @@ -18814,12 +19176,12 @@ var ts; error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 | 16 | 32); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -18845,15 +19207,22 @@ var ts; if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { + if (node.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112) !== (otherAccessor.flags & 112))) { + if (((node.flags & 56) !== (otherAccessor.flags & 56))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -18920,7 +19289,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32) && ts.isInAmbientContext(node); + return (node.flags & 16) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -18945,8 +19314,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -18959,10 +19328,10 @@ var ts; n.parent.kind !== 214 && n.parent.kind !== 186 && ts.isInAmbientContext(n)) { - if (!(flags & 2)) { - flags |= 1; + if (!(flags & 4)) { + flags |= 2; } - flags |= 2; + flags |= 4; } return flags & flagsToCheck; } @@ -18980,16 +19349,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1) { + if (deviation & 2) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2) { + else if (deviation & 4) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 | 64)) { + else if (deviation & (16 | 32)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256) { + else if (deviation & 128) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -19006,7 +19375,7 @@ var ts; }); } } - var flagsToCheck = 1 | 2 | 32 | 64 | 256; + var flagsToCheck = 2 | 4 | 16 | 32 | 128; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -19035,8 +19404,8 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { ts.Debug.assert(node.kind === 143 || node.kind === 142); - ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); - var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64) !== (subsequentNode.flags & 64)); + var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -19051,7 +19420,7 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - if (node.flags & 256) { + if (node.flags & 128) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -19062,8 +19431,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; @@ -19112,7 +19481,7 @@ var ts; }); } if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256)) { + !(lastSeenNonAmbientDeclaration.flags & 128)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -19122,8 +19491,8 @@ var ts; var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); if (!bodySignature.hasStringLiterals) { - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -19153,9 +19522,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); - if (effectiveDeclarationFlags & 1) { - if (effectiveDeclarationFlags & 1024) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 | 512); + if (effectiveDeclarationFlags & 2) { + if (effectiveDeclarationFlags & 512) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -19291,9 +19660,12 @@ var ts; if (promiseType === unknownType && compilerOptions.isolatedModules) { return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } var promiseConstructorType = getTypeOfSymbol(promiseConstructor); @@ -19452,7 +19824,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { @@ -19555,7 +19927,7 @@ var ts; } } function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { return; } if (node.kind === 211 && !node.initializer) { @@ -19567,7 +19939,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent @@ -19694,6 +20066,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -19943,7 +20318,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -20073,7 +20448,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { + if (!(member.flags & 64) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -20149,7 +20524,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024)) { + if (!node.name && !(node.flags & 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -20199,8 +20574,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -20232,8 +20607,8 @@ var ts; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728) { continue; @@ -20244,7 +20619,7 @@ var ts; if (derived) { if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -20255,10 +20630,10 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + if ((baseDeclarationFlags & 16) || (derivedDeclarationFlags & 16)) { continue; } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + if ((baseDeclarationFlags & 64) !== (derivedDeclarationFlags & 64)) { continue; } if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { @@ -20324,11 +20699,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -20597,8 +20972,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 || (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -20726,7 +21101,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -20753,7 +21128,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1) { + if (node.flags & 2) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -20781,7 +21156,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -20820,7 +21195,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69) { @@ -21205,7 +21580,7 @@ var ts; } case 214: case 215: - if (!(memberFlags & 128)) { + if (!(memberFlags & 64)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; @@ -21467,7 +21842,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 + return node.flags & 64 ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -21753,7 +22128,7 @@ var ts; } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalModule(file)) { @@ -21897,19 +22272,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112) { + if (flags & 56) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128) { + else if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256) { + else if (flags & 128) { if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -21920,10 +22295,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113: - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { @@ -21932,23 +22307,23 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128; + flags |= 64; lastStatic = modifier; break; case 82: - if (flags & 1) { + if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2) { + else if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214) { @@ -21957,13 +22332,13 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1; + flags |= 2; break; case 122: - if (flags & 2) { + if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.parent.kind === 214) { @@ -21975,69 +22350,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2; + flags |= 4; lastDeclare = modifier; break; case 115: - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214) { if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32) { + if (flags & 16) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256; + flags |= 128; break; case 118: - if (flags & 512) { + if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512; + flags |= 256; lastAsync = modifier; break; } } if (node.kind === 144) { - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64) { + else if (flags & 32) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32) { + else if (flags & 16) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 || node.kind === 221) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 4) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 56) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512) { + if (flags & 256) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -22137,7 +22512,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035) { + if (parameter.flags & 1022) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -22157,7 +22532,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035) { + if (node.flags & 1022) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -22179,8 +22554,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -22420,7 +22795,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035) { + else if (parameter.flags & 1022) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -22554,8 +22929,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -22674,8 +23049,8 @@ var ts; node.kind === 221 || node.kind === 228 || node.kind === 227 || - (node.flags & 2) || - (node.flags & (1 | 1024))) { + (node.flags & 4) || + (node.flags & (2 | 512))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -22713,7 +23088,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 65536 && languageVersion >= 1) { + if (node.flags & 32768 && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -22760,7 +23135,7 @@ var ts; var addedGlobalFileReference = false; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 8192) || + if (referencedFile && ((referencedFile.flags & 4096) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -22938,15 +23313,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -23088,6 +23463,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true); emitLines(node.statements); } function getExportDefaultTempVariableName() { @@ -23194,10 +23570,10 @@ var ts; } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } else if (node.kind !== 215) { @@ -23206,22 +23582,22 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32) { + if (node.flags & 16) { write("private "); } - else if (node.flags & 64) { + else if (node.flags & 32) { write("protected "); } - if (node.flags & 128) { + if (node.flags & 64) { write("static "); } - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23256,11 +23632,11 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1)) { + if (!node.importClause && !(node.flags & 2)) { return; } emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23322,7 +23698,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072) { + if (node.flags & 65536) { write("namespace "); } else { @@ -23394,7 +23770,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 16); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23436,7 +23812,7 @@ var ts; break; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } else if (node.parent.parent.kind === 214) { @@ -23499,7 +23875,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { emitPropertyDeclaration(param); } }); @@ -23507,7 +23883,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } write("class "); @@ -23571,7 +23947,7 @@ var ts; if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32)) { + else if (!(node.flags & 16)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -23585,7 +23961,7 @@ var ts; ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } else if (node.kind === 141 || node.kind === 140) { - if (node.flags & 128) { + if (node.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -23680,7 +24056,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32)) { + if (!(node.flags & 16)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -23707,7 +24083,7 @@ var ts; function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146) { - if (accessorWithTypeAnnotation.parent.flags & 128) { + if (accessorWithTypeAnnotation.parent.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -23724,7 +24100,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128) { + if (accessorWithTypeAnnotation.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23805,7 +24181,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 16)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -23833,7 +24209,7 @@ var ts; break; case 143: case 142: - if (node.flags & 128) { + if (node.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -23890,7 +24266,7 @@ var ts; node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32)) { + else if (!(node.parent.flags & 16)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -23919,7 +24295,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24035,7 +24411,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 + var declFileName = referencedFile.flags & 4096 ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") @@ -24368,16 +24744,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { return false; @@ -25670,7 +26038,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, (node.flags & 1024) !== 0, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -25685,7 +26053,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; if (!multiLine) { write(" "); } @@ -25704,7 +26072,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -26222,7 +26590,7 @@ var ts; var current = node; while (current) { if (current.kind === 248) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219) { return false; @@ -26440,7 +26808,7 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576) === 0) { for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { var varDecl = _b[_a]; hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); @@ -26522,7 +26890,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576)) { loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; @@ -26779,22 +27147,22 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 69; var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var rhsReference = ts.createSynthesizedNode(69); + rhsReference.text = node.expression.kind === 69 ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0); emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); emitStart(node.initializer); emitNodeWithoutSourceMap(counter); @@ -27029,7 +27397,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { + if (ts.getCombinedNodeFlags(node) & 2) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -27051,7 +27419,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + ts.Debug.assert(!!(node.flags & 512) || node.kind === 227); if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1) { @@ -27067,12 +27435,12 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1) { + if (node.flags & 2) { writeLine(); emitStart(node); if (modulekind === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { + if (node.flags & 512) { write("default"); } else { @@ -27083,7 +27451,7 @@ var ts; write(")"); } else { - if (node.flags & 1024) { + if (node.flags & 512) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); @@ -27171,7 +27539,7 @@ var ts; var emitCount = 0; var canDefineTempVariablesInPlace = false; if (root.kind === 211) { - var isExported = ts.getCombinedNodeFlags(root) & 1; + var isExported = ts.getCombinedNodeFlags(root) & 2; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -27237,8 +27605,8 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value, true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 || p.kind === 246) { var propName = p.name; var target_1 = p.kind === 246 ? p : p.initializer || propName; @@ -27357,7 +27725,7 @@ var ts; var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); + (getCombinedFlagsForIdentifier(node.name) & 8192); if (isLetDefinedInLoop && node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { @@ -27396,13 +27764,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && + return !!(node.flags & 2) && modulekind === 5 && node.parent.kind === 248; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1) { + if (node.flags & 2) { if (isES6ExportedDeclaration(node)) { write("export "); startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); @@ -27426,7 +27794,7 @@ var ts; } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { + if (!(node.flags & 2)) { return true; } if (isES6ExportedDeclaration(node)) { @@ -27583,7 +27951,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -27722,7 +28090,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { + if (languageVersion < 2 || node.flags & 256) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -27738,7 +28106,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -27774,7 +28142,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); var startIndex = emitDirectivePrologues(body.statements, true); emitFunctionBodyPreamble(node); decreaseIndent(); @@ -27816,7 +28184,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { writeLine(); emitStart(param); emitStart(param.name); @@ -27848,15 +28216,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 141 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -27869,7 +28237,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128) { + if (property.flags & 64) { emitDeclarationName(node); } else { @@ -27968,7 +28336,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128) { + if (member.flags & 64) { write("static "); } if (member.kind === 145) { @@ -28013,7 +28381,7 @@ var ts; if (member.kind === 144 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 141 && member.initializer && (member.flags & 64) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28050,7 +28418,7 @@ var ts; increaseIndent(); if (ctor) { startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -28121,7 +28489,7 @@ var ts; var thisNodeIsDecorated = ts.nodeIsDecorated(node); if (node.kind === 214) { if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); } write("let "); @@ -28130,7 +28498,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -28146,7 +28514,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -28169,8 +28537,8 @@ var ts; write(";"); } if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, tempVariable, true); @@ -28186,7 +28554,7 @@ var ts; emitPropertyDeclarations(node, staticProperties); emitDecoratorsOfClass(node); } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -28195,7 +28563,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512) && thisNodeIsDecorated) { writeLine(); write("export default "); emitDeclarationName(node); @@ -28275,13 +28643,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128)) { + if (!(member.flags & 64)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfMembers(node, 64); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -28316,7 +28684,7 @@ var ts; function emitDecoratorsOfMembers(node, staticFlag) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { + if ((member.flags & 64) !== staticFlag) { continue; } if (!ts.nodeCanBeDecorated(member)) { @@ -28643,7 +29011,7 @@ var ts; return; } if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -28674,7 +29042,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -28685,7 +29053,7 @@ var ts; write(";"); } if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28787,7 +29155,7 @@ var ts; scopeEmitEnd(); } write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -28797,7 +29165,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -28895,7 +29263,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 221 && (node.flags & 2) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2) { emitLeadingComments(node); @@ -28961,7 +29329,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1)) { + else if (!(node.flags & 2)) { write("var "); } } @@ -29049,8 +29417,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -29184,8 +29552,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; var skipNode = importNode.kind === 228 || (importNode.kind === 222 && !importNode.importClause); if (skipNode) { @@ -29210,8 +29578,8 @@ var ts; } if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -29239,8 +29607,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228) { continue; } @@ -29284,7 +29652,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 69 && node.flags & 1024) { + if (node.kind !== 69 && node.flags & 512) { return; } if (started) { @@ -29337,7 +29705,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 1) { + if (flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29347,11 +29715,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1) { + if (f.flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29361,7 +29729,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2) { + if (node.flags & 4) { return; } if (node.kind === 213) { @@ -29431,7 +29799,7 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248; } function isCurrentFileSystemExternalModule() { @@ -29466,8 +29834,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222: @@ -29601,8 +29969,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; var externalModuleName = getExternalModuleNameText(importNode); var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { @@ -29855,7 +30223,7 @@ var ts; function emitSourceFileNode(node) { writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; emitModule(node); @@ -29878,7 +30246,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2) { + if (node.flags & 4) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -30111,10 +30479,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } function isTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && comment.pos + 2 < comment.end && @@ -30195,44 +30559,14 @@ var ts; ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -30535,7 +30869,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { var oldOptions = oldProgram.getCompilerOptions(); @@ -30583,8 +30917,8 @@ var ts; if (!classifiableNames) { getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -30600,7 +30934,7 @@ var ts; return false; } var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -30608,8 +30942,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { return false; @@ -30623,7 +30957,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); @@ -30646,12 +30980,12 @@ var ts; newSourceFiles.push(newSourceFile); } for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -30690,7 +31024,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -30799,7 +31133,7 @@ var ts; } break; case 218: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 && (node.flags & 4 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { collect(node, false); }); @@ -30816,7 +31150,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -30826,13 +31160,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -30874,6 +31208,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); if (existingFile) { @@ -30918,11 +31253,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -30973,8 +31304,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -31231,6 +31562,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -31329,11 +31666,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, { name: "forceConsistentCasingInFileNames", type: "boolean", description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, + } ]; var optionNameMapCache; function getOptionNameMap() { @@ -31459,13 +31816,31 @@ var ts; ts.readConfigFile = readConfigFile; function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } function parseJsonConfigFileContent(json, host, basePath) { var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; return { @@ -31554,6 +31929,13 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { + var reportDiagnostic = reportDiagnosticSimply; + function reportDiagnostics(diagnostics, host) { + for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) { + var diagnostic = diagnostics_1[_i]; + reportDiagnostic(diagnostic, host); + } + } function validateLocaleAndSetLanguage(locale, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { @@ -31612,20 +31994,84 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - function reportDiagnostic(diagnostic) { + function reportDiagnosticSimply(diagnostic, host) { var output = ""; if (diagnostic.file) { - var loc = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); - output += diagnostic.file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + "): "; + var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; + var relativeFileName = host + ? ts.convertToRelativePath(diagnostic.file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) + : diagnostic.file.fileName; + output += diagnostic.file.fileName + "(" + (line + 1) + "," + (character + 1) + "): "; } var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); output += category + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine) + ts.sys.newLine; ts.sys.write(output); } - function reportDiagnostics(diagnostics) { - for (var i = 0; i < diagnostics.length; i++) { - reportDiagnostic(diagnostics[i]); + var redForegroundEscapeSequence = "\u001b[91m"; + var yellowForegroundEscapeSequence = "\u001b[93m"; + var blueForegroundEscapeSequence = "\u001b[93m"; + var gutterStyleSequence = "\u001b[100;30m"; + var gutterSeparator = " "; + var resetEscapeSequence = "\u001b[0m"; + var elipsis = "..."; + var categoryFormatMap = (_a = {}, + _a[ts.DiagnosticCategory.Warning] = yellowForegroundEscapeSequence, + _a[ts.DiagnosticCategory.Error] = redForegroundEscapeSequence, + _a[ts.DiagnosticCategory.Message] = blueForegroundEscapeSequence, + _a + ); + function formatAndReset(text, formatStyle) { + return formatStyle + text + resetEscapeSequence; + } + function reportDiagnosticWithColorAndContext(diagnostic, host) { + var output = ""; + if (diagnostic.file) { + var start = diagnostic.start, length_3 = diagnostic.length, file = diagnostic.file; + var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_3), lastLine = _b.line, lastLineChar = _b.character; + var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; + var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; + var gutterWidth = (lastLine + 1 + "").length; + if (hasMoreThanFiveLines) { + gutterWidth = Math.max(elipsis.length, gutterWidth); + } + output += ts.sys.newLine; + for (var i = firstLine; i <= lastLine; i++) { + if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { + output += formatAndReset(padLeft(elipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + i = lastLine - 1; + } + var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); + var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; + var lineContent = file.text.slice(lineStart, lineEnd); + lineContent = lineContent.replace(/\s+$/g, ""); + lineContent = lineContent.replace("\t", " "); + output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; + output += lineContent + ts.sys.newLine; + output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; + output += redForegroundEscapeSequence; + if (i === firstLine) { + var lastCharForLine = i === lastLine ? lastLineChar : undefined; + output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); + output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); + } + else if (i === lastLine) { + output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); + } + else { + output += lineContent.replace(/./g, "~"); + } + output += resetEscapeSequence; + output += ts.sys.newLine; + } + output += ts.sys.newLine; + output += file.fileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } + var categoryColor = categoryFormatMap[diagnostic.category]; + var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); + output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); + output += ts.sys.newLine + ts.sys.newLine; + ts.sys.write(output); } function reportWatchDiagnostic(diagnostic) { var output = new Date().toLocaleTimeString() + " - "; @@ -31677,13 +32123,13 @@ var ts; var hostFileExists; if (commandLine.options.locale) { if (!isJSONSupported()) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale")); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--locale"), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } validateLocaleAndSetLanguage(commandLine.options.locale, commandLine.errors); } if (commandLine.errors.length > 0) { - reportDiagnostics(commandLine.errors); + reportDiagnostics(commandLine.errors, compilerHost); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (commandLine.options.init) { @@ -31691,7 +32137,7 @@ var ts; return ts.sys.exit(ts.ExitStatus.Success); } if (commandLine.options.version) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Version_0, ts.version), undefined); return ts.sys.exit(ts.ExitStatus.Success); } if (commandLine.options.help) { @@ -31701,12 +32147,12 @@ var ts; } if (commandLine.options.project) { if (!isJSONSupported()) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--project")); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--project"), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } configFileName = ts.normalizePath(ts.combinePaths(commandLine.options.project, "tsconfig.json")); if (commandLine.fileNames.length !== 0) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } } @@ -31721,7 +32167,7 @@ var ts; } if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!ts.sys.watchFile) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"), undefined); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { @@ -31749,7 +32195,7 @@ var ts; var configObject = result.config; var configParseResult = ts.parseJsonConfigFileContent(configObject, ts.sys, ts.getDirectoryPath(configFileName)); if (configParseResult.errors.length > 0) { - reportDiagnostics(configParseResult.errors); + reportDiagnostics(configParseResult.errors, undefined); ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); return; } @@ -31772,6 +32218,9 @@ var ts; hostFileExists = compilerHost.fileExists; compilerHost.fileExists = cachedFileExists; } + if (compilerOptions.pretty) { + reportDiagnostic = reportDiagnosticWithColorAndContext; + } cachedExistingFiles = {}; var compileResult = compile(rootFileNames, compilerOptions, compilerHost); if (!compilerOptions.watch) { @@ -31906,14 +32355,14 @@ var ts; diagnostics = program.getSemanticDiagnostics(); } } - reportDiagnostics(diagnostics); + reportDiagnostics(diagnostics, compilerHost); if (compilerOptions.noEmit) { return diagnostics.length ? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : ts.ExitStatus.Success; } var emitOutput = program.emit(); - reportDiagnostics(emitOutput.diagnostics); + reportDiagnostics(emitOutput.diagnostics, compilerHost); if (emitOutput.emitSkipped) { return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } @@ -31988,7 +32437,7 @@ var ts; var currentDirectory = ts.sys.getCurrentDirectory(); var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json")); if (ts.sys.fileExists(file)) { - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), undefined); } else { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); @@ -32000,7 +32449,7 @@ var ts; configurations.files = fileNames; } ts.sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); - reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file), undefined); } return; function serializeCompilerOptions(options) { @@ -32039,5 +32488,6 @@ var ts; return result; } } + var _a; })(ts || (ts = {})); ts.executeCommandLine(ts.sys.args); diff --git a/lib/tsserver.js b/lib/tsserver.js index ed62dd9068..2893dab82e 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -49,40 +49,49 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -97,8 +106,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -121,8 +130,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -135,8 +144,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -149,8 +158,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -169,8 +178,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -181,8 +190,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -190,8 +199,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -512,8 +521,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -661,8 +670,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -672,8 +681,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -747,8 +756,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -834,16 +843,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -894,6 +903,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); function createWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } if (chunkSize === void 0) { chunkSize = 30; } @@ -1006,8 +1016,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1021,8 +1031,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1032,14 +1042,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -1306,6 +1309,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -1358,7 +1362,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -1379,7 +1383,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -1669,8 +1673,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -1678,7 +1680,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -1696,6 +1705,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -3225,6 +3238,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -3323,11 +3342,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, { name: "forceConsistentCasingInFileNames", type: "boolean", description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, + } ]; var optionNameMapCache; function getOptionNameMap() { @@ -3453,13 +3492,31 @@ var ts; ts.readConfigFile = readConfigFile; function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1, false, 0, jsonText); + var token; + while ((token = scanner.scan()) !== 1) { + switch (token) { + case 2: + case 3: + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } function parseJsonConfigFileContent(json, host, basePath) { var _a = convertCompilerOptionsFromJson(json["compilerOptions"], basePath), options = _a.options, errors = _a.errors; return { @@ -3551,8 +3608,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -3722,7 +3779,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -3823,7 +3880,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192) !== 0; + return (file.flags & 4096) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -3853,11 +3910,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768); + return !!(getCombinedNodeFlags(node) & 16384); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384); + return !!(getCombinedNodeFlags(node) & 8192); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -4036,27 +4093,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144: - case 173: - case 213: - case 174: - case 143: - case 142: - case 145: - case 146: - case 147: - case 148: - case 149: - case 152: - case 153: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144: + case 173: + case 213: + case 174: + case 143: + case 142: + case 145: + case 146: + case 147: + case 148: + case 149: + case 152: + case 153: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143: @@ -4520,9 +4578,18 @@ var ts; return !!node && (node.kind === 162 || node.kind === 161); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 | 8192)) { + if (node.flags & (4 | 4096)) { return true; } node = node.parent; @@ -4580,7 +4647,7 @@ var ts; case 207: case 204: case 206: - case 98: + case 208: case 209: case 193: case 198: @@ -4679,8 +4746,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -4692,7 +4759,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -4750,7 +4816,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { @@ -5108,7 +5174,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 || member.kind === 146) - && (member.flags & 128) === (accessor.flags & 128)) { + && (member.flags & 64) === (accessor.flags & 64)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -5163,6 +5229,49 @@ var ts; }); } ts.emitComments = emitComments; + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -5227,16 +5336,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113: return 128; - case 112: return 16; - case 111: return 64; - case 110: return 32; - case 115: return 256; - case 82: return 1; - case 122: return 2; - case 74: return 32768; - case 77: return 1024; - case 118: return 512; + case 113: return 64; + case 112: return 8; + case 111: return 32; + case 110: return 16; + case 115: return 128; + case 82: return 2; + case 122: return 4; + case 74: return 16384; + case 77: return 512; + case 118: return 256; } return 0; } @@ -5315,7 +5424,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -5379,6 +5488,12 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !ts.isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); + } + ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -5551,8 +5666,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -6013,8 +6128,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -6045,7 +6160,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; return sourceFile; } @@ -6881,7 +6996,7 @@ var ts; if (node.kind === 8 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536; + node.flags |= 32768; } return node; } @@ -7450,7 +7565,7 @@ var ts; if (!arrowFunction) { return undefined; } - var isAsync = !!(arrowFunction.flags & 512); + var isAsync = !!(arrowFunction.flags & 256); var lastToken = token; arrowFunction.equalsGreaterThanToken = parseExpectedToken(34, false, ts.Diagnostics._0_expected, "=>"); arrowFunction.body = (lastToken === 34 || lastToken === 15) @@ -7542,7 +7657,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; @@ -8156,7 +8271,7 @@ var ts; var node = createNode(164); parseExpected(19); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048; + node.flags |= 1024; node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(20); return finishNode(node); @@ -8211,7 +8326,7 @@ var ts; var node = createNode(165); parseExpected(15); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048; + node.flags |= 1024; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(16); @@ -8227,7 +8342,7 @@ var ts; parseExpected(87); node.asteriskToken = parseOptionalToken(37); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -8765,10 +8880,10 @@ var ts; case 102: break; case 108: - node.flags |= 16384; + node.flags |= 8192; break; case 74: - node.flags |= 32768; + node.flags |= 16384; break; default: ts.Debug.fail(); @@ -8802,9 +8917,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87); node.asteriskToken = parseOptionalToken(37); - node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512); + var isAsync = !!(node.flags & 256); fillSignature(54, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -8826,7 +8941,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512); + var isAsync = !!(method.flags & 256); fillSignature(54, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -8838,7 +8953,7 @@ var ts; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - property.initializer = modifiers && modifiers.flags & 128 + property.initializer = modifiers && modifiers.flags & 64 ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 | 1, parseNonParameterInitializer); parseSemicolon(); @@ -9128,13 +9243,13 @@ var ts; } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { var node = createNode(218, fullStart); - var namespaceFlag = flags & 131072; + var namespaceFlag = flags & 65536; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21) - ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 1 | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 2 | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -9149,7 +9264,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126)) { - flags |= 131072; + flags |= 65536; } else { parseExpected(125); @@ -9363,7 +9478,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 + return node.flags & 2 || node.kind === 221 && node.moduleReference.kind === 232 || node.kind === 222 || node.kind === 227 @@ -9937,8 +10052,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -10010,8 +10125,8 @@ var ts; array.intersectsChange = true; array._children = undefined; adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -10164,6 +10279,13 @@ var ts; var ts; (function (ts) { ts.bindTime = 0; + function or(state1, state2) { + return (state1 | state2) & 2 + ? 2 + : (state1 & state2) & 8 + ? 8 + : 4; + } function getModuleInstanceState(node) { if (node.kind === 215 || node.kind === 216) { return 0; @@ -10171,7 +10293,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 1)) { + else if ((node.kind === 222 || node.kind === 221) && !(node.flags & 2)) { return 0; } else if (node.kind === 219) { @@ -10198,28 +10320,52 @@ var ts; } } ts.getModuleInstanceState = getModuleInstanceState; - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; - var inStrictMode = !!file.externalModuleIndicator; + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -10270,7 +10416,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213: case 214: - return node.flags & 1024 ? "default" : undefined; + return node.flags & 512 ? "default" : undefined; } } function getDisplayName(node) { @@ -10278,7 +10424,7 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024; + var isDefaultExport = node.flags & 512; var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { @@ -10296,7 +10442,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024) { + if (declaration.flags & 512) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -10315,7 +10461,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2; if (symbolFlags & 8388608) { if (node.kind === 230 || (node.kind === 221 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -10325,7 +10471,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 262144) { + if (hasExportModifier || container.flags & 131072) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -10356,18 +10502,202 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + flags &= ~1572864; + if (kind === 215) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 : node.flags & ~524288; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 || kind === 219 || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288; + if (hasExplicitReturn) { + flags |= 1048576; + } + } + if (kind === 215) { + flags = seenThisKeyword ? flags | 262144 : flags & ~262144; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198: + bindWhileStatement(node); + break; + case 197: + bindDoStatement(node); + break; + case 199: + bindForStatement(node); + break; + case 200: + case 201: + bindForInOrForOfStatement(node); + break; + case 196: + bindIfStatement(node); + break; + case 204: + case 208: + bindReturnOrThrow(node); + break; + case 203: + case 202: + bindBreakOrContinueStatement(node); + break; + case 209: + bindTryStatement(node); + break; + case 206: + bindSwitchStatement(node); + break; + case 220: + bindCaseBlock(node); + break; + case 207: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var postWhileState = n.expression.kind === 99 ? 4 : currentReachabilityState; + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 ? 4 : preDoState; + popImplicitLabel(postDoLabel, postDoState); + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + var isInfiniteLoop = (!n.condition || n.condition.kind === 99); + var postForState = isInfiniteLoop ? 4 : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + var ifTrueState = n.expression.kind === 84 ? 4 : currentReachabilityState; + var ifFalseState = n.expression.kind === 99 ? 4 : currentReachabilityState; + currentReachabilityState = ifTrueState; + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + bind(n.expression); + if (n.kind === 204) { + hasExplicitReturn = true; + } + currentReachabilityState = 4; + } + function bindBreakOrContinueStatement(n) { + bind(n.label); + var isValidJump = jumpToLabel(n.label, n.kind === 203 ? currentReachabilityState : 4); + if (isValidJump) { + currentReachabilityState = 4; + } + } + function bindTryStatement(n) { + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242; }); + var postSwitchState = hasDefault && currentReachabilityState !== 2 ? 4 : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186: @@ -10447,7 +10777,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 + return node.flags & 64 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -10456,15 +10786,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 ? node : node.body; if (body.kind === 248 || body.kind === 219) { @@ -10478,11 +10799,11 @@ var ts; return false; } function setExportContextFlag(node) { - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072; } else { - node.flags &= ~262144; + node.flags &= ~131072; } } function bindModuleDeclaration(node) { @@ -10633,7 +10954,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536) { + if (inStrictMode && node.flags & 32768) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -10651,10 +10972,10 @@ var ts; } function checkStrictModeWithStatement(node) { if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -10662,6 +10983,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -10689,8 +11013,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -10877,7 +11201,7 @@ var ts; else { declareSymbolAndAddToSymbolTable(node, 1, 107455); } - if (node.flags & 112 && + if (node.flags & 56 && node.parent.kind === 144 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -10889,6 +11213,95 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4: + var reportError = ts.isStatement(node) || + node.kind === 214 || + (node.kind === 218 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 217 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8; + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 || + ts.getCombinedNodeFlags(node.declarationList) & 24576 || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 || (instanceState === 2 && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); var ts; @@ -11014,6 +11427,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -11262,7 +11676,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 && - (current.parent.flags & 128) === 0 && + (current.parent.flags & 64) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -11321,7 +11735,7 @@ var ts; break; case 141: case 140: - if (ts.isClassLike(location.parent) && !(location.flags & 128)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455)) { @@ -11334,7 +11748,7 @@ var ts; case 186: case 215: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056)) { - if (lastLocation && lastLocation.flags & 128) { + if (lastLocation && lastLocation.flags & 64) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; } @@ -11768,8 +12182,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 && ts.nodeIsPresent(member.body)) { return member; } @@ -11975,7 +12389,7 @@ var ts; if (!isDeclarationVisible(declaration)) { var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1) && + !(anyImportSyntax.flags & 2) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -12105,8 +12519,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -12272,7 +12686,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -12378,8 +12792,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { writePunctuation(writer, 53); @@ -12582,7 +12996,7 @@ var ts; case 217: case 221: var parent_4 = getDeclarationContainer(node); - if (!(ts.getCombinedNodeFlags(node) & 1) && + if (!(ts.getCombinedNodeFlags(node) & 2) && !(node.kind !== 221 && parent_4.kind !== 248 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -12593,7 +13007,7 @@ var ts; case 146: case 143: case 142: - if (node.flags & (32 | 64)) { + if (node.flags & (16 | 32)) { return false; } case 144: @@ -13022,8 +13436,8 @@ var ts; } } function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -13204,13 +13618,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215) { - if (declaration.flags & 524288) { + if (declaration.flags & 262144) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056, true); if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -13378,23 +13792,23 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; } function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -13402,8 +13816,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -13446,8 +13860,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); @@ -13493,8 +13907,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -13522,8 +13936,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -13577,8 +13991,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -13742,12 +14156,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 | 32))) { if (!props) { props = [prop]; } @@ -13768,8 +14182,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -14102,8 +14516,8 @@ var ts; } function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064; @@ -14224,8 +14638,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214: case 215: @@ -14323,8 +14737,8 @@ var ts; } } function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -14346,8 +14760,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -14450,7 +14864,8 @@ var ts; var container = ts.getThisContainer(node, false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215)) { - if (!(container.flags & 128)) { + if (!(container.flags & 64) && + (container.kind !== 144 || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -14515,8 +14930,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -14555,8 +14970,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -14921,8 +15336,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0; @@ -14944,8 +15359,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0; @@ -14967,8 +15382,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0; @@ -15081,8 +15496,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -15096,20 +15511,20 @@ var ts; else if (!(targetProp.flags & 134217728)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 || targetPropFlags & 32) { + if (sourcePropFlags & 16 || targetPropFlags & 16) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 && targetPropFlags & 32) { + if (sourcePropFlags & 16 && targetPropFlags & 16) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 ? source : target), typeToString(sourcePropFlags & 16 ? target : source)); } } return 0; } } - else if (targetPropFlags & 64) { + else if (targetPropFlags & 32) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -15120,7 +15535,7 @@ var ts; return 0; } } - else if (sourcePropFlags & 64) { + else if (sourcePropFlags & 32) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -15155,8 +15570,8 @@ var ts; return 0; } var result = -1; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0; @@ -15188,13 +15603,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -15222,8 +15637,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); @@ -15424,8 +15839,8 @@ var ts; if (sourceProp === targetProp) { return -1; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 | 64); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 | 64); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 | 32); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 | 32); if (sourcePropAccessibility !== targetPropAccessibility) { return 0; } @@ -15491,8 +15906,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -15705,8 +16120,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -15772,8 +16187,8 @@ var ts; var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -15790,8 +16205,8 @@ var ts; } else if (source.flags & 49152) { var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -15824,8 +16239,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -16316,7 +16731,7 @@ var ts; break; case 141: case 140: - if (container.flags & 128) { + if (container.flags & 64) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -16329,7 +16744,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -16357,7 +16772,7 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (canUseSuperExpression) { - if ((container.flags & 128) || isCallExpression) { + if ((container.flags & 64) || isCallExpression) { nodeCheckFlag = 512; } else { @@ -16402,7 +16817,7 @@ var ts; } else { if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128) { + if (container.flags & 64) { return container.kind === 143 || container.kind === 142 || container.kind === 145 || @@ -16541,8 +16956,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -16706,8 +17121,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -16758,8 +17173,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || @@ -17018,8 +17433,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; if (!nameTable[prop.name]) { var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { @@ -17188,7 +17603,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -17255,7 +17669,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 8 | 64 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); @@ -17268,17 +17682,17 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256) { + if (flags & 128) { error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); return false; } } - if (!(flags & (32 | 64))) { + if (!(flags & (16 | 32))) { return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - if (flags & 32) { + if (flags & 16) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -17292,7 +17706,7 @@ var ts; error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); return false; } - if (flags & 128) { + if (flags & 64) { return true; } if (type.flags & 33554432) { @@ -17472,8 +17886,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -17884,8 +18298,8 @@ var ts; reportError(ts.Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target); } if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -17904,8 +18318,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -18008,7 +18422,7 @@ var ts; return resolveErrorCall(node); } var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256) { + if (valueDecl && valueDecl.flags & 128) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -18294,32 +18708,24 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208); - } - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 || !(func.flags & 524288)) { return; } - var bodyBlock = func.body; - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 || ts.isObjectLiteralMethod(node)); @@ -18378,7 +18784,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -18437,7 +18843,7 @@ var ts; case 69: case 166: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384) !== 0; } case 167: { var index = n.argumentExpression; @@ -18445,7 +18851,7 @@ var ts; if (symbol && index && index.kind === 9) { var name_13 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384) !== 0; } return false; } @@ -18525,8 +18931,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -18541,8 +18947,8 @@ var ts; } if (type.flags & 49152) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -18577,8 +18983,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 || p.kind === 246) { var name_14 = p.name; var type = isTypeAny(sourceType) @@ -19040,7 +19446,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112) { + if (node.flags & 56) { func = ts.getContainingFunction(node); if (!(func.kind === 144 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -19221,7 +19627,7 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionLikeDeclaration(node); - if (node.flags & 256 && node.body) { + if (node.flags & 128 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -19268,7 +19674,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 && - !(n.flags & 128) && + !(n.flags & 64) && !!n.initializer; } var containingClassDecl = node.parent; @@ -19281,12 +19687,12 @@ var ts; error(node, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null); } var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 | 16 | 32); }); if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -19312,15 +19718,22 @@ var ts; if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288)) { + if (node.flags & 1048576) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { var otherKind = node.kind === 145 ? 146 : 145; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112) !== (otherAccessor.flags & 112))) { + if (((node.flags & 56) !== (otherAccessor.flags & 56))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -19387,7 +19800,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32) && ts.isInAmbientContext(node); + return (node.flags & 16) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -19412,8 +19825,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -19426,10 +19839,10 @@ var ts; n.parent.kind !== 214 && n.parent.kind !== 186 && ts.isInAmbientContext(n)) { - if (!(flags & 2)) { - flags |= 1; + if (!(flags & 4)) { + flags |= 2; } - flags |= 2; + flags |= 4; } return flags & flagsToCheck; } @@ -19447,16 +19860,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1) { + if (deviation & 2) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2) { + else if (deviation & 4) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 | 64)) { + else if (deviation & (16 | 32)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256) { + else if (deviation & 128) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -19473,7 +19886,7 @@ var ts; }); } } - var flagsToCheck = 1 | 2 | 32 | 64 | 256; + var flagsToCheck = 2 | 4 | 16 | 32 | 128; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -19502,8 +19915,8 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { ts.Debug.assert(node.kind === 143 || node.kind === 142); - ts.Debug.assert((node.flags & 128) !== (subsequentNode.flags & 128)); - var diagnostic = node.flags & 128 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64) !== (subsequentNode.flags & 64)); + var diagnostic = node.flags & 64 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -19518,7 +19931,7 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - if (node.flags & 256) { + if (node.flags & 128) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -19529,8 +19942,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 || node.parent.kind === 155 || inAmbientContext; @@ -19579,7 +19992,7 @@ var ts; }); } if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256)) { + !(lastSeenNonAmbientDeclaration.flags & 128)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -19589,8 +20002,8 @@ var ts; var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); if (!bodySignature.hasStringLiterals) { - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -19620,9 +20033,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 1024); - if (effectiveDeclarationFlags & 1) { - if (effectiveDeclarationFlags & 1024) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 | 512); + if (effectiveDeclarationFlags & 2) { + if (effectiveDeclarationFlags & 512) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -19758,9 +20171,12 @@ var ts; if (promiseType === unknownType && compilerOptions.isolatedModules) { return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } var promiseConstructorType = getTypeOfSymbol(promiseConstructor); @@ -19919,7 +20335,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { @@ -20022,7 +20438,7 @@ var ts; } } function checkVarDeclaredNamesNotShadowed(node) { - if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576) !== 0 || ts.isParameterDeclaration(node)) { return; } if (node.kind === 211 && !node.initializer) { @@ -20034,7 +20450,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212); var container = varDeclList.parent.kind === 193 && varDeclList.parent.parent ? varDeclList.parent.parent @@ -20161,6 +20577,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -20410,7 +20829,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -20540,7 +20959,7 @@ var ts; var classDeclaration = type.symbol.valueDeclaration; for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) { var member = _a[_i]; - if (!(member.flags & 128) && ts.hasDynamicName(member)) { + if (!(member.flags & 64) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1); @@ -20616,7 +21035,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024)) { + if (!node.name && !(node.flags & 512)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -20666,8 +21085,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -20699,8 +21118,8 @@ var ts; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728) { continue; @@ -20711,7 +21130,7 @@ var ts; if (derived) { if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); - if (baseDeclarationFlags & 256 && (!derivedClassDecl || !(derivedClassDecl.flags & 256))) { + if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(derivedClassDecl.flags & 128))) { if (derivedClassDecl.kind === 186) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -20722,10 +21141,10 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + if ((baseDeclarationFlags & 16) || (derivedDeclarationFlags & 16)) { continue; } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + if ((baseDeclarationFlags & 64) !== (derivedDeclarationFlags & 64)) { continue; } if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { @@ -20791,11 +21210,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -21064,8 +21483,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 || (declaration.kind === 213 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -21193,7 +21612,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -21220,7 +21639,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1) { + if (node.flags & 2) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21248,7 +21667,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -21287,7 +21706,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69) { @@ -21672,7 +22091,7 @@ var ts; } case 214: case 215: - if (!(memberFlags & 128)) { + if (!(memberFlags & 64)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; @@ -21934,7 +22353,7 @@ var ts; } function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 + return node.flags & 64 ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -22220,7 +22639,7 @@ var ts; } function initializeTypeChecker() { ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); ts.forEach(host.getSourceFiles(), function (file) { if (!ts.isExternalModule(file)) { @@ -22364,19 +22783,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112) { + if (flags & 56) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128) { + else if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256) { + else if (flags & 128) { if (modifier.kind === 110) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -22387,10 +22806,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113: - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 || node.parent.kind === 248) { @@ -22399,23 +22818,23 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128; + flags |= 64; lastStatic = modifier; break; case 82: - if (flags & 1) { + if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2) { + else if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256) { + else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214) { @@ -22424,13 +22843,13 @@ var ts; else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1; + flags |= 2; break; case 122: - if (flags & 2) { + if (flags & 4) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.parent.kind === 214) { @@ -22442,69 +22861,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2; + flags |= 4; lastDeclare = modifier; break; case 115: - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214) { if (node.kind !== 143) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 && node.parent.flags & 256)) { + if (!(node.parent.kind === 214 && node.parent.flags & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32) { + if (flags & 16) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256; + flags |= 128; break; case 118: - if (flags & 512) { + if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512; + flags |= 256; lastAsync = modifier; break; } } if (node.kind === 144) { - if (flags & 128) { + if (flags & 64) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256) { + if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64) { + else if (flags & 32) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32) { + else if (flags & 16) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512) { + else if (flags & 256) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 || node.kind === 221) && flags & 2) { + else if ((node.kind === 222 || node.kind === 221) && flags & 4) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 && (flags & 56) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512) { + if (flags & 256) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -22604,7 +23023,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035) { + if (parameter.flags & 1022) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -22624,7 +23043,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035) { + if (node.flags & 1022) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -22646,8 +23065,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -22887,7 +23306,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035) { + else if (parameter.flags & 1022) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -23021,8 +23440,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -23141,8 +23560,8 @@ var ts; node.kind === 221 || node.kind === 228 || node.kind === 227 || - (node.flags & 2) || - (node.flags & (1 | 1024))) { + (node.flags & 4) || + (node.flags & (2 | 512))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -23180,7 +23599,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 65536 && languageVersion >= 1) { + if (node.flags & 32768 && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -23227,7 +23646,7 @@ var ts; var addedGlobalFileReference = false; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 8192) || + if (referencedFile && ((referencedFile.flags & 4096) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -23405,15 +23824,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -23555,6 +23974,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true); emitLines(node.statements); } function getExportDefaultTempVariableName() { @@ -23661,10 +24081,10 @@ var ts; } function emitModuleElementDeclarationFlags(node) { if (node.parent === currentSourceFile) { - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } else if (node.kind !== 215) { @@ -23673,22 +24093,22 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32) { + if (node.flags & 16) { write("private "); } - else if (node.flags & 64) { + else if (node.flags & 32) { write("protected "); } - if (node.flags & 128) { + if (node.flags & 64) { write("static "); } - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23723,11 +24143,11 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1)) { + if (!node.importClause && !(node.flags & 2)) { return; } emitJsDocComments(node); - if (node.flags & 1) { + if (node.flags & 2) { write("export "); } write("import "); @@ -23789,7 +24209,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072) { + if (node.flags & 65536) { write("namespace "); } else { @@ -23861,7 +24281,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 && (node.parent.flags & 32); + return node.parent.kind === 143 && (node.parent.flags & 16); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -23903,7 +24323,7 @@ var ts; break; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } else if (node.parent.parent.kind === 214) { @@ -23966,7 +24386,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { emitPropertyDeclaration(param); } }); @@ -23974,7 +24394,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256) { + if (node.flags & 128) { write("abstract "); } write("class "); @@ -24038,7 +24458,7 @@ var ts; if ((node.kind === 141 || node.kind === 140) && node.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32)) { + else if (!(node.flags & 16)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -24052,7 +24472,7 @@ var ts; ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } else if (node.kind === 141 || node.kind === 140) { - if (node.flags & 128) { + if (node.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24147,7 +24567,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32)) { + if (!(node.flags & 16)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -24174,7 +24594,7 @@ var ts; function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146) { - if (accessorWithTypeAnnotation.parent.flags & 128) { + if (accessorWithTypeAnnotation.parent.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -24191,7 +24611,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128) { + if (accessorWithTypeAnnotation.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -24272,7 +24692,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 && !(node.flags & 32)) { + else if (node.kind !== 144 && !(node.flags & 16)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -24300,7 +24720,7 @@ var ts; break; case 143: case 142: - if (node.flags & 128) { + if (node.flags & 64) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -24357,7 +24777,7 @@ var ts; node.parent.parent.kind === 155) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32)) { + else if (!(node.parent.flags & 16)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -24386,7 +24806,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143: case 142: - if (node.parent.flags & 128) { + if (node.parent.flags & 64) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -24502,7 +24922,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 + var declFileName = referencedFile.flags & 4096 ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") @@ -24835,16 +25255,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { if (node.locals[name].flags & (107455 | 1048576 | 8388608)) { return false; @@ -26137,7 +26549,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, (node.flags & 1024) !== 0, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -26152,7 +26564,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; if (!multiLine) { write(" "); } @@ -26171,7 +26583,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048) !== 0; + var multiLine = (node.flags & 1024) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -26689,7 +27101,7 @@ var ts; var current = node; while (current) { if (current.kind === 248) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219) { return false; @@ -26907,7 +27319,7 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576) === 0) { for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { var varDecl = _b[_a]; hoistVariableDeclarationFromLoop(convertedLoopState, varDecl); @@ -26989,7 +27401,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576)) { loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { var varDeclaration = _b[_a]; @@ -27246,22 +27658,22 @@ var ts; var endPos = emitToken(86, node.pos); write(" "); endPos = emitToken(17, endPos); - var rhsIsIdentifier = node.expression.kind === 69; var counter = createTempVariable(268435456); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); + var rhsReference = ts.createSynthesizedNode(69); + rhsReference.text = node.expression.kind === 69 ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0); emitStart(node.expression); write("var "); emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); emitStart(node.initializer); emitNodeWithoutSourceMap(counter); @@ -27496,7 +27908,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1) { + if (ts.getCombinedNodeFlags(node) & 2) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -27518,7 +27930,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248) { - ts.Debug.assert(!!(node.flags & 1024) || node.kind === 227); + ts.Debug.assert(!!(node.flags & 512) || node.kind === 227); if (modulekind === 1 || modulekind === 2 || modulekind === 3) { if (!currentSourceFile.symbol.exports["___esModule"]) { if (languageVersion === 1) { @@ -27534,12 +27946,12 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1) { + if (node.flags & 2) { writeLine(); emitStart(node); if (modulekind === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); - if (node.flags & 1024) { + if (node.flags & 512) { write("default"); } else { @@ -27550,7 +27962,7 @@ var ts; write(")"); } else { - if (node.flags & 1024) { + if (node.flags & 512) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0) { write("exports[\"default\"]"); @@ -27638,7 +28050,7 @@ var ts; var emitCount = 0; var canDefineTempVariablesInPlace = false; if (root.kind === 211) { - var isExported = ts.getCombinedNodeFlags(root) & 1; + var isExported = ts.getCombinedNodeFlags(root) & 2; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -27704,8 +28116,8 @@ var ts; if (properties.length !== 1) { value = ensureIdentifier(value, true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 || p.kind === 246) { var propName = p.name; var target_1 = p.kind === 246 ? p : p.initializer || propName; @@ -27824,7 +28236,7 @@ var ts; var initializer = node.initializer; if (!initializer && languageVersion < 2) { var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384) && - (getCombinedFlagsForIdentifier(node.name) & 16384); + (getCombinedFlagsForIdentifier(node.name) & 8192); if (isLetDefinedInLoop && node.parent.parent.kind !== 200 && node.parent.parent.kind !== 201) { @@ -27863,13 +28275,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1) && + return !!(node.flags & 2) && modulekind === 5 && node.parent.kind === 248; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1) { + if (node.flags & 2) { if (isES6ExportedDeclaration(node)) { write("export "); startIsEmitted = tryEmitStartOfVariableDeclarationList(node.declarationList); @@ -27893,7 +28305,7 @@ var ts; } } function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { - if (!(node.flags & 1)) { + if (!(node.flags & 2)) { return true; } if (isES6ExportedDeclaration(node)) { @@ -28050,7 +28462,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -28189,7 +28601,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 || node.flags & 512) { + if (languageVersion < 2 || node.flags & 256) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -28205,7 +28617,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -28241,7 +28653,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); var startIndex = emitDirectivePrologues(body.statements, true); emitFunctionBodyPreamble(node); decreaseIndent(); @@ -28283,7 +28695,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112) { + if (param.flags & 56) { writeLine(); emitStart(param); emitStart(param.name); @@ -28315,15 +28727,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 141 && isStatic === ((member.flags & 64) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -28336,7 +28748,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128) { + if (property.flags & 64) { emitDeclarationName(node); } else { @@ -28435,7 +28847,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128) { + if (member.flags & 64) { write("static "); } if (member.kind === 145) { @@ -28480,7 +28892,7 @@ var ts; if (member.kind === 144 && !member.body) { emitCommentsOnNotEmittedNode(member); } - if (member.kind === 141 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 141 && member.initializer && (member.flags & 64) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -28517,7 +28929,7 @@ var ts; increaseIndent(); if (ctor) { startIndex = emitDirectivePrologues(ctor.body.statements, true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -28588,7 +29000,7 @@ var ts; var thisNodeIsDecorated = ts.nodeIsDecorated(node); if (node.kind === 214) { if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512)) { write("export "); } write("let "); @@ -28597,7 +29009,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024) { + if (node.flags & 512) { write("default "); } } @@ -28613,7 +29025,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || (node.flags & 1024 && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -28636,8 +29048,8 @@ var ts; write(";"); } if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, tempVariable, true); @@ -28653,7 +29065,7 @@ var ts; emitPropertyDeclarations(node, staticProperties); emitDecoratorsOfClass(node); } - if (!isES6ExportedDeclaration(node) && (node.flags & 1)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -28662,7 +29074,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512) && thisNodeIsDecorated) { writeLine(); write("export default "); emitDeclarationName(node); @@ -28742,13 +29154,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128)) { + if (!(member.flags & 64)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, 0); - emitDecoratorsOfMembers(node, 128); + emitDecoratorsOfMembers(node, 64); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -28783,7 +29195,7 @@ var ts; function emitDecoratorsOfMembers(node, staticFlag) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.flags & 128) !== staticFlag) { + if ((member.flags & 64) !== staticFlag) { continue; } if (!ts.nodeCanBeDecorated(member)) { @@ -29110,7 +29522,7 @@ var ts; return; } if (!shouldHoistDeclarationInSystemJsModule(node)) { - if (!(node.flags & 1) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -29141,7 +29553,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 && !shouldHoistDeclarationInSystemJsModule(node)) { writeLine(); emitStart(node); write("var "); @@ -29152,7 +29564,7 @@ var ts; write(";"); } if (modulekind !== 5 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -29254,7 +29666,7 @@ var ts; scopeEmitEnd(); } write(")("); - if ((node.flags & 1) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -29264,7 +29676,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 && node.parent === currentSourceFile) { - if (modulekind === 4 && (node.flags & 1)) { + if (modulekind === 4 && (node.flags & 2)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -29362,7 +29774,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 221 && (node.flags & 2) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2) { emitLeadingComments(node); @@ -29428,7 +29840,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1)) { + else if (!(node.flags & 2)) { write("var "); } } @@ -29516,8 +29928,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -29651,8 +30063,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; var skipNode = importNode.kind === 228 || (importNode.kind === 222 && !importNode.importClause); if (skipNode) { @@ -29677,8 +30089,8 @@ var ts; } if (!exportedDeclarations && ts.isEmpty(exportSpecifiers)) { var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -29706,8 +30118,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228) { continue; } @@ -29751,7 +30163,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 69 && node.flags & 1024) { + if (node.kind !== 69 && node.flags & 512) { return; } if (started) { @@ -29804,7 +30216,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 ? local.parent : local); - if (flags & 1) { + if (flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29814,11 +30226,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1) { + if (f.flags & 2) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -29828,7 +30240,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2) { + if (node.flags & 4) { return; } if (node.kind === 213) { @@ -29898,7 +30310,7 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248; } function isCurrentFileSystemExternalModule() { @@ -29933,8 +30345,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222: @@ -30068,8 +30480,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; var externalModuleName = getExternalModuleNameText(importNode); var importAliasName = getLocalNameForExternalImport(importNode); if (includeNonAmdDependencies && importAliasName) { @@ -30322,7 +30734,7 @@ var ts; function emitSourceFileNode(node) { writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1]; emitModule(node); @@ -30345,7 +30757,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2) { + if (node.flags & 4) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -30578,10 +30990,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33; - } function isTripleSlashComment(comment) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 && comment.pos + 2 < comment.end && @@ -30662,44 +31070,14 @@ var ts; ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments); ts.emitComments(currentSourceFile, writer, leadingComments, true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -31002,7 +31380,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; if (oldProgram) { var oldOptions = oldProgram.getCompilerOptions(); @@ -31050,8 +31428,8 @@ var ts; if (!classifiableNames) { getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -31067,7 +31445,7 @@ var ts; return false; } var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -31075,8 +31453,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { return false; @@ -31090,7 +31468,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; var oldResolution = ts.getResolvedModule(oldSourceFile, moduleNames[i]); @@ -31113,12 +31491,12 @@ var ts; newSourceFiles.push(newSourceFile); } for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -31157,7 +31535,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -31266,7 +31644,7 @@ var ts; } break; case 218: - if (node.name.kind === 9 && (node.flags & 2 || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 && (node.flags & 4 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { collect(node, false); }); @@ -31283,7 +31661,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -31293,13 +31671,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -31341,6 +31719,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); if (existingFile) { @@ -31385,11 +31764,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -31440,8 +31815,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -31557,7 +31932,7 @@ var ts; var BreakpointResolver; (function (BreakpointResolver) { function spanInSourceFileAtLocation(sourceFile, position) { - if (sourceFile.flags & 8192) { + if (sourceFile.flags & 4096) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -31732,7 +32107,7 @@ var ts; : isDeclarationOfForStatement ? variableDeclaration.parent.parent.initializer.declarations : undefined; - if (variableDeclaration.initializer || (variableDeclaration.flags & 1)) { + if (variableDeclaration.initializer || (variableDeclaration.flags & 2)) { if (declarations && declarations[0] === variableDeclaration) { if (isParentVariableStatement) { return textSpan(variableDeclaration.parent, variableDeclaration); @@ -31753,7 +32128,7 @@ var ts; } function canHaveSpanInParameterDeclaration(parameter) { return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16) || !!(parameter.flags & 32); + !!(parameter.flags & 8) || !!(parameter.flags & 16); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -31771,7 +32146,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1) || + return !!(functionDeclaration.flags & 2) || (functionDeclaration.parent.kind === 214 && functionDeclaration.kind !== 144); } function spanInFunctionDeclaration(functionDeclaration) { @@ -31853,7 +32228,6 @@ var ts; } case 244: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; case 220: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -31888,7 +32262,6 @@ var ts; default: return spanInNode(node.parent); } - return spanInNode(node.parent); } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || node.parent.kind === 245) { @@ -31949,8 +32322,8 @@ var ts; var lastSingleLineCommentEnd = -1; var isFirstSingleLineComment = true; var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var currentComment = comments_2[_i]; if (currentComment.kind === 2) { if (isFirstSingleLineComment) { firstSingleLineCommentStart = currentComment.pos; @@ -32071,6 +32444,7 @@ var ts; function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; + var baseSensitivity = { sensitivity: "base" }; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); @@ -32081,8 +32455,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; if (patternMatcher.patternContainsDots) { var containers = getContainers(declaration); if (!containers) { @@ -32108,8 +32482,8 @@ var ts; return items; function allMatchesAreCaseSensitive(matches) { ts.Debug.assert(matches.length > 0); - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; if (!match.isCaseSensitive) { return false; } @@ -32177,8 +32551,8 @@ var ts; function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; var kind = match.kind; if (kind < bestMatchKind) { bestMatchKind = kind; @@ -32186,7 +32560,6 @@ var ts; } return bestMatchKind; } - var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { return i1.matchKind - i2.matchKind || i1.name.localeCompare(i2.name, undefined, baseSensitivity) || @@ -32314,8 +32687,8 @@ var ts; } function addTopLevelNodes(nodes, topLevelNodes) { nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; switch (node.kind) { case 214: case 217: @@ -32353,8 +32726,8 @@ var ts; function getItemsWorker(nodes, createItem) { var items = []; var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var child = nodes_5[_i]; var item = createItem(child); if (item !== undefined) { if (item.text.length > 0) { @@ -32397,7 +32770,7 @@ var ts; if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 2035) === 0) { + if ((node.flags & 1022) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); @@ -32661,8 +33034,8 @@ var ts; if (isLowercase) { if (index > 0) { var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; + for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { + var span = wordSpans_1[_i]; if (partStartsWith(candidate, span, chunk.text, true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span, chunk.text, false)); } @@ -32714,8 +33087,8 @@ var ts; } var subWordTextChunks = segment.subWordTextChunks; var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; + for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { + var subWordTextChunk = subWordTextChunks_1[_i]; var result = matchTextChunk(candidate, subWordTextChunk, true); if (!result) { return undefined; @@ -33078,8 +33451,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0; _b < declarations.length; _b++) { - var declaration = declarations[_b]; + for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { + var declaration = declarations_7[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -33155,8 +33528,8 @@ var ts; function getArgumentIndex(argumentsList, node) { var argumentIndex = 0; var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; + for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { + var child = listChildren_1[_i]; if (child === node) { break; } @@ -33598,8 +33971,8 @@ var ts; return n; } var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; var shouldDiveInChildNode = (child.pos <= previousToken.pos && child.end > previousToken.end) || (child.pos === previousToken.end); if (shouldDiveInChildNode && nodeHasTokens(child)) { @@ -33722,17 +34095,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 32) - result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64) - result.push(ts.ScriptElementKindModifier.protectedMemberModifier); if (flags & 16) + result.push(ts.ScriptElementKindModifier.privateMemberModifier); + if (flags & 32) + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); + if (flags & 8) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128) + if (flags & 64) result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256) + if (flags & 128) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1) + if (flags & 2) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -35533,8 +35906,8 @@ var ts; } } var inheritedIndentation = -1; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var child = nodes_6[_i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, true); } if (listEndToken !== 0) { @@ -35616,8 +35989,8 @@ var ts; } } function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; + for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { + var triviaItem = trivia_1[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); @@ -36146,7 +36519,6 @@ var ts; return node; } } - return node; } } function deriveActualIndentationFromList(list, index, sourceFile, options) { @@ -36374,17 +36746,17 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096, this)); + nodes.push(createNode(token, pos, textPos, 2048, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271, nodes.pos, nodes.end, 4096, this); + var list = createNode(271, nodes.pos, nodes.end, 2048, this); list._children = []; var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_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); } @@ -36890,7 +37262,7 @@ var ts; } break; case 138: - if (!(node.flags & 112)) { + if (!(node.flags & 56)) { break; } case 211: @@ -37089,18 +37461,20 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + this.getCanonicalFileName = getCanonicalFileName; + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = ts.createFileMap(); var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); + for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { + var fileName = rootFileNames_1[_i]; + this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); } HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.createEntry = function (fileName) { + HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { @@ -37110,36 +37484,37 @@ var ts; scriptSnapshot: scriptSnapshot }; } - this.fileNameToEntry.set(fileName, entry); + this.fileNameToEntry.set(path, entry); return entry; }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); + HostCache.prototype.getEntry = function (path) { + return this.fileNameToEntry.get(path); }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); + HostCache.prototype.contains = function (path) { + return this.fileNameToEntry.contains(path); }; HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); + var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); + if (this.contains(path)) { + return this.getEntry(path); } - return this.createEntry(fileName); + return this.createEntry(fileName, path); }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { + this.fileNameToEntry.forEachValue(function (path, value) { if (value) { fileNames.push(value.hostFileName); } }); return fileNames; }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getVersion = function (path) { + var file = this.getEntry(path); return file && file.version; }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getScriptSnapshot = function (path) { + var file = this.getEntry(path); return file && file.scriptSnapshot; }; return HostCache; @@ -37282,7 +37657,8 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { + function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } var buckets = {}; var getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyFromCompilationSettings(settings) { @@ -37292,7 +37668,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + buckets[key] = bucket = ts.createFileMap(); } return bucket; } @@ -37300,14 +37676,13 @@ var ts; var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { var entries = ts.lookUp(buckets, name); var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); + entries.forEachValue(function (key, entry) { sourceFiles.push({ - name: i, + name: key, refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); - } + }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { bucket: name, @@ -37324,7 +37699,8 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, true); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); var sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false); @@ -37333,7 +37709,7 @@ var ts; languageServiceRefCount: 0, owners: [] }; - bucket.set(fileName, entry); + bucket.set(path, entry); } else { if (entry.sourceFile.version !== version) { @@ -37348,11 +37724,12 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); + bucket.remove(path); } } return { @@ -37705,7 +38082,7 @@ var ts; case 144: return ScriptElementKind.constructorImplementationElement; case 137: return ScriptElementKind.typeParameterElement; case 247: return ScriptElementKind.variableElement; - case 138: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 138: return (node.flags & 56) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221: case 226: case 223: @@ -37731,13 +38108,14 @@ var ts; return CancellationTokenObject; })(); function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; var lastProjectVersion; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + var currentDirectory = host.getCurrentDirectory(); if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); } @@ -37748,8 +38126,7 @@ var ts; } var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { throw new Error("Could not find file: '" + fileName + "'."); } @@ -37791,7 +38168,7 @@ var ts; getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { ts.Debug.assert(!host.resolveModuleNames); return hostCache.getOrCreateEntry(fileName) !== undefined; @@ -37807,11 +38184,10 @@ var ts; var newProgram = ts.createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); if (program) { var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; + if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings); } } } @@ -37834,7 +38210,8 @@ var ts; return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile && sourceFile.version === hostCache.getVersion(path); } function programUpToDate() { if (!program) { @@ -37844,8 +38221,8 @@ var ts; if (program.getSourceFiles().length !== rootFileNames.length) { return false; } - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; + for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { + var fileName = rootFileNames_2[_i]; if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } @@ -38007,8 +38384,8 @@ var ts; } function checkModifiers(modifiers) { if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; switch (modifier.kind) { case 112: case 110: @@ -38571,8 +38948,8 @@ var ts; } function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; + for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { + var element = namedImportsOrExports_1[_i]; if (element.getStart() <= position && position <= element.getEnd()) { continue; } @@ -38589,8 +38966,8 @@ var ts; return contextualMemberSymbols; } var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; + for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { + var m = existingMembers_1[_i]; if (m.kind !== 245 && m.kind !== 246 && m.kind !== 163) { @@ -38612,8 +38989,8 @@ var ts; } function filterJsxAttributes(symbols, attributes) { var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; + for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { + var attr = attributes_1[_i]; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } @@ -38701,8 +39078,8 @@ var ts; var entries = []; if (symbols) { var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { + var symbol = symbols_3[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -39385,8 +39762,8 @@ var ts; } var fileNameToDocumentHighlights = {}; var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { var referenceEntry = _b[_a]; var fileName_1 = referenceEntry.fileName; @@ -39522,7 +39899,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function getThrowStatementOwner(throwStatement) { var child = throwStatement; @@ -39553,7 +39929,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); @@ -39617,7 +39992,7 @@ var ts; switch (container.kind) { case 219: case 248: - if (modifierFlag & 256) { + if (modifierFlag & 128) { nodes = declaration.members.concat(declaration); } else { @@ -39630,7 +40005,7 @@ var ts; case 214: case 186: nodes = container.members; - if (modifierFlag & 112) { + if (modifierFlag & 56) { var constructor = ts.forEach(container.members, function (member) { return member.kind === 144 && member; }); @@ -39638,7 +40013,7 @@ var ts; nodes = nodes.concat(constructor.parameters); } } - else if (modifierFlag & 256) { + else if (modifierFlag & 128) { nodes = nodes.concat(container); } break; @@ -39654,19 +40029,19 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112: - return 16; + return 8; case 110: - return 32; + return 16; case 111: - return 64; + return 32; case 113: - return 128; + return 64; case 82: - return 1; - case 122: return 2; + case 122: + return 4; case 115: - return 256; + return 128; default: ts.Debug.fail(); } @@ -39851,8 +40226,8 @@ var ts; return undefined; } var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; + for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { + var entry = documentHighlights_1[_i]; for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { var highlightSpan = _b[_a]; result.push({ @@ -39870,8 +40245,8 @@ var ts; return undefined; } var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; + for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { + var referenceSymbol = referenceSymbols_1[_i]; ts.addRange(referenceEntries, referenceSymbol.references); } return referenceEntries; @@ -39939,8 +40314,8 @@ var ts; } else { var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { @@ -39985,7 +40360,7 @@ var ts; return valueDeclaration; } if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16) ? d : undefined; }); if (privateDeclaration) { return ts.getAncestor(privateDeclaration, 214); } @@ -39999,8 +40374,8 @@ var ts; var scope = undefined; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -40153,7 +40528,7 @@ var ts; if (!searchSpaceNode) { return undefined; } - var staticFlag = 128; + var staticFlag = 64; switch (searchSpaceNode.kind) { case 141: case 140: @@ -40178,7 +40553,7 @@ var ts; return; } var container = ts.getSuperContainer(node, false); - if (container && (128 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (64 & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -40187,7 +40562,7 @@ var ts; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 128; + var staticFlag = 64; switch (searchSpaceNode.kind) { case 143: case 142: @@ -40259,7 +40634,7 @@ var ts; break; case 186: case 214: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; @@ -40386,8 +40761,8 @@ var ts; var lastIterationMeaning; do { lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -40500,7 +40875,6 @@ var ts; return 4 | 1; } return 1 | 2 | 4; - ts.Debug.fail("Unknown declaration type"); } function isTypeReference(node) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { @@ -41007,8 +41381,8 @@ var ts; if (matchKind) { var parentElement = token.parent; var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; + for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { + var current = childNodes_1[_i]; if (current.kind === matchKind) { var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); @@ -41224,8 +41598,8 @@ var ts; if (declarations && declarations.length > 0) { var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var current = declarations_10[_i]; var sourceFile_2 = current.getSourceFile(); var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { @@ -41962,8 +42336,8 @@ var ts; if (this.logger.isVerbose()) { this.logger.info(msg.type + ": " + json); } - this.sendLineToClient('Content-Length: ' + (1 + this.byteLength(json, 'utf8')) + - '\r\n\r\n' + json); + this.sendLineToClient("Content-Length: " + (1 + this.byteLength(json, "utf8")) + + "\r\n\r\n" + json); }; Session.prototype.event = function (info, eventName) { var ev = { @@ -42346,7 +42720,8 @@ var ts; }; var preferredIndent = compilerService.languageService.getIndentationAtPosition(file, position, editorOptions); var hasIndent = 0; - for (var i = 0, len = lineText.length; i < len; i++) { + var i, len; + for (i = 0, len = lineText.length; i < len; i++) { if (lineText.charAt(i) == " ") { hasIndent++; } @@ -42553,7 +42928,7 @@ var ts; if (navItem.kindModifiers && (navItem.kindModifiers != "")) { bakedItem.kindModifiers = navItem.kindModifiers; } - if (navItem.matchKind != 'none') { + if (navItem.matchKind !== "none") { bakedItem.matchKind = navItem.matchKind; } if (navItem.containerName && (navItem.containerName.length > 0)) { @@ -42592,8 +42967,8 @@ var ts; var veryLowPriorityFiles = []; var normalizedFileName = ts.normalizePath(fileName); var project = this.projectService.getProjectForFile(normalizedFileName); - for (var _i = 0; _i < fileNamesInProject.length; _i++) { - var fileNameInProject = fileNamesInProject[_i]; + for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { + var fileNameInProject = fileNamesInProject_1[_i]; if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) highPriorityFiles.push(fileNameInProject); else { @@ -42641,12 +43016,14 @@ var ts; } }; Session.prototype.onMessage = function (message) { + var start; if (this.logger.isVerbose()) { this.logger.info("request: " + message); - var start = this.hrtime(); + start = this.hrtime(); } + var request; try { - var request = JSON.parse(message); + request = JSON.parse(message); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; if (this.logger.isVerbose()) { var elapsed = this.hrtime(start); @@ -42701,6 +43078,7 @@ var ts; this.isOpen = isOpen; this.children = []; this.formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); + this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); this.svc = ScriptVersionCache.fromString(host, content); } ScriptInfo.prototype.setFormatOptions = function (formatOptions) { @@ -42742,23 +43120,23 @@ var ts; var _this = this; this.host = host; this.project = project; - this.ls = null; this.roots = []; - var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - this.resolvedModuleNames = ts.createFileMap(getCanonicalFileName); - this.filenameToScript = ts.createFileMap(getCanonicalFileName); + this.getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.resolvedModuleNames = ts.createFileMap(); + this.filenameToScript = ts.createFileMap(); this.moduleResolutionHost = { fileExists: function (fileName) { return _this.fileExists(fileName); }, readFile: function (fileName) { return _this.host.readFile(fileName); } }; } LSHost.prototype.resolveModuleNames = function (moduleNames, containingFile) { - var currentResolutionsInFile = this.resolvedModuleNames.get(containingFile); + var path = ts.toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var currentResolutionsInFile = this.resolvedModuleNames.get(path); var newResolutions = {}; var resolvedModules = []; var compilerOptions = this.getCompilationSettings(); - for (var _i = 0; _i < moduleNames.length; _i++) { - var moduleName = moduleNames[_i]; + for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { + var moduleName = moduleNames_1[_i]; var resolution = ts.lookUp(newResolutions, moduleName); if (!resolution) { var existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, moduleName); @@ -42774,7 +43152,7 @@ var ts; ts.Debug.assert(resolution !== undefined); resolvedModules.push(resolution.resolvedModule); } - this.resolvedModuleNames.set(containingFile, newResolutions); + this.resolvedModuleNames.set(path, newResolutions); return resolvedModules; function moduleResolutionIsValid(resolution) { if (!resolution) { @@ -42825,31 +43203,32 @@ var ts; }; LSHost.prototype.removeReferencedFile = function (info) { if (!info.isOpen) { - this.filenameToScript.remove(info.fileName); - this.resolvedModuleNames.remove(info.fileName); + this.filenameToScript.remove(info.path); + this.resolvedModuleNames.remove(info.path); } }; LSHost.prototype.getScriptInfo = function (filename) { - var scriptInfo = this.filenameToScript.get(filename); + var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var scriptInfo = this.filenameToScript.get(path); if (!scriptInfo) { scriptInfo = this.project.openReferencedFile(filename); if (scriptInfo) { - this.filenameToScript.set(scriptInfo.fileName, scriptInfo); + this.filenameToScript.set(path, scriptInfo); } } return scriptInfo; }; LSHost.prototype.addRoot = function (info) { - if (!this.filenameToScript.contains(info.fileName)) { - this.filenameToScript.set(info.fileName, info); + if (!this.filenameToScript.contains(info.path)) { + this.filenameToScript.set(info.path, info); this.roots.push(info); } }; LSHost.prototype.removeRoot = function (info) { - if (!this.filenameToScript.contains(info.fileName)) { - this.filenameToScript.remove(info.fileName); + if (!this.filenameToScript.contains(info.path)) { + this.filenameToScript.remove(info.path); this.roots = copyListRemovingItem(info, this.roots); - this.resolvedModuleNames.remove(info.fileName); + this.resolvedModuleNames.remove(info.path); } }; LSHost.prototype.saveTo = function (filename, tmpfilename) { @@ -42887,7 +43266,8 @@ var ts; return this.host.directoryExists(path); }; LSHost.prototype.lineToTextSpan = function (filename, line) { - var script = this.filenameToScript.get(filename); + var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var script = this.filenameToScript.get(path); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line + 1); var len; @@ -42901,13 +43281,15 @@ var ts; return ts.createTextSpan(lineInfo.offset, len); }; LSHost.prototype.lineOffsetToPosition = function (filename, line, offset) { - var script = this.filenameToScript.get(filename); + var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var script = this.filenameToScript.get(path); var index = script.snap().index; var lineInfo = index.lineNumberToInfo(line); return (lineInfo.offset + offset - 1); }; LSHost.prototype.positionToLineOffset = function (filename, position) { - var script = this.filenameToScript.get(filename); + var path = ts.toPath(filename, this.host.getCurrentDirectory(), this.getCanonicalFileName); + var script = this.filenameToScript.get(path); var index = script.snap().index; var lineOffset = index.charOffsetToLineNumberAndPos(position); return { line: lineOffset.line, offset: lineOffset.offset + 1 }; @@ -42921,22 +43303,22 @@ var ts; return filename; } else { - var splitFilename = filename.split('/'); - var splitDir = directory.split('/'); + var splitFilename = filename.split("/"); + var splitDir = directory.split("/"); var i = 0; var dirTail = 0; var sflen = splitFilename.length; - while ((i < sflen) && (splitFilename[i].charAt(0) == '.')) { + while ((i < sflen) && (splitFilename[i].charAt(0) == ".")) { var dots = splitFilename[i]; - if (dots == '..') { + if (dots == "..") { dirTail++; } - else if (dots != '.') { + else if (dots != ".") { return undefined; } i++; } - return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join('/'); + return splitDir.slice(0, splitDir.length - dirTail).concat(splitFilename.slice(i)).join("/"); } } var Project = (function () { @@ -43111,8 +43493,8 @@ var ts; var _a = this.configFileToProjectOptions(fileName), succeeded = _a.succeeded, projectOptions = _a.projectOptions, error = _a.error; var rootFilesInTsconfig = projectOptions.files.map(function (f) { return _this.getCanonicalFileName(f); }); var openFileRoots = this.openFileRoots.map(function (s) { return _this.getCanonicalFileName(s.fileName); }); - for (var _i = 0; _i < openFileRoots.length; _i++) { - var openFileRoot = openFileRoots[_i]; + for (var _i = 0, openFileRoots_1 = openFileRoots; _i < openFileRoots_1.length; _i++) { + var openFileRoot = openFileRoots_1[_i]; if (rootFilesInTsconfig.indexOf(openFileRoot) >= 0) { this.reloadProjects(); return; @@ -43236,8 +43618,8 @@ var ts; this.inferredProjects = copyListRemovingItem(project, this.inferredProjects); } var fileNames = project.getFileNames(); - for (var _b = 0; _b < fileNames.length; _b++) { - var fileName = fileNames[_b]; + for (var _b = 0, fileNames_1 = fileNames; _b < fileNames_1.length; _b++) { + var fileName = fileNames_1[_b]; var info = this.getScriptInfo(fileName); if (info.defaultProject == project) { info.defaultProject = undefined; @@ -43591,10 +43973,11 @@ var ts; } else { var parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath); + ts.Debug.assert(!!parsedCommandLine.fileNames); if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { return { succeeded: false, error: { errorMsg: "tsconfig option errors" } }; } - else if (parsedCommandLine.fileNames == null) { + else if (parsedCommandLine.fileNames.length === 0) { return { succeeded: false, error: { errorMsg: "no files found" } }; } else { @@ -43646,15 +44029,15 @@ var ts; var newFileNames = projectOptions.files; var fileNamesToRemove = oldFileNames.filter(function (f) { return newFileNames.indexOf(f) < 0; }); var fileNamesToAdd = newFileNames.filter(function (f) { return oldFileNames.indexOf(f) < 0; }); - for (var _i = 0; _i < fileNamesToRemove.length; _i++) { - var fileName = fileNamesToRemove[_i]; + for (var _i = 0, fileNamesToRemove_1 = fileNamesToRemove; _i < fileNamesToRemove_1.length; _i++) { + var fileName = fileNamesToRemove_1[_i]; var info = this.getScriptInfo(fileName); if (info) { project.removeRoot(info); } } - for (var _b = 0; _b < fileNamesToAdd.length; _b++) { - var fileName = fileNamesToAdd[_b]; + for (var _b = 0, fileNamesToAdd_1 = fileNamesToAdd; _b < fileNamesToAdd_1.length; _b++) { + var fileName = fileNamesToAdd_1[_b]; var info = this.getScriptInfo(fileName); if (!info) { info = this.openFile(fileName, false); @@ -43714,7 +44097,7 @@ var ts; CompilerService.defaultFormatCodeOptions = { IndentSize: 4, TabSize: 4, - NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', + NewLineCharacter: ts.sys ? ts.sys.newLine : "\n", ConvertTabsToSpaces: true, IndentStyle: ts.IndentStyle.Smart, InsertSpaceAfterCommaDelimiter: true, @@ -43804,7 +44187,7 @@ var ts; if (len > 1) { var insertedNodes = new Array(len - 1); var startNode = leafNode; - for (var i = 1, len = lines.length; i < len; i++) { + for (var i = 1, len_1 = lines.length; i < len_1; i++) { insertedNodes[i - 1] = new LineLeaf(lines[i]); } var pathIndex = this.startPath.length - 2; @@ -44172,8 +44555,9 @@ var ts; } } else { + var checkText; if (this.checkEdits) { - var checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); + checkText = editFlat(this.getText(0, this.root.charCount()), pos, deleteLength, newText); } var walker = new EditWalker(); if (pos >= this.root.charCount()) { @@ -44399,7 +44783,9 @@ var ts; LineNode.prototype.childFromLineNumber = function (lineNumber, charOffset) { var child; var relativeLineNumber = lineNumber; - for (var i = 0, len = this.children.length; i < len; i++) { + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { child = this.children[i]; var childLineCount = child.lineCount(); if (childLineCount >= relativeLineNumber) { @@ -44419,7 +44805,9 @@ var ts; }; LineNode.prototype.childFromCharOffset = function (lineNumber, charOffset) { var child; - for (var i = 0, len = this.children.length; i < len; i++) { + var i; + var len; + for (i = 0, len = this.children.length; i < len; i++) { child = this.children[i]; if (child.charCount() > charOffset) { break; @@ -44501,7 +44889,7 @@ var ts; splitNode = splitNodes[splitNodeIndex]; } } - for (i = splitNodes.length - 1; i >= 0; i--) { + for (var i = splitNodes.length - 1; i >= 0; i--) { if (splitNodes[i].children.length === 0) { splitNodes.length--; } @@ -44511,7 +44899,7 @@ var ts; splitNodes[splitNodes.length] = shiftNode; } this.updateCounts(); - for (i = 0; i < splitNodeCount; i++) { + for (var i = 0; i < splitNodeCount; i++) { splitNodes[i].updateCounts(); } return splitNodes; @@ -44561,10 +44949,10 @@ var ts; (function (ts) { var server; (function (server) { - var nodeproto = require('_debugger'); - var readline = require('readline'); - var path = require('path'); - var fs = require('fs'); + var nodeproto = require("_debugger"); + var readline = require("readline"); + var path = require("path"); + var fs = require("fs"); var rl = readline.createInterface({ input: process.stdin, output: process.stdout, @@ -44644,11 +45032,11 @@ var ts; }; IOSession.prototype.listen = function () { var _this = this; - rl.on('line', function (input) { + rl.on("line", function (input) { var message = input.trim(); _this.onMessage(message); }); - rl.on('close', function () { + rl.on("close", function () { _this.exit(); }); }; @@ -44656,7 +45044,7 @@ var ts; })(server.Session); function parseLoggingEnvironmentString(logEnvStr) { var logEnv = {}; - var args = logEnvStr.split(' '); + var args = logEnvStr.split(" "); for (var i = 0, len = args.length; i < (len - 1); i += 2) { var option = args[i]; var value = args[i + 1]; @@ -44711,7 +45099,7 @@ var ts; } ts.sys.write = function (s) { return writeMessage(s); }; var ioSession = new IOSession(ts.sys, logger); - process.on('uncaughtException', function (err) { + process.on("uncaughtException", function (err) { ioSession.logError(err, "unknown"); }); ioSession.listen(); @@ -44794,7 +45182,6 @@ var ts; var settingsJson = this.shimHost.getCompilationSettings(); if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; } return JSON.parse(settingsJson); }; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index d94e55eb48..972ebfa472 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -17,19 +17,22 @@ declare namespace ts { interface Map { [index: string]: T; } + type Path = string & { + __pathBrand: any; + }; interface FileMap { - get(fileName: string): T; - set(fileName: string, value: T): void; - contains(fileName: string): boolean; - remove(fileName: string): void; - forEachValue(f: (v: T) => void): void; + get(fileName: Path): T; + set(fileName: Path, value: T): void; + contains(fileName: Path): boolean; + remove(fileName: Path): void; + forEachValue(f: (key: Path, v: T) => void): void; clear(): void; } interface TextRange { pos: number; end: number; } - const enum SyntaxKind { + enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -327,31 +330,34 @@ declare namespace ts { LastBinaryOperator = 68, FirstNode = 135, } - const enum NodeFlags { + enum NodeFlags { None = 0, - Export = 1, - Ambient = 2, - Public = 16, - Private = 32, - Protected = 64, - Static = 128, - Abstract = 256, - Async = 512, - Default = 1024, - MultiLine = 2048, - Synthetic = 4096, - DeclarationFile = 8192, - Let = 16384, - Const = 32768, - OctalLiteral = 65536, - Namespace = 131072, - ExportContext = 262144, - ContainsThis = 524288, - Modifier = 2035, - AccessibilityModifier = 112, - BlockScoped = 49152, + Export = 2, + Ambient = 4, + Public = 8, + Private = 16, + Protected = 32, + Static = 64, + Abstract = 128, + Async = 256, + Default = 512, + MultiLine = 1024, + Synthetic = 2048, + DeclarationFile = 4096, + Let = 8192, + Const = 16384, + OctalLiteral = 32768, + Namespace = 65536, + ExportContext = 131072, + ContainsThis = 262144, + HasImplicitReturn = 524288, + HasExplicitReturn = 1048576, + Modifier = 1022, + AccessibilityModifier = 56, + BlockScoped = 24576, + ReachabilityCheckFlags = 1572864, } - const enum JsxFlags { + enum JsxFlags { None = 0, IntrinsicNamedElement = 1, IntrinsicIndexedElement = 2, @@ -931,6 +937,7 @@ declare namespace ts { statements: NodeArray; endOfFileToken: Node; fileName: string; + path: Path; text: string; amdDependencies: { path: string; @@ -1093,7 +1100,7 @@ declare namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; } - const enum TypeFormatFlags { + enum TypeFormatFlags { None = 0, WriteArrayAsGenericType = 1, UseTypeOfFunction = 2, @@ -1104,7 +1111,7 @@ declare namespace ts { InElementType = 64, UseFullyQualifiedType = 128, } - const enum SymbolFormatFlags { + enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, @@ -1114,7 +1121,7 @@ declare namespace ts { parameterIndex: number; type: Type; } - const enum SymbolFlags { + enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -1191,7 +1198,7 @@ declare namespace ts { interface SymbolTable { [index: string]: Symbol; } - const enum TypeFlags { + enum TypeFlags { Any = 1, String = 2, Number = 4, @@ -1262,7 +1269,7 @@ declare namespace ts { interface TypeParameter extends Type { constraint: Type; } - const enum SignatureKind { + enum SignatureKind { Call = 0, Construct = 1, } @@ -1272,7 +1279,7 @@ declare namespace ts { parameters: Symbol[]; typePredicate?: TypePredicate; } - const enum IndexKind { + enum IndexKind { String = 0, Number = 1, } @@ -1307,7 +1314,7 @@ declare namespace ts { Error = 1, Message = 2, } - const enum ModuleResolutionKind { + enum ModuleResolutionKind { Classic = 1, NodeJs = 2, } @@ -1352,10 +1359,14 @@ declare namespace ts { experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; + allowUnusedLabels?: boolean; + allowUnreachableCode?: boolean; + noImplicitReturns?: boolean; + noFallthroughCasesInSwitch?: boolean; forceConsistentCasingInFileNames?: boolean; [option: string]: string | number | boolean; } - const enum ModuleKind { + enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -1364,12 +1375,12 @@ declare namespace ts { ES6 = 5, ES2015 = 5, } - const enum JsxEmit { + enum JsxEmit { None = 0, Preserve = 1, React = 2, } - const enum NewLineKind { + enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } @@ -1377,14 +1388,14 @@ declare namespace ts { line: number; character: number; } - const enum ScriptTarget { + enum ScriptTarget { ES3 = 0, ES5 = 1, ES6 = 2, ES2015 = 2, Latest = 2, } - const enum LanguageVariant { + enum LanguageVariant { Standard = 0, JSX = 1, } @@ -1938,7 +1949,7 @@ declare namespace ts { outputFiles: OutputFile[]; emitSkipped: boolean; } - const enum OutputFileType { + enum OutputFileType { JavaScript = 0, SourceMap = 1, Declaration = 2, @@ -1948,7 +1959,7 @@ declare namespace ts { writeByteOrderMark: boolean; text: string; } - const enum EndOfLineState { + enum EndOfLineState { None = 0, InMultiLineCommentTrivia = 1, InSingleQuoteStringLiteral = 2, @@ -2116,7 +2127,7 @@ declare namespace ts { static parameterName: string; static docCommentTagName: string; } - const enum ClassificationType { + enum ClassificationType { comment = 1, identifier = 2, keyword = 3, @@ -2159,7 +2170,7 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; - function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/lib/typescript.js b/lib/typescript.js index 1e0c0edad0..8b0ef04f96 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -350,27 +350,30 @@ var ts; var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 1] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 16] = "Public"; - NodeFlags[NodeFlags["Private"] = 32] = "Private"; - NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; - NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; - NodeFlags[NodeFlags["Async"] = 512] = "Async"; - NodeFlags[NodeFlags["Default"] = 1024] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 16384] = "Let"; - NodeFlags[NodeFlags["Const"] = 32768] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; - NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; + NodeFlags[NodeFlags["Export"] = 2] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 4] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 8] = "Public"; + NodeFlags[NodeFlags["Private"] = 16] = "Private"; + NodeFlags[NodeFlags["Protected"] = 32] = "Protected"; + NodeFlags[NodeFlags["Static"] = 64] = "Static"; + NodeFlags[NodeFlags["Abstract"] = 128] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 256] = "Async"; + NodeFlags[NodeFlags["Default"] = 512] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 1024] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 2048] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 4096] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 8192] = "Let"; + NodeFlags[NodeFlags["Const"] = 16384] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 32768] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 65536] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 131072] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; + NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ @@ -690,6 +693,12 @@ var ts; })(ts.LanguageVariant || (ts.LanguageVariant = {})); var LanguageVariant = ts.LanguageVariant; /* @internal */ + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + /* @internal */ (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; @@ -838,40 +847,50 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + // path should already be well-formed so it does not need to be normalized + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -897,8 +916,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -921,8 +940,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -935,8 +954,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -949,8 +968,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -969,8 +988,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -981,8 +1000,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -990,8 +1009,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -1341,8 +1360,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -1521,8 +1540,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -1532,8 +1551,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -1614,8 +1633,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -1709,16 +1728,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -1769,6 +1788,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond function createWatchedFileSet(interval, chunkSize) { @@ -1906,8 +1926,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1921,8 +1941,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1932,15 +1952,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - // 1 is a standard descriptor for stdout - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -2223,6 +2235,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2275,7 +2288,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -2296,7 +2309,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -2586,8 +2599,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -2595,7 +2606,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2613,6 +2631,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4166,6 +4188,20 @@ var ts; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); var ModuleInstanceState = ts.ModuleInstanceState; + var Reachability; + (function (Reachability) { + Reachability[Reachability["Unintialized"] = 1] = "Unintialized"; + Reachability[Reachability["Reachable"] = 2] = "Reachable"; + Reachability[Reachability["Unreachable"] = 4] = "Unreachable"; + Reachability[Reachability["ReportedUnreachable"] = 8] = "ReportedUnreachable"; + })(Reachability || (Reachability = {})); + function or(state1, state2) { + return (state1 | state2) & 2 /* Reachable */ + ? 2 /* Reachable */ + : (state1 & state2) & 8 /* ReportedUnreachable */ + ? 8 /* ReportedUnreachable */ + : 4 /* Unreachable */; + } function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations @@ -4175,7 +4211,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { return 0 /* NonInstantiated */; } else if (node.kind === 219 /* ModuleBlock */) { @@ -4226,31 +4262,56 @@ var ts; // Functions, Methods, Modules, Source-files. ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; })(ContainerFlags || (ContainerFlags = {})); - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; + // state used by reachability checks + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). - var inStrictMode = !!file.externalModuleIndicator; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -4303,7 +4364,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213 /* FunctionDeclaration */: case 214 /* ClassDeclaration */: - return node.flags & 1024 /* Default */ ? "default" : undefined; + return node.flags & 512 /* Default */ ? "default" : undefined; } } function getDisplayName(node) { @@ -4319,7 +4380,7 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024 /* Default */; + var isDefaultExport = node.flags & 512 /* Default */; // The exported symbol for an export default function/class node is always named "default" var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; @@ -4358,7 +4419,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024 /* Default */) { + if (declaration.flags & 512 /* Default */) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -4377,7 +4438,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; if (symbolFlags & 8388608 /* Alias */) { if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -4398,7 +4459,7 @@ var ts; // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || container.flags & 262144 /* ExportContext */) { + if (hasExportModifier || container.flags & 131072 /* ExportContext */) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -4453,18 +4514,229 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215 /* InterfaceDeclaration */) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + // reset all reachability check related flags on node (for incremental scenarios) + flags &= ~1572864 /* ReachabilityCheckFlags */; + if (kind === 215 /* InterfaceDeclaration */) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 /* SourceFile */ || kind === 219 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2 /* Reachable */; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 /* Reachable */ && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288 /* HasImplicitReturn */; + if (hasExplicitReturn) { + flags |= 1048576 /* HasExplicitReturn */; + } + } + if (kind === 215 /* InterfaceDeclaration */) { + flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + /** + * Returns true if node and its subnodes were successfully traversed. + * Returning false means that node was not examined and caller needs to dive into the node himself. + */ + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198 /* WhileStatement */: + bindWhileStatement(node); + break; + case 197 /* DoStatement */: + bindDoStatement(node); + break; + case 199 /* ForStatement */: + bindForStatement(node); + break; + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + bindForInOrForOfStatement(node); + break; + case 196 /* IfStatement */: + bindIfStatement(node); + break; + case 204 /* ReturnStatement */: + case 208 /* ThrowStatement */: + bindReturnOrThrow(node); + break; + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + bindBreakOrContinueStatement(node); + break; + case 209 /* TryStatement */: + bindTryStatement(node); + break; + case 206 /* SwitchStatement */: + bindSwitchStatement(node); + break; + case 220 /* CaseBlock */: + bindCaseBlock(node); + break; + case 207 /* LabeledStatement */: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + var postWhileState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // bind expressions (don't affect reachability) + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : preDoState; + popImplicitLabel(postDoLabel, postDoState); + // bind expressions (don't affect reachability) + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + // for statement is considered infinite when it condition is either omitted or is true keyword + // - for(..;;..) + // - for(..;true;..) + var isInfiniteLoop = (!n.condition || n.condition.kind === 99 /* TrueKeyword */); + var postForState = isInfiniteLoop ? 4 /* Unreachable */ : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + // denotes reachability state when entering 'thenStatement' part of the if statement: + // i.e. if condition is false then thenStatement is unreachable + var ifTrueState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // denotes reachability state when entering 'elseStatement': + // i.e. if condition is true then elseStatement is unreachable + var ifFalseState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + currentReachabilityState = ifTrueState; + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + // bind expression (don't affect reachability) + bind(n.expression); + if (n.kind === 204 /* ReturnStatement */) { + hasExplicitReturn = true; + } + currentReachabilityState = 4 /* Unreachable */; + } + function bindBreakOrContinueStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + // for continue case touch label so it will be marked a used + var isValidJump = jumpToLabel(n.label, n.kind === 203 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + if (isValidJump) { + currentReachabilityState = 4 /* Unreachable */; + } + } + function bindTryStatement(n) { + // catch\finally blocks has the same reachability as try block + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + // post catch/finally state is reachable if + // - post try state is reachable - control flow can fall out of try block + // - post catch state is reachable - control flow can fall out of catch block + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242 /* DefaultClause */; }); + // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 /* Reachable */ && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186 /* ClassExpression */: @@ -4576,7 +4848,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -4585,15 +4857,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2 /* Ambient */) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 /* SourceFile */ ? node : node.body; if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { @@ -4609,11 +4872,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144 /* ExportContext */; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072 /* ExportContext */; } else { - node.flags &= ~262144 /* ExportContext */; + node.flags &= ~131072 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -4805,7 +5068,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { + if (inStrictMode && node.flags & 32768 /* OctalLiteral */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -4829,10 +5092,10 @@ var ts; function checkStrictModeWithStatement(node) { // Grammar checking for withStatement if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -4840,6 +5103,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -4882,8 +5148,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -5105,7 +5371,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (node.flags & 112 /* AccessibilityModifier */ && + if (node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -5117,6 +5383,112 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + // reachability checks + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1 /* Unintialized */) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1 /* Unintialized */) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1 /* Unintialized */) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + // reference to unknown label or + // break/continue used outside of loops + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 /* Unintialized */ ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4 /* Unreachable */: + var reportError = + // report error on all statements + ts.isStatement(node) || + // report error on class declarations + node.kind === 214 /* ClassDeclaration */ || + // report error on instantiated modules or const-enums only modules if preserveConstEnums is set + (node.kind === 218 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + // report error on regular enums and const enums if preserveConstEnums is set + (node.kind === 217 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8 /* ReportedUnreachable */; + // unreachable code is reported if + // - user has explicitly asked about it AND + // - statement is in not ambient context (statements in ambient context is already an error + // so we should not report extras) AND + // - node is not variable statement OR + // - node is block scoped variable statement OR + // - node is not block scoped variable statement and at least one variable declaration has initializer + // Rationale: we don't want to report errors on non-initialized var's since they are hoisted + // On the other side we do want to report errors on non-initialized 'lets' because of TDZ + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 /* VariableStatement */ || + ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8 /* ReportedUnreachable */: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2 /* Reachable */; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); /// @@ -5127,8 +5499,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -5328,7 +5700,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -5441,7 +5813,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192 /* DeclarationFile */) !== 0; + return (file.flags & 4096 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -5478,11 +5850,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768 /* Const */); + return !!(getCombinedNodeFlags(node) & 16384 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Let */); + return !!(getCombinedNodeFlags(node) & 8192 /* Let */); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -5683,27 +6055,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143 /* MethodDeclaration */: @@ -6206,9 +6579,18 @@ var ts; return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { + if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) { return true; } node = node.parent; @@ -6266,7 +6648,7 @@ var ts; case 207 /* LabeledStatement */: case 204 /* ReturnStatement */: case 206 /* SwitchStatement */: - case 98 /* ThrowKeyword */: + case 208 /* ThrowStatement */: case 209 /* TryStatement */: case 193 /* VariableStatement */: case 198 /* WhileStatement */: @@ -6379,8 +6761,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -6392,7 +6774,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -6450,7 +6831,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256 /* Async */) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; /** @@ -6837,7 +7218,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) - && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -6894,6 +7275,66 @@ var ts; }); } ts.emitComments = emitComments; + /** + * Detached comment is a comment at the top of file or function body that is separated from + * the next statement by space. + */ + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -6983,16 +7424,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 128 /* Static */; - case 112 /* PublicKeyword */: return 16 /* Public */; - case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* PrivateKeyword */: return 32 /* Private */; - case 115 /* AbstractKeyword */: return 256 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 32768 /* Const */; - case 77 /* DefaultKeyword */: return 1024 /* Default */; - case 118 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 64 /* Static */; + case 112 /* PublicKeyword */: return 8 /* Public */; + case 111 /* ProtectedKeyword */: return 32 /* Protected */; + case 110 /* PrivateKeyword */: return 16 /* Private */; + case 115 /* AbstractKeyword */: return 128 /* Abstract */; + case 82 /* ExportKeyword */: return 2 /* Export */; + case 122 /* DeclareKeyword */: return 4 /* Ambient */; + case 74 /* ConstKeyword */: return 16384 /* Const */; + case 77 /* DefaultKeyword */: return 512 /* Default */; + case 118 /* AsyncKeyword */: return 256 /* Async */; } return 0; } @@ -7073,7 +7514,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -7150,6 +7591,12 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !ts.isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false); + } + ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -7414,8 +7861,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -7982,8 +8429,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -8021,7 +8468,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 /* DeclarationFile */ : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; return sourceFile; } @@ -9079,7 +9526,7 @@ var ts; if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536 /* OctalLiteral */; + node.flags |= 32768 /* OctalLiteral */; } return node; } @@ -9832,7 +10279,7 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } - var isAsync = !!(arrowFunction.flags & 512 /* Async */); + var isAsync = !!(arrowFunction.flags & 256 /* Async */); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; @@ -9959,7 +10406,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -10802,7 +11249,7 @@ var ts; var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(20 /* CloseBracketToken */); return finishNode(node); @@ -10863,7 +11310,7 @@ var ts; var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); parseExpected(16 /* CloseBraceToken */); @@ -10884,7 +11331,7 @@ var ts; parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -11476,10 +11923,10 @@ var ts; case 102 /* VarKeyword */: break; case 108 /* LetKeyword */: - node.flags |= 16384 /* Let */; + node.flags |= 8192 /* Let */; break; case 74 /* ConstKeyword */: - node.flags |= 32768 /* Const */; + node.flags |= 16384 /* Const */; break; default: ts.Debug.fail(); @@ -11522,9 +11969,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -11546,7 +11993,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512 /* Async */); + var isAsync = !!(method.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -11567,7 +12014,7 @@ var ts; // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 128 /* Static */ + property.initializer = modifiers && modifiers.flags & 64 /* Static */ ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); parseSemicolon(); @@ -11900,13 +12347,13 @@ var ts; var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 131072 /* Namespace */; + var namespaceFlag = flags & 65536 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 2 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -11921,7 +12368,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 131072 /* Namespace */; + flags |= 65536 /* Namespace */; } else { parseExpected(125 /* ModuleKeyword */); @@ -12179,7 +12626,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 /* Export */ + return node.flags & 2 /* Export */ || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ || node.kind === 222 /* ImportDeclaration */ || node.kind === 227 /* ExportAssignment */ @@ -12868,8 +13315,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -13006,8 +13453,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -13374,6 +13821,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13643,7 +14091,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 /* PropertyDeclaration */ && - (current.parent.flags & 128 /* Static */) === 0 && + (current.parent.flags & 64 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -13725,7 +14173,7 @@ var ts; // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -13739,7 +14187,7 @@ var ts; case 186 /* ClassExpression */: case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 128 /* Static */) { + if (lastLocation && lastLocation.flags & 64 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -14267,8 +14715,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } @@ -14515,7 +14963,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1 /* Export */) && + !(anyImportSyntax.flags & 2 /* Export */) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -14669,8 +15117,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -14860,7 +15308,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64 /* Static */; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -14971,8 +15419,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { writePunctuation(writer, 53 /* QuestionToken */); @@ -15186,7 +15634,7 @@ var ts; case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -15198,7 +15646,7 @@ var ts; case 146 /* SetAccessor */: case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & (32 /* Private */ | 64 /* Protected */)) { + if (node.flags & (16 /* Private */ | 32 /* Protected */)) { // Private/protected properties/methods are not visible return false; } @@ -15728,8 +16176,8 @@ var ts; // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -15934,13 +16382,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215 /* InterfaceDeclaration */) { - if (declaration.flags & 524288 /* ContainsThis */) { + if (declaration.flags & 262144 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -16130,8 +16578,8 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; @@ -16140,15 +16588,15 @@ var ts; // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -16156,8 +16604,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -16200,8 +16648,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); @@ -16247,8 +16695,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -16277,8 +16725,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -16342,8 +16790,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -16522,12 +16970,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 /* Private */ | 32 /* Protected */))) { if (!props) { props = [prop]; } @@ -16549,8 +16997,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -16908,8 +17356,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064 /* PropagatingFlags */; @@ -17059,8 +17507,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214 /* ClassDeclaration */: case 215 /* InterfaceDeclaration */: @@ -17170,8 +17618,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -17193,8 +17641,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -17310,7 +17758,8 @@ var ts; var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { - if (!(container.flags & 128 /* Static */)) { + if (!(container.flags & 64 /* Static */) && + (container.kind !== 144 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -17377,8 +17826,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -17417,8 +17866,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -17836,8 +18285,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0 /* False */; @@ -17859,8 +18308,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -17882,8 +18331,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0 /* False */; @@ -18008,8 +18457,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -18023,20 +18472,20 @@ var ts; else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ || targetPropFlags & 16 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ && targetPropFlags & 16 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 /* Private */ ? source : target), typeToString(sourcePropFlags & 16 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetPropFlags & 64 /* Protected */) { + else if (targetPropFlags & 32 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -18047,7 +18496,7 @@ var ts; return 0 /* False */; } } - else if (sourcePropFlags & 64 /* Protected */) { + else if (sourcePropFlags & 32 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -18089,8 +18538,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -18130,13 +18579,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -18167,8 +18616,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128 /* Abstract */; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. if (reportErrors) { @@ -18284,7 +18733,7 @@ var ts; var targetType = getIndexTypeOfType(target, 0 /* String */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: string]: any } = { property: 12 };` return -1 /* True */; } @@ -18313,7 +18762,7 @@ var ts; var targetType = getIndexTypeOfType(target, 1 /* Number */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: number]: any } = { property: 12 };` return -1 /* True */; } @@ -18386,8 +18835,8 @@ var ts; if (sourceProp === targetProp) { return -1 /* True */; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 /* Private */ | 32 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 /* Private */ | 32 /* Protected */); if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -18455,8 +18904,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -18692,8 +19141,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -18774,8 +19223,8 @@ var ts; var typeParameterCount = 0; var typeParameter; // First infer to each type in union or intersection that isn't a type parameter - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -18797,8 +19246,8 @@ var ts; else if (source.flags & 49152 /* UnionOrIntersection */) { // Source is a union or intersection type, infer from each consituent type var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -18832,8 +19281,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -19324,9 +19773,9 @@ var ts; symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } - // 1. walk from the use site up to the declaration and check + // 1. walk from the use site up to the declaration and check // if there is anything function like between declaration and use-site (is binding/class is captured in function). - // 2. walk from the declaration up to the boundary of lexical environment and check + // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container; if (symbol.flags & 32 /* Class */) { @@ -19398,7 +19847,7 @@ var ts; break; case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -19411,7 +19860,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -19441,7 +19890,7 @@ var ts; var nodeCheckFlag = 0; // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { - if ((container.flags & 128 /* Static */) || isCallExpression) { + if ((container.flags & 64 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { @@ -19497,7 +19946,7 @@ var ts; // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { return container.kind === 143 /* MethodDeclaration */ || container.kind === 142 /* MethodSignature */ || container.kind === 145 /* GetAccessor */ || @@ -19654,8 +20103,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -19845,8 +20294,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -19926,8 +20375,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; @@ -20259,8 +20708,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { @@ -20479,7 +20928,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -20558,7 +21006,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; } /** * Check whether the requested property access is valid. @@ -20588,7 +21036,7 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -20598,7 +21046,7 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & (32 /* Private */ | 64 /* Protected */))) { + if (!(flags & (16 /* Private */ | 32 /* Protected */))) { return true; } // Property is known to be private or protected at this point @@ -20606,7 +21054,7 @@ var ts; var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; // Private property is accessible if declaring and enclosing class are the same - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -20624,7 +21072,7 @@ var ts; return false; } // No further restrictions for static properties - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return true; } // An instance property must be accessed through an instance of the enclosing class @@ -20851,8 +21299,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -21494,8 +21942,8 @@ var ts; // declare function f(a: { xa: number; xb: number; }); // f({ | if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -21514,8 +21962,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -21652,7 +22100,7 @@ var ts; // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + if (valueDecl && valueDecl.flags & 128 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -22017,19 +22465,11 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); - } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type // must have at least one return statement somewhere in its body. // An exception to this rule is if the function implementation consists of a single 'throw' statement. - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } @@ -22038,22 +22478,19 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { + // also if HasImplicitReturnValue flags is not set this means that all codepaths in function body end with return of throw + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { return; } - var bodyBlock = func.body; - // Ensure the body has at least one return expression. - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - // If there are no return expressions, then we need to check if - // the function body consists solely of a throw statement; - // this is to make an exception for unimplemented functions. - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + // This function does not conform to the specification. + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - // This function does not conform to the specification. - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); @@ -22120,7 +22557,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -22205,7 +22642,7 @@ var ts; case 69 /* Identifier */: case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; } case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; @@ -22213,7 +22650,7 @@ var ts; if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384 /* Const */) !== 0; } return false; } @@ -22298,8 +22735,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -22315,8 +22752,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -22361,8 +22798,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; @@ -22896,7 +23333,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112 /* AccessibilityModifier */) { + if (node.flags & 56 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -23096,7 +23533,7 @@ var ts; checkFunctionLikeDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (node.flags & 256 /* Abstract */ && node.body) { + if (node.flags & 128 /* Abstract */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -23147,7 +23584,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 /* PropertyDeclaration */ && - !(n.flags & 128 /* Static */) && + !(n.flags & 64 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -23168,14 +23605,14 @@ var ts; // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 /* Public */ | 16 /* Private */ | 32 /* Protected */); }); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -23203,8 +23640,15 @@ var ts; // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { + if (node.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { @@ -23213,7 +23657,7 @@ var ts; var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -23284,7 +23728,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); + return (node.flags & 16 /* Private */) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -23316,8 +23760,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -23332,11 +23776,11 @@ var ts; n.parent.kind !== 214 /* ClassDeclaration */ && n.parent.kind !== 186 /* ClassExpression */ && ts.isInAmbientContext(n)) { - if (!(flags & 2 /* Ambient */)) { + if (!(flags & 4 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 2 /* Export */; } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; } return flags & flagsToCheck; } @@ -23361,16 +23805,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1 /* Export */) { + if (deviation & 2 /* Export */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 4 /* Ambient */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 /* Private */ | 64 /* Protected */)) { + else if (deviation & (16 /* Private */ | 32 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256 /* Abstract */) { + else if (deviation & 128 /* Abstract */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -23387,7 +23831,7 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; + var flagsToCheck = 2 /* Export */ | 4 /* Ambient */ | 16 /* Private */ | 32 /* Protected */ | 128 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -23418,8 +23862,8 @@ var ts; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); - ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); - var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */)); + var diagnostic = node.flags & 64 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -23436,7 +23880,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -23449,8 +23893,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; @@ -23507,7 +23951,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { + !(lastSeenNonAmbientDeclaration.flags & 128 /* Abstract */)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -23533,8 +23977,8 @@ var ts; // function g(x: string, y: string) { } // // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -23571,9 +24015,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 /* Export */ | 512 /* Default */); + if (effectiveDeclarationFlags & 2 /* Export */) { + if (effectiveDeclarationFlags & 512 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -23826,9 +24270,12 @@ var ts; // type as a value. As such, we will just return unknownType; return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } // Validate the promise constructor type. @@ -24020,7 +24467,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -24162,7 +24609,7 @@ var ts; // let x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers @@ -24177,7 +24624,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent @@ -24330,6 +24777,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194 /* EmptyStatement */) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -24688,7 +25138,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144 /* Constructor */) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -24835,7 +25285,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + if (!(member.flags & 64 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -24921,7 +25371,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024 /* Default */)) { + if (!node.name && !(node.flags & 512 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -24975,8 +25425,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -25024,8 +25474,8 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728 /* Prototype */) { continue; @@ -25043,7 +25493,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 128 /* Abstract */))) { if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -25055,11 +25505,11 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + if ((baseDeclarationFlags & 16 /* Private */) || (derivedDeclarationFlags & 16 /* Private */)) { // either base or derived property is private - not override, skip it continue; } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + if ((baseDeclarationFlags & 64 /* Static */) !== (derivedDeclarationFlags & 64 /* Static */)) { // value of 'static' is not the same for properties - not override, skip it continue; } @@ -25130,11 +25580,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -25431,8 +25881,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 /* ClassDeclaration */ || (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -25571,7 +26021,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -25599,7 +26049,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -25630,7 +26080,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -25674,7 +26124,7 @@ var ts; return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69 /* Identifier */) { @@ -26087,7 +26537,7 @@ var ts; // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 128 /* Static */)) { + if (!(memberFlags & 64 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; @@ -26388,7 +26838,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -26709,7 +27159,7 @@ var ts; function initializeTypeChecker() { // Bind all source files and propagate errors ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { @@ -26863,19 +27313,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112 /* AccessibilityModifier */) { + if (flags & 56 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128 /* Static */) { + else if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -26886,10 +27336,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113 /* StaticKeyword */: - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { @@ -26898,23 +27348,23 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128 /* Static */; + flags |= 64 /* Static */; lastStatic = modifier; break; case 82 /* ExportKeyword */: - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214 /* ClassDeclaration */) { @@ -26923,13 +27373,13 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 2 /* Export */; break; case 122 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.parent.kind === 214 /* ClassDeclaration */) { @@ -26941,69 +27391,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; lastDeclare = modifier; break; case 115 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214 /* ClassDeclaration */) { if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256 /* Abstract */; + flags |= 128 /* Abstract */; break; case 118 /* AsyncKeyword */: - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512 /* Async */; + flags |= 256 /* Async */; lastAsync = modifier; break; } } if (node.kind === 144 /* Constructor */) { - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64 /* Protected */) { + else if (flags & 32 /* Protected */) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32 /* Private */) { + else if (flags & 16 /* Private */) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -27104,7 +27554,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035 /* Modifier */) { + if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -27124,7 +27574,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035 /* Modifier */) { + if (node.flags & 1022 /* Modifier */) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -27147,8 +27597,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -27403,7 +27853,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035 /* Modifier */) { + else if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -27554,8 +28004,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -27691,8 +28141,8 @@ var ts; node.kind === 221 /* ImportEqualsDeclaration */ || node.kind === 228 /* ExportDeclaration */ || node.kind === 227 /* ExportAssignment */ || - (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 1024 /* Default */))) { + (node.flags & 4 /* Ambient */) || + (node.flags & (2 /* Export */ | 512 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -27739,7 +28189,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.flags & 32768 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -27793,7 +28243,7 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || + if (referencedFile && ((referencedFile.flags & 4096 /* DeclarationFile */) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -27988,15 +28438,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -28142,6 +28592,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true /* remove comments */); emitLines(node.statements); } // Return a temp variable name to be used in `export default` statements. @@ -28258,10 +28709,10 @@ var ts; // If the node is parented in the current source file we need to emit export declare or just export if (node.parent === currentSourceFile) { // If the node is exported - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } else if (node.kind !== 215 /* InterfaceDeclaration */) { @@ -28270,16 +28721,16 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32 /* Private */) { + if (node.flags & 16 /* Private */) { write("private "); } - else if (node.flags & 64 /* Protected */) { + else if (node.flags & 32 /* Protected */) { write("protected "); } - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { write("static "); } - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } } @@ -28287,7 +28738,7 @@ var ts; // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28322,12 +28773,12 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1 /* Export */)) { + if (!node.importClause && !(node.flags & 2 /* Export */)) { // do not write non-exported import declarations that don't have import clauses return; } emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28392,7 +28843,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072 /* Namespace */) { + if (node.flags & 65536 /* Namespace */) { write("namespace "); } else { @@ -28464,7 +28915,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -28508,7 +28959,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { @@ -28574,7 +29025,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -28582,7 +29033,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } write("class "); @@ -28652,7 +29103,7 @@ var ts; if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32 /* Private */)) { + else if (!(node.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -28667,7 +29118,7 @@ var ts; } else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28771,7 +29222,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32 /* Private */)) { + if (!(node.flags & 16 /* Private */)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -28800,7 +29251,7 @@ var ts; var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -28818,7 +29269,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28905,7 +29356,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 16 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28936,7 +29387,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28997,7 +29448,7 @@ var ts; node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32 /* Private */)) { + else if (!(node.parent.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -29028,7 +29479,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -29170,7 +29621,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ + var declFileName = referencedFile.flags & 4096 /* DeclarationFile */ ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file @@ -29216,6 +29667,12 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29525,16 +29982,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { // We conservatively include alias symbols to cover cases where they're emitted as locals if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { @@ -29544,12 +29993,6 @@ var ts; } return true; } - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); function setLabeledJump(state, isBreak, labelText, labelMarker) { if (isBreak) { if (!state.labeledNonLocalBreaks) { @@ -31026,7 +31469,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 1024 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } @@ -31045,7 +31488,7 @@ var ts; emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; if (!multiLine) { write(" "); } @@ -31064,7 +31507,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -31693,7 +32136,7 @@ var ts; var current = node; while (current) { if (current.kind === 248 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { return false; @@ -31934,7 +32377,7 @@ var ts; // variables in variable declaration list were already hoisted return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152 /* BlockScoped */) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576 /* BlockScoped */) === 0) { // we are inside a converted loop - this can only happen in downlevel scenarios // record names for all variable declarations for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { @@ -32019,7 +32462,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576 /* BlockScoped */)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { @@ -32334,10 +32777,12 @@ var ts; // // for (let v of arr) { } // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + // we can't reuse 'arr' because it might be modified within the body of the loop. var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + var rhsReference = ts.createSynthesizedNode(69 /* Identifier */); + rhsReference.text = node.expression.kind === 69 /* Identifier */ ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for // the LHS will be emitted inside the body. emitStart(node.expression); @@ -32346,15 +32791,13 @@ var ts; emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); // _i < _a.length; emitStart(node.initializer); @@ -32609,7 +33052,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + if (ts.getCombinedNodeFlags(node) & 2 /* Export */) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -32631,7 +33074,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 227 /* ExportAssignment */); // only allow export default at a source file level if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!currentSourceFile.symbol.exports["___esModule"]) { @@ -32649,7 +33092,7 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { writeLine(); emitStart(node); // emit call to exporter only for top level nodes @@ -32657,7 +33100,7 @@ var ts; // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default"); } else { @@ -32668,7 +33111,7 @@ var ts; write(")"); } else { - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); @@ -32772,7 +33215,7 @@ var ts; // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; if (root.kind === 211 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -32854,8 +33297,8 @@ var ts; // to ensure value is evaluated exactly once. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { var propName = p.name; var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; @@ -32990,7 +33433,7 @@ var ts; // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isLetDefinedInLoop && node.parent.parent.kind !== 200 /* ForInStatement */ && @@ -33030,13 +33473,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && + return !!(node.flags & 2 /* Export */) && modulekind === 5 /* ES6 */ && node.parent.kind === 248 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); @@ -33063,7 +33506,7 @@ var ts; function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { // If we're not exporting the variables, there's nothing special here. // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { + if (!(node.flags & 2 /* Export */)) { return true; } // If we are exporting, but it's a top-level ES6 module exports, @@ -33246,7 +33689,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33466,7 +33909,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + if (languageVersion < 2 /* ES6 */ || node.flags & 256 /* Async */) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -33487,7 +33930,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -33525,7 +33968,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); @@ -33569,7 +34012,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -33604,15 +34047,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -33625,7 +34068,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128 /* Static */) { + if (property.flags & 64 /* Static */) { emitDeclarationName(node); } else { @@ -33724,7 +34167,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128 /* Static */) { + if (member.flags & 64 /* Static */) { write("static "); } if (member.kind === 145 /* GetAccessor */) { @@ -33774,7 +34217,7 @@ var ts; emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -33821,7 +34264,7 @@ var ts; // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -33941,7 +34384,7 @@ var ts; // _default = __decorate([dec], _default); // export default _default; // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */)) { write("export "); } write("let "); @@ -33950,7 +34393,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33980,7 +34423,7 @@ var ts; // emit name if // - node has a name // - this is default export with static initializers - if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -34016,8 +34459,8 @@ var ts; // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); @@ -34035,7 +34478,7 @@ var ts; } // If this is an exported class, but not on the top level (i.e. on an internal // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2 /* Export */)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -34044,7 +34487,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512 /* Default */) && thisNodeIsDecorated) { // if this is a top level default export of decorated class, write the export after the declaration. writeLine(); write("export default "); @@ -34126,13 +34569,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { + if (!(member.flags & 64 /* Static */)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfMembers(node, 64 /* Static */); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -34179,7 +34622,7 @@ var ts; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { + if ((member.flags & 64 /* Static */) !== staticFlag) { continue; } // skip members that cannot be decorated (such as the constructor) @@ -34580,7 +35023,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2 /* Export */) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -34611,7 +35054,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted writeLine(); emitStart(node); @@ -34623,7 +35066,7 @@ var ts; write(";"); } if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -34728,7 +35171,7 @@ var ts; } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2 /* Export */) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -34738,7 +35181,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -34841,7 +35284,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); @@ -34923,7 +35366,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1 /* Export */)) { + else if (!(node.flags & 2 /* Export */)) { write("var "); } } @@ -35014,8 +35457,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5 /* ES6 */); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -35158,8 +35601,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause var skipNode = importNode.kind === 228 /* ExportDeclaration */ || (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); @@ -35193,8 +35636,8 @@ var ts; // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -35225,8 +35668,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228 /* ExportDeclaration */) { continue; } @@ -35275,7 +35718,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 69 /* Identifier */ && node.flags & 512 /* Default */) { return; } if (started) { @@ -35338,7 +35781,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35348,11 +35791,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1 /* Export */) { + if (f.flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35362,7 +35805,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return; } if (node.kind === 213 /* FunctionDeclaration */) { @@ -35437,7 +35880,7 @@ var ts; // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; } function isCurrentFileSystemExternalModule() { @@ -35509,8 +35952,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222 /* ImportDeclaration */: @@ -35679,8 +36122,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; // Find the name of the external module var externalModuleName = getExternalModuleNameText(importNode); // Find the name of the module alias, if there is one @@ -35959,7 +36402,7 @@ var ts; // Start new file on new line writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; emitModule(node); @@ -35983,7 +36426,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -36232,10 +36675,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } /** * Determine if the given comment is a triple-slash * @@ -36350,57 +36789,14 @@ var ts; // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -36716,7 +37112,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; @@ -36774,8 +37170,8 @@ var ts; // Initialize a checker so that all our files are bound. getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -36793,7 +37189,7 @@ var ts; } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -36801,8 +37197,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -36822,7 +37218,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; @@ -36850,12 +37246,12 @@ var ts; } // update fileName -> file mapping for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -36905,7 +37301,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -37024,7 +37420,7 @@ var ts; } break; case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -37049,7 +37445,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -37059,13 +37455,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -37111,6 +37507,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); @@ -37157,13 +37554,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - // convert an absolute import path to path that is relative to current directory - // this was host still can locate it but files names in user output will be shorter (and thus look nicer). - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -37219,8 +37610,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -37344,6 +37735,7 @@ var ts; /// /// /// +/// /// var ts; (function (ts) { @@ -37493,6 +37885,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -37591,11 +37989,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, { name: "forceConsistentCasingInFileNames", type: "boolean", description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, + } ]; var optionNameMapCache; /* @internal */ @@ -37734,13 +38152,38 @@ var ts; */ function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + /** + * Remove the comments from a json like text. + * Comments can be single line comments (starting with # or //) or multiline comments using / * * / + * + * This method replace comment content by whitespace rather than completely remove them to keep positions in json parsing error reporting accurate. + */ + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1 /* ES5 */, /* skipTrivia */ false, 0 /* Standard */, jsonText); + var token; + while ((token = scanner.scan()) !== 1 /* EndOfFileToken */) { + switch (token) { + case 2 /* SingleLineCommentTrivia */: + case 3 /* MultiLineCommentTrivia */: + // replace comments with whitespace to preserve original character positions + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -37871,8 +38314,8 @@ var ts; var lastSingleLineCommentEnd = -1; var isFirstSingleLineComment = true; var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var currentComment = comments_2[_i]; // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { @@ -38004,6 +38447,8 @@ var ts; function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; + // This means "compare in a case insensitive manner." + var baseSensitivity = { sensitivity: "base" }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -38017,8 +38462,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -38047,8 +38492,8 @@ var ts; function allMatchesAreCaseSensitive(matches) { ts.Debug.assert(matches.length > 0); // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; if (!match.isCaseSensitive) { return false; } @@ -38123,8 +38568,8 @@ var ts; function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; var kind = match.kind; if (kind < bestMatchKind) { bestMatchKind = kind; @@ -38132,8 +38577,6 @@ var ts; } return bestMatchKind; } - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { // TODO(cyrusn): get the gamut of comparisons that VS already uses here. // Right now we just sort by kind first, and then by name of the item. @@ -38296,8 +38739,8 @@ var ts; } function addTopLevelNodes(nodes, topLevelNodes) { nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; switch (node.kind) { case 214 /* ClassDeclaration */: case 217 /* EnumDeclaration */: @@ -38340,8 +38783,8 @@ var ts; function getItemsWorker(nodes, createItem) { var items = []; var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var child = nodes_5[_i]; var item = createItem(child); if (item !== undefined) { if (item.text.length > 0) { @@ -38389,7 +38832,7 @@ var ts; if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 2035 /* Modifier */) === 0) { + if ((node.flags & 1022 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); @@ -38693,8 +39136,8 @@ var ts; // word part. That way we don't match something like 'Class' when the user types 'a'. // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; + for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { + var span = wordSpans_1[_i]; if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); @@ -38800,8 +39243,8 @@ var ts; // Only if all words have some sort of match is the pattern considered matched. var subWordTextChunks = segment.subWordTextChunks; var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; + for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { + var subWordTextChunk = subWordTextChunks_1[_i]; // Try to match the candidate with this word var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { @@ -39386,8 +39829,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0; _b < declarations.length; _b++) { - var declaration = declarations[_b]; + for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { + var declaration = declarations_7[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -39503,8 +39946,8 @@ var ts; // arg index. var argumentIndex = 0; var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; + for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { + var child = listChildren_1[_i]; if (child === node) { break; } @@ -40049,8 +40492,8 @@ var ts; return n; } var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -40212,17 +40655,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 32 /* Private */) + if (flags & 16 /* Private */) result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) + if (flags & 32 /* Protected */) result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) + if (flags & 8 /* Public */) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) + if (flags & 64 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256 /* Abstract */) + if (flags & 128 /* Abstract */) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1 /* Export */) + if (flags & 2 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -42366,8 +42809,8 @@ var ts; } } var inheritedIndentation = -1 /* Unknown */; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var child = nodes_6[_i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { @@ -42458,8 +42901,8 @@ var ts; } } function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; + for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { + var triviaItem = trivia_1[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); @@ -43056,7 +43499,6 @@ var ts; return node; } } - return node; } } function deriveActualIndentationFromList(list, index, sourceFile, options) { @@ -43307,17 +43749,17 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 2048 /* Synthetic */, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); list._children = []; var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_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); } @@ -43872,7 +44314,7 @@ var ts; break; case 138 /* Parameter */: // Only consider properties defined as constructor parameters - if (!(node.flags & 112 /* AccessibilityModifier */)) { + if (!(node.flags & 56 /* AccessibilityModifier */)) { break; } // fall through @@ -44148,13 +44590,15 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; + this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = ts.createFileMap(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); + for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { + var fileName = rootFileNames_1[_i]; + this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } // store the compilation settings this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); @@ -44162,7 +44606,7 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.createEntry = function (fileName) { + HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { @@ -44172,36 +44616,37 @@ var ts; scriptSnapshot: scriptSnapshot }; } - this.fileNameToEntry.set(fileName, entry); + this.fileNameToEntry.set(path, entry); return entry; }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); + HostCache.prototype.getEntry = function (path) { + return this.fileNameToEntry.get(path); }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); + HostCache.prototype.contains = function (path) { + return this.fileNameToEntry.contains(path); }; HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); + var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); + if (this.contains(path)) { + return this.getEntry(path); } - return this.createEntry(fileName); + return this.createEntry(fileName, path); }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { + this.fileNameToEntry.forEachValue(function (path, value) { if (value) { fileNames.push(value.hostFileName); } }); return fileNames; }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getVersion = function (path) { + var file = this.getEntry(path); return file && file.version; }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getScriptSnapshot = function (path) { + var file = this.getEntry(path); return file && file.scriptSnapshot; }; return HostCache; @@ -44383,7 +44828,8 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { + function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; @@ -44395,7 +44841,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + buckets[key] = bucket = ts.createFileMap(); } return bucket; } @@ -44403,14 +44849,13 @@ var ts; var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { var entries = ts.lookUp(buckets, name); var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); + entries.forEachValue(function (key, entry) { sourceFiles.push({ - name: i, + name: key, refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); - } + }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { bucket: name, @@ -44427,7 +44872,8 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. @@ -44437,7 +44883,7 @@ var ts; languageServiceRefCount: 0, owners: [] }; - bucket.set(fileName, entry); + bucket.set(path, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -44460,11 +44906,12 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); + bucket.remove(path); } } return { @@ -44871,7 +45318,7 @@ var ts; case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; case 247 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 138 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221 /* ImportEqualsDeclaration */: case 226 /* ImportSpecifier */: case 223 /* ImportClause */: @@ -44897,13 +45344,14 @@ var ts; return CancellationTokenObject; })(); function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; var lastProjectVersion; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + var currentDirectory = host.getCurrentDirectory(); // Check if the localized messages json is set, otherwise query the host for it if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); @@ -44915,8 +45363,7 @@ var ts; } var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { throw new Error("Could not find file: '" + fileName + "'."); } @@ -44968,7 +45415,7 @@ var ts; getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality ts.Debug.assert(!host.resolveModuleNames); @@ -44988,11 +45435,10 @@ var ts; // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; + if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings); } } } @@ -45048,7 +45494,8 @@ var ts; return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile && sourceFile.version === hostCache.getVersion(path); } function programUpToDate() { // If we haven't create a program yet, then it is not up-to-date @@ -45061,8 +45508,8 @@ var ts; return false; } // If any file is not up-to-date, then the whole program is not up-to-date - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; + for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { + var fileName = rootFileNames_2[_i]; if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } @@ -45237,8 +45684,8 @@ var ts; } function checkModifiers(modifiers) { if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; switch (modifier.kind) { case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: @@ -45940,8 +46387,8 @@ var ts; */ function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; + for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { + var element = namedImportsOrExports_1[_i]; // If this is the current item we are editing right now, do not filter it out if (element.getStart() <= position && position <= element.getEnd()) { continue; @@ -45965,8 +46412,8 @@ var ts; return contextualMemberSymbols; } var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; + for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { + var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members if (m.kind !== 245 /* PropertyAssignment */ && m.kind !== 246 /* ShorthandPropertyAssignment */ && @@ -45999,8 +46446,8 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; + for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { + var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (attr.getStart() <= position && position <= attr.getEnd()) { continue; @@ -46101,8 +46548,8 @@ var ts; var entries = []; if (symbols) { var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { + var symbol = symbols_3[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -46844,8 +47291,8 @@ var ts; } var fileNameToDocumentHighlights = {}; var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { var referenceEntry = _b[_a]; var fileName_1 = referenceEntry.fileName; @@ -46989,7 +47436,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } /** * For lack of a better name, this function takes a throw statement and returns the @@ -47027,7 +47473,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); @@ -47096,7 +47541,7 @@ var ts; case 219 /* ModuleBlock */: case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 256 /* Abstract */) { + if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); } else { @@ -47111,7 +47556,7 @@ var ts; nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 112 /* AccessibilityModifier */) { + if (modifierFlag & 56 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { return member.kind === 144 /* Constructor */ && member; }); @@ -47119,7 +47564,7 @@ var ts; nodes = nodes.concat(constructor.parameters); } } - else if (modifierFlag & 256 /* Abstract */) { + else if (modifierFlag & 128 /* Abstract */) { nodes = nodes.concat(container); } break; @@ -47135,19 +47580,19 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112 /* PublicKeyword */: - return 16 /* Public */; + return 8 /* Public */; case 110 /* PrivateKeyword */: - return 32 /* Private */; + return 16 /* Private */; case 111 /* ProtectedKeyword */: - return 64 /* Protected */; + return 32 /* Protected */; case 113 /* StaticKeyword */: - return 128 /* Static */; + return 64 /* Static */; case 82 /* ExportKeyword */: - return 1 /* Export */; + return 2 /* Export */; case 122 /* DeclareKeyword */: - return 2 /* Ambient */; + return 4 /* Ambient */; case 115 /* AbstractKeyword */: - return 256 /* Abstract */; + return 128 /* Abstract */; default: ts.Debug.fail(); } @@ -47346,8 +47791,8 @@ var ts; return undefined; } var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; + for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { + var entry = documentHighlights_1[_i]; for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { var highlightSpan = _b[_a]; result.push({ @@ -47365,8 +47810,8 @@ var ts; return undefined; } var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; + for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { + var referenceSymbol = referenceSymbols_1[_i]; ts.addRange(referenceEntries, referenceSymbol.references); } return referenceEntries; @@ -47451,8 +47896,8 @@ var ts; } else { var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { @@ -47512,7 +47957,7 @@ var ts; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16 /* Private */) ? d : undefined; }); if (privateDeclaration) { return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } @@ -47530,8 +47975,8 @@ var ts; var scope = undefined; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -47711,7 +48156,7 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: @@ -47739,7 +48184,7 @@ var ts; // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. - if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (64 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -47749,7 +48194,7 @@ var ts; function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: @@ -47827,7 +48272,7 @@ var ts; case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; @@ -47998,8 +48443,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -48115,7 +48560,6 @@ var ts; return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - ts.Debug.fail("Unknown declaration type"); } function isTypeReference(node) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { @@ -48694,8 +49138,8 @@ var ts; if (matchKind) { var parentElement = token.parent; var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; + for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { + var current = childNodes_1[_i]; if (current.kind === matchKind) { var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); @@ -49025,8 +49469,8 @@ var ts; // Disallow rename for elements that are defined in the standard TypeScript library. var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var current = declarations_10[_i]; var sourceFile_2 = current.getSourceFile(); var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { @@ -49609,7 +50053,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 8192 /* DeclarationFile */) { + if (sourceFile.flags & 4096 /* DeclarationFile */) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -49827,7 +50271,7 @@ var ts; ? variableDeclaration.parent.parent.initializer.declarations : undefined; // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { + if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) { if (declarations && declarations[0] === variableDeclaration) { if (isParentVariableStatement) { // First declaration - include let keyword @@ -49853,7 +50297,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -49873,7 +50317,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || + return !!(functionDeclaration.flags & 2 /* Export */) || (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { @@ -49967,7 +50411,6 @@ var ts; // fall through. case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; @@ -50008,8 +50451,6 @@ var ts; default: return spanInNode(node.parent); } - // Default to parent node - return spanInNode(node.parent); } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration @@ -50138,7 +50579,6 @@ var ts; // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; } return JSON.parse(settingsJson); }; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index badaff1c3e..d2758e6d5e 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -17,19 +17,22 @@ declare namespace ts { interface Map { [index: string]: T; } + type Path = string & { + __pathBrand: any; + }; interface FileMap { - get(fileName: string): T; - set(fileName: string, value: T): void; - contains(fileName: string): boolean; - remove(fileName: string): void; - forEachValue(f: (v: T) => void): void; + get(fileName: Path): T; + set(fileName: Path, value: T): void; + contains(fileName: Path): boolean; + remove(fileName: Path): void; + forEachValue(f: (key: Path, v: T) => void): void; clear(): void; } interface TextRange { pos: number; end: number; } - const enum SyntaxKind { + enum SyntaxKind { Unknown = 0, EndOfFileToken = 1, SingleLineCommentTrivia = 2, @@ -327,31 +330,34 @@ declare namespace ts { LastBinaryOperator = 68, FirstNode = 135, } - const enum NodeFlags { + enum NodeFlags { None = 0, - Export = 1, - Ambient = 2, - Public = 16, - Private = 32, - Protected = 64, - Static = 128, - Abstract = 256, - Async = 512, - Default = 1024, - MultiLine = 2048, - Synthetic = 4096, - DeclarationFile = 8192, - Let = 16384, - Const = 32768, - OctalLiteral = 65536, - Namespace = 131072, - ExportContext = 262144, - ContainsThis = 524288, - Modifier = 2035, - AccessibilityModifier = 112, - BlockScoped = 49152, + Export = 2, + Ambient = 4, + Public = 8, + Private = 16, + Protected = 32, + Static = 64, + Abstract = 128, + Async = 256, + Default = 512, + MultiLine = 1024, + Synthetic = 2048, + DeclarationFile = 4096, + Let = 8192, + Const = 16384, + OctalLiteral = 32768, + Namespace = 65536, + ExportContext = 131072, + ContainsThis = 262144, + HasImplicitReturn = 524288, + HasExplicitReturn = 1048576, + Modifier = 1022, + AccessibilityModifier = 56, + BlockScoped = 24576, + ReachabilityCheckFlags = 1572864, } - const enum JsxFlags { + enum JsxFlags { None = 0, IntrinsicNamedElement = 1, IntrinsicIndexedElement = 2, @@ -931,6 +937,7 @@ declare namespace ts { statements: NodeArray; endOfFileToken: Node; fileName: string; + path: Path; text: string; amdDependencies: { path: string; @@ -1093,7 +1100,7 @@ declare namespace ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; reportInaccessibleThisError(): void; } - const enum TypeFormatFlags { + enum TypeFormatFlags { None = 0, WriteArrayAsGenericType = 1, UseTypeOfFunction = 2, @@ -1104,7 +1111,7 @@ declare namespace ts { InElementType = 64, UseFullyQualifiedType = 128, } - const enum SymbolFormatFlags { + enum SymbolFormatFlags { None = 0, WriteTypeParametersOrArguments = 1, UseOnlyExternalAliasing = 2, @@ -1114,7 +1121,7 @@ declare namespace ts { parameterIndex: number; type: Type; } - const enum SymbolFlags { + enum SymbolFlags { None = 0, FunctionScopedVariable = 1, BlockScopedVariable = 2, @@ -1191,7 +1198,7 @@ declare namespace ts { interface SymbolTable { [index: string]: Symbol; } - const enum TypeFlags { + enum TypeFlags { Any = 1, String = 2, Number = 4, @@ -1262,7 +1269,7 @@ declare namespace ts { interface TypeParameter extends Type { constraint: Type; } - const enum SignatureKind { + enum SignatureKind { Call = 0, Construct = 1, } @@ -1272,7 +1279,7 @@ declare namespace ts { parameters: Symbol[]; typePredicate?: TypePredicate; } - const enum IndexKind { + enum IndexKind { String = 0, Number = 1, } @@ -1307,7 +1314,7 @@ declare namespace ts { Error = 1, Message = 2, } - const enum ModuleResolutionKind { + enum ModuleResolutionKind { Classic = 1, NodeJs = 2, } @@ -1352,10 +1359,14 @@ declare namespace ts { experimentalDecorators?: boolean; emitDecoratorMetadata?: boolean; moduleResolution?: ModuleResolutionKind; + allowUnusedLabels?: boolean; + allowUnreachableCode?: boolean; + noImplicitReturns?: boolean; + noFallthroughCasesInSwitch?: boolean; forceConsistentCasingInFileNames?: boolean; [option: string]: string | number | boolean; } - const enum ModuleKind { + enum ModuleKind { None = 0, CommonJS = 1, AMD = 2, @@ -1364,12 +1375,12 @@ declare namespace ts { ES6 = 5, ES2015 = 5, } - const enum JsxEmit { + enum JsxEmit { None = 0, Preserve = 1, React = 2, } - const enum NewLineKind { + enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, } @@ -1377,14 +1388,14 @@ declare namespace ts { line: number; character: number; } - const enum ScriptTarget { + enum ScriptTarget { ES3 = 0, ES5 = 1, ES6 = 2, ES2015 = 2, Latest = 2, } - const enum LanguageVariant { + enum LanguageVariant { Standard = 0, JSX = 1, } @@ -1938,7 +1949,7 @@ declare namespace ts { outputFiles: OutputFile[]; emitSkipped: boolean; } - const enum OutputFileType { + enum OutputFileType { JavaScript = 0, SourceMap = 1, Declaration = 2, @@ -1948,7 +1959,7 @@ declare namespace ts { writeByteOrderMark: boolean; text: string; } - const enum EndOfLineState { + enum EndOfLineState { None = 0, InMultiLineCommentTrivia = 1, InSingleQuoteStringLiteral = 2, @@ -2116,7 +2127,7 @@ declare namespace ts { static parameterName: string; static docCommentTagName: string; } - const enum ClassificationType { + enum ClassificationType { comment = 1, identifier = 2, keyword = 3, @@ -2159,7 +2170,7 @@ declare namespace ts { let disableIncrementalParsing: boolean; function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string; - function createDocumentRegistry(useCaseSensitiveFileNames?: boolean): DocumentRegistry; + function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory?: string): DocumentRegistry; function preProcessFile(sourceText: string, readImportFiles?: boolean): PreProcessedFileInfo; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 1e0c0edad0..8b0ef04f96 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -350,27 +350,30 @@ var ts; var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { NodeFlags[NodeFlags["None"] = 0] = "None"; - NodeFlags[NodeFlags["Export"] = 1] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 2] = "Ambient"; - NodeFlags[NodeFlags["Public"] = 16] = "Public"; - NodeFlags[NodeFlags["Private"] = 32] = "Private"; - NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; - NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; - NodeFlags[NodeFlags["Async"] = 512] = "Async"; - NodeFlags[NodeFlags["Default"] = 1024] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 16384] = "Let"; - NodeFlags[NodeFlags["Const"] = 32768] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 524288] = "ContainsThis"; - NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; + NodeFlags[NodeFlags["Export"] = 2] = "Export"; + NodeFlags[NodeFlags["Ambient"] = 4] = "Ambient"; + NodeFlags[NodeFlags["Public"] = 8] = "Public"; + NodeFlags[NodeFlags["Private"] = 16] = "Private"; + NodeFlags[NodeFlags["Protected"] = 32] = "Protected"; + NodeFlags[NodeFlags["Static"] = 64] = "Static"; + NodeFlags[NodeFlags["Abstract"] = 128] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 256] = "Async"; + NodeFlags[NodeFlags["Default"] = 512] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 1024] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 2048] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 4096] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 8192] = "Let"; + NodeFlags[NodeFlags["Const"] = 16384] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 32768] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 65536] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 131072] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 262144] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 524288] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 1048576] = "HasExplicitReturn"; + NodeFlags[NodeFlags["Modifier"] = 1022] = "Modifier"; + NodeFlags[NodeFlags["AccessibilityModifier"] = 56] = "AccessibilityModifier"; + NodeFlags[NodeFlags["BlockScoped"] = 24576] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 1572864] = "ReachabilityCheckFlags"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ @@ -690,6 +693,12 @@ var ts; })(ts.LanguageVariant || (ts.LanguageVariant = {})); var LanguageVariant = ts.LanguageVariant; /* @internal */ + (function (DiagnosticStyle) { + DiagnosticStyle[DiagnosticStyle["Simple"] = 0] = "Simple"; + DiagnosticStyle[DiagnosticStyle["Pretty"] = 1] = "Pretty"; + })(ts.DiagnosticStyle || (ts.DiagnosticStyle = {})); + var DiagnosticStyle = ts.DiagnosticStyle; + /* @internal */ (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 127] = "maxAsciiCharacter"; @@ -838,40 +847,50 @@ var ts; Ternary[Ternary["True"] = -1] = "True"; })(ts.Ternary || (ts.Ternary = {})); var Ternary = ts.Ternary; - function createFileMap(getCanonicalFileName) { + function createFileMap(keyMapper) { var files = {}; return { get: get, set: set, contains: contains, remove: remove, - clear: clear, - forEachValue: forEachValueInMap + forEachValue: forEachValueInMap, + clear: clear }; - function set(fileName, value) { - files[normalizeKey(fileName)] = value; - } - function get(fileName) { - return files[normalizeKey(fileName)]; - } - function contains(fileName) { - return hasProperty(files, normalizeKey(fileName)); - } - function remove(fileName) { - var key = normalizeKey(fileName); - delete files[key]; - } function forEachValueInMap(f) { - forEachValue(files, f); + for (var key in files) { + f(key, files[key]); + } } - function normalizeKey(key) { - return getCanonicalFileName(normalizeSlashes(key)); + // path should already be well-formed so it does not need to be normalized + function get(path) { + return files[toKey(path)]; + } + function set(path, value) { + files[toKey(path)] = value; + } + function contains(path) { + return hasProperty(files, toKey(path)); + } + function remove(path) { + var key = toKey(path); + delete files[key]; } function clear() { files = {}; } + function toKey(path) { + return keyMapper ? keyMapper(path) : path; + } } ts.createFileMap = createFileMap; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; (function (Comparison) { Comparison[Comparison["LessThan"] = -1] = "LessThan"; Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; @@ -897,8 +916,8 @@ var ts; ts.forEach = forEach; function contains(array, value) { if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; if (v === value) { return true; } @@ -921,8 +940,8 @@ var ts; function countWhere(array, predicate) { var count = 0; if (array) { - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; if (predicate(v)) { count++; } @@ -935,8 +954,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var item = array_3[_i]; if (f(item)) { result.push(item); } @@ -949,8 +968,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var v = array_4[_i]; result.push(f(v)); } } @@ -969,8 +988,8 @@ var ts; var result; if (array) { result = []; - for (var _i = 0; _i < array.length; _i++) { - var item = array[_i]; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var item = array_5[_i]; if (!contains(result, item)) { result.push(item); } @@ -981,8 +1000,8 @@ var ts; ts.deduplicate = deduplicate; function sum(array, prop) { var result = 0; - for (var _i = 0; _i < array.length; _i++) { - var v = array[_i]; + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var v = array_6[_i]; result += v[prop]; } return result; @@ -990,8 +1009,8 @@ var ts; ts.sum = sum; function addRange(to, from) { if (to && from) { - for (var _i = 0; _i < from.length; _i++) { - var v = from[_i]; + for (var _i = 0, from_1 = from; _i < from_1.length; _i++) { + var v = from_1[_i]; to.push(v); } } @@ -1341,8 +1360,8 @@ var ts; function getNormalizedParts(normalizedSlashedPath, rootLength) { var parts = normalizedSlashedPath.substr(rootLength).split(ts.directorySeparator); var normalized = []; - for (var _i = 0; _i < parts.length; _i++) { - var part = parts[_i]; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; if (part !== ".") { if (part === ".." && normalized.length > 0 && lastOrUndefined(normalized) !== "..") { normalized.pop(); @@ -1521,8 +1540,8 @@ var ts; if (!fileName) { return false; } - for (var _i = 0; _i < ts.supportedExtensions.length; _i++) { - var extension = ts.supportedExtensions[_i]; + for (var _i = 0, supportedExtensions_1 = ts.supportedExtensions; _i < supportedExtensions_1.length; _i++) { + var extension = supportedExtensions_1[_i]; if (fileExtensionIs(fileName, extension)) { return true; } @@ -1532,8 +1551,8 @@ var ts; ts.isSupportedSourceFileName = isSupportedSourceFileName; var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { - for (var _i = 0; _i < extensionsToRemove.length; _i++) { - var ext = extensionsToRemove[_i]; + for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { + var ext = extensionsToRemove_1[_i]; if (fileExtensionIs(path, ext)) { return path.substr(0, path.length - ext.length); } @@ -1614,8 +1633,8 @@ var ts; })(Debug = ts.Debug || (ts.Debug = {})); function copyListRemovingItem(item, list) { var copiedList = []; - for (var _i = 0; _i < list.length; _i++) { - var e = list[_i]; + for (var _i = 0, list_1 = list; _i < list_1.length; _i++) { + var e = list_1[_i]; if (e !== item) { copiedList.push(e); } @@ -1709,16 +1728,16 @@ var ts; function visitDirectory(path) { var folder = fso.GetFolder(path || "."); var files = getNames(folder.files); - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { + var current = files_1[_i]; var name_1 = ts.combinePaths(path, current); if ((!extension || ts.fileExtensionIs(name_1, extension)) && !ts.contains(exclude, getCanonicalPath(name_1))) { result.push(name_1); } } var subfolders = getNames(folder.subfolders); - for (var _a = 0; _a < subfolders.length; _a++) { - var current = subfolders[_a]; + for (var _a = 0, subfolders_1 = subfolders; _a < subfolders_1.length; _a++) { + var current = subfolders_1[_a]; var name_2 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_2))) { visitDirectory(name_2); @@ -1769,6 +1788,7 @@ var ts; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); + var _tty = require("tty"); // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond function createWatchedFileSet(interval, chunkSize) { @@ -1906,8 +1926,8 @@ var ts; function visitDirectory(path) { var files = _fs.readdirSync(path || ".").sort(); var directories = []; - for (var _i = 0; _i < files.length; _i++) { - var current = files[_i]; + for (var _i = 0, files_2 = files; _i < files_2.length; _i++) { + var current = files_2[_i]; var name_3 = ts.combinePaths(path, current); if (!ts.contains(exclude, getCanonicalPath(name_3))) { var stat = _fs.statSync(name_3); @@ -1921,8 +1941,8 @@ var ts; } } } - for (var _a = 0; _a < directories.length; _a++) { - var current = directories[_a]; + for (var _a = 0, directories_1 = directories; _a < directories_1.length; _a++) { + var current = directories_1[_a]; visitDirectory(current); } } @@ -1932,15 +1952,7 @@ var ts; newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, write: function (s) { - var buffer = new Buffer(s, "utf8"); - var offset = 0; - var toWrite = buffer.length; - var written = 0; - // 1 is a standard descriptor for stdout - while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { - offset += written; - toWrite -= written; - } + process.stdout.write(s); }, readFile: readFile, writeFile: writeFile, @@ -2223,6 +2235,7 @@ var ts; await_expression_is_only_allowed_within_an_async_function: { code: 1308, category: ts.DiagnosticCategory.Error, key: "await_expression_is_only_allowed_within_an_async_function_1308", message: "'await' expression is only allowed within an async function." }, Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1311, category: ts.DiagnosticCategory.Error, key: "Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher_1311", message: "Async functions are only available when targeting ECMAScript 6 and higher." }, can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: { code: 1312, category: ts.DiagnosticCategory.Error, key: "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", message: "'=' can only be used in an object literal property inside a destructuring assignment." }, + The_body_of_an_if_statement_cannot_be_the_empty_statement: { code: 1313, category: ts.DiagnosticCategory.Error, key: "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", message: "The body of an 'if' statement cannot be the empty statement." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2275,7 +2288,7 @@ var ts; Neither_type_0_nor_type_1_is_assignable_to_the_other: { code: 2352, category: ts.DiagnosticCategory.Error, key: "Neither_type_0_nor_type_1_is_assignable_to_the_other_2352", message: "Neither type '{0}' nor type '{1}' is assignable to the other." }, Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: { code: 2353, category: ts.DiagnosticCategory.Error, key: "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", message: "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'." }, No_best_common_type_exists_among_return_expressions: { code: 2354, category: ts.DiagnosticCategory.Error, key: "No_best_common_type_exists_among_return_expressions_2354", message: "No best common type exists among return expressions." }, - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_th_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement." }, + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: { code: 2355, category: ts.DiagnosticCategory.Error, key: "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", message: "A function whose declared type is neither 'void' nor 'any' must return a value." }, An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type: { code: 2356, category: ts.DiagnosticCategory.Error, key: "An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type_2356", message: "An arithmetic operand must be of type 'any', 'number' or an enum type." }, The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2357, category: ts.DiagnosticCategory.Error, key: "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer_2357", message: "The operand of an increment or decrement operator must be a variable, property or indexer." }, The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, @@ -2296,7 +2309,7 @@ var ts; Duplicate_number_index_signature: { code: 2375, category: ts.DiagnosticCategory.Error, key: "Duplicate_number_index_signature_2375", message: "Duplicate number index signature." }, A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: { code: 2376, category: ts.DiagnosticCategory.Error, key: "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", message: "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties." }, Constructors_for_derived_classes_must_contain_a_super_call: { code: 2377, category: ts.DiagnosticCategory.Error, key: "Constructors_for_derived_classes_must_contain_a_super_call_2377", message: "Constructors for derived classes must contain a 'super' call." }, - A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement_2378", message: "A 'get' accessor must return a value or consist of a single 'throw' statement." }, + A_get_accessor_must_return_a_value: { code: 2378, category: ts.DiagnosticCategory.Error, key: "A_get_accessor_must_return_a_value_2378", message: "A 'get' accessor must return a value." }, Getter_and_setter_accessors_do_not_agree_in_visibility: { code: 2379, category: ts.DiagnosticCategory.Error, key: "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", message: "Getter and setter accessors do not agree in visibility." }, get_and_set_accessor_must_have_the_same_type: { code: 2380, category: ts.DiagnosticCategory.Error, key: "get_and_set_accessor_must_have_the_same_type_2380", message: "'get' and 'set' accessor must have the same type." }, A_signature_with_an_implementation_cannot_use_a_string_literal_type: { code: 2381, category: ts.DiagnosticCategory.Error, key: "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", message: "A signature with an implementation cannot use a string literal type." }, @@ -2586,8 +2599,6 @@ var ts; NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE_6061", message: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument_for_newLine_option_must_be_CRLF_or_LF_6062", message: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, Argument_for_moduleResolution_option_must_be_node_or_classic: { code: 6063, category: ts.DiagnosticCategory.Error, key: "Argument_for_moduleResolution_option_must_be_node_or_classic_6063", message: "Argument for '--moduleResolution' option must be 'node' or 'classic'." }, - Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, - Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_decorators_6065", message: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_emitting_type_metadata_for_decorators_6066", message: "Enables experimental support for emitting type metadata for decorators." }, Enables_experimental_support_for_ES7_async_functions: { code: 6068, category: ts.DiagnosticCategory.Message, key: "Enables_experimental_support_for_ES7_async_functions_6068", message: "Enables experimental support for ES7 async functions." }, @@ -2595,7 +2606,14 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Disallow_inconsistently_cased_references_to_the_same_file: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6073", message: "Disallow inconsistently-cased references to the same file." }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, + Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, + Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, + Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, + Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_or_react_6080", message: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument_for_jsx_must_be_preserve_or_react_6081", message: "Argument for '--jsx' must be 'preserve' or 'react'." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." }, @@ -2613,6 +2631,10 @@ var ts; Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, + Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, + Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, + Not_all_code_paths_return_a_value: { code: 7030, category: ts.DiagnosticCategory.Error, key: "Not_all_code_paths_return_a_value_7030", message: "Not all code paths return a value." }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4166,6 +4188,20 @@ var ts; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); var ModuleInstanceState = ts.ModuleInstanceState; + var Reachability; + (function (Reachability) { + Reachability[Reachability["Unintialized"] = 1] = "Unintialized"; + Reachability[Reachability["Reachable"] = 2] = "Reachable"; + Reachability[Reachability["Unreachable"] = 4] = "Unreachable"; + Reachability[Reachability["ReportedUnreachable"] = 8] = "ReportedUnreachable"; + })(Reachability || (Reachability = {})); + function or(state1, state2) { + return (state1 | state2) & 2 /* Reachable */ + ? 2 /* Reachable */ + : (state1 & state2) & 8 /* ReportedUnreachable */ + ? 8 /* ReportedUnreachable */ + : 4 /* Unreachable */; + } function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations @@ -4175,7 +4211,7 @@ var ts; else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && !(node.flags & 2 /* Export */)) { return 0 /* NonInstantiated */; } else if (node.kind === 219 /* ModuleBlock */) { @@ -4226,31 +4262,56 @@ var ts; // Functions, Methods, Modules, Source-files. ContainerFlags[ContainerFlags["IsContainerWithLocals"] = 5] = "IsContainerWithLocals"; })(ContainerFlags || (ContainerFlags = {})); - function bindSourceFile(file) { + var binder = createBinder(); + function bindSourceFile(file, options) { var start = new Date().getTime(); - bindSourceFileWorker(file); + binder(file, options); ts.bindTime += new Date().getTime() - start; } ts.bindSourceFile = bindSourceFile; - function bindSourceFileWorker(file) { + function createBinder() { + var file; + var options; var parent; var container; var blockScopeContainer; var lastContainer; var seenThisKeyword; + // state used by reachability checks + var hasExplicitReturn; + var currentReachabilityState; + var labelStack; + var labelIndexMap; + var implicitLabels; // If this file is an external module, then it is automatically in strict-mode according to // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). - var inStrictMode = !!file.externalModuleIndicator; + var inStrictMode; var symbolCount = 0; - var Symbol = ts.objectAllocator.getSymbolConstructor(); - var classifiableNames = {}; - if (!file.locals) { - bind(file); - file.symbolCount = symbolCount; - file.classifiableNames = classifiableNames; + var Symbol; + var classifiableNames; + function bindSourceFile(f, opts) { + file = f; + options = opts; + inStrictMode = !!file.externalModuleIndicator; + classifiableNames = {}; + Symbol = ts.objectAllocator.getSymbolConstructor(); + if (!file.locals) { + bind(file); + file.symbolCount = symbolCount; + file.classifiableNames = classifiableNames; + } + parent = undefined; + container = undefined; + blockScopeContainer = undefined; + lastContainer = undefined; + seenThisKeyword = false; + hasExplicitReturn = false; + labelStack = undefined; + labelIndexMap = undefined; + implicitLabels = undefined; } - return; + return bindSourceFile; function createSymbol(flags, name) { symbolCount++; return new Symbol(flags, name); @@ -4303,7 +4364,7 @@ var ts; return node.isExportEquals ? "export=" : "default"; case 213 /* FunctionDeclaration */: case 214 /* ClassDeclaration */: - return node.flags & 1024 /* Default */ ? "default" : undefined; + return node.flags & 512 /* Default */ ? "default" : undefined; } } function getDisplayName(node) { @@ -4319,7 +4380,7 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = node.flags & 1024 /* Default */; + var isDefaultExport = node.flags & 512 /* Default */; // The exported symbol for an export default function/class node is always named "default" var name = isDefaultExport && parent ? "default" : getDeclarationName(node); var symbol; @@ -4358,7 +4419,7 @@ var ts; ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.flags & 1024 /* Default */) { + if (declaration.flags & 512 /* Default */) { message = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } }); @@ -4377,7 +4438,7 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; + var hasExportModifier = ts.getCombinedNodeFlags(node) & 2 /* Export */; if (symbolFlags & 8388608 /* Alias */) { if (node.kind === 230 /* ExportSpecifier */ || (node.kind === 221 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); @@ -4398,7 +4459,7 @@ var ts; // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || container.flags & 262144 /* ExportContext */) { + if (hasExportModifier || container.flags & 131072 /* ExportContext */) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -4453,18 +4514,229 @@ var ts; blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (node.kind === 215 /* InterfaceDeclaration */) { + var savedReachabilityState; + var savedLabelStack; + var savedLabels; + var savedImplicitLabels; + var savedHasExplicitReturn; + var kind = node.kind; + var flags = node.flags; + // reset all reachability check related flags on node (for incremental scenarios) + flags &= ~1572864 /* ReachabilityCheckFlags */; + if (kind === 215 /* InterfaceDeclaration */) { seenThisKeyword = false; - ts.forEachChild(node, bind); - node.flags = seenThisKeyword ? node.flags | 524288 /* ContainsThis */ : node.flags & ~524288 /* ContainsThis */; } - else { - ts.forEachChild(node, bind); + var saveState = kind === 248 /* SourceFile */ || kind === 219 /* ModuleBlock */ || ts.isFunctionLikeKind(kind); + if (saveState) { + savedReachabilityState = currentReachabilityState; + savedLabelStack = labelStack; + savedLabels = labelIndexMap; + savedImplicitLabels = implicitLabels; + savedHasExplicitReturn = hasExplicitReturn; + currentReachabilityState = 2 /* Reachable */; + hasExplicitReturn = false; + labelStack = labelIndexMap = implicitLabels = undefined; + } + bindReachableStatement(node); + if (currentReachabilityState === 2 /* Reachable */ && ts.isFunctionLikeKind(kind) && ts.nodeIsPresent(node.body)) { + flags |= 524288 /* HasImplicitReturn */; + if (hasExplicitReturn) { + flags |= 1048576 /* HasExplicitReturn */; + } + } + if (kind === 215 /* InterfaceDeclaration */) { + flags = seenThisKeyword ? flags | 262144 /* ContainsThis */ : flags & ~262144 /* ContainsThis */; + } + node.flags = flags; + if (saveState) { + hasExplicitReturn = savedHasExplicitReturn; + currentReachabilityState = savedReachabilityState; + labelStack = savedLabelStack; + labelIndexMap = savedLabels; + implicitLabels = savedImplicitLabels; } container = saveContainer; parent = saveParent; blockScopeContainer = savedBlockScopeContainer; } + /** + * Returns true if node and its subnodes were successfully traversed. + * Returning false means that node was not examined and caller needs to dive into the node himself. + */ + function bindReachableStatement(node) { + if (checkUnreachable(node)) { + ts.forEachChild(node, bind); + return; + } + switch (node.kind) { + case 198 /* WhileStatement */: + bindWhileStatement(node); + break; + case 197 /* DoStatement */: + bindDoStatement(node); + break; + case 199 /* ForStatement */: + bindForStatement(node); + break; + case 200 /* ForInStatement */: + case 201 /* ForOfStatement */: + bindForInOrForOfStatement(node); + break; + case 196 /* IfStatement */: + bindIfStatement(node); + break; + case 204 /* ReturnStatement */: + case 208 /* ThrowStatement */: + bindReturnOrThrow(node); + break; + case 203 /* BreakStatement */: + case 202 /* ContinueStatement */: + bindBreakOrContinueStatement(node); + break; + case 209 /* TryStatement */: + bindTryStatement(node); + break; + case 206 /* SwitchStatement */: + bindSwitchStatement(node); + break; + case 220 /* CaseBlock */: + bindCaseBlock(node); + break; + case 207 /* LabeledStatement */: + bindLabeledStatement(node); + break; + default: + ts.forEachChild(node, bind); + break; + } + } + function bindWhileStatement(n) { + var preWhileState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + var postWhileState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // bind expressions (don't affect reachability) + bind(n.expression); + currentReachabilityState = preWhileState; + var postWhileLabel = pushImplicitLabel(); + bind(n.statement); + popImplicitLabel(postWhileLabel, postWhileState); + } + function bindDoStatement(n) { + var preDoState = currentReachabilityState; + var postDoLabel = pushImplicitLabel(); + bind(n.statement); + var postDoState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : preDoState; + popImplicitLabel(postDoLabel, postDoState); + // bind expressions (don't affect reachability) + bind(n.expression); + } + function bindForStatement(n) { + var preForState = currentReachabilityState; + var postForLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.condition); + bind(n.incrementor); + bind(n.statement); + // for statement is considered infinite when it condition is either omitted or is true keyword + // - for(..;;..) + // - for(..;true;..) + var isInfiniteLoop = (!n.condition || n.condition.kind === 99 /* TrueKeyword */); + var postForState = isInfiniteLoop ? 4 /* Unreachable */ : preForState; + popImplicitLabel(postForLabel, postForState); + } + function bindForInOrForOfStatement(n) { + var preStatementState = currentReachabilityState; + var postStatementLabel = pushImplicitLabel(); + // bind expressions (don't affect reachability) + bind(n.initializer); + bind(n.expression); + bind(n.statement); + popImplicitLabel(postStatementLabel, preStatementState); + } + function bindIfStatement(n) { + // denotes reachability state when entering 'thenStatement' part of the if statement: + // i.e. if condition is false then thenStatement is unreachable + var ifTrueState = n.expression.kind === 84 /* FalseKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + // denotes reachability state when entering 'elseStatement': + // i.e. if condition is true then elseStatement is unreachable + var ifFalseState = n.expression.kind === 99 /* TrueKeyword */ ? 4 /* Unreachable */ : currentReachabilityState; + currentReachabilityState = ifTrueState; + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.thenStatement); + if (n.elseStatement) { + var preElseState = currentReachabilityState; + currentReachabilityState = ifFalseState; + bind(n.elseStatement); + currentReachabilityState = or(currentReachabilityState, preElseState); + } + else { + currentReachabilityState = or(currentReachabilityState, ifFalseState); + } + } + function bindReturnOrThrow(n) { + // bind expression (don't affect reachability) + bind(n.expression); + if (n.kind === 204 /* ReturnStatement */) { + hasExplicitReturn = true; + } + currentReachabilityState = 4 /* Unreachable */; + } + function bindBreakOrContinueStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + // for continue case touch label so it will be marked a used + var isValidJump = jumpToLabel(n.label, n.kind === 203 /* BreakStatement */ ? currentReachabilityState : 4 /* Unreachable */); + if (isValidJump) { + currentReachabilityState = 4 /* Unreachable */; + } + } + function bindTryStatement(n) { + // catch\finally blocks has the same reachability as try block + var preTryState = currentReachabilityState; + bind(n.tryBlock); + var postTryState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.catchClause); + var postCatchState = currentReachabilityState; + currentReachabilityState = preTryState; + bind(n.finallyBlock); + // post catch/finally state is reachable if + // - post try state is reachable - control flow can fall out of try block + // - post catch state is reachable - control flow can fall out of catch block + currentReachabilityState = or(postTryState, postCatchState); + } + function bindSwitchStatement(n) { + var preSwitchState = currentReachabilityState; + var postSwitchLabel = pushImplicitLabel(); + // bind expression (don't affect reachability) + bind(n.expression); + bind(n.caseBlock); + var hasDefault = ts.forEach(n.caseBlock.clauses, function (c) { return c.kind === 242 /* DefaultClause */; }); + // post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case + var postSwitchState = hasDefault && currentReachabilityState !== 2 /* Reachable */ ? 4 /* Unreachable */ : preSwitchState; + popImplicitLabel(postSwitchLabel, postSwitchState); + } + function bindCaseBlock(n) { + var startState = currentReachabilityState; + for (var _i = 0, _a = n.clauses; _i < _a.length; _i++) { + var clause = _a[_i]; + currentReachabilityState = startState; + bind(clause); + if (clause.statements.length && currentReachabilityState === 2 /* Reachable */ && options.noFallthroughCasesInSwitch) { + errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } + } + } + function bindLabeledStatement(n) { + // call bind on label (don't affect reachability) + bind(n.label); + var ok = pushNamedLabel(n.label); + bind(n.statement); + if (ok) { + popNamedLabel(n.label, currentReachabilityState); + } + } function getContainerFlags(node) { switch (node.kind) { case 186 /* ClassExpression */: @@ -4576,7 +4848,7 @@ var ts; } } function declareClassMember(node, symbolFlags, symbolExcludes) { - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes) : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); } @@ -4585,15 +4857,6 @@ var ts; ? declareModuleMember(node, symbolFlags, symbolExcludes) : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } - function isAmbientContext(node) { - while (node) { - if (node.flags & 2 /* Ambient */) { - return true; - } - node = node.parent; - } - return false; - } function hasExportDeclarations(node) { var body = node.kind === 248 /* SourceFile */ ? node : node.body; if (body.kind === 248 /* SourceFile */ || body.kind === 219 /* ModuleBlock */) { @@ -4609,11 +4872,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 262144 /* ExportContext */; + if (ts.isInAmbientContext(node) && !hasExportDeclarations(node)) { + node.flags |= 131072 /* ExportContext */; } else { - node.flags &= ~262144 /* ExportContext */; + node.flags &= ~131072 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -4805,7 +5068,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { + if (inStrictMode && node.flags & 32768 /* OctalLiteral */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -4829,10 +5092,10 @@ var ts; function checkStrictModeWithStatement(node) { // Grammar checking for withStatement if (inStrictMode) { - grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); + errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode); } } - function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) { + function errorOnFirstToken(node, message, arg0, arg1, arg2) { var span = ts.getSpanOfTokenAtPosition(file, node.pos); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2)); } @@ -4840,6 +5103,9 @@ var ts; return "__" + ts.indexOf(node.parent.parameters, node); } function bind(node) { + if (!node) { + return; + } node.parent = parent; var savedInStrictMode = inStrictMode; if (!savedInStrictMode) { @@ -4882,8 +5148,8 @@ var ts; } } function updateStrictModeStatementList(statements) { - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -5105,7 +5371,7 @@ var ts; } // If this is a property-parameter, then also declare the property symbol into the // containing class. - if (node.flags & 112 /* AccessibilityModifier */ && + if (node.flags & 56 /* AccessibilityModifier */ && node.parent.kind === 144 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; @@ -5117,6 +5383,112 @@ var ts; ? bindAnonymousDeclaration(node, symbolFlags, "__computed") : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } + // reachability checks + function pushNamedLabel(name) { + initializeReachabilityStateIfNecessary(); + if (ts.hasProperty(labelIndexMap, name.text)) { + return false; + } + labelIndexMap[name.text] = labelStack.push(1 /* Unintialized */) - 1; + return true; + } + function pushImplicitLabel() { + initializeReachabilityStateIfNecessary(); + var index = labelStack.push(1 /* Unintialized */) - 1; + implicitLabels.push(index); + return index; + } + function popNamedLabel(label, outerState) { + var index = labelIndexMap[label.text]; + ts.Debug.assert(index !== undefined); + ts.Debug.assert(labelStack.length == index + 1); + labelIndexMap[label.text] = undefined; + setCurrentStateAtLabel(labelStack.pop(), outerState, label); + } + function popImplicitLabel(implicitLabelIndex, outerState) { + if (labelStack.length !== implicitLabelIndex + 1) { + ts.Debug.assert(false, "Label stack: " + labelStack.length + ", index:" + implicitLabelIndex); + } + var i = implicitLabels.pop(); + if (implicitLabelIndex !== i) { + ts.Debug.assert(false, "i: " + i + ", index: " + implicitLabelIndex); + } + setCurrentStateAtLabel(labelStack.pop(), outerState, /*name*/ undefined); + } + function setCurrentStateAtLabel(innerMergedState, outerState, label) { + if (innerMergedState === 1 /* Unintialized */) { + if (label && !options.allowUnusedLabels) { + file.bindDiagnostics.push(ts.createDiagnosticForNode(label, ts.Diagnostics.Unused_label)); + } + currentReachabilityState = outerState; + } + else { + currentReachabilityState = or(innerMergedState, outerState); + } + } + function jumpToLabel(label, outerState) { + initializeReachabilityStateIfNecessary(); + var index = label ? labelIndexMap[label.text] : ts.lastOrUndefined(implicitLabels); + if (index === undefined) { + // reference to unknown label or + // break/continue used outside of loops + return false; + } + var stateAtLabel = labelStack[index]; + labelStack[index] = stateAtLabel === 1 /* Unintialized */ ? outerState : or(stateAtLabel, outerState); + return true; + } + function checkUnreachable(node) { + switch (currentReachabilityState) { + case 4 /* Unreachable */: + var reportError = + // report error on all statements + ts.isStatement(node) || + // report error on class declarations + node.kind === 214 /* ClassDeclaration */ || + // report error on instantiated modules or const-enums only modules if preserveConstEnums is set + (node.kind === 218 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + // report error on regular enums and const enums if preserveConstEnums is set + (node.kind === 217 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + if (reportError) { + currentReachabilityState = 8 /* ReportedUnreachable */; + // unreachable code is reported if + // - user has explicitly asked about it AND + // - statement is in not ambient context (statements in ambient context is already an error + // so we should not report extras) AND + // - node is not variable statement OR + // - node is block scoped variable statement OR + // - node is not block scoped variable statement and at least one variable declaration has initializer + // Rationale: we don't want to report errors on non-initialized var's since they are hoisted + // On the other side we do want to report errors on non-initialized 'lets' because of TDZ + var reportUnreachableCode = !options.allowUnreachableCode && + !ts.isInAmbientContext(node) && + (node.kind !== 193 /* VariableStatement */ || + ts.getCombinedNodeFlags(node.declarationList) & 24576 /* BlockScoped */ || + ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); + if (reportUnreachableCode) { + errorOnFirstToken(node, ts.Diagnostics.Unreachable_code_detected); + } + } + case 8 /* ReportedUnreachable */: + return true; + default: + return false; + } + function shouldReportErrorOnModuleDeclaration(node) { + var instanceState = getModuleInstanceState(node); + return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && options.preserveConstEnums); + } + } + function initializeReachabilityStateIfNecessary() { + if (labelIndexMap) { + return; + } + currentReachabilityState = 2 /* Reachable */; + labelIndexMap = {}; + labelStack = []; + implicitLabels = []; + } } })(ts || (ts = {})); /// @@ -5127,8 +5499,8 @@ var ts; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) { + var declaration = declarations_1[_i]; if (declaration.kind === kind) { return declaration; } @@ -5328,7 +5700,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 24576 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -5441,7 +5813,7 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 8192 /* DeclarationFile */) !== 0; + return (file.flags & 4096 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { @@ -5478,11 +5850,11 @@ var ts; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 32768 /* Const */); + return !!(getCombinedNodeFlags(node) & 16384 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 16384 /* Let */); + return !!(getCombinedNodeFlags(node) & 8192 /* Let */); } ts.isLet = isLet; function isPrologueDirective(node) { @@ -5683,27 +6055,28 @@ var ts; } ts.isClassLike = isClassLike; function isFunctionLike(node) { - if (node) { - switch (node.kind) { - case 144 /* Constructor */: - case 173 /* FunctionExpression */: - case 213 /* FunctionDeclaration */: - case 174 /* ArrowFunction */: - case 143 /* MethodDeclaration */: - case 142 /* MethodSignature */: - case 145 /* GetAccessor */: - case 146 /* SetAccessor */: - case 147 /* CallSignature */: - case 148 /* ConstructSignature */: - case 149 /* IndexSignature */: - case 152 /* FunctionType */: - case 153 /* ConstructorType */: - return true; - } - } - return false; + return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; + function isFunctionLikeKind(kind) { + switch (kind) { + case 144 /* Constructor */: + case 173 /* FunctionExpression */: + case 213 /* FunctionDeclaration */: + case 174 /* ArrowFunction */: + case 143 /* MethodDeclaration */: + case 142 /* MethodSignature */: + case 145 /* GetAccessor */: + case 146 /* SetAccessor */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: + case 149 /* IndexSignature */: + case 152 /* FunctionType */: + case 153 /* ConstructorType */: + return true; + } + } + ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { case 143 /* MethodDeclaration */: @@ -6206,9 +6579,18 @@ var ts; return !!node && (node.kind === 162 /* ArrayBindingPattern */ || node.kind === 161 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; + function isNodeDescendentOf(node, ancestor) { + while (node) { + if (node === ancestor) + return true; + node = node.parent; + } + return false; + } + ts.isNodeDescendentOf = isNodeDescendentOf; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { + if (node.flags & (4 /* Ambient */ | 4096 /* DeclarationFile */)) { return true; } node = node.parent; @@ -6266,7 +6648,7 @@ var ts; case 207 /* LabeledStatement */: case 204 /* ReturnStatement */: case 206 /* SwitchStatement */: - case 98 /* ThrowKeyword */: + case 208 /* ThrowStatement */: case 209 /* TryStatement */: case 193 /* VariableStatement */: case 198 /* WhileStatement */: @@ -6379,8 +6761,8 @@ var ts; ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; function getHeritageClause(clauses, kind) { if (clauses) { - for (var _i = 0; _i < clauses.length; _i++) { - var clause = clauses[_i]; + for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) { + var clause = clauses_1[_i]; if (clause.token === kind) { return clause; } @@ -6392,7 +6774,6 @@ var ts; function tryResolveScriptReference(host, sourceFile, reference) { if (!host.getCompilerOptions().noResolve) { var referenceFileName = ts.isRootedDiskPath(reference.fileName) ? reference.fileName : ts.combinePaths(ts.getDirectoryPath(sourceFile.fileName), reference.fileName); - referenceFileName = ts.getNormalizedAbsolutePath(referenceFileName, host.getCurrentDirectory()); return host.getSourceFile(referenceFileName); } } @@ -6450,7 +6831,7 @@ var ts; } ts.isTrivia = isTrivia; function isAsyncFunctionLike(node) { - return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + return isFunctionLike(node) && (node.flags & 256 /* Async */) !== 0 && !isAccessor(node); } ts.isAsyncFunctionLike = isAsyncFunctionLike; /** @@ -6837,7 +7218,7 @@ var ts; else { ts.forEach(declarations, function (member) { if ((member.kind === 145 /* GetAccessor */ || member.kind === 146 /* SetAccessor */) - && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + && (member.flags & 64 /* Static */) === (accessor.flags & 64 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { @@ -6894,6 +7275,66 @@ var ts; }); } ts.emitComments = emitComments; + /** + * Detached comment is a comment at the top of file or function body that is separated from + * the next statement by space. + */ + function emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, removeComments) { + var leadingComments; + var currentDetachedCommentInfo; + if (removeComments) { + // removeComments is true, only reserve pinned comment at the top of file + // For example: + // /*! Pinned Comment */ + // + // var x = 10; + if (node.pos === 0) { + leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComment); + } + } + else { + // removeComments is false, just get detached as normal and bypass the process to filter comment + leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); + } + if (leadingComments) { + var detachedComments = []; + var lastComment; + for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) { + var comment = leadingComments_1[_i]; + if (lastComment) { + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, lastComment.end); + var commentLine = getLineOfLocalPosition(currentSourceFile, comment.pos); + if (commentLine >= lastCommentLine + 2) { + // There was a blank line between the last comment and this comment. This + // comment is not part of the copyright comments. Return what we have so + // far. + break; + } + } + detachedComments.push(comment); + lastComment = comment; + } + if (detachedComments.length) { + // All comments look like they could have been part of the copyright header. Make + // sure there is at least one blank line between it and the node. If not, it's not + // a copyright header. + var lastCommentLine = getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); + var nodeLine = getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); + if (nodeLine >= lastCommentLine + 2) { + // Valid detachedComments + emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); + emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); + currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; + } + } + } + return currentDetachedCommentInfo; + function isPinnedComment(comment) { + return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && + currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; + } + } + ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(currentSourceFile, writer, comment, newLine) { if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) { var firstCommentLineAndCharacter = ts.getLineAndCharacterOfPosition(currentSourceFile, comment.pos); @@ -6983,16 +7424,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 113 /* StaticKeyword */: return 128 /* Static */; - case 112 /* PublicKeyword */: return 16 /* Public */; - case 111 /* ProtectedKeyword */: return 64 /* Protected */; - case 110 /* PrivateKeyword */: return 32 /* Private */; - case 115 /* AbstractKeyword */: return 256 /* Abstract */; - case 82 /* ExportKeyword */: return 1 /* Export */; - case 122 /* DeclareKeyword */: return 2 /* Ambient */; - case 74 /* ConstKeyword */: return 32768 /* Const */; - case 77 /* DefaultKeyword */: return 1024 /* Default */; - case 118 /* AsyncKeyword */: return 512 /* Async */; + case 113 /* StaticKeyword */: return 64 /* Static */; + case 112 /* PublicKeyword */: return 8 /* Public */; + case 111 /* ProtectedKeyword */: return 32 /* Protected */; + case 110 /* PrivateKeyword */: return 16 /* Private */; + case 115 /* AbstractKeyword */: return 128 /* Abstract */; + case 82 /* ExportKeyword */: return 2 /* Export */; + case 122 /* DeclareKeyword */: return 4 /* Ambient */; + case 74 /* ConstKeyword */: return 16384 /* Const */; + case 77 /* DefaultKeyword */: return 512 /* Default */; + case 118 /* AsyncKeyword */: return 256 /* Async */; } return 0; } @@ -7073,7 +7514,7 @@ var ts; } ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 512 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { @@ -7150,6 +7591,12 @@ var ts; return result; } ts.convertToBase64 = convertToBase64; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !ts.isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /* isAbsolutePathAnUrl */ false); + } + ts.convertToRelativePath = convertToRelativePath; var carriageReturnLineFeed = "\r\n"; var lineFeed = "\n"; function getNewLineCharacter(options) { @@ -7414,8 +7861,8 @@ var ts; } function visitEachNode(cbNode, nodes) { if (nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; var result = cbNode(node); if (result) { return result; @@ -7982,8 +8429,8 @@ var ts; function addJSDocComment(node) { var comments = ts.getLeadingCommentRangesOfNode(node, sourceFile); if (comments) { - for (var _i = 0; _i < comments.length; _i++) { - var comment = comments[_i]; + for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) { + var comment = comments_1[_i]; var jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); if (jsDocComment) { node.jsDocComment = jsDocComment; @@ -8021,7 +8468,7 @@ var ts; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 4096 /* DeclarationFile */ : 0; sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; return sourceFile; } @@ -9079,7 +9526,7 @@ var ts; if (node.kind === 8 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 65536 /* OctalLiteral */; + node.flags |= 32768 /* OctalLiteral */; } return node; } @@ -9832,7 +10279,7 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } - var isAsync = !!(arrowFunction.flags & 512 /* Async */); + var isAsync = !!(arrowFunction.flags & 256 /* Async */); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; @@ -9959,7 +10406,7 @@ var ts; function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { var node = createNode(174 /* ArrowFunction */); setModifiers(node, parseModifiersForArrowFunction()); - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -10802,7 +11249,7 @@ var ts; var node = createNode(164 /* ArrayLiteralExpression */); parseExpected(19 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(20 /* CloseBracketToken */); return finishNode(node); @@ -10863,7 +11310,7 @@ var ts; var node = createNode(165 /* ObjectLiteralExpression */); parseExpected(15 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 2048 /* MultiLine */; + node.flags |= 1024 /* MultiLine */; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimeter*/ true); parseExpected(16 /* CloseBraceToken */); @@ -10884,7 +11331,7 @@ var ts; parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); node.name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : isGenerator ? doInYieldContext(parseOptionalIdentifier) : @@ -11476,10 +11923,10 @@ var ts; case 102 /* VarKeyword */: break; case 108 /* LetKeyword */: - node.flags |= 16384 /* Let */; + node.flags |= 8192 /* Let */; break; case 74 /* ConstKeyword */: - node.flags |= 32768 /* Const */; + node.flags |= 16384 /* Const */; break; default: ts.Debug.fail(); @@ -11522,9 +11969,9 @@ var ts; setModifiers(node, modifiers); parseExpected(87 /* FunctionKeyword */); node.asteriskToken = parseOptionalToken(37 /* AsteriskToken */); - node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + node.name = node.flags & 512 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; - var isAsync = !!(node.flags & 512 /* Async */); + var isAsync = !!(node.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); @@ -11546,7 +11993,7 @@ var ts; method.name = name; method.questionToken = questionToken; var isGenerator = !!asteriskToken; - var isAsync = !!(method.flags & 512 /* Async */); + var isAsync = !!(method.flags & 256 /* Async */); fillSignature(54 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); @@ -11567,7 +12014,7 @@ var ts; // AccessibilityModifier_opt static_opt PropertyName TypeAnnotation_opt Initialiser_opt[In, ?Yield]; // // The checker may still error in the static case to explicitly disallow the yield expression. - property.initializer = modifiers && modifiers.flags & 128 /* Static */ + property.initializer = modifiers && modifiers.flags & 64 /* Static */ ? allowInAnd(parseNonParameterInitializer) : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); parseSemicolon(); @@ -11900,13 +12347,13 @@ var ts; var node = createNode(218 /* ModuleDeclaration */, fullStart); // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 131072 /* Namespace */; + var namespaceFlag = flags & 65536 /* Namespace */; node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; node.name = parseIdentifier(); node.body = parseOptional(21 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 1 /* Export */ | namespaceFlag) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 2 /* Export */ | namespaceFlag) : parseModuleBlock(); return finishNode(node); } @@ -11921,7 +12368,7 @@ var ts; function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; if (parseOptional(126 /* NamespaceKeyword */)) { - flags |= 131072 /* Namespace */; + flags |= 65536 /* Namespace */; } else { parseExpected(125 /* ModuleKeyword */); @@ -12179,7 +12626,7 @@ var ts; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { - return node.flags & 1 /* Export */ + return node.flags & 2 /* Export */ || node.kind === 221 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 232 /* ExternalModuleReference */ || node.kind === 222 /* ImportDeclaration */ || node.kind === 227 /* ExportAssignment */ @@ -12868,8 +13315,8 @@ var ts; array._children = undefined; array.pos += delta; array.end += delta; - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var node = array_7[_i]; visitNode(node); } } @@ -13006,8 +13453,8 @@ var ts; array._children = undefined; // Adjust the pos or end (or both) of the intersecting array accordingly. adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta); - for (var _i = 0; _i < array.length; _i++) { - var node = array[_i]; + for (var _i = 0, array_8 = array; _i < array_8.length; _i++) { + var node = array_8[_i]; visitNode(node); } return; @@ -13374,6 +13821,7 @@ var ts; var getInstantiatedGlobalPromiseLikeType; var getGlobalPromiseConstructorLikeType; var getGlobalThenableType; + var jsxElementClassType; var tupleTypes = {}; var unionTypes = {}; var intersectionTypes = {}; @@ -13643,7 +14091,7 @@ var ts; } var initializerOfNonStaticProperty = current.parent && current.parent.kind === 141 /* PropertyDeclaration */ && - (current.parent.flags & 128 /* Static */) === 0 && + (current.parent.flags & 64 /* Static */) === 0 && current.parent.initializer === current; if (initializerOfNonStaticProperty) { return true; @@ -13725,7 +14173,7 @@ var ts; // local variables of the constructor. This effectively means that entities from outer scopes // by the same name as a constructor parameter or local variable are inaccessible // in initializer expressions for instance member variables. - if (ts.isClassLike(location.parent) && !(location.flags & 128 /* Static */)) { + if (ts.isClassLike(location.parent) && !(location.flags & 64 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { @@ -13739,7 +14187,7 @@ var ts; case 186 /* ClassExpression */: case 215 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { - if (lastLocation && lastLocation.flags & 128 /* Static */) { + if (lastLocation && lastLocation.flags & 64 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 // The scope of a type parameter extends over the entire declaration with which the type // parameter list is associated, with the exception of static member declarations in classes. @@ -14267,8 +14715,8 @@ var ts; } function findConstructorDeclaration(node) { var members = node.members; - for (var _i = 0; _i < members.length; _i++) { - var member = members[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.kind === 144 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } @@ -14515,7 +14963,7 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !(anyImportSyntax.flags & 1 /* Export */) && + !(anyImportSyntax.flags & 2 /* Export */) && isDeclarationVisible(anyImportSyntax.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { @@ -14669,8 +15117,8 @@ var ts; walkSymbol(getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } if (accessibleSymbolChain) { - for (var _i = 0; _i < accessibleSymbolChain.length; _i++) { - var accessibleSymbol = accessibleSymbolChain[_i]; + for (var _i = 0, accessibleSymbolChain_1 = accessibleSymbolChain; _i < accessibleSymbolChain_1.length; _i++) { + var accessibleSymbol = accessibleSymbolChain_1[_i]; appendParentTypeArgumentsAndSymbolName(accessibleSymbol); } } @@ -14860,7 +15308,7 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && - ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + ts.forEach(symbol.declarations, function (declaration) { return declaration.flags & 64 /* Static */; })); var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { @@ -14971,8 +15419,8 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0; _f < signatures.length; _f++) { - var signature = signatures[_f]; + for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { + var signature = signatures_1[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { writePunctuation(writer, 53 /* QuestionToken */); @@ -15186,7 +15634,7 @@ var ts; case 221 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && + if (!(ts.getCombinedNodeFlags(node) & 2 /* Export */) && !(node.kind !== 221 /* ImportEqualsDeclaration */ && parent_4.kind !== 248 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } @@ -15198,7 +15646,7 @@ var ts; case 146 /* SetAccessor */: case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & (32 /* Private */ | 64 /* Protected */)) { + if (node.flags & (16 /* Private */ | 32 /* Protected */)) { // Private/protected properties/methods are not visible return false; } @@ -15728,8 +16176,8 @@ var ts; // The function allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set // in-place and returns the same array. function appendTypeParameters(typeParameters, declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { + var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); if (!typeParameters) { typeParameters = [tp]; @@ -15934,13 +16382,13 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (declaration.kind === 215 /* InterfaceDeclaration */) { - if (declaration.flags & 524288 /* ContainsThis */) { + if (declaration.flags & 262144 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { - for (var _b = 0; _b < baseTypeNodes.length; _b++) { - var node = baseTypeNodes[_b]; + for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { + var node = baseTypeNodes_1[_b]; if (ts.isSupportedExpressionWithTypeArguments(node)) { var baseSymbol = resolveEntityName(node.expression, 793056 /* Type */, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { @@ -16130,8 +16578,8 @@ var ts; } function createSymbolTable(symbols) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { + var symbol = symbols_1[_i]; result[symbol.name] = symbol; } return result; @@ -16140,15 +16588,15 @@ var ts; // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) { var result = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { + var symbol = symbols_2[_i]; result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } return result; } function addInheritedMembers(symbols, baseSymbols) { - for (var _i = 0; _i < baseSymbols.length; _i++) { - var s = baseSymbols[_i]; + for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) { + var s = baseSymbols_1[_i]; if (!ts.hasProperty(symbols, s.name)) { symbols[s.name] = s; } @@ -16156,8 +16604,8 @@ var ts; } function addInheritedSignatures(signatures, baseSignatures) { if (baseSignatures) { - for (var _i = 0; _i < baseSignatures.length; _i++) { - var signature = baseSignatures[_i]; + for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) { + var signature = baseSignatures_1[_i]; signatures.push(signature); } } @@ -16200,8 +16648,8 @@ var ts; members = createSymbolTable(source.declaredProperties); } var thisArgument = ts.lastOrUndefined(typeArguments); - for (var _i = 0; _i < baseTypes.length; _i++) { - var baseType = baseTypes[_i]; + for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) { + var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfObjectType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); @@ -16247,8 +16695,8 @@ var ts; var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = typeArguments ? typeArguments.length : 0; var result = []; - for (var _i = 0; _i < baseSignatures.length; _i++) { - var baseSig = baseSignatures[_i]; + for (var _i = 0, baseSignatures_2 = baseSignatures; _i < baseSignatures_2.length; _i++) { + var baseSig = baseSignatures_2[_i]; var typeParamCount = baseSig.typeParameters ? baseSig.typeParameters.length : 0; if (typeParamCount === typeArgCount) { var sig = typeParamCount ? getSignatureInstantiation(baseSig, typeArguments) : cloneSignature(baseSig); @@ -16277,8 +16725,8 @@ var ts; setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); } function findMatchingSignature(signatureList, signature, partialMatch, ignoreReturnTypes) { - for (var _i = 0; _i < signatureList.length; _i++) { - var s = signatureList[_i]; + for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) { + var s = signatureList_1[_i]; if (compareSignatures(s, signature, partialMatch, ignoreReturnTypes, compareTypes)) { return s; } @@ -16342,8 +16790,8 @@ var ts; } function getUnionIndexType(types, kind) { var indexTypes = []; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type = types_1[_i]; var indexType = getIndexTypeOfType(type, kind); if (!indexType) { return undefined; @@ -16522,12 +16970,12 @@ var ts; function createUnionOrIntersectionProperty(containingType, name) { var types = containingType.types; var props; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var current = types_2[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (16 /* Private */ | 32 /* Protected */))) { if (!props) { props = [prop]; } @@ -16549,8 +16997,8 @@ var ts; } var propTypes = []; var declarations = []; - for (var _a = 0; _a < props.length; _a++) { - var prop = props[_a]; + for (var _a = 0, props_1 = props; _a < props_1.length; _a++) { + var prop = props_1[_a]; if (prop.declarations) { ts.addRange(declarations, prop.declarations); } @@ -16908,8 +17356,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types) { var result = 0; - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; result |= type.flags; } return result & 14680064 /* PropagatingFlags */; @@ -17059,8 +17507,8 @@ var ts; function getTypeOfGlobalSymbol(symbol, arity) { function getTypeDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { + var declaration = declarations_3[_i]; switch (declaration.kind) { case 214 /* ClassDeclaration */: case 215 /* InterfaceDeclaration */: @@ -17170,8 +17618,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToSet(typeSet, types, typeSetKind) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var type = types_4[_i]; addTypeToSet(typeSet, type, typeSetKind); } } @@ -17193,8 +17641,8 @@ var ts; } } function containsTypeAny(types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (isTypeAny(type)) { return true; } @@ -17310,7 +17758,8 @@ var ts; var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; if (parent && (ts.isClassLike(parent) || parent.kind === 215 /* InterfaceDeclaration */)) { - if (!(container.flags & 128 /* Static */)) { + if (!(container.flags & 64 /* Static */) && + (container.kind !== 144 /* Constructor */ || ts.isNodeDescendentOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -17377,8 +17826,8 @@ var ts; function instantiateList(items, mapper, instantiator) { if (items && items.length) { var result = []; - for (var _i = 0; _i < items.length; _i++) { - var v = items[_i]; + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var v = items_1[_i]; result.push(instantiator(v, mapper)); } return result; @@ -17417,8 +17866,8 @@ var ts; case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { - for (var _i = 0; _i < sources.length; _i++) { - var source = sources[_i]; + for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) { + var source = sources_1[_i]; if (t === source) { return anyType; } @@ -17836,8 +18285,8 @@ var ts; function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { + var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0 /* False */; @@ -17859,8 +18308,8 @@ var ts; function typeRelatedToEachType(source, target, reportErrors) { var result = -1 /* True */; var targetTypes = target.types; - for (var _i = 0; _i < targetTypes.length; _i++) { - var targetType = targetTypes[_i]; + for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { + var targetType = targetTypes_1[_i]; var related = isRelatedTo(source, targetType, reportErrors); if (!related) { return 0 /* False */; @@ -17882,8 +18331,8 @@ var ts; function eachTypeRelatedToType(source, target, reportErrors) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0; _i < sourceTypes.length; _i++) { - var sourceType = sourceTypes[_i]; + for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { + var sourceType = sourceTypes_2[_i]; var related = isRelatedTo(sourceType, target, reportErrors); if (!related) { return 0 /* False */; @@ -18008,8 +18457,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) { + var targetProp = properties_1[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -18023,20 +18472,20 @@ var ts; else if (!(targetProp.flags & 134217728 /* Prototype */)) { var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ || targetPropFlags & 16 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { + if (sourcePropFlags & 16 /* Private */ && targetPropFlags & 16 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 16 /* Private */ ? source : target), typeToString(sourcePropFlags & 16 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetPropFlags & 64 /* Protected */) { + else if (targetPropFlags & 32 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -18047,7 +18496,7 @@ var ts; return 0 /* False */; } } - else if (sourcePropFlags & 64 /* Protected */) { + else if (sourcePropFlags & 32 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -18089,8 +18538,8 @@ var ts; return 0 /* False */; } var result = -1 /* True */; - for (var _i = 0; _i < sourceProperties.length; _i++) { - var sourceProp = sourceProperties[_i]; + for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { + var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); if (!targetProp) { return 0 /* False */; @@ -18130,13 +18579,13 @@ var ts; return result; } } - outer: for (var _i = 0; _i < targetSignatures.length; _i++) { - var t = targetSignatures[_i]; + outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { + var t = targetSignatures_1[_i]; if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; var checkedAbstractAssignability = false; - for (var _a = 0; _a < sourceSignatures.length; _a++) { - var s = sourceSignatures[_a]; + for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { + var s = sourceSignatures_1[_a]; if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { var related = signatureRelatedTo(s, t, localErrors); if (related) { @@ -18167,8 +18616,8 @@ var ts; var targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); var sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getClassLikeDeclarationOfSymbol(sourceReturnType.symbol); var targetReturnDecl = targetReturnType && targetReturnType.symbol && getClassLikeDeclarationOfSymbol(targetReturnType.symbol); - var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 256 /* Abstract */; - var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 256 /* Abstract */; + var sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & 128 /* Abstract */; + var targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & 128 /* Abstract */; if (sourceIsAbstract && !(targetIsAbstract && targetDecl)) { // if target isn't a class-declaration type, then it can be new'd, so we forbid the assignment. if (reportErrors) { @@ -18284,7 +18733,7 @@ var ts; var targetType = getIndexTypeOfType(target, 0 /* String */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: string]: any } = { property: 12 };` return -1 /* True */; } @@ -18313,7 +18762,7 @@ var ts; var targetType = getIndexTypeOfType(target, 1 /* Number */); if (targetType) { if ((targetType.flags & 1 /* Any */) && !(originalSource.flags & 16777726 /* Primitive */)) { - // non-primitive assignment to any is always allowed, eg + // non-primitive assignment to any is always allowed, eg // `var x: { [index: number]: any } = { property: 12 };` return -1 /* True */; } @@ -18386,8 +18835,8 @@ var ts; if (sourceProp === targetProp) { return -1 /* True */; } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (16 /* Private */ | 32 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (16 /* Private */ | 32 /* Protected */); if (sourcePropAccessibility !== targetPropAccessibility) { return 0 /* False */; } @@ -18455,8 +18904,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0; _i < types.length; _i++) { - var type = types[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; if (candidate !== type && !isTypeSubtypeOf(type, candidate)) return false; } @@ -18692,8 +19141,8 @@ var ts; } function createInferenceContext(typeParameters, inferUnionTypes) { var inferences = []; - for (var _i = 0; _i < typeParameters.length; _i++) { - var unused = typeParameters[_i]; + for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { + var unused = typeParameters_1[_i]; inferences.push({ primary: undefined, secondary: undefined, isFixed: false }); @@ -18774,8 +19223,8 @@ var ts; var typeParameterCount = 0; var typeParameter; // First infer to each type in union or intersection that isn't a type parameter - for (var _i = 0; _i < targetTypes.length; _i++) { - var t = targetTypes[_i]; + for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { + var t = targetTypes_2[_i]; if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { typeParameter = t; typeParameterCount++; @@ -18797,8 +19246,8 @@ var ts; else if (source.flags & 49152 /* UnionOrIntersection */) { // Source is a union or intersection type, infer from each consituent type var sourceTypes = source.types; - for (var _a = 0; _a < sourceTypes.length; _a++) { - var sourceType = sourceTypes[_a]; + for (var _a = 0, sourceTypes_3 = sourceTypes; _a < sourceTypes_3.length; _a++) { + var sourceType = sourceTypes_3[_a]; inferFromTypes(sourceType, target); } } @@ -18832,8 +19281,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0; _i < properties.length; _i++) { - var targetProp = properties[_i]; + for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { + var targetProp = properties_2[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -19324,9 +19773,9 @@ var ts; symbol.valueDeclaration.parent.kind === 244 /* CatchClause */) { return; } - // 1. walk from the use site up to the declaration and check + // 1. walk from the use site up to the declaration and check // if there is anything function like between declaration and use-site (is binding/class is captured in function). - // 2. walk from the declaration up to the boundary of lexical environment and check + // 2. walk from the declaration up to the boundary of lexical environment and check // if there is an iteration statement in between declaration and boundary (is binding/class declared inside iteration statement) var container; if (symbol.flags & 32 /* Class */) { @@ -19398,7 +19847,7 @@ var ts; break; case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; @@ -19411,7 +19860,7 @@ var ts; } if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); - return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + return container.flags & 64 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; } return anyType; } @@ -19441,7 +19890,7 @@ var ts; var nodeCheckFlag = 0; // always set NodeCheckFlags for 'super' expression node if (canUseSuperExpression) { - if ((container.flags & 128 /* Static */) || isCallExpression) { + if ((container.flags & 64 /* Static */) || isCallExpression) { nodeCheckFlag = 512 /* SuperStatic */; } else { @@ -19497,7 +19946,7 @@ var ts; // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration if (container && ts.isClassLike(container.parent)) { - if (container.flags & 128 /* Static */) { + if (container.flags & 64 /* Static */) { return container.kind === 143 /* MethodDeclaration */ || container.kind === 142 /* MethodSignature */ || container.kind === 145 /* GetAccessor */ || @@ -19654,8 +20103,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var current = types_7[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -19845,8 +20294,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var current = types_8[_i]; var signature = getNonGenericSignature(current); if (signature) { if (!signatureList) { @@ -19926,8 +20375,8 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = isAssignmentTarget(node); - for (var _i = 0; _i < elements.length; _i++) { - var e = elements[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var e = elements_1[_i]; if (inDestructuringPattern && e.kind === 185 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; @@ -20259,8 +20708,8 @@ var ts; function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { var type = checkExpression(node.expression); var props = getPropertiesOfType(type); - for (var _i = 0; _i < props.length; _i++) { - var prop = props[_i]; + for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { + var prop = props_2[_i]; // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { @@ -20479,7 +20928,6 @@ var ts; var prop = getPropertyOfType(attributesType, attrib.name.text); return prop || unknownSymbol; } - var jsxElementClassType = undefined; function getJsxGlobalElementClassType() { if (!jsxElementClassType) { jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); @@ -20558,7 +21006,7 @@ var ts; return s.valueDeclaration ? s.valueDeclaration.kind : 141 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 8 /* Public */ | 64 /* Static */ : 0; } /** * Check whether the requested property access is valid. @@ -20588,7 +21036,7 @@ var ts; error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -20598,7 +21046,7 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & (32 /* Private */ | 64 /* Protected */))) { + if (!(flags & (16 /* Private */ | 32 /* Protected */))) { return true; } // Property is known to be private or protected at this point @@ -20606,7 +21054,7 @@ var ts; var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; // Private property is accessible if declaring and enclosing class are the same - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); return false; @@ -20624,7 +21072,7 @@ var ts; return false; } // No further restrictions for static properties - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return true; } // An instance property must be accessed through an instance of the enclosing class @@ -20851,8 +21299,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0; _i < signatures.length; _i++) { - var signature = signatures[_i]; + 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_5 = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -21494,8 +21942,8 @@ var ts; // declare function f(a: { xa: number; xb: number; }); // f({ | if (!produceDiagnostics) { - for (var _i = 0; _i < candidates.length; _i++) { - var candidate = candidates[_i]; + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; if (hasCorrectArity(node, args, candidate)) { if (candidate.typeParameters && typeArguments) { candidate = getSignatureInstantiation(candidate, ts.map(typeArguments, getTypeFromTypeNode)); @@ -21514,8 +21962,8 @@ var ts; diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, errorInfo)); } function chooseOverload(candidates, relation) { - for (var _i = 0; _i < candidates.length; _i++) { - var originalCandidate = candidates[_i]; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var originalCandidate = candidates_2[_i]; if (!hasCorrectArity(node, args, originalCandidate)) { continue; } @@ -21652,7 +22100,7 @@ var ts; // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + if (valueDecl && valueDecl.flags & 128 /* Abstract */) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); return resolveErrorCall(node); } @@ -22017,19 +22465,11 @@ var ts; }); return aggregatedTypes; } - function bodyContainsAReturnStatement(funcBody) { - return ts.forEachReturnStatement(funcBody, function (returnStatement) { - return true; - }); - } - function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 208 /* ThrowStatement */); - } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type // must have at least one return statement somewhere in its body. // An exception to this rule is if the function implementation consists of a single 'throw' statement. - function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { + function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) { if (!produceDiagnostics) { return; } @@ -22038,22 +22478,19 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */) { + // also if HasImplicitReturnValue flags is not set this means that all codepaths in function body end with return of throw + if (ts.nodeIsMissing(func.body) || func.body.kind !== 192 /* Block */ || !(func.flags & 524288 /* HasImplicitReturn */)) { return; } - var bodyBlock = func.body; - // Ensure the body has at least one return expression. - if (bodyContainsAReturnStatement(bodyBlock)) { - return; + if (func.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(func.type, ts.Diagnostics.Not_all_code_paths_return_a_value); + } } - // If there are no return expressions, then we need to check if - // the function body consists solely of a throw statement; - // this is to make an exception for unimplemented functions. - if (bodyContainsSingleThrowStatement(bodyBlock)) { - return; + else { + // This function does not conform to the specification. + error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value); } - // This function does not conform to the specification. - error(func.type, ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_or_consist_of_a_single_throw_statement); } function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { ts.Debug.assert(node.kind !== 143 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); @@ -22120,7 +22557,7 @@ var ts; promisedType = checkAsyncFunctionReturnType(node); } if (returnType && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -22205,7 +22642,7 @@ var ts; case 69 /* Identifier */: case 166 /* PropertyAccessExpression */: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 16384 /* Const */) !== 0; } case 167 /* ElementAccessExpression */: { var index = n.argumentExpression; @@ -22213,7 +22650,7 @@ var ts; if (symbol && index && index.kind === 9 /* StringLiteral */) { var name_12 = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 16384 /* Const */) !== 0; } return false; } @@ -22298,8 +22735,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var current = types_9[_i]; if (current.flags & kind) { return true; } @@ -22315,8 +22752,8 @@ var ts; } if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0; _i < types.length; _i++) { - var current = types[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var current = types_10[_i]; if (!(current.flags & kind)) { return false; } @@ -22361,8 +22798,8 @@ var ts; } function checkObjectLiteralAssignment(node, sourceType, contextualMapper) { var properties = node.properties; - for (var _i = 0; _i < properties.length; _i++) { - var p = properties[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var p = properties_3[_i]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support var name_13 = p.name; @@ -22896,7 +23333,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (node.flags & 112 /* AccessibilityModifier */) { + if (node.flags & 56 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); if (!(func.kind === 144 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); @@ -23096,7 +23533,7 @@ var ts; checkFunctionLikeDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (node.flags & 256 /* Abstract */ && node.body) { + if (node.flags & 128 /* Abstract */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -23147,7 +23584,7 @@ var ts; } function isInstancePropertyWithInitializer(n) { return n.kind === 141 /* PropertyDeclaration */ && - !(n.flags & 128 /* Static */) && + !(n.flags & 64 /* Static */) && !!n.initializer; } // TS 1.0 spec (April 2014): 8.3.2 @@ -23168,14 +23605,14 @@ var ts; // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || - ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); + ts.forEach(node.parameters, function (p) { return p.flags & (8 /* Public */ | 16 /* Private */ | 32 /* Protected */); }); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement; - for (var _i = 0; _i < statements.length; _i++) { - var statement = statements[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (statement.kind === 195 /* ExpressionStatement */ && isSuperCallExpression(statement.expression)) { superCallStatement = statement; break; @@ -23203,8 +23640,15 @@ var ts; // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); if (node.kind === 145 /* GetAccessor */) { - if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { - error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); + if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 524288 /* HasImplicitReturn */)) { + if (node.flags & 1048576 /* HasExplicitReturn */) { + if (compilerOptions.noImplicitReturns) { + error(node.name, ts.Diagnostics.Not_all_code_paths_return_a_value); + } + } + else { + error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); + } } } if (!ts.hasDynamicName(node)) { @@ -23213,7 +23657,7 @@ var ts; var otherKind = node.kind === 145 /* GetAccessor */ ? 146 /* SetAccessor */ : 145 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { + if (((node.flags & 56 /* AccessibilityModifier */) !== (otherAccessor.flags & 56 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var currentAccessorType = getAnnotatedAccessorType(node); @@ -23284,7 +23728,7 @@ var ts; ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { - return (node.flags & 32 /* Private */) && ts.isInAmbientContext(node); + return (node.flags & 16 /* Private */) && ts.isInAmbientContext(node); } function checkSpecializedSignatureDeclaration(signatureDeclarationNode) { if (!produceDiagnostics) { @@ -23316,8 +23760,8 @@ var ts; else { signaturesToCheck = getSignaturesOfSymbol(getSymbolOfNode(signatureDeclarationNode)); } - for (var _i = 0; _i < signaturesToCheck.length; _i++) { - var otherSignature = signaturesToCheck[_i]; + for (var _i = 0, signaturesToCheck_1 = signaturesToCheck; _i < signaturesToCheck_1.length; _i++) { + var otherSignature = signaturesToCheck_1[_i]; if (!otherSignature.hasStringLiterals && isSignatureAssignableTo(signature, otherSignature)) { return; } @@ -23332,11 +23776,11 @@ var ts; n.parent.kind !== 214 /* ClassDeclaration */ && n.parent.kind !== 186 /* ClassExpression */ && ts.isInAmbientContext(n)) { - if (!(flags & 2 /* Ambient */)) { + if (!(flags & 4 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 2 /* Export */; } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; } return flags & flagsToCheck; } @@ -23361,16 +23805,16 @@ var ts; var canonicalFlags = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; - if (deviation & 1 /* Export */) { + if (deviation & 2 /* Export */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_exported_or_not_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 4 /* Ambient */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (32 /* Private */ | 64 /* Protected */)) { + else if (deviation & (16 /* Private */ | 32 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 256 /* Abstract */) { + else if (deviation & 128 /* Abstract */) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); } }); @@ -23387,7 +23831,7 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; + var flagsToCheck = 2 /* Export */ | 4 /* Ambient */ | 16 /* Private */ | 32 /* Protected */ | 128 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -23418,8 +23862,8 @@ var ts; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members ts.Debug.assert(node.kind === 143 /* MethodDeclaration */ || node.kind === 142 /* MethodSignature */); - ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); - var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; + ts.Debug.assert((node.flags & 64 /* Static */) !== (subsequentNode.flags & 64 /* Static */)); + var diagnostic = node.flags & 64 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); return; } @@ -23436,7 +23880,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -23449,8 +23893,8 @@ var ts; var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { + var current = declarations_4[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); var inAmbientContextOrInterface = node.parent.kind === 215 /* InterfaceDeclaration */ || node.parent.kind === 155 /* TypeLiteral */ || inAmbientContext; @@ -23507,7 +23951,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { + !(lastSeenNonAmbientDeclaration.flags & 128 /* Abstract */)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -23533,8 +23977,8 @@ var ts; // function g(x: string, y: string) { } // // The implementation is completely unrelated to the specialized signature, yet we do not check this. - for (var _a = 0; _a < signatures.length; _a++) { - var signature = signatures[_a]; + for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { + var signature = signatures_3[_a]; if (!signature.hasStringLiterals && !isSignatureAssignableTo(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -23571,9 +24015,9 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 1024 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 1024 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 2 /* Export */ | 512 /* Default */); + if (effectiveDeclarationFlags & 2 /* Export */) { + if (effectiveDeclarationFlags & 512 /* Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -23826,9 +24270,12 @@ var ts; // type as a value. As such, we will just return unknownType; return unknownType; } - var promiseConstructor = getMergedSymbol(promiseType.symbol); + var promiseConstructor = getNodeLinks(node.type).resolvedSymbol; if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { - error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + var typeName = promiseConstructor + ? symbolToString(promiseConstructor) + : typeToString(promiseType); + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeName); return unknownType; } // Validate the promise constructor type. @@ -24020,7 +24467,7 @@ var ts; if (isAsync) { promisedType = checkAsyncFunctionReturnType(node); } - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -24162,7 +24609,7 @@ var ts; // let x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers @@ -24177,7 +24624,7 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 24576 /* BlockScoped */) { var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 212 /* VariableDeclarationList */); var container = varDeclList.parent.kind === 193 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent @@ -24330,6 +24777,9 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); + if (node.thenStatement.kind === 194 /* EmptyStatement */) { + error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); + } checkSourceElement(node.elseStatement); } function checkDoStatement(node) { @@ -24688,7 +25138,7 @@ var ts; error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } else if (func.kind === 144 /* Constructor */) { - if (!isTypeAssignableTo(exprType, returnType)) { + if (!checkTypeAssignableTo(exprType, returnType, node.expression)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } @@ -24835,7 +25285,7 @@ var ts; // Only process instance properties with computed names here. // Static properties cannot be in conflict with indexers, // and properties with literal names were already checked. - if (!(member.flags & 128 /* Static */) && ts.hasDynamicName(member)) { + if (!(member.flags & 64 /* Static */) && ts.hasDynamicName(member)) { var propType = getTypeOfSymbol(member.symbol); checkIndexConstraintForProperty(member.symbol, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */); checkIndexConstraintForProperty(member.symbol, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */); @@ -24921,7 +25371,7 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 1024 /* Default */)) { + if (!node.name && !(node.flags & 512 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -24975,8 +25425,8 @@ var ts; } var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { - for (var _b = 0; _b < implementedTypeNodes.length; _b++) { - var typeRefNode = implementedTypeNodes[_b]; + for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { + var typeRefNode = implementedTypeNodes_1[_b]; if (!ts.isSupportedExpressionWithTypeArguments(typeRefNode)) { error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } @@ -25024,8 +25474,8 @@ var ts; // derived class instance member variables and accessors, but not by other kinds of members. // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfObjectType(baseType); - for (var _i = 0; _i < baseProperties.length; _i++) { - var baseProperty = baseProperties[_i]; + for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { + var baseProperty = baseProperties_1[_i]; var base = getTargetSymbol(baseProperty); if (base.flags & 134217728 /* Prototype */) { continue; @@ -25043,7 +25493,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 128 /* Abstract */))) { if (derivedClassDecl.kind === 186 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } @@ -25055,11 +25505,11 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + if ((baseDeclarationFlags & 16 /* Private */) || (derivedDeclarationFlags & 16 /* Private */)) { // either base or derived property is private - not override, skip it continue; } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + if ((baseDeclarationFlags & 64 /* Static */) !== (derivedDeclarationFlags & 64 /* Static */)) { // value of 'static' is not the same for properties - not override, skip it continue; } @@ -25130,11 +25580,11 @@ var ts; var seen = {}; ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen[p.name] = { prop: p, containingType: type }; }); var ok = true; - for (var _i = 0; _i < baseTypes.length; _i++) { - var base = baseTypes[_i]; + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; var properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0; _a < properties.length; _a++) { - var prop = properties[_a]; + for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; if (!ts.hasProperty(seen, prop.name)) { seen[prop.name] = { prop: prop, containingType: base }; } @@ -25431,8 +25881,8 @@ var ts; } function getFirstNonAmbientClassOrFunctionDeclaration(symbol) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { + var declaration = declarations_5[_i]; if ((declaration.kind === 214 /* ClassDeclaration */ || (declaration.kind === 213 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { @@ -25571,7 +26021,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -25599,7 +26049,7 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { markExportAsReferenced(node); } if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -25630,7 +26080,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -25674,7 +26124,7 @@ var ts; return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 1022 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } if (node.expression.kind === 69 /* Identifier */) { @@ -26087,7 +26537,7 @@ var ts; // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. - if (!(memberFlags & 128 /* Static */)) { + if (!(memberFlags & 64 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; @@ -26388,7 +26838,7 @@ var ts; */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); - return node.flags & 128 /* Static */ + return node.flags & 64 /* Static */ ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -26709,7 +27159,7 @@ var ts; function initializeTypeChecker() { // Bind all source files and propagate errors ts.forEach(host.getSourceFiles(), function (file) { - ts.bindSourceFile(file); + ts.bindSourceFile(file, compilerOptions); }); // Initialize global symbol table ts.forEach(host.getSourceFiles(), function (file) { @@ -26863,19 +27313,19 @@ var ts; text = "private"; lastPrivate = modifier; } - if (flags & 112 /* AccessibilityModifier */) { + if (flags & 56 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 128 /* Static */) { + else if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { if (modifier.kind === 110 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } @@ -26886,10 +27336,10 @@ var ts; flags |= ts.modifierToFlag(modifier.kind); break; case 113 /* StaticKeyword */: - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } else if (node.parent.kind === 219 /* ModuleBlock */ || node.parent.kind === 248 /* SourceFile */) { @@ -26898,23 +27348,23 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - flags |= 128 /* Static */; + flags |= 64 /* Static */; lastStatic = modifier; break; case 82 /* ExportKeyword */: - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 256 /* Abstract */) { + else if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (node.parent.kind === 214 /* ClassDeclaration */) { @@ -26923,13 +27373,13 @@ var ts; else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 2 /* Export */; break; case 122 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + if (flags & 4 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.parent.kind === 214 /* ClassDeclaration */) { @@ -26941,69 +27391,69 @@ var ts; else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 219 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } - flags |= 2 /* Ambient */; + flags |= 4 /* Ambient */; lastDeclare = modifier; break; case 115 /* AbstractKeyword */: - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } if (node.kind !== 214 /* ClassDeclaration */) { if (node.kind !== 143 /* MethodDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); } - if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + if (!(node.parent.kind === 214 /* ClassDeclaration */ && node.parent.flags & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 32 /* Private */) { + if (flags & 16 /* Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } } - flags |= 256 /* Abstract */; + flags |= 128 /* Abstract */; break; case 118 /* AsyncKeyword */: - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + else if (flags & 4 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } else if (node.kind === 138 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - flags |= 512 /* Async */; + flags |= 256 /* Async */; lastAsync = modifier; break; } } if (node.kind === 144 /* Constructor */) { - if (flags & 128 /* Static */) { + if (flags & 64 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 256 /* Abstract */) { + if (flags & 128 /* Abstract */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); } - else if (flags & 64 /* Protected */) { + else if (flags & 32 /* Protected */) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (flags & 32 /* Private */) { + else if (flags & 16 /* Private */) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (flags & 512 /* Async */) { + else if (flags & 256 /* Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return; } - else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 222 /* ImportDeclaration */ || node.kind === 221 /* ImportEqualsDeclaration */) && flags & 4 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 138 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 138 /* Parameter */ && (flags & 56 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } - if (flags & 512 /* Async */) { + if (flags & 256 /* Async */) { return checkGrammarAsyncModifier(node, lastAsync); } } @@ -27104,7 +27554,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 2035 /* Modifier */) { + if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -27124,7 +27574,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 2035 /* Modifier */) { + if (node.flags & 1022 /* Modifier */) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -27147,8 +27597,8 @@ var ts; function checkGrammarForOmittedArgument(node, args) { if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < args.length; _i++) { - var arg = args[_i]; + for (var _i = 0, args_1 = args; _i < args_1.length; _i++) { + var arg = args_1[_i]; if (arg.kind === 187 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } @@ -27403,7 +27853,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 2035 /* Modifier */) { + else if (parameter.flags & 1022 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -27554,8 +28004,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0; _i < elements.length; _i++) { - var element = elements[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (element.kind !== 187 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -27691,8 +28141,8 @@ var ts; node.kind === 221 /* ImportEqualsDeclaration */ || node.kind === 228 /* ExportDeclaration */ || node.kind === 227 /* ExportAssignment */ || - (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 1024 /* Default */))) { + (node.flags & 4 /* Ambient */) || + (node.flags & (2 /* Export */ | 512 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -27739,7 +28189,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.flags & 32768 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -27793,7 +28243,7 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || + if (referencedFile && ((referencedFile.flags & 4096 /* DeclarationFile */) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -27988,15 +28438,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -28142,6 +28592,7 @@ var ts; function emitSourceFile(node) { currentSourceFile = node; enclosingDeclaration = node; + ts.emitDetachedComments(currentSourceFile, writer, ts.writeCommentRange, node, newLine, true /* remove comments */); emitLines(node.statements); } // Return a temp variable name to be used in `export default` statements. @@ -28258,10 +28709,10 @@ var ts; // If the node is parented in the current source file we need to emit export declare or just export if (node.parent === currentSourceFile) { // If the node is exported - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } else if (node.kind !== 215 /* InterfaceDeclaration */) { @@ -28270,16 +28721,16 @@ var ts; } } function emitClassMemberDeclarationFlags(node) { - if (node.flags & 32 /* Private */) { + if (node.flags & 16 /* Private */) { write("private "); } - else if (node.flags & 64 /* Protected */) { + else if (node.flags & 32 /* Protected */) { write("protected "); } - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { write("static "); } - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } } @@ -28287,7 +28738,7 @@ var ts; // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28322,12 +28773,12 @@ var ts; } } function writeImportDeclaration(node) { - if (!node.importClause && !(node.flags & 1 /* Export */)) { + if (!node.importClause && !(node.flags & 2 /* Export */)) { // do not write non-exported import declarations that don't have import clauses return; } emitJsDocComments(node); - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { write("export "); } write("import "); @@ -28392,7 +28843,7 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 131072 /* Namespace */) { + if (node.flags & 65536 /* Namespace */) { write("namespace "); } else { @@ -28464,7 +28915,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 143 /* MethodDeclaration */ && (node.parent.flags & 16 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -28508,7 +28959,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } else if (node.parent.parent.kind === 214 /* ClassDeclaration */) { @@ -28574,7 +29025,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -28582,7 +29033,7 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 256 /* Abstract */) { + if (node.flags & 128 /* Abstract */) { write("abstract "); } write("class "); @@ -28652,7 +29103,7 @@ var ts; if ((node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) && node.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.flags & 32 /* Private */)) { + else if (!(node.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getVariableDeclarationTypeVisibilityError); } } @@ -28667,7 +29118,7 @@ var ts; } else if (node.kind === 141 /* PropertyDeclaration */ || node.kind === 140 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -28771,7 +29222,7 @@ var ts; emitJsDocComments(accessors.setAccessor); emitClassMemberDeclarationFlags(node); writeTextOfNode(currentSourceFile, node.name); - if (!(node.flags & 32 /* Private */)) { + if (!(node.flags & 16 /* Private */)) { accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { @@ -28800,7 +29251,7 @@ var ts; var diagnosticMessage; if (accessorWithTypeAnnotation.kind === 146 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named - if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.parent.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; @@ -28818,7 +29269,7 @@ var ts; }; } else { - if (accessorWithTypeAnnotation.flags & 128 /* Static */) { + if (accessorWithTypeAnnotation.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28905,7 +29356,7 @@ var ts; emitType(node.type); } } - else if (node.kind !== 144 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 144 /* Constructor */ && !(node.flags & 16 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -28936,7 +29387,7 @@ var ts; break; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.flags & 128 /* Static */) { + if (node.flags & 64 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -28997,7 +29448,7 @@ var ts; node.parent.parent.kind === 155 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } - else if (!(node.parent.flags & 32 /* Private */)) { + else if (!(node.parent.flags & 16 /* Private */)) { writeTypeOfDeclaration(node, node.type, getParameterDeclarationTypeVisibilityError); } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { @@ -29028,7 +29479,7 @@ var ts; ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: - if (node.parent.flags & 128 /* Static */) { + if (node.parent.flags & 64 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -29170,7 +29621,7 @@ var ts; } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ + var declFileName = referencedFile.flags & 4096 /* DeclarationFile */ ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file @@ -29216,6 +29667,12 @@ var ts; return ts.isExternalModule(sourceFile) || ts.isDeclarationFile(sourceFile); } ts.isExternalModuleOrDeclarationFile = isExternalModuleOrDeclarationFile; + var Jump; + (function (Jump) { + Jump[Jump["Break"] = 2] = "Break"; + Jump[Jump["Continue"] = 4] = "Continue"; + Jump[Jump["Return"] = 8] = "Return"; + })(Jump || (Jump = {})); var entities = { "quot": 0x0022, "amp": 0x0026, @@ -29525,16 +29982,8 @@ var ts; diagnostics: diagnostics, sourceMaps: sourceMapDataList }; - function isNodeDescendentOf(node, ancestor) { - while (node) { - if (node === ancestor) - return true; - node = node.parent; - } - return false; - } function isUniqueLocalName(name, container) { - for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (var node = container; ts.isNodeDescendentOf(node, container); node = node.nextContainer) { if (node.locals && ts.hasProperty(node.locals, name)) { // We conservatively include alias symbols to cover cases where they're emitted as locals if (node.locals[name].flags & (107455 /* Value */ | 1048576 /* ExportValue */ | 8388608 /* Alias */)) { @@ -29544,12 +29993,6 @@ var ts; } return true; } - var Jump; - (function (Jump) { - Jump[Jump["Break"] = 2] = "Break"; - Jump[Jump["Continue"] = 4] = "Continue"; - Jump[Jump["Return"] = 8] = "Return"; - })(Jump || (Jump = {})); function setLabeledJump(state, isBreak, labelText, labelMarker) { if (isBreak) { if (!state.labeledNonLocalBreaks) { @@ -31026,7 +31469,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 2048 /* MultiLine */) !== 0, + emitListWithSpread(elements, /*needsUniqueCopy*/ true, /*multiLine*/ (node.flags & 1024 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma, /*useConcat*/ true); } } @@ -31045,7 +31488,7 @@ var ts; emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= 1 /* ES5 */, /* spacesBetweenBraces */ true); } else { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; if (!multiLine) { write(" "); } @@ -31064,7 +31507,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; + var multiLine = (node.flags & 1024 /* MultiLine */) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -31693,7 +32136,7 @@ var ts; var current = node; while (current) { if (current.kind === 248 /* SourceFile */) { - return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); + return !isExported || ((ts.getCombinedNodeFlags(node) & 2 /* Export */) !== 0); } else if (ts.isFunctionLike(current) || current.kind === 219 /* ModuleBlock */) { return false; @@ -31934,7 +32377,7 @@ var ts; // variables in variable declaration list were already hoisted return false; } - if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 49152 /* BlockScoped */) === 0) { + if (convertedLoopState && (ts.getCombinedNodeFlags(decl) & 24576 /* BlockScoped */) === 0) { // we are inside a converted loop - this can only happen in downlevel scenarios // record names for all variable declarations for (var _a = 0, _b = decl.declarations; _a < _b.length; _a++) { @@ -32019,7 +32462,7 @@ var ts; break; } var loopParameters; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 49152 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 24576 /* BlockScoped */)) { // if loop initializer contains block scoped variables - they should be passed to converted loop body as parameters loopParameters = []; for (var _a = 0, _b = loopInitializer.declarations; _a < _b.length; _a++) { @@ -32334,10 +32777,12 @@ var ts; // // for (let v of arr) { } // - // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 69 /* Identifier */; + // we can't reuse 'arr' because it might be modified within the body of the loop. var counter = createTempVariable(268435456 /* _i */); - var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); + var rhsReference = ts.createSynthesizedNode(69 /* Identifier */); + rhsReference.text = node.expression.kind === 69 /* Identifier */ ? + makeUniqueName(node.expression.text) : + makeTempVariableName(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for // the LHS will be emitted inside the body. emitStart(node.expression); @@ -32346,15 +32791,13 @@ var ts; emitNodeWithoutSourceMap(counter); write(" = 0"); emitEnd(node.expression); - if (!rhsIsIdentifier) { - // , _a = expr - write(", "); - emitStart(node.expression); - emitNodeWithoutSourceMap(rhsReference); - write(" = "); - emitNodeWithoutSourceMap(node.expression); - emitEnd(node.expression); - } + // , _a = expr + write(", "); + emitStart(node.expression); + emitNodeWithoutSourceMap(rhsReference); + write(" = "); + emitNodeWithoutSourceMap(node.expression); + emitEnd(node.expression); write("; "); // _i < _a.length; emitStart(node.initializer); @@ -32609,7 +33052,7 @@ var ts; } function emitModuleMemberName(node) { emitStart(node.name); - if (ts.getCombinedNodeFlags(node) & 1 /* Export */) { + if (ts.getCombinedNodeFlags(node) & 2 /* Export */) { var container = getContainingModule(node); if (container) { write(getGeneratedNameForNode(container)); @@ -32631,7 +33074,7 @@ var ts; } function emitEs6ExportDefaultCompat(node) { if (node.parent.kind === 248 /* SourceFile */) { - ts.Debug.assert(!!(node.flags & 1024 /* Default */) || node.kind === 227 /* ExportAssignment */); + ts.Debug.assert(!!(node.flags & 512 /* Default */) || node.kind === 227 /* ExportAssignment */); // only allow export default at a source file level if (modulekind === 1 /* CommonJS */ || modulekind === 2 /* AMD */ || modulekind === 3 /* UMD */) { if (!currentSourceFile.symbol.exports["___esModule"]) { @@ -32649,7 +33092,7 @@ var ts; } } function emitExportMemberAssignment(node) { - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { writeLine(); emitStart(node); // emit call to exporter only for top level nodes @@ -32657,7 +33100,7 @@ var ts; // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default"); } else { @@ -32668,7 +33111,7 @@ var ts; write(")"); } else { - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { emitEs6ExportDefaultCompat(node); if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); @@ -32772,7 +33215,7 @@ var ts; // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; if (root.kind === 211 /* VariableDeclaration */) { - var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; + var isExported = ts.getCombinedNodeFlags(root) & 2 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } @@ -32854,8 +33297,8 @@ var ts; // to ensure value is evaluated exactly once. value = ensureIdentifier(value, /*reuseIdentifierExpressions*/ true); } - for (var _a = 0; _a < properties.length; _a++) { - var p = properties[_a]; + for (var _a = 0, properties_5 = properties; _a < properties_5.length; _a++) { + var p = properties_5[_a]; if (p.kind === 245 /* PropertyAssignment */ || p.kind === 246 /* ShorthandPropertyAssignment */) { var propName = p.name; var target_1 = p.kind === 246 /* ShorthandPropertyAssignment */ ? p : p.initializer || propName; @@ -32990,7 +33433,7 @@ var ts; // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations var isLetDefinedInLoop = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); + (getCombinedFlagsForIdentifier(node.name) & 8192 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isLetDefinedInLoop && node.parent.parent.kind !== 200 /* ForInStatement */ && @@ -33030,13 +33473,13 @@ var ts; return ts.getCombinedNodeFlags(node.parent); } function isES6ExportedDeclaration(node) { - return !!(node.flags & 1 /* Export */) && + return !!(node.flags & 2 /* Export */) && modulekind === 5 /* ES6 */ && node.parent.kind === 248 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; - if (node.flags & 1 /* Export */) { + if (node.flags & 2 /* Export */) { if (isES6ExportedDeclaration(node)) { // Exported ES6 module member write("export "); @@ -33063,7 +33506,7 @@ var ts; function shouldEmitLeadingAndTrailingCommentsForVariableStatement(node) { // If we're not exporting the variables, there's nothing special here. // Always emit comments for these nodes. - if (!(node.flags & 1 /* Export */)) { + if (!(node.flags & 2 /* Export */)) { return true; } // If we are exporting, but it's a top-level ES6 module exports, @@ -33246,7 +33689,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33466,7 +33909,7 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { + if (languageVersion < 2 /* ES6 */ || node.flags & 256 /* Async */) { emitDownLevelExpressionFunctionBody(node, body); return; } @@ -33487,7 +33930,7 @@ var ts; scopeEmitStart(node); increaseIndent(); var outPos = writer.getTextPos(); - emitDetachedComments(node.body); + emitDetachedCommentsAndUpdateCommentsInfo(node.body); emitFunctionBodyPreamble(node); var preambleEmitted = writer.getTextPos() !== outPos; decreaseIndent(); @@ -33525,7 +33968,7 @@ var ts; scopeEmitStart(node); var initialTextPos = writer.getTextPos(); increaseIndent(); - emitDetachedComments(body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(body.statements); // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). var startIndex = emitDirectivePrologues(body.statements, /*startWithNewLine*/ true); @@ -33569,7 +34012,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & 112 /* AccessibilityModifier */) { + if (param.flags & 56 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -33604,15 +34047,15 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 141 /* PropertyDeclaration */ && isStatic === ((member.flags & 64 /* Static */) !== 0) && member.initializer) { properties.push(member); } } return properties; } function emitPropertyDeclarations(node, properties) { - for (var _a = 0; _a < properties.length; _a++) { - var property = properties[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var property = properties_6[_a]; emitPropertyDeclaration(node, property); } } @@ -33625,7 +34068,7 @@ var ts; emit(receiver); } else { - if (property.flags & 128 /* Static */) { + if (property.flags & 64 /* Static */) { emitDeclarationName(node); } else { @@ -33724,7 +34167,7 @@ var ts; writeLine(); emitLeadingComments(member); emitStart(member); - if (member.flags & 128 /* Static */) { + if (member.flags & 64 /* Static */) { write("static "); } if (member.kind === 145 /* GetAccessor */) { @@ -33774,7 +34217,7 @@ var ts; emitCommentsOnNotEmittedNode(member); } // Check if there is any non-static property assignment - if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 141 /* PropertyDeclaration */ && member.initializer && (member.flags & 64 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -33821,7 +34264,7 @@ var ts; // Emit all the directive prologues (like "use strict"). These have to come before // any other preamble code we write (like parameter initializers). startIndex = emitDirectivePrologues(ctor.body.statements, /*startWithNewLine*/ true); - emitDetachedComments(ctor.body.statements); + emitDetachedCommentsAndUpdateCommentsInfo(ctor.body.statements); } emitCaptureThisForNodeIfNecessary(node); var superCall; @@ -33941,7 +34384,7 @@ var ts; // _default = __decorate([dec], _default); // export default _default; // - if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 512 /* Default */)) { write("export "); } write("let "); @@ -33950,7 +34393,7 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 1024 /* Default */) { + if (node.flags & 512 /* Default */) { write("default "); } } @@ -33980,7 +34423,7 @@ var ts; // emit name if // - node has a name // - this is default export with static initializers - if ((node.name || (node.flags & 1024 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { + if ((node.name || (node.flags & 512 /* Default */ && staticProperties.length > 0)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -34016,8 +34459,8 @@ var ts; // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. if (isClassExpressionWithStaticProperties) { - for (var _a = 0; _a < staticProperties.length; _a++) { - var property = staticProperties[_a]; + for (var _a = 0, staticProperties_1 = staticProperties; _a < staticProperties_1.length; _a++) { + var property = staticProperties_1[_a]; write(","); writeLine(); emitPropertyDeclaration(node, property, /*receiver:*/ tempVariable, /*isExpression:*/ true); @@ -34035,7 +34478,7 @@ var ts; } // If this is an exported class, but not on the top level (i.e. on an internal // module), export it - if (!isES6ExportedDeclaration(node) && (node.flags & 1 /* Export */)) { + if (!isES6ExportedDeclaration(node) && (node.flags & 2 /* Export */)) { writeLine(); emitStart(node); emitModuleMemberName(node); @@ -34044,7 +34487,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 512 /* Default */) && thisNodeIsDecorated) { // if this is a top level default export of decorated class, write the export after the declaration. writeLine(); write("export default "); @@ -34126,13 +34569,13 @@ var ts; } function emitClassMemberPrefix(node, member) { emitDeclarationName(node); - if (!(member.flags & 128 /* Static */)) { + if (!(member.flags & 64 /* Static */)) { write(".prototype"); } } function emitDecoratorsOfClass(node) { emitDecoratorsOfMembers(node, /*staticFlag*/ 0); - emitDecoratorsOfMembers(node, 128 /* Static */); + emitDecoratorsOfMembers(node, 64 /* Static */); emitDecoratorsOfConstructor(node); } function emitDecoratorsOfConstructor(node) { @@ -34179,7 +34622,7 @@ var ts; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; // only emit members in the correct group - if ((member.flags & 128 /* Static */) !== staticFlag) { + if ((member.flags & 64 /* Static */) !== staticFlag) { continue; } // skip members that cannot be decorated (such as the constructor) @@ -34580,7 +35023,7 @@ var ts; } if (!shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted - if (!(node.flags & 1 /* Export */) || isES6ExportedDeclaration(node)) { + if (!(node.flags & 2 /* Export */) || isES6ExportedDeclaration(node)) { emitStart(node); if (isES6ExportedDeclaration(node)) { write("export "); @@ -34611,7 +35054,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.flags & 1 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { + if (!isES6ExportedDeclaration(node) && node.flags & 2 /* Export */ && !shouldHoistDeclarationInSystemJsModule(node)) { // do not emit var if variable was already hoisted writeLine(); emitStart(node); @@ -34623,7 +35066,7 @@ var ts; write(";"); } if (modulekind !== 5 /* ES6 */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { // write the call to exporter for enum writeLine(); write(exportFunctionForFile + "(\""); @@ -34728,7 +35171,7 @@ var ts; } write(")("); // write moduleDecl = containingModule.m only if it is not exported es6 module member - if ((node.flags & 1 /* Export */) && !isES6ExportedDeclaration(node)) { + if ((node.flags & 2 /* Export */) && !isES6ExportedDeclaration(node)) { emit(node.name); write(" = "); } @@ -34738,7 +35181,7 @@ var ts; write(" = {}));"); emitEnd(node); if (!isES6ExportedDeclaration(node) && node.name.kind === 69 /* Identifier */ && node.parent === currentSourceFile) { - if (modulekind === 4 /* System */ && (node.flags & 1 /* Export */)) { + if (modulekind === 4 /* System */ && (node.flags & 2 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); emitDeclarationName(node); @@ -34841,7 +35284,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 221 /* ImportEqualsDeclaration */ && (node.flags & 2 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (modulekind !== 2 /* AMD */) { emitLeadingComments(node); @@ -34923,7 +35366,7 @@ var ts; write("export "); write("var "); } - else if (!(node.flags & 1 /* Export */)) { + else if (!(node.flags & 2 /* Export */)) { write("var "); } } @@ -35014,8 +35457,8 @@ var ts; function emitExportOrImportSpecifierList(specifiers, shouldEmit) { ts.Debug.assert(modulekind === 5 /* ES6 */); var needsComma = false; - for (var _a = 0; _a < specifiers.length; _a++) { - var specifier = specifiers[_a]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var specifier = specifiers_1[_a]; if (shouldEmit(specifier)) { if (needsComma) { write(", "); @@ -35158,8 +35601,8 @@ var ts; } writeLine(); var started = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var importNode = externalImports[_a]; + for (var _a = 0, externalImports_1 = externalImports; _a < externalImports_1.length; _a++) { + var importNode = externalImports_1[_a]; // do not create variable declaration for exports and imports that lack import clause var skipNode = importNode.kind === 228 /* ExportDeclaration */ || (importNode.kind === 222 /* ImportDeclaration */ && !importNode.importClause); @@ -35193,8 +35636,8 @@ var ts; // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. var hasExportDeclarationWithExportClause = false; - for (var _a = 0; _a < externalImports.length; _a++) { - var externalImport = externalImports[_a]; + for (var _a = 0, externalImports_2 = externalImports; _a < externalImports_2.length; _a++) { + var externalImport = externalImports_2[_a]; if (externalImport.kind === 228 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; @@ -35225,8 +35668,8 @@ var ts; } } } - for (var _d = 0; _d < externalImports.length; _d++) { - var externalImport = externalImports[_d]; + for (var _d = 0, externalImports_3 = externalImports; _d < externalImports_3.length; _d++) { + var externalImport = externalImports_3[_d]; if (externalImport.kind !== 228 /* ExportDeclaration */) { continue; } @@ -35275,7 +35718,7 @@ var ts; function writeExportedName(node) { // do not record default exports // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 69 /* Identifier */ && node.flags & 1024 /* Default */) { + if (node.kind !== 69 /* Identifier */ && node.flags & 512 /* Default */) { return; } if (started) { @@ -35338,7 +35781,7 @@ var ts; emit(local); } var flags = ts.getCombinedNodeFlags(local.kind === 69 /* Identifier */ ? local.parent : local); - if (flags & 1 /* Export */) { + if (flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35348,11 +35791,11 @@ var ts; write(";"); } if (hoistedFunctionDeclarations) { - for (var _a = 0; _a < hoistedFunctionDeclarations.length; _a++) { - var f = hoistedFunctionDeclarations[_a]; + for (var _a = 0, hoistedFunctionDeclarations_1 = hoistedFunctionDeclarations; _a < hoistedFunctionDeclarations_1.length; _a++) { + var f = hoistedFunctionDeclarations_1[_a]; writeLine(); emit(f); - if (f.flags & 1 /* Export */) { + if (f.flags & 2 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; } @@ -35362,7 +35805,7 @@ var ts; } return exportedDeclarations; function visit(node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return; } if (node.kind === 213 /* FunctionDeclaration */) { @@ -35437,7 +35880,7 @@ var ts; // - it is top level block scoped // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + return (ts.getCombinedNodeFlags(node) & 24576 /* BlockScoped */) === 0 || ts.getEnclosingBlockScopeContainer(node).kind === 248 /* SourceFile */; } function isCurrentFileSystemExternalModule() { @@ -35509,8 +35952,8 @@ var ts; var parameterName = makeUniqueName(ts.forEach(group, getLocalNameForExternalImport) || ""); write("function (" + parameterName + ") {"); increaseIndent(); - for (var _a = 0; _a < group.length; _a++) { - var entry = group[_a]; + for (var _a = 0, group_1 = group; _a < group_1.length; _a++) { + var entry = group_1[_a]; var importVariableName = getLocalNameForExternalImport(entry) || ""; switch (entry.kind) { case 222 /* ImportDeclaration */: @@ -35679,8 +36122,8 @@ var ts; unaliasedModuleNames.push("\"" + amdDependency.path + "\""); } } - for (var _c = 0; _c < externalImports.length; _c++) { - var importNode = externalImports[_c]; + for (var _c = 0, externalImports_4 = externalImports; _c < externalImports_4.length; _c++) { + var importNode = externalImports_4[_c]; // Find the name of the external module var externalModuleName = getExternalModuleNameText(importNode); // Find the name of the module alias, if there is one @@ -35959,7 +36402,7 @@ var ts; // Start new file on new line writeLine(); emitShebang(); - emitDetachedComments(node); + emitDetachedCommentsAndUpdateCommentsInfo(node); if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { var emitModule = moduleEmitDelegates[modulekind] || moduleEmitDelegates[1 /* CommonJS */]; emitModule(node); @@ -35983,7 +36426,7 @@ var ts; } function emitNodeConsideringCommentsOption(node, emitNodeConsideringSourcemap) { if (node) { - if (node.flags & 2 /* Ambient */) { + if (node.flags & 4 /* Ambient */) { return emitCommentsOnNotEmittedNode(node); } if (isSpecializedCommentHandling(node)) { @@ -36232,10 +36675,6 @@ var ts; } return leadingComments; } - function isPinnedComments(comment) { - return currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */; - } /** * Determine if the given comment is a triple-slash * @@ -36350,57 +36789,14 @@ var ts; // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space ts.emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitDetachedComments(node) { - var leadingComments; - if (compilerOptions.removeComments) { - // removeComments is true, only reserve pinned comment at the top of file - // For example: - // /*! Pinned Comment */ - // - // var x = 10; - if (node.pos === 0) { - leadingComments = ts.filter(ts.getLeadingCommentRanges(currentSourceFile.text, node.pos), isPinnedComments); + function emitDetachedCommentsAndUpdateCommentsInfo(node) { + var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile, writer, writeComment, node, newLine, compilerOptions.removeComments); + if (currentDetachedCommentInfo) { + if (detachedCommentsInfo) { + detachedCommentsInfo.push(currentDetachedCommentInfo); } - } - else { - // removeComments is false, just get detached as normal and bypass the process to filter comment - leadingComments = ts.getLeadingCommentRanges(currentSourceFile.text, node.pos); - } - if (leadingComments) { - var detachedComments = []; - var lastComment; - ts.forEach(leadingComments, function (comment) { - if (lastComment) { - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, lastComment.end); - var commentLine = ts.getLineOfLocalPosition(currentSourceFile, comment.pos); - if (commentLine >= lastCommentLine + 2) { - // There was a blank line between the last comment and this comment. This - // comment is not part of the copyright comments. Return what we have so - // far. - return detachedComments; - } - } - detachedComments.push(comment); - lastComment = comment; - }); - if (detachedComments.length) { - // All comments look like they could have been part of the copyright header. Make - // sure there is at least one blank line between it and the node. If not, it's not - // a copyright header. - var lastCommentLine = ts.getLineOfLocalPosition(currentSourceFile, ts.lastOrUndefined(detachedComments).end); - var nodeLine = ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node.pos)); - if (nodeLine >= lastCommentLine + 2) { - // Valid detachedComments - ts.emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments); - ts.emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment); - var currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end }; - if (detachedCommentsInfo) { - detachedCommentsInfo.push(currentDetachedCommentInfo); - } - else { - detachedCommentsInfo = [currentDetachedCommentInfo]; - } - } + else { + detachedCommentsInfo = [currentDetachedCommentInfo]; } } } @@ -36716,7 +37112,7 @@ var ts; var resolveModuleNamesWorker = host.resolveModuleNames ? (function (moduleNames, containingFile) { return host.resolveModuleNames(moduleNames, containingFile); }) : (function (moduleNames, containingFile) { return ts.map(moduleNames, function (moduleName) { return resolveModuleName(moduleName, containingFile, options, host).resolvedModule; }); }); - var filesByName = ts.createFileMap(getCanonicalFileName); + var filesByName = ts.createFileMap(); // stores 'filename -> file association' ignoring case // used to track cases when two file names differ only in casing var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined; @@ -36774,8 +37170,8 @@ var ts; // Initialize a checker so that all our files are bound. getTypeChecker(); classifiableNames = {}; - for (var _i = 0; _i < files.length; _i++) { - var sourceFile = files[_i]; + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var sourceFile = files_3[_i]; ts.copyMap(sourceFile.classifiableNames, classifiableNames); } } @@ -36793,7 +37189,7 @@ var ts; } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; - var normalizedAbsoluteFileNames = []; + var filePaths = []; var modifiedSourceFiles = []; for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { var oldSourceFile = _a[_i]; @@ -36801,8 +37197,8 @@ var ts; if (!newSourceFile) { return false; } - var normalizedAbsolutePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); - normalizedAbsoluteFileNames.push(normalizedAbsolutePath); + newSourceFile.path = oldSourceFile.path; + filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed @@ -36822,7 +37218,7 @@ var ts; } if (resolveModuleNamesWorker) { var moduleNames = ts.map(newSourceFile.imports, function (name) { return name.text; }); - var resolutions = resolveModuleNamesWorker(moduleNames, normalizedAbsolutePath); + var resolutions = resolveModuleNamesWorker(moduleNames, ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory)); // ensure that module resolution results are still correct for (var i = 0; i < moduleNames.length; ++i) { var newResolution = resolutions[i]; @@ -36850,12 +37246,12 @@ var ts; } // update fileName -> file mapping for (var i = 0, len = newSourceFiles.length; i < len; ++i) { - filesByName.set(normalizedAbsoluteFileNames[i], newSourceFiles[i]); + filesByName.set(filePaths[i], newSourceFiles[i]); } files = newSourceFiles; fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); - for (var _b = 0; _b < modifiedSourceFiles.length; _b++) { - var modifiedFile = modifiedSourceFiles[_b]; + for (var _b = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _b < modifiedSourceFiles_1.length; _b++) { + var modifiedFile = modifiedSourceFiles_1[_b]; fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile); } oldProgram.structureIsReused = true; @@ -36905,7 +37301,7 @@ var ts; return emitResult; } function getSourceFile(fileName) { - return filesByName.get(ts.getNormalizedAbsolutePath(fileName, currentDirectory)); + return filesByName.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName)); } function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { @@ -37024,7 +37420,7 @@ var ts; } break; case 218 /* ModuleDeclaration */: - if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + if (node.name.kind === 9 /* StringLiteral */ && (node.flags & 4 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. @@ -37049,7 +37445,7 @@ var ts; diagnostic = ts.Diagnostics.File_0_has_unsupported_extension_The_only_supported_extensions_are_1; diagnosticArgument = [fileName, "'" + ts.supportedExtensions.join("', '") + "'"]; } - else if (!findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd)) { + else if (!findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd)) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } @@ -37059,13 +37455,13 @@ var ts; } } else { - var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.getNormalizedAbsolutePath(fileName, currentDirectory), isDefaultLib, refFile, refPos, refEnd); + var nonTsFile = options.allowNonTsExtensions && findSourceFile(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); if (!nonTsFile) { if (options.allowNonTsExtensions) { diagnostic = ts.Diagnostics.File_0_not_found; diagnosticArgument = [fileName]; } - else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.getNormalizedAbsolutePath(fileName + extension, currentDirectory), isDefaultLib, refFile, refPos, refEnd); })) { + else if (!ts.forEach(ts.supportedExtensions, function (extension) { return findSourceFile(fileName + extension, ts.toPath(fileName + extension, currentDirectory, getCanonicalFileName), isDefaultLib, refFile, refPos, refEnd); })) { diagnostic = ts.Diagnostics.File_0_not_found; fileName += ".ts"; diagnosticArgument = [fileName]; @@ -37111,6 +37507,7 @@ var ts; }); filesByName.set(normalizedAbsolutePath, file); if (file) { + file.path = normalizedAbsolutePath; if (host.useCaseSensitiveFileNames()) { // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(normalizedAbsolutePath); @@ -37157,13 +37554,7 @@ var ts; var resolution = resolutions[i]; ts.setResolvedModule(file, moduleNames[i], resolution); if (resolution && !options.noResolve) { - var absoluteImportPath = ts.isRootedDiskPath(resolution.resolvedFileName) - ? resolution.resolvedFileName - : ts.getNormalizedAbsolutePath(resolution.resolvedFileName, currentDirectory); - // convert an absolute import path to path that is relative to current directory - // this was host still can locate it but files names in user output will be shorter (and thus look nicer). - var relativePath = ts.getRelativePathToDirectoryOrUrl(currentDirectory, absoluteImportPath, currentDirectory, getCanonicalFileName, false); - var importedFile = findSourceFile(relativePath, absoluteImportPath, /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); + var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /* isDefaultLib */ false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end); if (importedFile && resolution.isExternalLibraryImport) { if (!ts.isExternalModule(importedFile)) { var start_2 = ts.getTokenPosOfNode(file.imports[i], file); @@ -37219,8 +37610,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { + var sourceFile = sourceFiles_1[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -37344,6 +37735,7 @@ var ts; /// /// /// +/// /// var ts; (function (ts) { @@ -37493,6 +37885,12 @@ var ts; type: "boolean", description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "pretty", + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, + type: "boolean" + }, { name: "project", shortName: "p", @@ -37591,11 +37989,31 @@ var ts; description: ts.Diagnostics.Specifies_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, error: ts.Diagnostics.Argument_for_moduleResolution_option_must_be_node_or_classic }, + { + name: "allowUnusedLabels", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "noImplicitReturns", + type: "boolean", + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, { name: "forceConsistentCasingInFileNames", type: "boolean", description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, + } ]; var optionNameMapCache; /* @internal */ @@ -37734,13 +38152,38 @@ var ts; */ function parseConfigFileTextToJson(fileName, jsonText) { try { - return { config: /\S/.test(jsonText) ? JSON.parse(jsonText) : {} }; + var jsonTextWithoutComments = removeComments(jsonText); + return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} }; } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) }; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; + /** + * Remove the comments from a json like text. + * Comments can be single line comments (starting with # or //) or multiline comments using / * * / + * + * This method replace comment content by whitespace rather than completely remove them to keep positions in json parsing error reporting accurate. + */ + function removeComments(jsonText) { + var output = ""; + var scanner = ts.createScanner(1 /* ES5 */, /* skipTrivia */ false, 0 /* Standard */, jsonText); + var token; + while ((token = scanner.scan()) !== 1 /* EndOfFileToken */) { + switch (token) { + case 2 /* SingleLineCommentTrivia */: + case 3 /* MultiLineCommentTrivia */: + // replace comments with whitespace to preserve original character positions + output += scanner.getTokenText().replace(/\S/g, " "); + break; + default: + output += scanner.getTokenText(); + break; + } + } + return output; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -37871,8 +38314,8 @@ var ts; var lastSingleLineCommentEnd = -1; var isFirstSingleLineComment = true; var singleLineCommentCount = 0; - for (var _i = 0; _i < comments.length; _i++) { - var currentComment = comments[_i]; + for (var _i = 0, comments_2 = comments; _i < comments_2.length; _i++) { + var currentComment = comments_2[_i]; // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { @@ -38004,6 +38447,8 @@ var ts; function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) { var patternMatcher = ts.createPatternMatcher(searchValue); var rawItems = []; + // This means "compare in a case insensitive manner." + var baseSensitivity = { sensitivity: "base" }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); @@ -38017,8 +38462,8 @@ var ts; if (!matches) { continue; } - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { + var declaration = declarations_6[_i]; // It was a match! If the pattern has dots in it, then also see if the // declaration container matches as well. if (patternMatcher.patternContainsDots) { @@ -38047,8 +38492,8 @@ var ts; function allMatchesAreCaseSensitive(matches) { ts.Debug.assert(matches.length > 0); // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; if (!match.isCaseSensitive) { return false; } @@ -38123,8 +38568,8 @@ var ts; function bestMatchKind(matches) { ts.Debug.assert(matches.length > 0); var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0; _i < matches.length; _i++) { - var match = matches[_i]; + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; var kind = match.kind; if (kind < bestMatchKind) { bestMatchKind = kind; @@ -38132,8 +38577,6 @@ var ts; } return bestMatchKind; } - // This means "compare in a case insensitive manner." - var baseSensitivity = { sensitivity: "base" }; function compareNavigateToItems(i1, i2) { // TODO(cyrusn): get the gamut of comparisons that VS already uses here. // Right now we just sort by kind first, and then by name of the item. @@ -38296,8 +38739,8 @@ var ts; } function addTopLevelNodes(nodes, topLevelNodes) { nodes = sortNodes(nodes); - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_i]; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; switch (node.kind) { case 214 /* ClassDeclaration */: case 217 /* EnumDeclaration */: @@ -38340,8 +38783,8 @@ var ts; function getItemsWorker(nodes, createItem) { var items = []; var keyToItem = {}; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var child = nodes_5[_i]; var item = createItem(child); if (item !== undefined) { if (item.text.length > 0) { @@ -38389,7 +38832,7 @@ var ts; if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 2035 /* Modifier */) === 0) { + if ((node.flags & 1022 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); @@ -38693,8 +39136,8 @@ var ts; // word part. That way we don't match something like 'Class' when the user types 'a'. // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). var wordSpans = getWordSpans(candidate); - for (var _i = 0; _i < wordSpans.length; _i++) { - var span = wordSpans[_i]; + for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { + var span = wordSpans_1[_i]; if (partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, /*isCaseSensitive:*/ partStartsWith(candidate, span, chunk.text, /*ignoreCase:*/ false)); @@ -38800,8 +39243,8 @@ var ts; // Only if all words have some sort of match is the pattern considered matched. var subWordTextChunks = segment.subWordTextChunks; var matches = undefined; - for (var _i = 0; _i < subWordTextChunks.length; _i++) { - var subWordTextChunk = subWordTextChunks[_i]; + for (var _i = 0, subWordTextChunks_1 = subWordTextChunks; _i < subWordTextChunks_1.length; _i++) { + var subWordTextChunk = subWordTextChunks_1[_i]; // Try to match the candidate with this word var result = matchTextChunk(candidate, subWordTextChunk, /*punctuationStripped:*/ true); if (!result) { @@ -39386,8 +39829,8 @@ var ts; var nameToDeclarations = sourceFile_1.getNamedDeclarations(); var declarations = ts.getProperty(nameToDeclarations, name.text); if (declarations) { - for (var _b = 0; _b < declarations.length; _b++) { - var declaration = declarations[_b]; + for (var _b = 0, declarations_7 = declarations; _b < declarations_7.length; _b++) { + var declaration = declarations_7[_b]; var symbol = declaration.symbol; if (symbol) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration); @@ -39503,8 +39946,8 @@ var ts; // arg index. var argumentIndex = 0; var listChildren = argumentsList.getChildren(); - for (var _i = 0; _i < listChildren.length; _i++) { - var child = listChildren[_i]; + for (var _i = 0, listChildren_1 = listChildren; _i < listChildren_1.length; _i++) { + var child = listChildren_1[_i]; if (child === node) { break; } @@ -40049,8 +40492,8 @@ var ts; return n; } var children = n.getChildren(); - for (var _i = 0; _i < children.length; _i++) { - var child = children[_i]; + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -40212,17 +40655,17 @@ var ts; function getNodeModifiers(node) { var flags = ts.getCombinedNodeFlags(node); var result = []; - if (flags & 32 /* Private */) + if (flags & 16 /* Private */) result.push(ts.ScriptElementKindModifier.privateMemberModifier); - if (flags & 64 /* Protected */) + if (flags & 32 /* Protected */) result.push(ts.ScriptElementKindModifier.protectedMemberModifier); - if (flags & 16 /* Public */) + if (flags & 8 /* Public */) result.push(ts.ScriptElementKindModifier.publicMemberModifier); - if (flags & 128 /* Static */) + if (flags & 64 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); - if (flags & 256 /* Abstract */) + if (flags & 128 /* Abstract */) result.push(ts.ScriptElementKindModifier.abstractModifier); - if (flags & 1 /* Export */) + if (flags & 2 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) result.push(ts.ScriptElementKindModifier.ambientModifier); @@ -42366,8 +42809,8 @@ var ts; } } var inheritedIndentation = -1 /* Unknown */; - for (var _i = 0; _i < nodes.length; _i++) { - var child = nodes[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var child = nodes_6[_i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true); } if (listEndToken !== 0 /* Unknown */) { @@ -42458,8 +42901,8 @@ var ts; } } function processTrivia(trivia, parent, contextNode, dynamicIndentation) { - for (var _i = 0; _i < trivia.length; _i++) { - var triviaItem = trivia[_i]; + for (var _i = 0, trivia_1 = trivia; _i < trivia_1.length; _i++) { + var triviaItem = trivia_1[_i]; if (ts.isComment(triviaItem.kind) && ts.rangeContainsRange(originalRange, triviaItem)) { var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos); processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation); @@ -43056,7 +43499,6 @@ var ts; return node; } } - return node; } } function deriveActualIndentationFromList(list, index, sourceFile, options) { @@ -43307,17 +43749,17 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 2048 /* Synthetic */, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); + var list = createNode(271 /* SyntaxList */, nodes.pos, nodes.end, 2048 /* Synthetic */, this); list._children = []; var pos = nodes.pos; - for (var _i = 0; _i < nodes.length; _i++) { - var node = nodes[_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); } @@ -43872,7 +44314,7 @@ var ts; break; case 138 /* Parameter */: // Only consider properties defined as constructor parameters - if (!(node.flags & 112 /* AccessibilityModifier */)) { + if (!(node.flags & 56 /* AccessibilityModifier */)) { break; } // fall through @@ -44148,13 +44590,15 @@ var ts; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; + this.getCanonicalFileName = getCanonicalFileName; // script id => script index - this.fileNameToEntry = ts.createFileMap(getCanonicalFileName); + this.currentDirectory = host.getCurrentDirectory(); + this.fileNameToEntry = ts.createFileMap(); // Initialize the list with the root file names var rootFileNames = host.getScriptFileNames(); - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; - this.createEntry(fileName); + for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) { + var fileName = rootFileNames_1[_i]; + this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName)); } // store the compilation settings this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); @@ -44162,7 +44606,7 @@ var ts; HostCache.prototype.compilationSettings = function () { return this._compilationSettings; }; - HostCache.prototype.createEntry = function (fileName) { + HostCache.prototype.createEntry = function (fileName, path) { var entry; var scriptSnapshot = this.host.getScriptSnapshot(fileName); if (scriptSnapshot) { @@ -44172,36 +44616,37 @@ var ts; scriptSnapshot: scriptSnapshot }; } - this.fileNameToEntry.set(fileName, entry); + this.fileNameToEntry.set(path, entry); return entry; }; - HostCache.prototype.getEntry = function (fileName) { - return this.fileNameToEntry.get(fileName); + HostCache.prototype.getEntry = function (path) { + return this.fileNameToEntry.get(path); }; - HostCache.prototype.contains = function (fileName) { - return this.fileNameToEntry.contains(fileName); + HostCache.prototype.contains = function (path) { + return this.fileNameToEntry.contains(path); }; HostCache.prototype.getOrCreateEntry = function (fileName) { - if (this.contains(fileName)) { - return this.getEntry(fileName); + var path = ts.toPath(fileName, this.currentDirectory, this.getCanonicalFileName); + if (this.contains(path)) { + return this.getEntry(path); } - return this.createEntry(fileName); + return this.createEntry(fileName, path); }; HostCache.prototype.getRootFileNames = function () { var fileNames = []; - this.fileNameToEntry.forEachValue(function (value) { + this.fileNameToEntry.forEachValue(function (path, value) { if (value) { fileNames.push(value.hostFileName); } }); return fileNames; }; - HostCache.prototype.getVersion = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getVersion = function (path) { + var file = this.getEntry(path); return file && file.version; }; - HostCache.prototype.getScriptSnapshot = function (fileName) { - var file = this.getEntry(fileName); + HostCache.prototype.getScriptSnapshot = function (path) { + var file = this.getEntry(path); return file && file.scriptSnapshot; }; return HostCache; @@ -44383,7 +44828,8 @@ var ts; : (function (fileName) { return fileName.toLowerCase(); }); } ts.createGetCanonicalFileName = createGetCanonicalFileName; - function createDocumentRegistry(useCaseSensitiveFileNames) { + function createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. var buckets = {}; @@ -44395,7 +44841,7 @@ var ts; var key = getKeyFromCompilationSettings(settings); var bucket = ts.lookUp(buckets, key); if (!bucket && createIfMissing) { - buckets[key] = bucket = ts.createFileMap(getCanonicalFileName); + buckets[key] = bucket = ts.createFileMap(); } return bucket; } @@ -44403,14 +44849,13 @@ var ts; var bucketInfoArray = Object.keys(buckets).filter(function (name) { return name && name.charAt(0) === '_'; }).map(function (name) { var entries = ts.lookUp(buckets, name); var sourceFiles = []; - for (var i in entries) { - var entry = entries.get(i); + entries.forEachValue(function (key, entry) { sourceFiles.push({ - name: i, + name: key, refCount: entry.languageServiceRefCount, references: entry.owners.slice(0) }); - } + }); sourceFiles.sort(function (x, y) { return y.refCount - x.refCount; }); return { bucket: name, @@ -44427,7 +44872,8 @@ var ts; } function acquireOrUpdateDocument(fileName, compilationSettings, scriptSnapshot, version, acquiring) { var bucket = getBucketForCompilationSettings(compilationSettings, /*createIfMissing*/ true); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); if (!entry) { ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. @@ -44437,7 +44883,7 @@ var ts; languageServiceRefCount: 0, owners: [] }; - bucket.set(fileName, entry); + bucket.set(path, entry); } else { // We have an entry for this file. However, it may be for a different version of @@ -44460,11 +44906,12 @@ var ts; function releaseDocument(fileName, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); ts.Debug.assert(bucket !== undefined); - var entry = bucket.get(fileName); + var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); + var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); if (entry.languageServiceRefCount === 0) { - bucket.remove(fileName); + bucket.remove(path); } } return { @@ -44871,7 +45318,7 @@ var ts; case 144 /* Constructor */: return ScriptElementKind.constructorImplementationElement; case 137 /* TypeParameter */: return ScriptElementKind.typeParameterElement; case 247 /* EnumMember */: return ScriptElementKind.variableElement; - case 138 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 138 /* Parameter */: return (node.flags & 56 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; case 221 /* ImportEqualsDeclaration */: case 226 /* ImportSpecifier */: case 223 /* ImportClause */: @@ -44897,13 +45344,14 @@ var ts; return CancellationTokenObject; })(); function createLanguageService(host, documentRegistry) { - if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } + if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); var ruleProvider; var program; var lastProjectVersion; var useCaseSensitivefileNames = false; var cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + var currentDirectory = host.getCurrentDirectory(); // Check if the localized messages json is set, otherwise query the host for it if (!ts.localizedDiagnosticMessages && host.getLocalizedDiagnosticMessages) { ts.localizedDiagnosticMessages = host.getLocalizedDiagnosticMessages(); @@ -44915,8 +45363,7 @@ var ts; } var getCanonicalFileName = createGetCanonicalFileName(useCaseSensitivefileNames); function getValidSourceFile(fileName) { - fileName = ts.normalizeSlashes(fileName); - var sourceFile = program.getSourceFile(getCanonicalFileName(fileName)); + var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { throw new Error("Could not find file: '" + fileName + "'."); } @@ -44968,7 +45415,7 @@ var ts; getNewLine: function () { return ts.getNewLineOrDefaultFromHost(host); }, getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); }, writeFile: function (fileName, data, writeByteOrderMark) { }, - getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + getCurrentDirectory: function () { return currentDirectory; }, fileExists: function (fileName) { // stub missing host functionality ts.Debug.assert(!host.resolveModuleNames); @@ -44988,11 +45435,10 @@ var ts; // not part of the new program. if (program) { var oldSourceFiles = program.getSourceFiles(); - for (var _i = 0; _i < oldSourceFiles.length; _i++) { - var oldSourceFile = oldSourceFiles[_i]; - var fileName = oldSourceFile.fileName; - if (!newProgram.getSourceFile(fileName) || changesInCompilationSettingsAffectSyntax) { - documentRegistry.releaseDocument(fileName, oldSettings); + for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { + var oldSourceFile = oldSourceFiles_1[_i]; + if (!newProgram.getSourceFile(oldSourceFile.fileName) || changesInCompilationSettingsAffectSyntax) { + documentRegistry.releaseDocument(oldSourceFile.fileName, oldSettings); } } } @@ -45048,7 +45494,8 @@ var ts; return documentRegistry.acquireDocument(fileName, newSettings, hostFileInformation.scriptSnapshot, hostFileInformation.version); } function sourceFileUpToDate(sourceFile) { - return sourceFile && sourceFile.version === hostCache.getVersion(sourceFile.fileName); + var path = sourceFile.path || ts.toPath(sourceFile.fileName, currentDirectory, getCanonicalFileName); + return sourceFile && sourceFile.version === hostCache.getVersion(path); } function programUpToDate() { // If we haven't create a program yet, then it is not up-to-date @@ -45061,8 +45508,8 @@ var ts; return false; } // If any file is not up-to-date, then the whole program is not up-to-date - for (var _i = 0; _i < rootFileNames.length; _i++) { - var fileName = rootFileNames[_i]; + for (var _i = 0, rootFileNames_2 = rootFileNames; _i < rootFileNames_2.length; _i++) { + var fileName = rootFileNames_2[_i]; if (!sourceFileUpToDate(program.getSourceFile(fileName))) { return false; } @@ -45237,8 +45684,8 @@ var ts; } function checkModifiers(modifiers) { if (modifiers) { - for (var _i = 0; _i < modifiers.length; _i++) { - var modifier = modifiers[_i]; + for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { + var modifier = modifiers_1[_i]; switch (modifier.kind) { case 112 /* PublicKeyword */: case 110 /* PrivateKeyword */: @@ -45940,8 +46387,8 @@ var ts; */ function filterNamedImportOrExportCompletionItems(exportsOfModule, namedImportsOrExports) { var exisingImportsOrExports = {}; - for (var _i = 0; _i < namedImportsOrExports.length; _i++) { - var element = namedImportsOrExports[_i]; + for (var _i = 0, namedImportsOrExports_1 = namedImportsOrExports; _i < namedImportsOrExports_1.length; _i++) { + var element = namedImportsOrExports_1[_i]; // If this is the current item we are editing right now, do not filter it out if (element.getStart() <= position && position <= element.getEnd()) { continue; @@ -45965,8 +46412,8 @@ var ts; return contextualMemberSymbols; } var existingMemberNames = {}; - for (var _i = 0; _i < existingMembers.length; _i++) { - var m = existingMembers[_i]; + for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { + var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members if (m.kind !== 245 /* PropertyAssignment */ && m.kind !== 246 /* ShorthandPropertyAssignment */ && @@ -45999,8 +46446,8 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = {}; - for (var _i = 0; _i < attributes.length; _i++) { - var attr = attributes[_i]; + for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { + var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (attr.getStart() <= position && position <= attr.getEnd()) { continue; @@ -46101,8 +46548,8 @@ var ts; var entries = []; if (symbols) { var nameToSymbol = {}; - for (var _i = 0; _i < symbols.length; _i++) { - var symbol = symbols[_i]; + for (var _i = 0, symbols_3 = symbols; _i < symbols_3.length; _i++) { + var symbol = symbols_3[_i]; var entry = createCompletionEntry(symbol, location); if (entry) { var id = ts.escapeIdentifier(entry.name); @@ -46844,8 +47291,8 @@ var ts; } var fileNameToDocumentHighlights = {}; var result = []; - for (var _i = 0; _i < referencedSymbols.length; _i++) { - var referencedSymbol = referencedSymbols[_i]; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var referencedSymbol = referencedSymbols_1[_i]; for (var _a = 0, _b = referencedSymbol.references; _a < _b.length; _a++) { var referenceEntry = _b[_a]; var fileName_1 = referenceEntry.fileName; @@ -46989,7 +47436,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } /** * For lack of a better name, this function takes a throw statement and returns the @@ -47027,7 +47473,6 @@ var ts; ts.forEachChild(node, aggregate); } } - ; } function ownsBreakOrContinueStatement(owner, statement) { var actualOwner = getBreakOrContinueOwner(statement); @@ -47096,7 +47541,7 @@ var ts; case 219 /* ModuleBlock */: case 248 /* SourceFile */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 256 /* Abstract */) { + if (modifierFlag & 128 /* Abstract */) { nodes = declaration.members.concat(declaration); } else { @@ -47111,7 +47556,7 @@ var ts; nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & 112 /* AccessibilityModifier */) { + if (modifierFlag & 56 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { return member.kind === 144 /* Constructor */ && member; }); @@ -47119,7 +47564,7 @@ var ts; nodes = nodes.concat(constructor.parameters); } } - else if (modifierFlag & 256 /* Abstract */) { + else if (modifierFlag & 128 /* Abstract */) { nodes = nodes.concat(container); } break; @@ -47135,19 +47580,19 @@ var ts; function getFlagFromModifier(modifier) { switch (modifier) { case 112 /* PublicKeyword */: - return 16 /* Public */; + return 8 /* Public */; case 110 /* PrivateKeyword */: - return 32 /* Private */; + return 16 /* Private */; case 111 /* ProtectedKeyword */: - return 64 /* Protected */; + return 32 /* Protected */; case 113 /* StaticKeyword */: - return 128 /* Static */; + return 64 /* Static */; case 82 /* ExportKeyword */: - return 1 /* Export */; + return 2 /* Export */; case 122 /* DeclareKeyword */: - return 2 /* Ambient */; + return 4 /* Ambient */; case 115 /* AbstractKeyword */: - return 256 /* Abstract */; + return 128 /* Abstract */; default: ts.Debug.fail(); } @@ -47346,8 +47791,8 @@ var ts; return undefined; } var result = []; - for (var _i = 0; _i < documentHighlights.length; _i++) { - var entry = documentHighlights[_i]; + for (var _i = 0, documentHighlights_1 = documentHighlights; _i < documentHighlights_1.length; _i++) { + var entry = documentHighlights_1[_i]; for (var _a = 0, _b = entry.highlightSpans; _a < _b.length; _a++) { var highlightSpan = _b[_a]; result.push({ @@ -47365,8 +47810,8 @@ var ts; return undefined; } var referenceEntries = []; - for (var _i = 0; _i < referenceSymbols.length; _i++) { - var referenceSymbol = referenceSymbols[_i]; + for (var _i = 0, referenceSymbols_1 = referenceSymbols; _i < referenceSymbols_1.length; _i++) { + var referenceSymbol = referenceSymbols_1[_i]; ts.addRange(referenceEntries, referenceSymbol.references); } return referenceEntries; @@ -47451,8 +47896,8 @@ var ts; } else { var internedName = getInternedName(symbol, node, declarations); - for (var _i = 0; _i < sourceFiles.length; _i++) { - var sourceFile = sourceFiles[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var sourceFile = sourceFiles_2[_i]; cancellationToken.throwIfCancellationRequested(); var nameTable = getNameTable(sourceFile); if (ts.lookUp(nameTable, internedName)) { @@ -47512,7 +47957,7 @@ var ts; } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); + var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 16 /* Private */) ? d : undefined; }); if (privateDeclaration) { return ts.getAncestor(privateDeclaration, 214 /* ClassDeclaration */); } @@ -47530,8 +47975,8 @@ var ts; var scope = undefined; var declarations = symbol.getDeclarations(); if (declarations) { - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { + var declaration = declarations_8[_i]; var container = getContainerNode(declaration); if (!container) { return undefined; @@ -47711,7 +48156,7 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 141 /* PropertyDeclaration */: case 140 /* PropertySignature */: @@ -47739,7 +48184,7 @@ var ts; // If we have a 'super' container, we must have an enclosing class. // Now make sure the owning class is the same as the search-space // and has the same static qualifier as the original 'super's owner. - if (container && (128 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + if (container && (64 /* Static */ & container.flags) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { references.push(getReferenceEntryFromNode(node)); } }); @@ -47749,7 +48194,7 @@ var ts; function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 128 /* Static */; + var staticFlag = 64 /* Static */; switch (searchSpaceNode.kind) { case 143 /* MethodDeclaration */: case 142 /* MethodSignature */: @@ -47827,7 +48272,7 @@ var ts; case 214 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 64 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; @@ -47998,8 +48443,8 @@ var ts; // To achieve that we will keep iterating until the result stabilizes. // Remember the last meaning lastIterationMeaning = meaning; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; + for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { + var declaration = declarations_9[_i]; var declarationMeaning = getMeaningFromDeclaration(declaration); if (declarationMeaning & meaning) { meaning |= declarationMeaning; @@ -48115,7 +48560,6 @@ var ts; return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; - ts.Debug.fail("Unknown declaration type"); } function isTypeReference(node) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { @@ -48694,8 +49138,8 @@ var ts; if (matchKind) { var parentElement = token.parent; var childNodes = parentElement.getChildren(sourceFile); - for (var _i = 0; _i < childNodes.length; _i++) { - var current = childNodes[_i]; + for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) { + var current = childNodes_1[_i]; if (current.kind === matchKind) { var range1 = ts.createTextSpan(token.getStart(sourceFile), token.getWidth(sourceFile)); var range2 = ts.createTextSpan(current.getStart(sourceFile), current.getWidth(sourceFile)); @@ -49025,8 +49469,8 @@ var ts; // Disallow rename for elements that are defined in the standard TypeScript library. var defaultLibFileName = host.getDefaultLibFileName(host.getCompilationSettings()); if (defaultLibFileName) { - for (var _i = 0; _i < declarations.length; _i++) { - var current = declarations[_i]; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var current = declarations_10[_i]; var sourceFile_2 = current.getSourceFile(); var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { @@ -49609,7 +50053,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 8192 /* DeclarationFile */) { + if (sourceFile.flags & 4096 /* DeclarationFile */) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -49827,7 +50271,7 @@ var ts; ? variableDeclaration.parent.parent.initializer.declarations : undefined; // Breakpoint is possible in variableDeclaration only if there is initialization - if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { + if (variableDeclaration.initializer || (variableDeclaration.flags & 2 /* Export */)) { if (declarations && declarations[0] === variableDeclaration) { if (isParentVariableStatement) { // First declaration - include let keyword @@ -49853,7 +50297,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - !!(parameter.flags & 16 /* Public */) || !!(parameter.flags & 32 /* Private */); + !!(parameter.flags & 8 /* Public */) || !!(parameter.flags & 16 /* Private */); } function spanInParameterDeclaration(parameter) { if (canHaveSpanInParameterDeclaration(parameter)) { @@ -49873,7 +50317,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || + return !!(functionDeclaration.flags & 2 /* Export */) || (functionDeclaration.parent.kind === 214 /* ClassDeclaration */ && functionDeclaration.kind !== 144 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { @@ -49967,7 +50411,6 @@ var ts; // fall through. case 244 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - ; case 220 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; @@ -50008,8 +50451,6 @@ var ts; default: return spanInNode(node.parent); } - // Default to parent node - return spanInNode(node.parent); } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration @@ -50138,7 +50579,6 @@ var ts; // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); - return null; } return JSON.parse(settingsJson); };