From 57f2fbde95cb814e4a073765f47a4ac02bb68786 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Feb 2017 21:54:56 -0800 Subject: [PATCH 001/207] Make sure all options have descriptions --- src/compiler/commandLineParser.ts | 66 +++++++++++++++-------- src/compiler/diagnosticMessages.json | 81 ++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 22 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 4ee76d7b817..74640a318e0 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -12,6 +12,7 @@ namespace ts { { name: "charset", type: "string", + description: Diagnostics.The_character_set_of_the_input_files }, compileOnSaveCommandLineOption, { @@ -25,19 +26,23 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.DIRECTORY, + description: Diagnostics.Output_directory_for_generated_declaration_files }, { name: "diagnostics", type: "boolean", + description: Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - experimental: true + experimental: true, + description: Diagnostics.Show_extended_diagnostic_information }, { name: "emitBOM", - type: "boolean" + type: "boolean", + description:Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { name: "help", @@ -58,10 +63,12 @@ namespace ts { { name: "inlineSourceMap", type: "boolean", + description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", + description:Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, { name: "jsx", @@ -86,17 +93,19 @@ namespace ts { { name: "listFiles", type: "boolean", + description: Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "locale", type: "string", + description: Diagnostics.The_locale_to_use_to_show_error_messages_e_g_en_us }, { name: "mapRoot", type: "string", isFilePath: true, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, paramType: Diagnostics.LOCATION, + description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "module", @@ -110,8 +119,8 @@ namespace ts { "es6": ModuleKind.ES2015, "es2015": ModuleKind.ES2015, }), - description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: Diagnostics.KIND, + description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "newLine", @@ -119,8 +128,8 @@ namespace ts { "crlf": NewLineKind.CarriageReturnLineFeed, "lf": NewLineKind.LineFeed }), - description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, paramType: Diagnostics.NEWLINE, + description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noEmit", @@ -129,7 +138,8 @@ namespace ts { }, { name: "noEmitHelpers", - type: "boolean" + type: "boolean", + description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", @@ -138,7 +148,8 @@ namespace ts { }, { name: "noErrorTruncation", - type: "boolean" + type: "boolean", + description: Diagnostics.Do_not_truncation_error_messages }, { name: "noImplicitAny", @@ -163,14 +174,17 @@ namespace ts { { name: "noLib", type: "boolean", + description: Diagnostics.Do_not_include_the_default_library_file_lib_d_ts }, { name: "noResolve", type: "boolean", + description:Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files }, { name: "skipDefaultLibCheck", type: "boolean", + description: Diagnostics.Skip_type_checking_of_default_library_declaration_files }, { name: "skipLibCheck", @@ -183,20 +197,21 @@ namespace ts { isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files // for correct behaviour, please use outFile paramType: Diagnostics.FILE, + description: Diagnostics.Concatenate_and_emit_output_to_single_file, }, { name: "outFile", type: "string", isFilePath: true, - description: Diagnostics.Concatenate_and_emit_output_to_single_file, paramType: Diagnostics.FILE, + description: Diagnostics.Concatenate_and_emit_output_to_single_file, }, { name: "outDir", type: "string", isFilePath: true, - description: Diagnostics.Redirect_output_structure_to_the_directory, paramType: Diagnostics.DIRECTORY, + description: Diagnostics.Redirect_output_structure_to_the_directory, }, { name: "preserveConstEnums", @@ -205,16 +220,16 @@ namespace ts { }, { name: "pretty", - description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" + type: "boolean", + description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { name: "project", shortName: "p", type: "string", isFilePath: true, + paramType: Diagnostics.FILE_OR_DIRECTORY, description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: Diagnostics.FILE_OR_DIRECTORY }, { name: "removeComments", @@ -231,6 +246,7 @@ namespace ts { { name: "isolatedModules", type: "boolean", + description: Diagnostics.Unconditionally_emit_imports_for_unresolved_files }, { name: "sourceMap", @@ -241,14 +257,14 @@ namespace ts { name: "sourceRoot", type: "string", isFilePath: true, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, paramType: Diagnostics.LOCATION, + description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { name: "suppressExcessPropertyErrors", type: "boolean", + experimental: true, description: Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true }, { name: "suppressImplicitAnyIndexErrors", @@ -258,8 +274,8 @@ namespace ts { { name: "stripInternal", type: "boolean", + experimental: true, description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true }, { name: "target", @@ -273,8 +289,8 @@ namespace ts { "es2017": ScriptTarget.ES2017, "esnext": ScriptTarget.ESNext, }), - description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, paramType: Diagnostics.VERSION, + description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { name: "version", @@ -305,8 +321,8 @@ namespace ts { "node": ModuleResolutionKind.NodeJs, "classic": ModuleResolutionKind.Classic, }), - description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, paramType: Diagnostics.STRATEGY, + description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { name: "allowUnusedLabels", @@ -344,7 +360,9 @@ namespace ts { // use type = object to copy the value as-is name: "paths", type: "object", - isTSConfigOnly: true + isTSConfigOnly: true, + description: Diagnostics.List_of_path_mapping_entries_for_module_names_to_locations_relative_to_the_baseUrl + }, { // this option can only be specified in tsconfig.json @@ -356,7 +374,8 @@ namespace ts { name: "rootDirs", type: "string", isFilePath: true - } + }, + description: Diagnostics.List_of_root_folders_whose_combined_content_represent_the_structure_of_the_project_at_runtime }, { name: "typeRoots", @@ -365,7 +384,8 @@ namespace ts { name: "typeRoots", type: "string", isFilePath: true - } + }, + description: Diagnostics.List_of_folders_to_include_type_definitions_from }, { name: "types", @@ -403,7 +423,8 @@ namespace ts { }, { name: "listEmittedFiles", - type: "boolean" + type: "boolean", + description: Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, { name: "lib", @@ -443,7 +464,8 @@ namespace ts { }, { name: "disableSizeLimit", - type: "boolean" + type: "boolean", + description: Diagnostics.Disable_size_limitation_on_JavaScript_project }, { name: "strictNullChecks", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 93953a3b90a..cae9ad0a3a6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2997,6 +2997,87 @@ "category": "Message", "code": 6148 }, + "Show diagnostic information.": { + "category": "Message", + "code": 6149 + }, + "Show extended diagnostic information.": { + "category": "Message", + "code": 6150 + }, + "Emit a single file with source maps instead of having a separate file.": { + "category": "Message", + "code": 6151 + }, + "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set.": { + "category": "Message", + "code": 6152 + }, + "Unconditionally emit imports for unresolved files.": { + "category": "Message", + "code": 6153 + }, + "Print names of generated files part of the compilation.": { + "category": "Message", + "code": 6154 + }, + "Print names of files part of the compilation.": { + "category": "Message", + "code": 6155 + }, + "The locale to use to show error messages, e.g. 'en-us'.": { + "category": "Message", + "code": 6156 + }, + "Do not generate custom helper functions like __extends in compiled output.": { + "category": "Message", + "code": 6157 + }, + "Do not include the default library file (lib.d.ts).": { + "category": "Message", + "code": 6158 + }, + "Do not add triple-slash references or module import targets to the list of compiled files.": { + "category": "Message", + "code": 6159 + }, + "Skip type checking of default library declaration files.": { + "category": "Message", + "code": 6160 + }, + "List of folders to include type definitions from.": { + "category": "Message", + "code": 6161 + }, + "Disable size limitation on JavaScript project.": { + "category": "Message", + "code": 6162 + }, + "The character set of the input files.": { + "category": "Message", + "code": 6163 + }, + "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files.": { + "category": "Message", + "code": 6164 + }, + "Do not truncation error messages.": { + "category": "Message", + "code": 6165 + }, + "Output directory for generated declaration files.": { + "category": "Message", + "code": 6166 + }, + "List of path mapping entries for module names to locations relative to the 'baseUrl'.": { + "category": "Message", + "code": 6167 + }, + "List of root folders whose combined content represent the structure of the project at runtime.": { + "category": "Message", + "code": 6168 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 From 34597198720500ab600042ad227bb3ec052f3e71 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Feb 2017 23:10:43 -0800 Subject: [PATCH 002/207] Manually order options --- src/compiler/commandLineParser.ts | 584 +++++++++++++++--------------- src/compiler/tsc.ts | 2 +- 2 files changed, 301 insertions(+), 285 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 74640a318e0..26f6014987f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -9,41 +9,7 @@ namespace ts { export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean" }; /* @internal */ export const optionDeclarations: CommandLineOption[] = [ - { - name: "charset", - type: "string", - description: Diagnostics.The_character_set_of_the_input_files - }, - compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: Diagnostics.DIRECTORY, - description: Diagnostics.Output_directory_for_generated_declaration_files - }, - { - name: "diagnostics", - type: "boolean", - description: Diagnostics.Show_diagnostic_information - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true, - description: Diagnostics.Show_extended_diagnostic_information - }, - { - name: "emitBOM", - type: "boolean", - description:Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files - }, + // Basic options { name: "help", shortName: "h", @@ -55,57 +21,39 @@ namespace ts { shortName: "?", type: "boolean" }, + { + name: "version", + shortName: "v", + type: "boolean", + description: Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { - name: "inlineSourceMap", - type: "boolean", - description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file - }, - { - name: "inlineSources", - type: "boolean", - description:Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set - }, - { - name: "jsx", - type: createMapFromTemplate({ - "preserve": JsxEmit.Preserve, - "react-native": JsxEmit.ReactNative, - "react": JsxEmit.React - }), - paramType: Diagnostics.KIND, - description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - description: Diagnostics.Print_names_of_files_part_of_the_compilation - }, - { - name: "locale", - type: "string", - description: Diagnostics.The_locale_to_use_to_show_error_messages_e_g_en_us - }, - { - name: "mapRoot", + name: "project", + shortName: "p", type: "string", isFilePath: true, - paramType: Diagnostics.LOCATION, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + paramType: Diagnostics.FILE_OR_DIRECTORY, + description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + }, + { + name: "target", + shortName: "t", + type: createMapFromTemplate({ + "es3": ScriptTarget.ES3, + "es5": ScriptTarget.ES5, + "es6": ScriptTarget.ES2015, + "es2015": ScriptTarget.ES2015, + "es2016": ScriptTarget.ES2016, + "es2017": ScriptTarget.ES2017, + "esnext": ScriptTarget.ESNext, + }), + paramType: Diagnostics.VERSION, + description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { name: "module", @@ -123,73 +71,66 @@ namespace ts { description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { - name: "newLine", + name: "lib", + type: "list", + element: { + name: "lib", + type: createMapFromTemplate({ + // JavaScript only + "es5": "lib.es5.d.ts", + "es6": "lib.es2015.d.ts", + "es2015": "lib.es2015.d.ts", + "es7": "lib.es2016.d.ts", + "es2016": "lib.es2016.d.ts", + "es2017": "lib.es2017.d.ts", + // Host only + "dom": "lib.dom.d.ts", + "dom.iterable": "lib.dom.iterable.d.ts", + "webworker": "lib.webworker.d.ts", + "scripthost": "lib.scripthost.d.ts", + // ES2015 Or ESNext By-feature options + "es2015.core": "lib.es2015.core.d.ts", + "es2015.collection": "lib.es2015.collection.d.ts", + "es2015.generator": "lib.es2015.generator.d.ts", + "es2015.iterable": "lib.es2015.iterable.d.ts", + "es2015.promise": "lib.es2015.promise.d.ts", + "es2015.proxy": "lib.es2015.proxy.d.ts", + "es2015.reflect": "lib.es2015.reflect.d.ts", + "es2015.symbol": "lib.es2015.symbol.d.ts", + "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", + "es2016.array.include": "lib.es2016.array.include.d.ts", + "es2017.object": "lib.es2017.object.d.ts", + "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", + "es2017.string": "lib.es2017.string.d.ts", + }), + }, + description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + }, + { + name: "allowJs", + type: "boolean", + description: Diagnostics.Allow_javascript_files_to_be_compiled + }, + { + name: "jsx", type: createMapFromTemplate({ - "crlf": NewLineKind.CarriageReturnLineFeed, - "lf": NewLineKind.LineFeed + "preserve": JsxEmit.Preserve, + "react-native": JsxEmit.ReactNative, + "react": JsxEmit.React }), - paramType: Diagnostics.NEWLINE, - description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + paramType: Diagnostics.KIND, + description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { - name: "noEmit", + name: "declaration", + shortName: "d", type: "boolean", - description: Diagnostics.Do_not_emit_outputs, + description: Diagnostics.Generates_corresponding_d_ts_file, }, { - name: "noEmitHelpers", + name: "sourceMap", type: "boolean", - description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output - }, - { - name: "noEmitOnError", - type: "boolean", - description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean", - description: Diagnostics.Do_not_truncation_error_messages - }, - { - name: "noImplicitAny", - type: "boolean", - description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - description: Diagnostics.Do_not_include_the_default_library_file_lib_d_ts - }, - { - name: "noResolve", - type: "boolean", - description:Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - description: Diagnostics.Skip_type_checking_of_default_library_declaration_files - }, - { - name: "skipLibCheck", - type: "boolean", - description: Diagnostics.Skip_type_checking_of_declaration_files, + description: Diagnostics.Generates_corresponding_map_file, }, { name: "out", @@ -213,29 +154,6 @@ namespace ts { paramType: Diagnostics.DIRECTORY, description: Diagnostics.Redirect_output_structure_to_the_directory, }, - { - name: "preserveConstEnums", - type: "boolean", - description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - type: "boolean", - description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - paramType: Diagnostics.FILE_OR_DIRECTORY, - description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - }, - { - name: "removeComments", - type: "boolean", - description: Diagnostics.Do_not_emit_comments_to_output, - }, { name: "rootDir", type: "string", @@ -243,22 +161,116 @@ namespace ts { paramType: Diagnostics.LOCATION, description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: Diagnostics.DIRECTORY, + description: Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "removeComments", + type: "boolean", + description: Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + description: Diagnostics.Do_not_emit_outputs, + }, + { + name: "noEmitHelpers", + type: "boolean", + description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "importHelpers", + type: "boolean", + description: Diagnostics.Import_emit_helpers_from_tslib + }, + { + name: "skipLibCheck", + type: "boolean", + description: Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, { name: "isolatedModules", type: "boolean", description: Diagnostics.Unconditionally_emit_imports_for_unresolved_files }, { - name: "sourceMap", + name: "pretty", type: "boolean", - description: Diagnostics.Generates_corresponding_map_file, + description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { - name: "sourceRoot", - type: "string", - isFilePath: true, - paramType: Diagnostics.LOCATION, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + name: "watch", + shortName: "w", + type: "boolean", + description: Diagnostics.Watch_input_files, + }, + + // Strict Checks + { + name: "noImplicitAny", + type: "boolean", + description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + description: Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, + { + name: "noUnusedLocals", + type: "boolean", + description: Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "alwaysStrict", + type: "boolean", + description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + { + name: "noImplicitReturns", + type: "boolean", + description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + + { + name: "allowUnusedLabels", + type: "boolean", + description: Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + description: Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", @@ -272,49 +284,50 @@ namespace ts { description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { - name: "stripInternal", + name: "forceConsistentCasingInFileNames", type: "boolean", - experimental: true, - description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + + // Source Maps + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: Diagnostics.LOCATION, + description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { - name: "target", - shortName: "t", - type: createMapFromTemplate({ - "es3": ScriptTarget.ES3, - "es5": ScriptTarget.ES5, - "es6": ScriptTarget.ES2015, - "es2015": ScriptTarget.ES2015, - "es2016": ScriptTarget.ES2016, - "es2017": ScriptTarget.ES2017, - "esnext": ScriptTarget.ESNext, - }), - paramType: Diagnostics.VERSION, - description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: Diagnostics.LOCATION, + description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { - name: "version", - shortName: "v", + name: "inlineSourceMap", type: "boolean", - description: Diagnostics.Print_the_compiler_s_version, + description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { - name: "watch", - shortName: "w", + name: "inlineSources", type: "boolean", - description: Diagnostics.Watch_input_files, + description:Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + + // JSX + { + name: "reactNamespace", + type: "string", + description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit }, { - name: "experimentalDecorators", - type: "boolean", - description: Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + name: "jsxFactory", + type: "string", + description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, + + // Module Resolution { name: "moduleResolution", type: createMapFromTemplate({ @@ -324,31 +337,6 @@ namespace ts { paramType: Diagnostics.STRATEGY, description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, - { - name: "allowUnusedLabels", - type: "boolean", - description: Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, { name: "baseUrl", type: "string", @@ -396,71 +384,109 @@ namespace ts { }, description: Diagnostics.Type_declaration_files_to_be_included_in_compilation }, - { - name: "traceResolution", - type: "boolean", - description: Diagnostics.Enable_tracing_of_the_name_resolution_process - }, - { - name: "allowJs", - type: "boolean", - description: Diagnostics.Allow_javascript_files_to_be_compiled - }, { name: "allowSyntheticDefaultImports", type: "boolean", description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, - { - name: "noImplicitUseStrict", - type: "boolean", - description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output - }, { name: "maxNodeModuleJsDepth", type: "number", description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, + + // Experimental + { + name: "experimentalDecorators", + type: "boolean", + description: Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + experimental: true, + description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + + // Diagnostic + { + name: "diagnostics", + type: "boolean", + description: Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + experimental: true, + description: Diagnostics.Show_extended_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + description: Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + description: Diagnostics.Print_names_of_files_part_of_the_compilation + }, { name: "listEmittedFiles", type: "boolean", description: Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, + + // Other { - name: "lib", - type: "list", - element: { - name: "lib", - type: createMapFromTemplate({ - // JavaScript only - "es5": "lib.es5.d.ts", - "es6": "lib.es2015.d.ts", - "es2015": "lib.es2015.d.ts", - "es7": "lib.es2016.d.ts", - "es2016": "lib.es2016.d.ts", - "es2017": "lib.es2017.d.ts", - // Host only - "dom": "lib.dom.d.ts", - "dom.iterable": "lib.dom.iterable.d.ts", - "webworker": "lib.webworker.d.ts", - "scripthost": "lib.scripthost.d.ts", - // ES2015 Or ESNext By-feature options - "es2015.core": "lib.es2015.core.d.ts", - "es2015.collection": "lib.es2015.collection.d.ts", - "es2015.generator": "lib.es2015.generator.d.ts", - "es2015.iterable": "lib.es2015.iterable.d.ts", - "es2015.promise": "lib.es2015.promise.d.ts", - "es2015.proxy": "lib.es2015.proxy.d.ts", - "es2015.reflect": "lib.es2015.reflect.d.ts", - "es2015.symbol": "lib.es2015.symbol.d.ts", - "es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts", - "es2016.array.include": "lib.es2016.array.include.d.ts", - "es2017.object": "lib.es2017.object.d.ts", - "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", - "es2017.string": "lib.es2017.string.d.ts", - }), - }, - description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon + name: "charset", + type: "string", + description: Diagnostics.The_character_set_of_the_input_files + }, + compileOnSaveCommandLineOption, + { + name: "emitBOM", + type: "boolean", + description:Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + description: Diagnostics.The_locale_to_use_to_show_error_messages_e_g_en_us + }, + { + name: "newLine", + type: createMapFromTemplate({ + "crlf": NewLineKind.CarriageReturnLineFeed, + "lf": NewLineKind.LineFeed + }), + paramType: Diagnostics.NEWLINE, + description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + description: Diagnostics.Do_not_truncation_error_messages + }, + { + name: "noLib", + type: "boolean", + description: Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + description:Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + description: Diagnostics.Skip_type_checking_of_default_library_declaration_files + }, + { + name: "stripInternal", + type: "boolean", + experimental: true, + description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", @@ -468,20 +494,10 @@ namespace ts { description: Diagnostics.Disable_size_limitation_on_JavaScript_project }, { - name: "strictNullChecks", + name: "noImplicitUseStrict", type: "boolean", - description: Diagnostics.Enable_strict_null_checks + description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, - { - name: "importHelpers", - type: "boolean", - description: Diagnostics.Import_emit_helpers_from_tslib - }, - { - name: "alwaysStrict", - type: "boolean", - description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - } ]; /* @internal */ diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index b1ffcff43a4..936a6d69c68 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -644,7 +644,7 @@ namespace ts { // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch") const optsList = filter(optionDeclarations.slice(), v => !v.experimental); - optsList.sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())); + //optsList.sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())); // We want our descriptions to align at the same column in our output, // so we keep track of the longest option usage string. From 486757f51f557b9fcdb3dfa666f9f8252ea88964 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 12:14:43 -0800 Subject: [PATCH 003/207] Add simplified help view and full help view --- src/compiler/commandLineParser.ts | 272 ++++++++++++++++++--------- src/compiler/diagnosticMessages.json | 4 + src/compiler/tsc.ts | 11 +- src/compiler/types.ts | 5 +- 4 files changed, 201 insertions(+), 91 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 26f6014987f..c161aa55bbd 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -9,11 +9,13 @@ namespace ts { export const compileOnSaveCommandLineOption: CommandLineOption = { name: "compileOnSave", type: "boolean" }; /* @internal */ export const optionDeclarations: CommandLineOption[] = [ - // Basic options + // CommandLine only options { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: "CommandLine", description: Diagnostics.Print_this_message, }, { @@ -21,15 +23,26 @@ namespace ts { shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: "CommandLine", + description: Diagnostics.Show_all_compiler_options, + }, { name: "version", shortName: "v", type: "boolean", + showInSimplifiedHelpView: true, + category: "CommandLine", description: Diagnostics.Print_the_compiler_s_version, }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: "CommandLine", description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { @@ -37,9 +50,28 @@ namespace ts { shortName: "p", type: "string", isFilePath: true, + showInSimplifiedHelpView: true, + category: "CommandLine", paramType: Diagnostics.FILE_OR_DIRECTORY, description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: "CommandLine", + description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, + { + name: "watch", + shortName: "w", + type: "boolean", + showInSimplifiedHelpView: true, + category: "CommandLine", + description: Diagnostics.Watch_input_files, + }, + + // Basic { name: "target", shortName: "t", @@ -53,6 +85,8 @@ namespace ts { "esnext": ScriptTarget.ESNext, }), paramType: Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { @@ -68,6 +102,8 @@ namespace ts { "es2015": ModuleKind.ES2015, }), paramType: Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { @@ -104,11 +140,15 @@ namespace ts { "es2017.string": "lib.es2017.string.d.ts", }), }, + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { name: "allowJs", type: "boolean", + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Allow_javascript_files_to_be_compiled }, { @@ -119,32 +159,32 @@ namespace ts { "react": JsxEmit.React }), paramType: Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { name: "declaration", shortName: "d", type: "boolean", + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Generates_corresponding_d_ts_file, }, { name: "sourceMap", type: "boolean", + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Generates_corresponding_map_file, }, - { - name: "out", - type: "string", - isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files - // for correct behaviour, please use outFile - paramType: Diagnostics.FILE, - description: Diagnostics.Concatenate_and_emit_output_to_single_file, - }, { name: "outFile", type: "string", isFilePath: true, paramType: Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Concatenate_and_emit_output_to_single_file, }, { @@ -152,6 +192,8 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -159,6 +201,7 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.LOCATION, + category: "Basic", description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -166,167 +209,130 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.DIRECTORY, + category: "Basic", description: Diagnostics.Output_directory_for_generated_declaration_files }, { name: "removeComments", type: "boolean", + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", + showInSimplifiedHelpView: true, + category: "Basic", description: Diagnostics.Do_not_emit_outputs, }, - { - name: "noEmitHelpers", - type: "boolean", - description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output - }, - { - name: "noEmitOnError", - type: "boolean", - description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, { name: "importHelpers", type: "boolean", + category: "Basic", description: Diagnostics.Import_emit_helpers_from_tslib }, { name: "skipLibCheck", type: "boolean", + category: "Basic", description: Diagnostics.Skip_type_checking_of_declaration_files, }, - { - name: "preserveConstEnums", - type: "boolean", - description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, { name: "isolatedModules", type: "boolean", + category: "Basic", description: Diagnostics.Unconditionally_emit_imports_for_unresolved_files }, - { - name: "pretty", - type: "boolean", - description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: Diagnostics.Watch_input_files, - }, // Strict Checks { name: "noImplicitAny", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "strictNullChecks", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Enable_strict_null_checks }, { name: "noImplicitThis", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Report_errors_on_unused_parameters, }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, { name: "noImplicitReturns", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { name: "noFallthroughCasesInSwitch", type: "boolean", + showInSimplifiedHelpView: true, + category: "StrictChecks", description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, - { name: "allowUnusedLabels", type: "boolean", + category: "StrictChecks", description: Diagnostics.Do_not_report_errors_on_unused_labels }, { name: "allowUnreachableCode", type: "boolean", + category: "StrictChecks", description: Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", - experimental: true, + category: "StrictChecks", description: Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", + category: "StrictChecks", description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", + category: "StrictChecks", description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, - // Source Maps - { - name: "sourceRoot", - type: "string", - isFilePath: true, - paramType: Diagnostics.LOCATION, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - paramType: Diagnostics.LOCATION, - description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - }, - { - name: "inlineSourceMap", - type: "boolean", - description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file - }, - { - name: "inlineSources", - type: "boolean", - description:Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set - }, - - // JSX - { - name: "reactNamespace", - type: "string", - description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - // Module Resolution { name: "moduleResolution", @@ -335,12 +341,14 @@ namespace ts { "classic": ModuleResolutionKind.Classic, }), paramType: Diagnostics.STRATEGY, + category: "ModuleResolution", description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { name: "baseUrl", type: "string", isFilePath: true, + category: "ModuleResolution", description: Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -349,6 +357,7 @@ namespace ts { name: "paths", type: "object", isTSConfigOnly: true, + category: "ModuleResolution", description: Diagnostics.List_of_path_mapping_entries_for_module_names_to_locations_relative_to_the_baseUrl }, @@ -363,6 +372,7 @@ namespace ts { type: "string", isFilePath: true }, + category: "ModuleResolution", description: Diagnostics.List_of_root_folders_whose_combined_content_represent_the_structure_of_the_project_at_runtime }, { @@ -373,6 +383,7 @@ namespace ts { type: "string", isFilePath: true }, + category: "ModuleResolution", description: Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -382,75 +393,146 @@ namespace ts { name: "types", type: "string" }, + showInSimplifiedHelpView: true, + category: "ModuleResolution", description: Diagnostics.Type_declaration_files_to_be_included_in_compilation }, { name: "allowSyntheticDefaultImports", type: "boolean", + category: "ModuleResolution", description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { name: "maxNodeModuleJsDepth", type: "number", + category: "ModuleResolution", description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, + // Source Maps + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: Diagnostics.LOCATION, + category: "SourceMaps", + description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: Diagnostics.LOCATION, + category: "SourceMaps", + description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: "SourceMaps", + description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: "SourceMaps", + description:Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + + // JSX + { + name: "jsxFactory", + type: "string", + category: "JSX", + description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + // Experimental { name: "experimentalDecorators", type: "boolean", + category: "Experimental", description: Diagnostics.Enables_experimental_support_for_ES7_decorators }, { name: "emitDecoratorMetadata", type: "boolean", - experimental: true, + category: "Experimental", description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, - // Diagnostic + // Advanced { name: "diagnostics", type: "boolean", + category: "Advanced", description: Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - experimental: true, + category: "Advanced", description: Diagnostics.Show_extended_diagnostic_information }, { name: "traceResolution", type: "boolean", + category: "Advanced", description: Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "listFiles", type: "boolean", + category: "Advanced", description: Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "listEmittedFiles", type: "boolean", + category: "Advanced", description: Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, - // Other + { + name: "out", + type: "string", + isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files + // for correct behaviour, please use outFile + category: "Advanced", + paramType: Diagnostics.FILE, + description: Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: "Advanced", + description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: "Advanced", + description: Diagnostics.Skip_type_checking_of_default_library_declaration_files + }, + { name: "charset", type: "string", + category: "Advanced", description: Diagnostics.The_character_set_of_the_input_files }, compileOnSaveCommandLineOption, { name: "emitBOM", type: "boolean", + category: "Advanced", description:Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { name: "locale", type: "string", + category: "Advanced", description: Diagnostics.The_locale_to_use_to_show_error_messages_e_g_en_us }, { @@ -460,44 +542,63 @@ namespace ts { "lf": NewLineKind.LineFeed }), paramType: Diagnostics.NEWLINE, + category: "Advanced", description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", + category: "Advanced", description: Diagnostics.Do_not_truncation_error_messages }, { name: "noLib", type: "boolean", + category: "Advanced", description: Diagnostics.Do_not_include_the_default_library_file_lib_d_ts }, { name: "noResolve", type: "boolean", + category: "Advanced", description:Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files }, - { - name: "skipDefaultLibCheck", - type: "boolean", - description: Diagnostics.Skip_type_checking_of_default_library_declaration_files - }, { name: "stripInternal", type: "boolean", - experimental: true, + category: "Advanced", description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", + category: "Advanced", description: Diagnostics.Disable_size_limitation_on_JavaScript_project }, { name: "noImplicitUseStrict", type: "boolean", + category: "Advanced", description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, + { + name: "noEmitHelpers", + type: "boolean", + category: "Advanced", + description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: "Advanced", + description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: "Advanced", + description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, ]; /* @internal */ @@ -813,6 +914,7 @@ namespace ts { case "version": case "help": case "project": + case "all": break; default: const value = options[name]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index cae9ad0a3a6..166417118cd 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3077,6 +3077,10 @@ "category": "Message", "code": 6168 }, + "Show all compiler options.": { + "category": "Message", + "code": 6169 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 936a6d69c68..474e5af8e1d 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -227,7 +227,7 @@ namespace ts { if (commandLine.options.help) { printVersion(); - printHelp(); + printHelp(commandLine.options.all); return sys.exit(ExitStatus.Success); } @@ -264,7 +264,7 @@ namespace ts { if (commandLine.fileNames.length === 0 && !configFileName) { printVersion(); - printHelp(); + printHelp(commandLine.options.all); return sys.exit(ExitStatus.Success); } @@ -618,7 +618,7 @@ namespace ts { sys.write(getDiagnosticText(Diagnostics.Version_0, ts.version) + sys.newLine); } - function printHelp() { + function printHelp(showAllOptions: boolean) { const output: string[] = []; // We want to align our "syntax" and "examples" commands to a certain margin. @@ -643,8 +643,9 @@ namespace ts { output.push(getDiagnosticText(Diagnostics.Options_Colon) + sys.newLine); // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch") - const optsList = filter(optionDeclarations.slice(), v => !v.experimental); - //optsList.sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())); + const optsList = showAllOptions ? + optionDeclarations.slice().sort((a, b) => compareValues(a.name.toLowerCase(), b.name.toLowerCase())) : + filter(optionDeclarations.slice(), v => v.showInSimplifiedHelpView); // We want our descriptions to align at the same column in our output, // so we keep track of the longest option usage string. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 49e744682bc..69c8d7a5c95 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3194,6 +3194,7 @@ export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike; export interface CompilerOptions { + /*@internal*/ all?: boolean; allowJs?: boolean; /*@internal*/ allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; @@ -3382,8 +3383,10 @@ shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter - experimental?: boolean; isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file + isCommandLineOnly?: boolean; + showInSimplifiedHelpView?:boolean; + category?: "CommandLine" | "Basic" | "StrictChecks" | "ModuleResolution" | "JSX" | "SourceMaps" | "Experimental" | "Advanced"; } /* @internal */ From 6837125657f9f04321aa39767276b257d5639f2e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 12:25:38 -0800 Subject: [PATCH 004/207] Add deprecation notice for some options --- src/compiler/commandLineParser.ts | 6 +++--- src/compiler/diagnosticMessages.json | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index c161aa55bbd..3b5b7cbba20 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -501,19 +501,19 @@ namespace ts { // for correct behaviour, please use outFile category: "Advanced", paramType: Diagnostics.FILE, - description: Diagnostics.Concatenate_and_emit_output_to_single_file, + description: Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, }, { name: "reactNamespace", type: "string", category: "Advanced", - description: Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit + description: Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", category: "Advanced", - description: Diagnostics.Skip_type_checking_of_default_library_declaration_files + description: Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 166417118cd..b487b47b106 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2737,7 +2737,7 @@ "category": "Message", "code": 6083 }, - "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit": { + "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit": { "category": "Message", "code": 6084 }, @@ -3041,7 +3041,7 @@ "category": "Message", "code": 6159 }, - "Skip type checking of default library declaration files.": { + "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files.": { "category": "Message", "code": 6160 }, @@ -3081,6 +3081,10 @@ "category": "Message", "code": 6169 }, + "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file": { + "category": "Message", + "code": 6170 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", From f53eeae4d8332b6aa800d867287c46011bb979de Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 12:35:31 -0800 Subject: [PATCH 005/207] use category in serializeCompilerOptions --- src/compiler/commandLineParser.ts | 54 +++++++++++++------------------ 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 3b5b7cbba20..d3940b63428 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -908,39 +908,31 @@ namespace ts { if (hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - case "all": - break; - default: - const value = options[name]; - const optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - const convertedValue: string[] = []; - for (const element of value as (string | number)[]) { - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === "CommandLine") { + continue; + } + const value = options[name]; + const optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + const convertedValue: string[] = []; + for (const element of value as (string | number)[]) { + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } From 0bc2840af4695dcd96e1d50d08672d36b21e6165 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 12:41:40 -0800 Subject: [PATCH 006/207] Make generateTSConfig return a string --- src/compiler/commandLineParser.ts | 4 ++-- src/compiler/tsc.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d3940b63428..d8a6f402a17 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -866,7 +866,7 @@ namespace ts { * @param fileNames array of filenames to be generated into tsconfig.json */ /* @internal */ - export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: MapLike } { + export function generateTSConfig(options: CompilerOptions, fileNames: string[]): string { const compilerOptions = extend(options, defaultInitCompilerOptions); const configurations: any = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -876,7 +876,7 @@ namespace ts { configurations.files = fileNames; } - return configurations; + return JSON.stringify(configurations, undefined, 4); function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map | undefined { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 474e5af8e1d..3800ed91aa3 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -739,7 +739,7 @@ namespace ts { reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* host */ undefined); } else { - sys.writeFile(file, JSON.stringify(generateTSConfig(options, fileNames), undefined, 4)); + sys.writeFile(file, generateTSConfig(options, fileNames)); reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* host */ undefined); } From 9fc4f6e1b9175f2649f4b14f46285ab889764285 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 19:07:15 -0800 Subject: [PATCH 007/207] Write comments for compiler options in `tsc --init` output --- src/compiler/commandLineParser.ts | 71 ++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d8a6f402a17..1a388c9e96a 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -868,7 +868,7 @@ namespace ts { /* @internal */ export function generateTSConfig(options: CompilerOptions, fileNames: string[]): string { const compilerOptions = extend(options, defaultInitCompilerOptions); - const configurations: any = { + const configurations: { compilerOptions: MapLike; files?: string[] } = { compilerOptions: serializeCompilerOptions(compilerOptions) }; if (fileNames && fileNames.length) { @@ -876,7 +876,8 @@ namespace ts { configurations.files = fileNames; } - return JSON.stringify(configurations, undefined, 4); + + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map | undefined { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { @@ -938,6 +939,72 @@ namespace ts { } return result; } + + function getDefaultValueForOption(option: CommandLineOption) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return arrayFrom((option).type.keys())[0]; + } + } + + function writeConfigurations() { + const categorizedOptions = reduceLeft( + filter(optionDeclarations, o => o.category !== "CommandLine" && o.category !== "Advanced"), + (memo, value) => { + if (value.category) { + (memo[value.category] || (memo[value.category] = [])).push(value); + } + return memo; + }, >{}); + const knownKesyCount = getOwnKeys(configurations.compilerOptions).length; + + const newLine = "\n"; + const tab = " "; + + let result = ""; + let seenKnownKeys = 0; + result += `{${newLine}`; + result += `${tab}"compilerOptions": {${newLine}`; + for (const category in categorizedOptions) { + result += `${tab}${tab}// ${category}${newLine}`; + result += `${newLine}`; + for (const option of categorizedOptions[category]) { + result += `${tab}${tab}// ${option.description && option.description.message || option.name}${newLine}`; + if (option.name in configurations.compilerOptions) { + result += `${tab}${tab}"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${++seenKnownKeys === knownKesyCount ? "" : ","}${newLine}`; + } + else { + result += `${tab}${tab}// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},${newLine}`; + } + result += `${newLine}`; + } + result += `${newLine}`; + } + if (configurations.files && configurations.files.length) { + result += `${tab}},${newLine}`; + result += `${tab}"files": [${newLine}`; + for (let i = 0; i < configurations.files.length; i++) { + result += `${tab}${tab}${JSON.stringify(configurations.files[i])}${i === configurations.files.length - 1 ? "" : ","}${newLine}`; + } + result += `${tab}]${newLine}`; + } + else { + result += `${tab}}${newLine}`; + } + result += `}${newLine}`; + + return result; + } } /** From 1c0ca7ce1d9f8a147e1ff00c63ed15475437fa98 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 19:09:22 -0800 Subject: [PATCH 008/207] Remove properties from tsconfig.json that defaults to false --- src/compiler/commandLineParser.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1a388c9e96a..adbb879d5ec 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -641,9 +641,7 @@ namespace ts { /* @internal */ export const defaultInitCompilerOptions: CompilerOptions = { module: ModuleKind.CommonJS, - target: ScriptTarget.ES5, - noImplicitAny: false, - sourceMap: false, + target: ScriptTarget.ES5 }; let optionNameMapCache: OptionNameMap; From c97673c55cf12b880d6177a143aa2b4dc112fded Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 19:25:08 -0800 Subject: [PATCH 009/207] Make categories localizable --- src/compiler/commandLineParser.ts | 153 ++++++++++++++------------- src/compiler/diagnosticMessages.json | 33 ++++++ src/compiler/types.ts | 2 +- 3 files changed, 111 insertions(+), 77 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index adbb879d5ec..46327668f26 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -15,7 +15,7 @@ namespace ts { shortName: "h", type: "boolean", showInSimplifiedHelpView: true, - category: "CommandLine", + category: Diagnostics.CommandLine_Options, description: Diagnostics.Print_this_message, }, { @@ -27,7 +27,7 @@ namespace ts { name: "all", type: "boolean", showInSimplifiedHelpView: true, - category: "CommandLine", + category: Diagnostics.CommandLine_Options, description: Diagnostics.Show_all_compiler_options, }, { @@ -35,14 +35,14 @@ namespace ts { shortName: "v", type: "boolean", showInSimplifiedHelpView: true, - category: "CommandLine", + category: Diagnostics.CommandLine_Options, description: Diagnostics.Print_the_compiler_s_version, }, { name: "init", type: "boolean", showInSimplifiedHelpView: true, - category: "CommandLine", + category: Diagnostics.CommandLine_Options, description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { @@ -51,7 +51,7 @@ namespace ts { type: "string", isFilePath: true, showInSimplifiedHelpView: true, - category: "CommandLine", + category: Diagnostics.CommandLine_Options, paramType: Diagnostics.FILE_OR_DIRECTORY, description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, }, @@ -59,7 +59,7 @@ namespace ts { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: "CommandLine", + category: Diagnostics.CommandLine_Options, description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { @@ -67,7 +67,7 @@ namespace ts { shortName: "w", type: "boolean", showInSimplifiedHelpView: true, - category: "CommandLine", + category: Diagnostics.CommandLine_Options, description: Diagnostics.Watch_input_files, }, @@ -86,7 +86,7 @@ namespace ts { }), paramType: Diagnostics.VERSION, showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { @@ -103,7 +103,7 @@ namespace ts { }), paramType: Diagnostics.KIND, showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { @@ -141,14 +141,14 @@ namespace ts { }), }, showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { name: "allowJs", type: "boolean", showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Allow_javascript_files_to_be_compiled }, { @@ -160,7 +160,7 @@ namespace ts { }), paramType: Diagnostics.KIND, showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, }, { @@ -168,14 +168,14 @@ namespace ts { shortName: "d", type: "boolean", showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Generates_corresponding_d_ts_file, }, { name: "sourceMap", type: "boolean", showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Generates_corresponding_map_file, }, { @@ -184,7 +184,7 @@ namespace ts { isFilePath: true, paramType: Diagnostics.FILE, showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Concatenate_and_emit_output_to_single_file, }, { @@ -193,7 +193,7 @@ namespace ts { isFilePath: true, paramType: Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Redirect_output_structure_to_the_directory, }, { @@ -201,7 +201,7 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.LOCATION, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, { @@ -209,39 +209,39 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.DIRECTORY, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Output_directory_for_generated_declaration_files }, { name: "removeComments", type: "boolean", showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Do_not_emit_comments_to_output, }, { name: "noEmit", type: "boolean", showInSimplifiedHelpView: true, - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Import_emit_helpers_from_tslib }, { name: "skipLibCheck", type: "boolean", - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Skip_type_checking_of_declaration_files, }, { name: "isolatedModules", type: "boolean", - category: "Basic", + category: Diagnostics.Basic_Options, description: Diagnostics.Unconditionally_emit_imports_for_unresolved_files }, @@ -250,86 +250,86 @@ namespace ts { name: "noImplicitAny", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "strictNullChecks", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Enable_strict_null_checks }, { name: "noImplicitThis", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "noUnusedLocals", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Report_errors_on_unused_parameters, }, { name: "alwaysStrict", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, { name: "noImplicitReturns", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { name: "noFallthroughCasesInSwitch", type: "boolean", showInSimplifiedHelpView: true, - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, { name: "allowUnusedLabels", type: "boolean", - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Do_not_report_errors_on_unused_labels }, { name: "allowUnreachableCode", type: "boolean", - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Do_not_report_errors_on_unreachable_code }, { name: "suppressExcessPropertyErrors", type: "boolean", - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Suppress_excess_property_checks_for_object_literals, }, { name: "suppressImplicitAnyIndexErrors", type: "boolean", - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, }, { name: "forceConsistentCasingInFileNames", type: "boolean", - category: "StrictChecks", + category: Diagnostics.Strict_Checks, description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file }, @@ -341,14 +341,14 @@ namespace ts { "classic": ModuleResolutionKind.Classic, }), paramType: Diagnostics.STRATEGY, - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { name: "baseUrl", type: "string", isFilePath: true, - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Base_directory_to_resolve_non_absolute_module_names }, { @@ -357,7 +357,7 @@ namespace ts { name: "paths", type: "object", isTSConfigOnly: true, - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.List_of_path_mapping_entries_for_module_names_to_locations_relative_to_the_baseUrl }, @@ -372,7 +372,7 @@ namespace ts { type: "string", isFilePath: true }, - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.List_of_root_folders_whose_combined_content_represent_the_structure_of_the_project_at_runtime }, { @@ -383,7 +383,7 @@ namespace ts { type: "string", isFilePath: true }, - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.List_of_folders_to_include_type_definitions_from }, { @@ -394,19 +394,19 @@ namespace ts { type: "string" }, showInSimplifiedHelpView: true, - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Type_declaration_files_to_be_included_in_compilation }, { name: "allowSyntheticDefaultImports", type: "boolean", - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { name: "maxNodeModuleJsDepth", type: "number", - category: "ModuleResolution", + category: Diagnostics.Module_Resolution_Options, description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files }, @@ -416,7 +416,7 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.LOCATION, - category: "SourceMaps", + category: Diagnostics.SourceMap_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -424,19 +424,19 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.LOCATION, - category: "SourceMaps", + category: Diagnostics.SourceMap_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", - category: "SourceMaps", + category: Diagnostics.SourceMap_Options, description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", - category: "SourceMaps", + category: Diagnostics.SourceMap_Options, description:Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, @@ -444,7 +444,7 @@ namespace ts { { name: "jsxFactory", type: "string", - category: "JSX", + category: Diagnostics.JSX_Options, description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h }, @@ -452,13 +452,13 @@ namespace ts { { name: "experimentalDecorators", type: "boolean", - category: "Experimental", + category: Diagnostics.Experimental_Options, description: Diagnostics.Enables_experimental_support_for_ES7_decorators }, { name: "emitDecoratorMetadata", type: "boolean", - category: "Experimental", + category: Diagnostics.Experimental_Options, description: Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators }, @@ -466,31 +466,31 @@ namespace ts { { name: "diagnostics", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Show_diagnostic_information }, { name: "extendedDiagnostics", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Show_extended_diagnostic_information }, { name: "traceResolution", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Enable_tracing_of_the_name_resolution_process }, { name: "listFiles", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Print_names_of_files_part_of_the_compilation }, { name: "listEmittedFiles", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Print_names_of_generated_files_part_of_the_compilation }, @@ -499,40 +499,40 @@ namespace ts { type: "string", isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files // for correct behaviour, please use outFile - category: "Advanced", + category: Diagnostics.Advanced_Options, paramType: Diagnostics.FILE, description: Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, }, { name: "reactNamespace", type: "string", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, { name: "skipDefaultLibCheck", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, { name: "charset", type: "string", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.The_character_set_of_the_input_files }, compileOnSaveCommandLineOption, { name: "emitBOM", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description:Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { name: "locale", type: "string", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.The_locale_to_use_to_show_error_messages_e_g_en_us }, { @@ -542,61 +542,61 @@ namespace ts { "lf": NewLineKind.LineFeed }), paramType: Diagnostics.NEWLINE, - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, }, { name: "noErrorTruncation", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_truncation_error_messages }, { name: "noLib", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_include_the_default_library_file_lib_d_ts }, { name: "noResolve", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description:Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files }, { name: "stripInternal", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, { name: "disableSizeLimit", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Disable_size_limitation_on_JavaScript_project }, { name: "noImplicitUseStrict", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output }, { name: "noEmitHelpers", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "preserveConstEnums", type: "boolean", - category: "Advanced", + category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, ]; @@ -907,7 +907,7 @@ namespace ts { if (hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === "CommandLine") { + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === Diagnostics.CommandLine_Options) { continue; } const value = options[name]; @@ -957,10 +957,11 @@ namespace ts { function writeConfigurations() { const categorizedOptions = reduceLeft( - filter(optionDeclarations, o => o.category !== "CommandLine" && o.category !== "Advanced"), + filter(optionDeclarations, o => o.category !== Diagnostics.CommandLine_Options && o.category !== Diagnostics.Advanced_Options), (memo, value) => { if (value.category) { - (memo[value.category] || (memo[value.category] = [])).push(value); + const name = getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); } return memo; }, >{}); @@ -977,7 +978,7 @@ namespace ts { result += `${tab}${tab}// ${category}${newLine}`; result += `${newLine}`; for (const option of categorizedOptions[category]) { - result += `${tab}${tab}// ${option.description && option.description.message || option.name}${newLine}`; + result += `${tab}${tab}// ${option.description && getLocaleSpecificMessage(option.description) || option.name}${newLine}`; if (option.name in configurations.compilerOptions) { result += `${tab}${tab}"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${++seenKnownKeys === knownKesyCount ? "" : ","}${newLine}`; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b487b47b106..f5ee14a8cbb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3085,6 +3085,39 @@ "category": "Message", "code": 6170 }, + "CommandLine Options": { + "category": "Message", + "code": 6171 + }, + "Basic Options": { + "category": "Message", + "code": 6172 + }, + "Strict Checks": { + "category": "Message", + "code": 6173 + }, + "Module Resolution Options": { + "category": "Message", + "code": 6174 + }, + "SourceMap Options": { + "category": "Message", + "code": 6175 + }, + "JSX Options": { + "category": "Message", + "code": 6176 + }, + "Experimental Options": { + "category": "Message", + "code": 6177 + }, + "Advanced Options": { + "category": "Message", + "code": 6178 + }, + "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 69c8d7a5c95..589c196d132 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3386,7 +3386,7 @@ isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file isCommandLineOnly?: boolean; showInSimplifiedHelpView?:boolean; - category?: "CommandLine" | "Basic" | "StrictChecks" | "ModuleResolution" | "JSX" | "SourceMaps" | "Experimental" | "Advanced"; + category?: DiagnosticMessage; } /* @internal */ From 4de44ee1a241da87ccf2a797e5eb682c1ddbf57f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Feb 2017 19:32:27 -0800 Subject: [PATCH 010/207] Mark some more options as advanced --- src/compiler/commandLineParser.ts | 100 +++++++++++++++--------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 46327668f26..7b32a23a7d9 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -204,14 +204,6 @@ namespace ts { category: Diagnostics.Basic_Options, description: Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: Diagnostics.DIRECTORY, - category: Diagnostics.Basic_Options, - description: Diagnostics.Output_directory_for_generated_declaration_files - }, { name: "removeComments", type: "boolean", @@ -232,12 +224,6 @@ namespace ts { category: Diagnostics.Basic_Options, description: Diagnostics.Import_emit_helpers_from_tslib }, - { - name: "skipLibCheck", - type: "boolean", - category: Diagnostics.Basic_Options, - description: Diagnostics.Skip_type_checking_of_declaration_files, - }, { name: "isolatedModules", type: "boolean", @@ -302,36 +288,6 @@ namespace ts { category: Diagnostics.Strict_Checks, description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, - { - name: "allowUnusedLabels", - type: "boolean", - category: Diagnostics.Strict_Checks, - description: Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "allowUnreachableCode", - type: "boolean", - category: Diagnostics.Strict_Checks, - description: Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - category: Diagnostics.Strict_Checks, - description: Diagnostics.Suppress_excess_property_checks_for_object_literals, - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - category: Diagnostics.Strict_Checks, - description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - category: Diagnostics.Strict_Checks, - description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, // Module Resolution { @@ -403,12 +359,6 @@ namespace ts { category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, - { - name: "maxNodeModuleJsDepth", - type: "number", - category: Diagnostics.Module_Resolution_Options, - description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, // Source Maps { @@ -599,6 +549,56 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: Diagnostics.DIRECTORY, + category: Diagnostics.Advanced_Options, + description: Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: Diagnostics.Advanced_Options, + description: Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, ]; /* @internal */ From abae1bd13680e1fd13deb2f827563770181d071b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 13 Feb 2017 22:13:48 -0800 Subject: [PATCH 011/207] Accept baseline recursivelly --- Jakefile.js | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index f422a995725..89e693fe19a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -966,21 +966,31 @@ task("baseline-accept", function () { function acceptBaseline(sourceFolder, targetFolder) { console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder); - var files = fs.readdirSync(sourceFolder); var deleteEnding = '.delete'; - for (var i in files) { - var filename = files[i]; - var fullLocalPath = path.join(sourceFolder, filename); - if (fs.statSync(fullLocalPath).isFile()) { - if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { - filename = filename.substr(0, filename.length - deleteEnding.length); - fs.unlinkSync(path.join(targetFolder, filename)); - } else { - var target = path.join(targetFolder, filename); - if (fs.existsSync(target)) { - fs.unlinkSync(target); + + acceptBaselineFolder(sourceFolder, targetFolder); + + function acceptBaselineFolder(sourceFolder, targetFolder) { + var files = fs.readdirSync(sourceFolder); + + for (var i in files) { + var filename = files[i]; + var fullLocalPath = path.join(sourceFolder, filename); + var stat = fs.statSync(fullLocalPath); + if (stat.isFile()) { + if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { + filename = filename.substr(0, filename.length - deleteEnding.length); + fs.unlinkSync(path.join(targetFolder, filename)); + } else { + var target = path.join(targetFolder, filename); + if (fs.existsSync(target)) { + fs.unlinkSync(target); + } + fs.renameSync(path.join(sourceFolder, filename), target); } - fs.renameSync(path.join(sourceFolder, filename), target); + } + else if (stat.isDirectory()) { + acceptBaselineFolder(fullLocalPath, path.join(targetFolder, filename)); } } } From 66135309354f018550b515321ed5dce3cc85e8cb Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 13 Feb 2017 22:14:05 -0800 Subject: [PATCH 012/207] Accept baselines --- src/harness/unittests/initializeTSConfig.ts | 2 +- .../tsconfig.json | 130 ++++++++++++++++- .../tsconfig.json | 129 ++++++++++++++++- .../tsconfig.json | 129 ++++++++++++++++- .../tsconfig.json | 130 ++++++++++++++++- .../tsconfig.json | 134 ++++++++++++++++-- .../tsconfig.json | 130 ++++++++++++++++- .../tsconfig.json | 134 ++++++++++++++++-- .../tsconfig.json | 134 ++++++++++++++++-- 9 files changed, 1007 insertions(+), 45 deletions(-) diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts index cb995212a94..b71396411ea 100644 --- a/src/harness/unittests/initializeTSConfig.ts +++ b/src/harness/unittests/initializeTSConfig.ts @@ -12,7 +12,7 @@ namespace ts { it(`Correct output for ${outputFileName}`, () => { Harness.Baseline.runBaseline(outputFileName, () => { if (initResult) { - return JSON.stringify(initResult, undefined, 4); + return initResult; } else { // This can happen if compiler recieve invalid compiler-options diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index ea891967cb5..9234ce6ad8f 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -1,8 +1,130 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs" + + // Specify library files to be included in the compilation: + // "lib": [], + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' + // "jsx": "preserve", + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. + // "noUnusedLocals": true, + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + // "types": [], + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index abe135b4f16..7481eb6e866 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -1,9 +1,130 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false, + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs", + + // Specify library files to be included in the compilation: + // "lib": [], + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' + // "jsx": "preserve", + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. "noUnusedLocals": true + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + // "types": [], + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index e28b66c8c2b..37ddc8169bf 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -1,9 +1,130 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false, + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs", + + // Specify library files to be included in the compilation: + // "lib": [], + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' "jsx": "react" + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. + // "noUnusedLocals": true, + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + // "types": [], + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 5273b3cb7c8..24fb7b4431d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -1,13 +1,135 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs" + + // Specify library files to be included in the compilation: + // "lib": [], + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' + // "jsx": "preserve", + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. + // "noUnusedLocals": true, + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + // "types": [], + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + }, "files": [ "file0.st", "file1.ts", "file2.ts" ] -} \ No newline at end of file +} diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index fa9cb6cad84..0621c2991ed 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -1,12 +1,130 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false, - "lib": [ - "es5", - "es2015.promise" - ] + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs", + + // Specify library files to be included in the compilation: + "lib": ["es5","es2015.promise"] + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' + // "jsx": "preserve", + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. + // "noUnusedLocals": true, + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + // "types": [], + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index ea891967cb5..9234ce6ad8f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -1,8 +1,130 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs" + + // Specify library files to be included in the compilation: + // "lib": [], + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' + // "jsx": "preserve", + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. + // "noUnusedLocals": true, + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + // "types": [], + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 3ff8208d9d6..499c3d57de1 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -1,12 +1,130 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false, - "lib": [ - "es5", - "es2015.core" - ] + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs", + + // Specify library files to be included in the compilation: + "lib": ["es5","es2015.core"] + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' + // "jsx": "preserve", + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. + // "noUnusedLocals": true, + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + // "types": [], + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + } -} \ No newline at end of file +} diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index b1740ac4c12..7eebba70ab3 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -1,12 +1,130 @@ { "compilerOptions": { - "module": "commonjs", + // Basic Options + + // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT' "target": "es5", - "noImplicitAny": false, - "sourceMap": false, - "types": [ - "jquery", - "mocha" - ] + + // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015' + "module": "commonjs", + + // Specify library files to be included in the compilation: + // "lib": [], + + // Allow javascript files to be compiled. + // "allowJs": true, + + // Specify JSX code generation: 'preserve', 'react-native', or 'react' + // "jsx": "preserve", + + // Generates corresponding '.d.ts' file. + // "declaration": true, + + // Generates corresponding '.map' file. + // "sourceMap": true, + + // Concatenate and emit output to single file. + // "outFile": "./", + + // Redirect output structure to the directory. + // "outDir": "./", + + // Specify the root directory of input files. Use to control the output directory structure with --outDir. + // "rootDir": "./", + + // Do not emit comments to output. + // "removeComments": true, + + // Do not emit outputs. + // "noEmit": true, + + // Import emit helpers from 'tslib'. + // "importHelpers": true, + + // Unconditionally emit imports for unresolved files. + // "isolatedModules": true, + + + // Strict Checks + + // Raise error on expressions and declarations with an implied 'any' type. + // "noImplicitAny": true, + + // Enable strict null checks. + // "strictNullChecks": true, + + // Raise error on 'this' expressions with an implied 'any' type. + // "noImplicitThis": true, + + // Report errors on unused locals. + // "noUnusedLocals": true, + + // Report errors on unused parameters. + // "noUnusedParameters": true, + + // Parse in strict mode and emit "use strict" for each source file + // "alwaysStrict": true, + + // Report error when not all code paths in function return a value. + // "noImplicitReturns": true, + + // Report errors for fallthrough cases in switch statement. + // "noFallthroughCasesInSwitch": true, + + + // Module Resolution Options + + // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). + // "moduleResolution": "node", + + // Base directory to resolve non-absolute module names. + // "baseUrl": "./", + + // List of path mapping entries for module names to locations relative to the 'baseUrl'. + // "paths": {}, + + // List of root folders whose combined content represent the structure of the project at runtime. + // "rootDirs": [], + + // List of folders to include type definitions from. + // "typeRoots": [], + + // Type declaration files to be included in compilation. + "types": ["jquery","mocha"] + + // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. + // "allowSyntheticDefaultImports": true, + + + // SourceMap Options + + // Specify the location where debugger should locate TypeScript files instead of source locations. + // "sourceRoot": "./", + + // Specify the location where debugger should locate map files instead of generated locations. + // "mapRoot": "./", + + // Emit a single file with source maps instead of having a separate file. + // "inlineSourceMap": true, + + // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. + // "inlineSources": true, + + + // JSX Options + + // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. + // "jsxFactory": "", + + + // Experimental Options + + // Enables experimental support for ES7 decorators. + // "experimentalDecorators": true, + + // Enables experimental support for emitting type metadata for decorators. + // "emitDecoratorMetadata": true, + + } -} \ No newline at end of file +} From 2752bfb704a576108b6601b38738dd37ba7f2f62 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 13 Feb 2017 22:21:34 -0800 Subject: [PATCH 013/207] Fix lint failures --- src/compiler/commandLineParser.ts | 12 ++++++------ src/compiler/types.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7b32a23a7d9..c10045fce35 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -387,7 +387,7 @@ namespace ts { name: "inlineSources", type: "boolean", category: Diagnostics.SourceMap_Options, - description:Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + description: Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, // JSX @@ -477,7 +477,7 @@ namespace ts { name: "emitBOM", type: "boolean", category: Diagnostics.Advanced_Options, - description:Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + description: Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, { name: "locale", @@ -511,7 +511,7 @@ namespace ts { name: "noResolve", type: "boolean", category: Diagnostics.Advanced_Options, - description:Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files + description: Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files }, { name: "stripInternal", @@ -979,8 +979,8 @@ namespace ts { result += `${newLine}`; for (const option of categorizedOptions[category]) { result += `${tab}${tab}// ${option.description && getLocaleSpecificMessage(option.description) || option.name}${newLine}`; - if (option.name in configurations.compilerOptions) { - result += `${tab}${tab}"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${++seenKnownKeys === knownKesyCount ? "" : ","}${newLine}`; + if (configurations.compilerOptions[option.name]) { + result += `${tab}${tab}"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${(seenKnownKeys += 1) === knownKesyCount ? "" : ","}${newLine}`; } else { result += `${tab}${tab}// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},${newLine}`; @@ -1606,4 +1606,4 @@ namespace ts { function caseInsensitiveKeyMapper(key: string) { return key.toLowerCase(); } -} +} \ No newline at end of file diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 589c196d132..7dee8bca9c9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3385,7 +3385,7 @@ paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file isCommandLineOnly?: boolean; - showInSimplifiedHelpView?:boolean; + showInSimplifiedHelpView?: boolean; category?: DiagnosticMessage; } From ea01ad4cbdd84f3ccdf79e3843722c9d544211b5 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 16 Feb 2017 14:03:41 -0800 Subject: [PATCH 014/207] Check for conflict marker when trying to parse JSX child --- src/compiler/parser.ts | 3 +++ src/compiler/scanner.ts | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ebd4208832c..2aaf1cb4124 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3862,6 +3862,9 @@ namespace ts { parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, getTextOfNodeFromSourceText(sourceText, openingTagName)); break; } + else if (token() === SyntaxKind.ConflictMarkerTrivia) { + break; + } result.push(parseJsxChild()); } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 52c75a37005..54cd191b43d 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1716,9 +1716,18 @@ namespace ts { while (pos < end) { pos++; char = text.charCodeAt(pos); - if ((char === CharacterCodes.openBrace) || (char === CharacterCodes.lessThan)) { + if (char === CharacterCodes.openBrace) { break; } + if (char === CharacterCodes.lessThan) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = SyntaxKind.ConflictMarkerTrivia; + } + else { + break; + } + } } return token = SyntaxKind.JsxText; } From 8f79f9529f73cb34c75a39649650093ef34230e1 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 16 Feb 2017 14:03:59 -0800 Subject: [PATCH 015/207] Add tests and baselines --- .../reference/conflictMarkerTrivia3.errors.txt | 15 +++++++++++++++ .../baselines/reference/conflictMarkerTrivia3.js | 6 ++++++ .../reference/conflictMarkerTrivia4.errors.txt | 14 ++++++++++++++ .../baselines/reference/conflictMarkerTrivia4.js | 6 ++++++ tests/cases/compiler/conflictMarkerTrivia3.tsx | 2 ++ tests/cases/compiler/conflictMarkerTrivia4.ts | 2 ++ 6 files changed, 45 insertions(+) create mode 100644 tests/baselines/reference/conflictMarkerTrivia3.errors.txt create mode 100644 tests/baselines/reference/conflictMarkerTrivia3.js create mode 100644 tests/baselines/reference/conflictMarkerTrivia4.errors.txt create mode 100644 tests/baselines/reference/conflictMarkerTrivia4.js create mode 100644 tests/cases/compiler/conflictMarkerTrivia3.tsx create mode 100644 tests/cases/compiler/conflictMarkerTrivia4.ts diff --git a/tests/baselines/reference/conflictMarkerTrivia3.errors.txt b/tests/baselines/reference/conflictMarkerTrivia3.errors.txt new file mode 100644 index 00000000000..124201ce0ba --- /dev/null +++ b/tests/baselines/reference/conflictMarkerTrivia3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/conflictMarkerTrivia3.tsx(1,11): error TS17004: Cannot use JSX unless the '--jsx' flag is provided. +tests/cases/compiler/conflictMarkerTrivia3.tsx(1,16): error TS1005: ' + ~~~~~ +!!! error TS17004: Cannot use JSX unless the '--jsx' flag is provided. + + <<<<<<< HEAD + ~~~~~~~~~~~~ +!!! error TS1005: ' +<<<<<<< HEAD + +//// [conflictMarkerTrivia3.js] +var x =
; diff --git a/tests/baselines/reference/conflictMarkerTrivia4.errors.txt b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt new file mode 100644 index 00000000000..476dbbce6ce --- /dev/null +++ b/tests/baselines/reference/conflictMarkerTrivia4.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/conflictMarkerTrivia4.ts(1,12): error TS2304: Cannot find name 'div'. +tests/cases/compiler/conflictMarkerTrivia4.ts(2,1): error TS1185: Merge conflict marker encountered. +tests/cases/compiler/conflictMarkerTrivia4.ts(2,13): error TS1109: Expression expected. + + +==== tests/cases/compiler/conflictMarkerTrivia4.ts (3 errors) ==== + const x =
+ ~~~ +!!! error TS2304: Cannot find name 'div'. + <<<<<<< HEAD + ~~~~~~~ +!!! error TS1185: Merge conflict marker encountered. + +!!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/conflictMarkerTrivia4.js b/tests/baselines/reference/conflictMarkerTrivia4.js new file mode 100644 index 00000000000..945e82b2f2d --- /dev/null +++ b/tests/baselines/reference/conflictMarkerTrivia4.js @@ -0,0 +1,6 @@ +//// [conflictMarkerTrivia4.ts] +const x =
+<<<<<<< HEAD + +//// [conflictMarkerTrivia4.js] +var x = ; diff --git a/tests/cases/compiler/conflictMarkerTrivia3.tsx b/tests/cases/compiler/conflictMarkerTrivia3.tsx new file mode 100644 index 00000000000..21f83715ad0 --- /dev/null +++ b/tests/cases/compiler/conflictMarkerTrivia3.tsx @@ -0,0 +1,2 @@ +const x =
+<<<<<<< HEAD \ No newline at end of file diff --git a/tests/cases/compiler/conflictMarkerTrivia4.ts b/tests/cases/compiler/conflictMarkerTrivia4.ts new file mode 100644 index 00000000000..21f83715ad0 --- /dev/null +++ b/tests/cases/compiler/conflictMarkerTrivia4.ts @@ -0,0 +1,2 @@ +const x =
+<<<<<<< HEAD \ No newline at end of file From e66c824f31e01340af34e47417a224f8b9b721dd Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Thu, 16 Feb 2017 14:07:27 -0800 Subject: [PATCH 016/207] Remove unnecessary else clause --- src/compiler/scanner.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 54cd191b43d..82d75d2fa7c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1724,9 +1724,7 @@ namespace ts { pos = scanConflictMarkerTrivia(text, pos, error); return token = SyntaxKind.ConflictMarkerTrivia; } - else { - break; - } + break; } } return token = SyntaxKind.JsxText; From 096c15b0dedeae3cc4cebf28748bb5f70b5e848c Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 17 Feb 2017 12:58:17 -0800 Subject: [PATCH 017/207] Defer get JSX.Element type allow null to be returned in SFC --- src/compiler/checker.ts | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12b55aa818b..669a2e0f7c8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -278,6 +278,8 @@ namespace ts { let deferredGlobalAsyncIterableIteratorType: GenericType; let deferredGlobalTemplateStringsArrayType: ObjectType; let deferredJsxElementClassType: Type; + let deferredJsxElementType: Type; + let deferredJsxStatelessElementType: Type; let deferredNodes: Node[]; let deferredUnusedIdentifierNodes: Node[]; @@ -398,7 +400,6 @@ namespace ts { }); const typeofType = createTypeofType(); - let jsxElementType: Type; let _jsxNamespace: string; let _jsxFactoryEntity: EntityName; @@ -12306,12 +12307,12 @@ namespace ts { type.flags & TypeFlags.UnionOrIntersection && !forEach((type).types, t => !isValidSpreadType(t))); } - function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { + function checkJsxSelfClosingElement(node: JsxSelfClosingElement): Type { checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } - function checkJsxElement(node: JsxElement) { + function checkJsxElement(node: JsxElement): Type { // Check attributes checkJsxOpeningLikeElement(node.openingElement); @@ -12338,7 +12339,7 @@ namespace ts { } } - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } /** @@ -12579,13 +12580,14 @@ namespace ts { function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement: JsxOpeningLikeElement, elementType: Type, elemInstanceType: Type, elementClassType?: Type): Type { Debug.assert(!(elementType.flags & TypeFlags.Union)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + const jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. const callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); if (callSignature !== unknownSignature) { const callReturnType = callSignature && getReturnTypeOfSignature(callSignature); let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { @@ -12613,7 +12615,8 @@ namespace ts { Debug.assert(!(elementType.flags & TypeFlags.Union)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - if (jsxElementType) { + const jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. const candidatesOutArray: Signature[] = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); @@ -12622,7 +12625,7 @@ namespace ts { for (const candidate of candidatesOutArray) { const callReturnType = getReturnTypeOfSignature(candidate); const paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { let shouldBeCandidate = true; for (const attribute of openingLikeElement.attributes.properties) { if (isJsxAttribute(attribute) && @@ -12871,6 +12874,23 @@ namespace ts { return deferredJsxElementClassType; } + function getJsxGlobalElementType(): Type { + if (!deferredJsxElementType) { + deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element); + } + return deferredJsxElementType; + } + + function getJsxGlobalStatelessElementType(): Type { + if (!deferredJsxStatelessElementType) { + const jsxElementType = getJsxGlobalElementType(); + if (jsxElementType){ + deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); + } + } + return deferredJsxStatelessElementType; + } + /** * Returns all the properties of the Jsx.IntrinsicElements interface */ @@ -12885,7 +12905,7 @@ namespace ts { error(errorNode, Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === undefined) { + if (getJsxGlobalElementType() === undefined) { if (compilerOptions.noImplicitAny) { error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } @@ -21917,7 +21937,6 @@ namespace ts { globalNumberType = getGlobalType("Number", /*arity*/ 0, /*reportErrors*/ true); globalBooleanType = getGlobalType("Boolean", /*arity*/ 0, /*reportErrors*/ true); globalRegExpType = getGlobalType("RegExp", /*arity*/ 0, /*reportErrors*/ true); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); From fc6eee1a6c694300cf1509a041d21078f53c5632 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 17 Feb 2017 13:13:26 -0800 Subject: [PATCH 018/207] Add tests and baselines --- tests/baselines/reference/tsxSfcReturnNull.js | 24 +++++++++++++++ .../reference/tsxSfcReturnNull.symbols | 25 ++++++++++++++++ .../reference/tsxSfcReturnNull.types | 30 +++++++++++++++++++ .../tsxSfcReturnNullStrictNullChecks.js | 24 +++++++++++++++ .../tsxSfcReturnNullStrictNullChecks.symbols | 25 ++++++++++++++++ .../tsxSfcReturnNullStrictNullChecks.types | 30 +++++++++++++++++++ ...ReturnUndefinedStrictNullChecks.errors.txt | 20 +++++++++++++ .../tsxSfcReturnUndefinedStrictNullChecks.js | 25 ++++++++++++++++ .../conformance/jsx/tsxSfcReturnNull.tsx | 16 ++++++++++ .../jsx/tsxSfcReturnNullStrictNullChecks.tsx | 17 +++++++++++ .../tsxSfcReturnUndefinedStrictNullChecks.tsx | 17 +++++++++++ 11 files changed, 253 insertions(+) create mode 100644 tests/baselines/reference/tsxSfcReturnNull.js create mode 100644 tests/baselines/reference/tsxSfcReturnNull.symbols create mode 100644 tests/baselines/reference/tsxSfcReturnNull.types create mode 100644 tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.js create mode 100644 tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.symbols create mode 100644 tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.types create mode 100644 tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt create mode 100644 tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.js create mode 100644 tests/cases/conformance/jsx/tsxSfcReturnNull.tsx create mode 100644 tests/cases/conformance/jsx/tsxSfcReturnNullStrictNullChecks.tsx create mode 100644 tests/cases/conformance/jsx/tsxSfcReturnUndefinedStrictNullChecks.tsx diff --git a/tests/baselines/reference/tsxSfcReturnNull.js b/tests/baselines/reference/tsxSfcReturnNull.js new file mode 100644 index 00000000000..8a332a7057f --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNull.js @@ -0,0 +1,24 @@ +//// [file.tsx] + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; + +//// [file.jsx] +define(["require", "exports", "react"], function (require, exports, React) { + "use strict"; + exports.__esModule = true; + var Foo = function (props) { return null; }; + function Greet(x) { + return null; + } + var foo = ; + var G = ; +}); diff --git a/tests/baselines/reference/tsxSfcReturnNull.symbols b/tests/baselines/reference/tsxSfcReturnNull.symbols new file mode 100644 index 00000000000..483b7db6c59 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNull.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +const Foo = (props: any) => null; +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) +>props : Symbol(props, Decl(file.tsx, 3, 13)) + +function Greet(x: {name?: string}) { +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) +>x : Symbol(x, Decl(file.tsx, 5, 15)) +>name : Symbol(name, Decl(file.tsx, 5, 19)) + + return null; +} + +const foo = ; +>foo : Symbol(foo, Decl(file.tsx, 9, 5)) +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) + +const G = ; +>G : Symbol(G, Decl(file.tsx, 10, 5)) +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) + diff --git a/tests/baselines/reference/tsxSfcReturnNull.types b/tests/baselines/reference/tsxSfcReturnNull.types new file mode 100644 index 00000000000..edc346b03e6 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNull.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : typeof React + +const Foo = (props: any) => null; +>Foo : (props: any) => any +>(props: any) => null : (props: any) => any +>props : any +>null : null + +function Greet(x: {name?: string}) { +>Greet : (x: { name?: string; }) => any +>x : { name?: string; } +>name : string + + return null; +>null : null +} + +const foo = ; +>foo : JSX.Element +> : JSX.Element +>Foo : (props: any) => any + +const G = ; +>G : JSX.Element +> : JSX.Element +>Greet : (x: { name?: string; }) => any + diff --git a/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.js b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.js new file mode 100644 index 00000000000..8a332a7057f --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.js @@ -0,0 +1,24 @@ +//// [file.tsx] + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; + +//// [file.jsx] +define(["require", "exports", "react"], function (require, exports, React) { + "use strict"; + exports.__esModule = true; + var Foo = function (props) { return null; }; + function Greet(x) { + return null; + } + var foo = ; + var G = ; +}); diff --git a/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.symbols b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.symbols new file mode 100644 index 00000000000..483b7db6c59 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +const Foo = (props: any) => null; +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) +>props : Symbol(props, Decl(file.tsx, 3, 13)) + +function Greet(x: {name?: string}) { +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) +>x : Symbol(x, Decl(file.tsx, 5, 15)) +>name : Symbol(name, Decl(file.tsx, 5, 19)) + + return null; +} + +const foo = ; +>foo : Symbol(foo, Decl(file.tsx, 9, 5)) +>Foo : Symbol(Foo, Decl(file.tsx, 3, 5)) + +const G = ; +>G : Symbol(G, Decl(file.tsx, 10, 5)) +>Greet : Symbol(Greet, Decl(file.tsx, 3, 33)) + diff --git a/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.types b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.types new file mode 100644 index 00000000000..5268592b8d7 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnNullStrictNullChecks.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsx/file.tsx === + +import React = require('react'); +>React : typeof React + +const Foo = (props: any) => null; +>Foo : (props: any) => null +>(props: any) => null : (props: any) => null +>props : any +>null : null + +function Greet(x: {name?: string}) { +>Greet : (x: { name?: string | undefined; }) => null +>x : { name?: string | undefined; } +>name : string | undefined + + return null; +>null : null +} + +const foo = ; +>foo : JSX.Element +> : JSX.Element +>Foo : (props: any) => null + +const G = ; +>G : JSX.Element +> : JSX.Element +>Greet : (x: { name?: string | undefined; }) => null + diff --git a/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt new file mode 100644 index 00000000000..127eb4b0d44 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt @@ -0,0 +1,20 @@ +tests/cases/conformance/jsx/file.tsx(10,13): error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. +tests/cases/conformance/jsx/file.tsx(11,11): error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. + + +==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== + + import React = require('react'); + + const Foo = (props: any) => undefined; + function Greet(x: {name?: string}) { + return undefined; + } + + // Error + const foo = ; + ~~~~~~~ +!!! error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. + const G = ; + ~~~~~~~~~ +!!! error TS2605: JSX element type 'undefined' is not a constructor function for JSX elements. \ No newline at end of file diff --git a/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.js b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.js new file mode 100644 index 00000000000..0fcaa2f1689 --- /dev/null +++ b/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.js @@ -0,0 +1,25 @@ +//// [file.tsx] + +import React = require('react'); + +const Foo = (props: any) => undefined; +function Greet(x: {name?: string}) { + return undefined; +} + +// Error +const foo = ; +const G = ; + +//// [file.jsx] +define(["require", "exports", "react"], function (require, exports, React) { + "use strict"; + exports.__esModule = true; + var Foo = function (props) { return undefined; }; + function Greet(x) { + return undefined; + } + // Error + var foo = ; + var G = ; +}); diff --git a/tests/cases/conformance/jsx/tsxSfcReturnNull.tsx b/tests/cases/conformance/jsx/tsxSfcReturnNull.tsx new file mode 100644 index 00000000000..436b361eaf8 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSfcReturnNull.tsx @@ -0,0 +1,16 @@ +// @filename: file.tsx +// @jsx: preserve +// @module: amd +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxSfcReturnNullStrictNullChecks.tsx b/tests/cases/conformance/jsx/tsxSfcReturnNullStrictNullChecks.tsx new file mode 100644 index 00000000000..cbc7218698f --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSfcReturnNullStrictNullChecks.tsx @@ -0,0 +1,17 @@ +// @filename: file.tsx +// @jsx: preserve +// @module: amd +// @noLib: true +// @strictNullChecks: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +const Foo = (props: any) => null; + +function Greet(x: {name?: string}) { + return null; +} + +const foo = ; +const G = ; \ No newline at end of file diff --git a/tests/cases/conformance/jsx/tsxSfcReturnUndefinedStrictNullChecks.tsx b/tests/cases/conformance/jsx/tsxSfcReturnUndefinedStrictNullChecks.tsx new file mode 100644 index 00000000000..cb0c6444e73 --- /dev/null +++ b/tests/cases/conformance/jsx/tsxSfcReturnUndefinedStrictNullChecks.tsx @@ -0,0 +1,17 @@ +// @filename: file.tsx +// @jsx: preserve +// @module: amd +// @noLib: true +// @strictNullChecks: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +const Foo = (props: any) => undefined; +function Greet(x: {name?: string}) { + return undefined; +} + +// Error +const foo = ; +const G = ; \ No newline at end of file From 9ca08a4efafec79abf16043de3cd4b92fda6ad54 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 17 Feb 2017 13:50:05 -0800 Subject: [PATCH 019/207] Fix linting --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 669a2e0f7c8..bc39712f2f2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12884,7 +12884,7 @@ namespace ts { function getJsxGlobalStatelessElementType(): Type { if (!deferredJsxStatelessElementType) { const jsxElementType = getJsxGlobalElementType(); - if (jsxElementType){ + if (jsxElementType) { deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); } } From 3f198e6751892a531d20524300bba34544c02bf2 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Fri, 17 Feb 2017 13:54:07 -0800 Subject: [PATCH 020/207] Adding cancellation token checks for lower priority tasks --- .../unittests/tsserverProjectSystem.ts | 82 +++++++ src/services/navigationBar.ts | 232 +++++++++--------- src/services/outliningElementsCollector.ts | 4 +- src/services/services.ts | 6 +- 4 files changed, 207 insertions(+), 117 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 92ec0b4ee0e..01e484fd4ba 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3460,6 +3460,88 @@ namespace ts.projectSystem { return JSON.parse(server.extractMessage(host.getOutput()[n])); } }); + it("Lower priority tasks are cancellable", () => { + const f1 = { + path: "/a/app.ts", + content: `{ let x = 1; } var foo = "foo"; var bar = "bar"; var fooBar = "fooBar";` + }; + const config = { + path: "/a/tsconfig.json", + content: JSON.stringify({ + compilerOptions: {} + }) + }; + + let requestToCancel = -1; + let isCancellationRequestedCount = 0; + let cancelAfterRequest = 3; + let operationCanceledExceptionThrown = false; + const cancellationToken: server.ServerCancellationToken = (function () { + let currentId: number; + return { + setRequest(requestId) { + currentId = requestId; + }, + resetRequest(requestId) { + assert.equal(requestId, currentId, "unexpected request id in cancellation") + currentId = undefined; + }, + isCancellationRequested() { + isCancellationRequestedCount++; + return requestToCancel === currentId && isCancellationRequestedCount >= cancelAfterRequest; + } + } + })(); + const host = createServerHost([f1, config]); + const session = createSession(host, /*typingsInstaller*/ undefined, () => { }, cancellationToken); + { + session.executeCommandSeq({ + command: "open", + arguments: { file: f1.path } + }); + + // send navbar request (normal priority) + session.executeCommandSeq({ + command: "navbar", + arguments: { file: f1.path } + }); + + // ensure the nav bar request can be canceled + verifyExecuteCommandSeqIsCancellable({ + command: "navbar", + arguments: { file: f1.path } + }); + + // send outlining spans request (normal priority) + session.executeCommandSeq({ + command: "outliningSpans", + arguments: { file: f1.path } + }); + + // ensure the outlining spans request can be canceled + verifyExecuteCommandSeqIsCancellable({ + command: "outliningSpans", + arguments: { file: f1.path } + }); + } + + function verifyExecuteCommandSeqIsCancellable(request: Partial) { + // Set the next request to be cancellable + // The cancellation token will cancel the request the third time + // isCancellationRequested() is called. + requestToCancel = session.getNextSeq(); + isCancellationRequestedCount = 0; + operationCanceledExceptionThrown = false; + + try { + session.executeCommandSeq(request); + } catch (e) { + assert(e instanceof OperationCanceledException); + operationCanceledExceptionThrown = true; + } + assert(operationCanceledExceptionThrown); + } + }); }); describe("maxNodeModuleJsDepth for inferred projects", () => { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 25059d1f57d..37b6bedbd5b 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -14,16 +14,16 @@ namespace ts.NavigationBar { indent: number; // # of parents } - export function getNavigationBarItems(sourceFile: SourceFile): NavigationBarItem[] { + export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarItem[] { curSourceFile = sourceFile; - const result = map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + const result = map(topLevelItems(rootNavigationBarNode(sourceFile, cancellationToken)), convertToTopLevelItem); curSourceFile = undefined; return result; } - export function getNavigationTree(sourceFile: SourceFile): NavigationTree { + export function getNavigationTree(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationTree { curSourceFile = sourceFile; - const result = convertToTree(rootNavigationBarNode(sourceFile)); + const result = convertToTree(rootNavigationBarNode(sourceFile, cancellationToken)); curSourceFile = undefined; return result; } @@ -55,12 +55,12 @@ namespace ts.NavigationBar { const parentsStack: NavigationBarNode[] = []; let parent: NavigationBarNode; - function rootNavigationBarNode(sourceFile: SourceFile): NavigationBarNode { + function rootNavigationBarNode(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarNode { Debug.assert(!parentsStack.length); const root: NavigationBarNode = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; parent = root; for (const statement of sourceFile.statements) { - addChildrenRecursively(statement); + addChildrenRecursively(statement, cancellationToken); } endNode(); Debug.assert(!parent && !parentsStack.length); @@ -103,138 +103,144 @@ namespace ts.NavigationBar { parent = parentsStack.pop(); } - function addNodeWithRecursiveChild(node: Node, child: Node): void { + function addNodeWithRecursiveChild(node: Node, child: Node, addChildrenRecursively: (node: Node) => void): void { startNode(node); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ - function addChildrenRecursively(node: Node): void { - if (!node || isToken(node)) { - return; - } + function addChildrenRecursively(node: Node, cancellationToken: CancellationToken): void { + function addChildrenRecursively(node: Node): void { + cancellationToken.throwIfCancellationRequested(); - switch (node.kind) { - case SyntaxKind.Constructor: - // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. - const ctr = node; - addNodeWithRecursiveChild(ctr, ctr.body); + if (!node || isToken(node)) { + return; + } - // Parameter properties are children of the class, not the constructor. - for (const param of ctr.parameters) { - if (isParameterPropertyDeclaration(param)) { - addLeafNode(param); + switch (node.kind) { + case SyntaxKind.Constructor: + // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. + const ctr = node; + addNodeWithRecursiveChild(ctr, ctr.body, addChildrenRecursively); + + // Parameter properties are children of the class, not the constructor. + for (const param of ctr.parameters) { + if (isParameterPropertyDeclaration(param)) { + addLeafNode(param); + } } - } - break; + break; - case SyntaxKind.MethodDeclaration: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.MethodSignature: - if (!hasDynamicName((node))) { - addNodeWithRecursiveChild(node, (node).body); - } - break; + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.MethodSignature: + if (!hasDynamicName((node))) { + addNodeWithRecursiveChild(node, (node).body, addChildrenRecursively); + } + break; - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - if (!hasDynamicName((node))) { - addLeafNode(node); - } - break; + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + if (!hasDynamicName((node))) { + addLeafNode(node); + } + break; - case SyntaxKind.ImportClause: - const importClause = node; - // Handle default import case e.g.: - // import d from "mod"; - if (importClause.name) { - addLeafNode(importClause); - } + case SyntaxKind.ImportClause: + const importClause = node; + // Handle default import case e.g.: + // import d from "mod"; + if (importClause.name) { + addLeafNode(importClause); + } - // Handle named bindings in imports e.g.: - // import * as NS from "mod"; - // import {a, b as B} from "mod"; - const {namedBindings} = importClause; - if (namedBindings) { - if (namedBindings.kind === SyntaxKind.NamespaceImport) { - addLeafNode(namedBindings); + // Handle named bindings in imports e.g.: + // import * as NS from "mod"; + // import {a, b as B} from "mod"; + const {namedBindings} = importClause; + if (namedBindings) { + if (namedBindings.kind === SyntaxKind.NamespaceImport) { + addLeafNode(namedBindings); + } + else { + for (const element of (namedBindings).elements) { + addLeafNode(element); + } + } + } + break; + + case SyntaxKind.BindingElement: + case SyntaxKind.VariableDeclaration: + const decl = node; + const name = decl.name; + if (isBindingPattern(name)) { + addChildrenRecursively(name); + } + else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { + // For `const x = function() {}`, just use the function node, not the const. + addChildrenRecursively(decl.initializer); } else { - for (const element of (namedBindings).elements) { - addLeafNode(element); + addNodeWithRecursiveChild(decl, decl.initializer, addChildrenRecursively); + } + break; + + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + addNodeWithRecursiveChild(node, (node).body, addChildrenRecursively); + break; + + case SyntaxKind.EnumDeclaration: + startNode(node); + for (const member of (node).members) { + if (!isComputedProperty(member)) { + addLeafNode(member); } } - } - break; + endNode(); + break; - case SyntaxKind.BindingElement: - case SyntaxKind.VariableDeclaration: - const decl = node; - const name = decl.name; - if (isBindingPattern(name)) { - addChildrenRecursively(name); - } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - // For `const x = function() {}`, just use the function node, not the const. - addChildrenRecursively(decl.initializer); - } - else { - addNodeWithRecursiveChild(decl, decl.initializer); - } - break; - - case SyntaxKind.ArrowFunction: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.FunctionExpression: - addNodeWithRecursiveChild(node, (node).body); - break; - - case SyntaxKind.EnumDeclaration: - startNode(node); - for (const member of (node).members) { - if (!isComputedProperty(member)) { - addLeafNode(member); + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + startNode(node); + for (const member of (node).members) { + addChildrenRecursively(member); } - } - endNode(); - break; + endNode(); + break; - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - case SyntaxKind.InterfaceDeclaration: - startNode(node); - for (const member of (node).members) { - addChildrenRecursively(member); - } - endNode(); - break; + case SyntaxKind.ModuleDeclaration: + addNodeWithRecursiveChild(node, getInteriorModule(node).body, addChildrenRecursively); + break; - case SyntaxKind.ModuleDeclaration: - addNodeWithRecursiveChild(node, getInteriorModule(node).body); - break; + case SyntaxKind.ExportSpecifier: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.IndexSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.TypeAliasDeclaration: + addLeafNode(node); + break; - case SyntaxKind.ExportSpecifier: - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.IndexSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.TypeAliasDeclaration: - addLeafNode(node); - break; - - default: - forEach(node.jsDoc, jsDoc => { - forEach(jsDoc.tags, tag => { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { - addLeafNode(tag); - } + default: + forEach(node.jsDoc, jsDoc => { + forEach(jsDoc.tags, tag => { + if (tag.kind === SyntaxKind.JSDocTypedefTag) { + addLeafNode(tag); + } + }); }); - }); - forEachChild(node, addChildrenRecursively); + forEachChild(node, addChildrenRecursively); + } } + + addChildrenRecursively(node); } /** Merge declarations of the same kind. */ diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 2ad20a7ed0c..96a7c9a3c4a 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.OutliningElementsCollector { - export function collectElements(sourceFile: SourceFile): OutliningSpan[] { + export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; const collapseText = "..."; @@ -38,6 +38,7 @@ namespace ts.OutliningElementsCollector { let singleLineCommentCount = 0; for (const currentComment of comments) { + cancellationToken.throwIfCancellationRequested(); // 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 @@ -84,6 +85,7 @@ namespace ts.OutliningElementsCollector { let depth = 0; const maxDepth = 20; function walk(n: Node): void { + cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } diff --git a/src/services/services.ts b/src/services/services.ts index c1b719d3477..cef307eb8fd 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1541,11 +1541,11 @@ namespace ts { } function getNavigationBarItems(fileName: string): NavigationBarItem[] { - return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function getNavigationTree(fileName: string): NavigationTree { - return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function isTsOrTsxFile(fileName: string): boolean { @@ -1584,7 +1584,7 @@ namespace ts { function getOutliningSpans(fileName: string): OutliningSpan[] { // doesn't use compiler - no need to synchronize with host const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return OutliningElementsCollector.collectElements(sourceFile); + return OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } function getBraceMatchingAtPosition(fileName: string, position: number) { From 51966076d4ee5f76752053ec89aa3c79cd1381f7 Mon Sep 17 00:00:00 2001 From: Herrington Darkholme Date: Tue, 21 Feb 2017 11:52:12 +0800 Subject: [PATCH 021/207] fix #14187, forIn should allow non primitive object as right hand side --- src/compiler/checker.ts | 4 ++-- .../reference/nonPrimitiveIndexingWithForIn.js | 13 +++++++++++++ .../nonPrimitiveIndexingWithForIn.symbols | 14 ++++++++++++++ .../reference/nonPrimitiveIndexingWithForIn.types | 15 +++++++++++++++ ...itiveIndexingWithForInNoImplicitAny.errors.txt | 12 ++++++++++++ .../nonPrimitiveIndexingWithForInNoImplicitAny.js | 13 +++++++++++++ .../nonPrimitiveIndexingWithForInSupressError.js | 13 +++++++++++++ ...PrimitiveIndexingWithForInSupressError.symbols | 14 ++++++++++++++ ...onPrimitiveIndexingWithForInSupressError.types | 15 +++++++++++++++ .../nonPrimitive/nonPrimitiveIndexingWithForIn.ts | 5 +++++ .../nonPrimitiveIndexingWithForInNoImplicitAny.ts | 6 ++++++ .../nonPrimitiveIndexingWithForInSupressError.ts | 7 +++++++ 12 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForIn.js create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForIn.symbols create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForIn.types create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.errors.txt create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.js create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.js create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.symbols create mode 100644 tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.types create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts create mode 100644 tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12b55aa818b..1178276fc9b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,4 +1,4 @@ -/// +/// /// /* @internal */ @@ -18606,7 +18606,7 @@ namespace ts { // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, TypeFlags.Object | TypeFlags.TypeVariable | TypeFlags.NonPrimitive)) { error(node.expression, Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForIn.js b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.js new file mode 100644 index 00000000000..c5f4319c748 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.js @@ -0,0 +1,13 @@ +//// [nonPrimitiveIndexingWithForIn.ts] +var a: object; + +for (var key in a) { + var value = a[key]; +} + + +//// [nonPrimitiveIndexingWithForIn.js] +var a; +for (var key in a) { + var value = a[key]; +} diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForIn.symbols b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.symbols new file mode 100644 index 00000000000..3cb41269541 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts === +var a: object; +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForIn.ts, 0, 3)) + +for (var key in a) { +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForIn.ts, 2, 8)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForIn.ts, 0, 3)) + + var value = a[key]; +>value : Symbol(value, Decl(nonPrimitiveIndexingWithForIn.ts, 3, 7)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForIn.ts, 0, 3)) +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForIn.ts, 2, 8)) +} + diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForIn.types b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.types new file mode 100644 index 00000000000..44e2b3f4d50 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForIn.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts === +var a: object; +>a : object + +for (var key in a) { +>key : string +>a : object + + var value = a[key]; +>value : any +>a[key] : any +>a : object +>key : string +} + diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.errors.txt b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.errors.txt new file mode 100644 index 00000000000..f7f2ee3db16 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts(4,17): error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. + + +==== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts (1 errors) ==== + var a: object; + + for (var key in a) { + var value = a[key]; // error + ~~~~~~ +!!! error TS7017: Element implicitly has an 'any' type because type '{}' has no index signature. + } + \ No newline at end of file diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.js b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.js new file mode 100644 index 00000000000..e105e5ba9bb --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInNoImplicitAny.js @@ -0,0 +1,13 @@ +//// [nonPrimitiveIndexingWithForInNoImplicitAny.ts] +var a: object; + +for (var key in a) { + var value = a[key]; // error +} + + +//// [nonPrimitiveIndexingWithForInNoImplicitAny.js] +var a; +for (var key in a) { + var value = a[key]; // error +} diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.js b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.js new file mode 100644 index 00000000000..ce575b2a4d6 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.js @@ -0,0 +1,13 @@ +//// [nonPrimitiveIndexingWithForInSupressError.ts] +var a: object; + +for (var key in a) { + var value = a[key]; +} + + +//// [nonPrimitiveIndexingWithForInSupressError.js] +var a; +for (var key in a) { + var value = a[key]; +} diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.symbols b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.symbols new file mode 100644 index 00000000000..4e52e66b1c0 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts === +var a: object; +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 0, 3)) + +for (var key in a) { +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 2, 8)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 0, 3)) + + var value = a[key]; +>value : Symbol(value, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 3, 7)) +>a : Symbol(a, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 0, 3)) +>key : Symbol(key, Decl(nonPrimitiveIndexingWithForInSupressError.ts, 2, 8)) +} + diff --git a/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.types b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.types new file mode 100644 index 00000000000..3fafa40b596 --- /dev/null +++ b/tests/baselines/reference/nonPrimitiveIndexingWithForInSupressError.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts === +var a: object; +>a : object + +for (var key in a) { +>key : string +>a : object + + var value = a[key]; +>value : any +>a[key] : any +>a : object +>key : string +} + diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts new file mode 100644 index 00000000000..2ec8cf83cb7 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForIn.ts @@ -0,0 +1,5 @@ +var a: object; + +for (var key in a) { + var value = a[key]; +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts new file mode 100644 index 00000000000..1050cdea497 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInNoImplicitAny.ts @@ -0,0 +1,6 @@ +// @noImplicitAny: true +var a: object; + +for (var key in a) { + var value = a[key]; // error +} diff --git a/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts new file mode 100644 index 00000000000..3f63faee604 --- /dev/null +++ b/tests/cases/conformance/types/nonPrimitive/nonPrimitiveIndexingWithForInSupressError.ts @@ -0,0 +1,7 @@ +// @noImplicitAny: true +// @suppressImplicitAnyIndexErrors: true +var a: object; + +for (var key in a) { + var value = a[key]; +} From f55167e5658f92061b767e4cee839833a022d327 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 22 Feb 2017 10:23:47 -0800 Subject: [PATCH 022/207] Collect type from return statment in generator function --- src/compiler/checker.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 12b55aa818b..56306fb772f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14963,10 +14963,12 @@ namespace ts { } } else { - let types: Type[]; + let yieldTypes: Type[]; + let returnTypes: Type[]; if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function - types = checkAndAggregateYieldOperandTypes(func, contextualMapper); - if (types.length === 0) { + yieldTypes = checkAndAggregateYieldOperandTypes(func, contextualMapper); + returnTypes = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + if (yieldTypes.length === 0 && (!returnTypes || returnTypes.length === 0)) { const iterableIteratorAny = functionFlags & FunctionFlags.Async ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function : createIterableIteratorType(anyType); // Generator function @@ -14978,14 +14980,14 @@ namespace ts { } } else { - types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); - if (!types) { + returnTypes = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + if (!returnTypes) { // For an async function, the return type will not be never, but rather a Promise for never. return functionFlags & FunctionFlags.Async ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } - if (types.length === 0) { + if (returnTypes.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. return functionFlags & FunctionFlags.Async ? createPromiseReturnType(func, voidType) // Async function @@ -14993,7 +14995,7 @@ namespace ts { } } // Return a union of the return expression types. - type = getUnionType(types, /*subtypeReduction*/ true); + type = getUnionType(yieldTypes ? yieldTypes.concat(returnTypes) : returnTypes, /*subtypeReduction*/ true); if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function type = functionFlags & FunctionFlags.Async From 43cb2f56460de3d3883a2e8a39eb934de2d6c566 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 22 Feb 2017 10:24:00 -0800 Subject: [PATCH 023/207] Add tests --- .../yieldExpressions/generatorTypeCheck62.ts | 40 +++++++++++++++++ .../yieldExpressions/generatorTypeCheck63.ts | 43 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts create mode 100644 tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts new file mode 100644 index 00000000000..2f30fe9d902 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts @@ -0,0 +1,40 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { + return state; +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { + yield state; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield ; + return state; +}); + \ No newline at end of file diff --git a/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts new file mode 100644 index 00000000000..58411e409b8 --- /dev/null +++ b/tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts @@ -0,0 +1,43 @@ +// @module: commonjs +// @target: es6 +// @noImplicitAny: true + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing: Strategy = strategy("Nothing", function* (state: State) { + yield 1; + return state; +}); + +export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { +}); + +export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { + return 1; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield state; + return 1; +}); \ No newline at end of file From 5cc9414839351f673488a4d30181d312a7437d62 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 22 Feb 2017 10:24:24 -0800 Subject: [PATCH 024/207] Update baselines --- ....asyncGenerators.classMethods.es2015.types | 2 +- ...ter.asyncGenerators.classMethods.es5.types | 2 +- ....asyncGenerators.classMethods.esnext.types | 2 +- ...nerators.functionDeclarations.es2015.types | 2 +- ...cGenerators.functionDeclarations.es5.types | 2 +- ...nerators.functionDeclarations.esnext.types | 2 +- ...enerators.functionExpressions.es2015.types | 4 +- ...ncGenerators.functionExpressions.es5.types | 4 +- ...enerators.functionExpressions.esnext.types | 4 +- ...nerators.objectLiteralMethods.es2015.types | 6 +- ...cGenerators.objectLiteralMethods.es5.types | 6 +- ...nerators.objectLiteralMethods.esnext.types | 6 +- .../reference/generatorTypeCheck14.types | 2 +- .../reference/generatorTypeCheck15.types | 2 +- .../reference/generatorTypeCheck34.types | 2 +- .../reference/generatorTypeCheck62.js | 63 +++++++++ .../reference/generatorTypeCheck62.symbols | 106 +++++++++++++++ .../reference/generatorTypeCheck62.types | 122 ++++++++++++++++++ .../reference/generatorTypeCheck63.errors.txt | 63 +++++++++ .../reference/generatorTypeCheck63.js | 69 ++++++++++ 20 files changed, 447 insertions(+), 24 deletions(-) create mode 100644 tests/baselines/reference/generatorTypeCheck62.js create mode 100644 tests/baselines/reference/generatorTypeCheck62.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck62.types create mode 100644 tests/baselines/reference/generatorTypeCheck63.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck63.js diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types index 524f7c9b71b..c375fb6f455 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es2015.types @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types index c20e0d35010..e4be9f80d4a 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.es5.types @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types index b5230006f1b..1232130a389 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.classMethods.esnext.types @@ -80,7 +80,7 @@ class C7 { >C7 : C7 async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types index 5d57519d140..0e434639906 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es2015.types @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types index 2c3063eca59..9ebd2659ef4 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.es5.types @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types index 5eb09901ac8..4e61c903227 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionDeclarations.esnext.types @@ -53,7 +53,7 @@ async function * f6() { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === async function * f7() { ->f7 : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types index ab41ffd9c71..83d65ce5246 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es2015.types @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es2015/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> +>async function * () { return 1;} : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types index 424f09cf53b..7d736b2327c 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.es5.types @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/es5/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> +>async function * () { return 1;} : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types index e4559e3ecef..6c40f9cebb1 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.functionExpressions.esnext.types @@ -59,8 +59,8 @@ const f6 = async function * () { } === tests/cases/conformance/emitter/esnext/asyncGenerators/F7.ts === const f7 = async function * () { ->f7 : () => AsyncIterableIterator ->async function * () { return 1;} : () => AsyncIterableIterator +>f7 : () => AsyncIterableIterator<1> +>async function * () { return 1;} : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types index 0e89d9a1ca6..59c5bcfa167 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es2015.types @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es2015/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types index 4c8ae47b6a2..3e7ead2f737 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.es5.types @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/es5/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types index 511cd7ec9e0..9e5aad8af23 100644 --- a/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types +++ b/tests/baselines/reference/emitter.asyncGenerators.objectLiteralMethods.esnext.types @@ -83,11 +83,11 @@ const o6 = { } === tests/cases/conformance/emitter/esnext/asyncGenerators/O7.ts === const o7 = { ->o7 : { f(): AsyncIterableIterator; } ->{ async * f() { return 1; }} : { f(): AsyncIterableIterator; } +>o7 : { f(): AsyncIterableIterator<1>; } +>{ async * f() { return 1; }} : { f(): AsyncIterableIterator<1>; } async * f() { ->f : () => AsyncIterableIterator +>f : () => AsyncIterableIterator<1> return 1; >1 : 1 diff --git a/tests/baselines/reference/generatorTypeCheck14.types b/tests/baselines/reference/generatorTypeCheck14.types index 48565fe2be0..28401e68567 100644 --- a/tests/baselines/reference/generatorTypeCheck14.types +++ b/tests/baselines/reference/generatorTypeCheck14.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts === function* g() { ->g : () => IterableIterator<0> +>g : () => IterableIterator<0 | ""> yield 0; >yield 0 : any diff --git a/tests/baselines/reference/generatorTypeCheck15.types b/tests/baselines/reference/generatorTypeCheck15.types index eb14208009a..3851d8e56a4 100644 --- a/tests/baselines/reference/generatorTypeCheck15.types +++ b/tests/baselines/reference/generatorTypeCheck15.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck15.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<""> return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck34.types b/tests/baselines/reference/generatorTypeCheck34.types index 2ca11177218..239c5ff1493 100644 --- a/tests/baselines/reference/generatorTypeCheck34.types +++ b/tests/baselines/reference/generatorTypeCheck34.types @@ -7,7 +7,7 @@ function* g() { >0 : 0 function* g2() { ->g2 : () => IterableIterator +>g2 : () => IterableIterator<""> return ""; >"" : "" diff --git a/tests/baselines/reference/generatorTypeCheck62.js b/tests/baselines/reference/generatorTypeCheck62.js new file mode 100644 index 00000000000..30864722210 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck62.js @@ -0,0 +1,63 @@ +//// [generatorTypeCheck62.ts] + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { + return state; +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { + yield state; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield ; + return state; +}); + + +//// [generatorTypeCheck62.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function strategy(stratName, gen) { + return function* (state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + }; +} +exports.strategy = strategy; +exports.Nothing1 = strategy("Nothing", function* (state) { + return state; +}); +exports.Nothing2 = strategy("Nothing", function* (state) { + yield state; +}); +exports.Nothing3 = strategy("Nothing", function* (state) { + yield; + return state; +}); diff --git a/tests/baselines/reference/generatorTypeCheck62.symbols b/tests/baselines/reference/generatorTypeCheck62.symbols new file mode 100644 index 00000000000..580ab208840 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck62.symbols @@ -0,0 +1,106 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts === + +export interface StrategicState { +>StrategicState : Symbol(StrategicState, Decl(generatorTypeCheck62.ts, 0, 0)) + + lastStrategyApplied?: string; +>lastStrategyApplied : Symbol(StrategicState.lastStrategyApplied, Decl(generatorTypeCheck62.ts, 1, 33)) +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>StrategicState : Symbol(StrategicState, Decl(generatorTypeCheck62.ts, 0, 0)) +>stratName : Symbol(stratName, Decl(generatorTypeCheck62.ts, 5, 51)) +>gen : Symbol(gen, Decl(generatorTypeCheck62.ts, 5, 69)) +>a : Symbol(a, Decl(generatorTypeCheck62.ts, 5, 76)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>a : Symbol(a, Decl(generatorTypeCheck62.ts, 5, 120)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 5, 25)) + + return function*(state) { +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 6, 21)) + + for (const next of gen(state)) { +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) +>gen : Symbol(gen, Decl(generatorTypeCheck62.ts, 5, 69)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 6, 21)) + + if (next) { +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) + + next.lastStrategyApplied = stratName; +>next.lastStrategyApplied : Symbol(StrategicState.lastStrategyApplied, Decl(generatorTypeCheck62.ts, 1, 33)) +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) +>lastStrategyApplied : Symbol(StrategicState.lastStrategyApplied, Decl(generatorTypeCheck62.ts, 1, 33)) +>stratName : Symbol(stratName, Decl(generatorTypeCheck62.ts, 5, 51)) + } + yield next; +>next : Symbol(next, Decl(generatorTypeCheck62.ts, 7, 18)) + } + } +} + +export interface Strategy { +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 16, 26)) + + (a: T): IterableIterator; +>a : Symbol(a, Decl(generatorTypeCheck62.ts, 17, 5)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 16, 26)) +>IterableIterator : Symbol(IterableIterator, Decl(lib.es2015.iterable.d.ts, --, --)) +>T : Symbol(T, Decl(generatorTypeCheck62.ts, 16, 26)) +} + +export interface State extends StrategicState { +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>StrategicState : Symbol(StrategicState, Decl(generatorTypeCheck62.ts, 0, 0)) + + foo: number; +>foo : Symbol(State.foo, Decl(generatorTypeCheck62.ts, 20, 47)) +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { +>Nothing1 : Symbol(Nothing1, Decl(generatorTypeCheck62.ts, 24, 12)) +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 24, 71)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) + + return state; +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 24, 71)) + +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { +>Nothing2 : Symbol(Nothing2, Decl(generatorTypeCheck62.ts, 28, 12)) +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 28, 71)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) + + yield state; +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 28, 71)) + +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { +>Nothing3 : Symbol(Nothing3, Decl(generatorTypeCheck62.ts, 32, 12)) +>Strategy : Symbol(Strategy, Decl(generatorTypeCheck62.ts, 14, 1)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) +>strategy : Symbol(strategy, Decl(generatorTypeCheck62.ts, 3, 1)) +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 32, 72)) +>State : Symbol(State, Decl(generatorTypeCheck62.ts, 18, 1)) + + yield ; + return state; +>state : Symbol(state, Decl(generatorTypeCheck62.ts, 32, 72)) + +}); + diff --git a/tests/baselines/reference/generatorTypeCheck62.types b/tests/baselines/reference/generatorTypeCheck62.types new file mode 100644 index 00000000000..289d33dc7d4 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck62.types @@ -0,0 +1,122 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck62.ts === + +export interface StrategicState { +>StrategicState : StrategicState + + lastStrategyApplied?: string; +>lastStrategyApplied : string +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>T : T +>StrategicState : StrategicState +>stratName : string +>gen : (a: T) => IterableIterator +>a : T +>T : T +>IterableIterator : IterableIterator +>T : T +>a : T +>T : T +>IterableIterator : IterableIterator +>T : T + + return function*(state) { +>function*(state) { for (const next of gen(state)) { if (next) { next.lastStrategyApplied = stratName; } yield next; } } : (state: T) => IterableIterator +>state : T + + for (const next of gen(state)) { +>next : T +>gen(state) : IterableIterator +>gen : (a: T) => IterableIterator +>state : T + + if (next) { +>next : T + + next.lastStrategyApplied = stratName; +>next.lastStrategyApplied = stratName : string +>next.lastStrategyApplied : string +>next : T +>lastStrategyApplied : string +>stratName : string + } + yield next; +>yield next : any +>next : T + } + } +} + +export interface Strategy { +>Strategy : Strategy +>T : T + + (a: T): IterableIterator; +>a : T +>T : T +>IterableIterator : IterableIterator +>T : T +} + +export interface State extends StrategicState { +>State : State +>StrategicState : StrategicState + + foo: number; +>foo : number +} + +export const Nothing1: Strategy = strategy("Nothing", function*(state: State) { +>Nothing1 : Strategy +>Strategy : Strategy +>State : State +>strategy("Nothing", function*(state: State) { return state;}) : (a: State) => IterableIterator +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>"Nothing" : "Nothing" +>function*(state: State) { return state;} : (state: State) => IterableIterator +>state : State +>State : State + + return state; +>state : State + +}); + +export const Nothing2: Strategy = strategy("Nothing", function*(state: State) { +>Nothing2 : Strategy +>Strategy : Strategy +>State : State +>strategy("Nothing", function*(state: State) { yield state;}) : (a: State) => IterableIterator +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>"Nothing" : "Nothing" +>function*(state: State) { yield state;} : (state: State) => IterableIterator +>state : State +>State : State + + yield state; +>yield state : any +>state : State + +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { +>Nothing3 : Strategy +>Strategy : Strategy +>State : State +>strategy("Nothing", function* (state: State) { yield ; return state;}) : (a: State) => IterableIterator +>strategy : (stratName: string, gen: (a: T) => IterableIterator) => (a: T) => IterableIterator +>"Nothing" : "Nothing" +>function* (state: State) { yield ; return state;} : (state: State) => IterableIterator +>state : State +>State : State + + yield ; +>yield : any + + return state; +>state : State + +}); + diff --git a/tests/baselines/reference/generatorTypeCheck63.errors.txt b/tests/baselines/reference/generatorTypeCheck63.errors.txt new file mode 100644 index 00000000000..46e722a0dd1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck63.errors.txt @@ -0,0 +1,63 @@ +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(25,14): error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. + Type 'IterableIterator' is not assignable to type 'IterableIterator'. + Type 'State | 1' is not assignable to type 'State'. + Type '1' is not assignable to type 'State'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(30,70): error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(33,42): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. + Type argument candidate 'State' is not a valid type argument because it is not a supertype of candidate '1'. +tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts(37,14): error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. + + +==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck63.ts (4 errors) ==== + + export interface StrategicState { + lastStrategyApplied?: string; + } + + export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } + } + + export interface Strategy { + (a: T): IterableIterator; + } + + export interface State extends StrategicState { + foo: number; + } + + export const Nothing: Strategy = strategy("Nothing", function* (state: State) { + ~~~~~~~ +!!! error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. +!!! error TS2322: Type 'IterableIterator' is not assignable to type 'IterableIterator'. +!!! error TS2322: Type 'State | 1' is not assignable to type 'State'. +!!! error TS2322: Type '1' is not assignable to type 'State'. + yield 1; + return state; + }); + + export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { + ~ +!!! error TS7025: Generator implicitly has type 'IterableIterator' because it does not yield any values. Consider supplying a return type. + }); + + export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { + ~~~~~~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'State' is not a valid type argument because it is not a supertype of candidate '1'. + return 1; + }); + + export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + ~~~~~~~~ +!!! error TS2322: Type '(a: State | 1) => IterableIterator' is not assignable to type 'Strategy'. + yield state; + return 1; + }); \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck63.js b/tests/baselines/reference/generatorTypeCheck63.js new file mode 100644 index 00000000000..92cf2f867fc --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck63.js @@ -0,0 +1,69 @@ +//// [generatorTypeCheck63.ts] + +export interface StrategicState { + lastStrategyApplied?: string; +} + +export function strategy(stratName: string, gen: (a: T) => IterableIterator): (a: T) => IterableIterator { + return function*(state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + } +} + +export interface Strategy { + (a: T): IterableIterator; +} + +export interface State extends StrategicState { + foo: number; +} + +export const Nothing: Strategy = strategy("Nothing", function* (state: State) { + yield 1; + return state; +}); + +export const Nothing1: Strategy = strategy("Nothing", function* (state: State) { +}); + +export const Nothing2: Strategy = strategy("Nothing", function* (state: State) { + return 1; +}); + +export const Nothing3: Strategy = strategy("Nothing", function* (state: State) { + yield state; + return 1; +}); + +//// [generatorTypeCheck63.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function strategy(stratName, gen) { + return function* (state) { + for (const next of gen(state)) { + if (next) { + next.lastStrategyApplied = stratName; + } + yield next; + } + }; +} +exports.strategy = strategy; +exports.Nothing = strategy("Nothing", function* (state) { + yield 1; + return state; +}); +exports.Nothing1 = strategy("Nothing", function* (state) { +}); +exports.Nothing2 = strategy("Nothing", function* (state) { + return 1; +}); +exports.Nothing3 = strategy("Nothing", function* (state) { + yield state; + return 1; +}); From a37053f780583e979386a8ff7802e51e64e5bf67 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 22 Feb 2017 09:54:45 -0800 Subject: [PATCH 025/207] Addressing CR comments - Adding a throttle - Refactor - Navbar reset onCancel --- src/compiler/program.ts | 52 +++++----- src/compiler/types.ts | 2 + .../unittests/tsserverProjectSystem.ts | 94 ++++++++++--------- src/services/navigationBar.ts | 17 ++-- src/services/outliningElementsCollector.ts | 2 +- src/services/services.ts | 48 +++++++++- src/services/shims.ts | 23 ----- src/services/types.ts | 1 + 8 files changed, 137 insertions(+), 102 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 62f3c066442..083c812464d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -72,6 +72,20 @@ namespace ts { return getNormalizedPathFromPathComponents(commonPathComponents); } + /* @internal */ + export function runWithCancellationToken(func: () => T, onCancel?: () => void): T { + try { + return func(); + } + catch (e) { + if (e instanceof OperationCanceledException && onCancel) { + // We were canceled while performing the operation. + onCancel(); + } + throw e; + } + } + interface OutputFingerprint { hash: string; byteOrderMark: boolean; @@ -873,29 +887,19 @@ namespace ts { return sourceFile.parseDiagnostics; } - function runWithCancellationToken(func: () => T): T { - try { - return func(); - } - catch (e) { - if (e instanceof OperationCanceledException) { - // We were canceled while performing the operation. Because our type checker - // might be a bad state, we need to throw it away. - // - // Note: we are overly aggressive here. We do not actually *have* to throw away - // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep - // the lifetimes of these two TypeCheckers the same. Also, we generally only - // cancel when the user has made a change anyways. And, in that case, we (the - // program instance) will get thrown away anyways. So trying to keep one of - // these type checkers alive doesn't serve much purpose. - noDiagnosticsTypeChecker = undefined; - diagnosticsProducingTypeChecker = undefined; - } - - throw e; - } + function onCancel() { + // Because our type checker might be a bad state, we need to throw it away. + // Note: we are overly aggressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; } + function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { const typeChecker = getDiagnosticsProducingTypeChecker(); @@ -910,7 +914,7 @@ namespace ts { const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - }); + }, onCancel); } function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { @@ -1089,7 +1093,7 @@ namespace ts { function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic { return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); } - }); + }, onCancel); } function getDeclarationDiagnosticsWorker(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { @@ -1097,7 +1101,7 @@ namespace ts { const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. return ts.getDeclarationDiagnostics(getEmitHost(noop), resolver, sourceFile); - }); + }, onCancel); } function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7fc77b48708..17adbd2ea3f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2262,6 +2262,8 @@ /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; + + throttleWaitMilliseconds?: number; } export interface Program extends ScriptReferenceHost { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 01e484fd4ba..ee4273c3d2e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -547,6 +547,45 @@ namespace ts.projectSystem { readonly getEnvironmentVariable = notImplemented; } + export class TestServerCancellationToken implements server.ServerCancellationToken { + private currentId = -1; + private requestToCancel = -1; + private isCancellationRequestedCount = 0; + + constructor(private cancelAfterRequest = 0) { + } + + get throttleWaitMilliseconds() { + // For testing purposes disable the throttle + return 0; + } + + setRequest(requestId: number) { + this.currentId = requestId; + } + + setRequestToCancel(requestId: number) { + this.resetToken(); + this.requestToCancel = requestId; + } + + resetRequest(requestId: number) { + assert.equal(requestId, this.currentId, "unexpected request id in cancellation") + this.currentId = undefined; + } + + isCancellationRequested() { + this.isCancellationRequestedCount++; + return this.requestToCancel === this.currentId && this.isCancellationRequestedCount >= this.cancelAfterRequest; + } + + resetToken() { + this.currentId = -1; + this.isCancellationRequestedCount = 0; + this.requestToCancel = -1; + } + } + export function makeSessionRequest(command: string, args: T) { const newRequest: protocol.Request = { seq: 0, @@ -3324,22 +3363,7 @@ namespace ts.projectSystem { }) }; - let requestToCancel = -1; - const cancellationToken: server.ServerCancellationToken = (function(){ - let currentId: number; - return { - setRequest(requestId) { - currentId = requestId; - }, - resetRequest(requestId) { - assert.equal(requestId, currentId, "unexpected request id in cancellation") - currentId = undefined; - }, - isCancellationRequested() { - return requestToCancel === currentId; - } - } - })(); + const cancellationToken = new TestServerCancellationToken(); const host = createServerHost([f1, config]); const session = createSession(host, /*typingsInstaller*/ undefined, () => {}, cancellationToken); { @@ -3374,13 +3398,13 @@ namespace ts.projectSystem { host.clearOutput(); // cancel previously issued Geterr - requestToCancel = getErrId; + cancellationToken.setRequestToCancel(getErrId); host.runQueuedTimeoutCallbacks(); assert.equal(host.getOutput().length, 1, "expect 1 message"); verifyRequestCompleted(getErrId, 0); - requestToCancel = -1; + cancellationToken.resetToken(); } { const getErrId = session.getNextSeq(); @@ -3397,12 +3421,12 @@ namespace ts.projectSystem { assert.equal(e1.event, "syntaxDiag"); host.clearOutput(); - requestToCancel = getErrId; + cancellationToken.setRequestToCancel(getErrId); host.runQueuedImmediateCallbacks(); assert.equal(host.getOutput().length, 1, "expect 1 message"); verifyRequestCompleted(getErrId, 0); - requestToCancel = -1; + cancellationToken.resetToken(); } { const getErrId = session.getNextSeq(); @@ -3425,7 +3449,7 @@ namespace ts.projectSystem { assert.equal(e2.event, "semanticDiag"); verifyRequestCompleted(getErrId, 1); - requestToCancel = -1; + cancellationToken.resetToken(); } { const getErr1 = session.getNextSeq(); @@ -3472,26 +3496,8 @@ namespace ts.projectSystem { }) }; - let requestToCancel = -1; - let isCancellationRequestedCount = 0; - let cancelAfterRequest = 3; let operationCanceledExceptionThrown = false; - const cancellationToken: server.ServerCancellationToken = (function () { - let currentId: number; - return { - setRequest(requestId) { - currentId = requestId; - }, - resetRequest(requestId) { - assert.equal(requestId, currentId, "unexpected request id in cancellation") - currentId = undefined; - }, - isCancellationRequested() { - isCancellationRequestedCount++; - return requestToCancel === currentId && isCancellationRequestedCount >= cancelAfterRequest; - } - } - })(); + const cancellationToken = new TestServerCancellationToken(/*cancelAfterRequest*/ 3); const host = createServerHost([f1, config]); const session = createSession(host, /*typingsInstaller*/ undefined, () => { }, cancellationToken); { @@ -3529,17 +3535,17 @@ namespace ts.projectSystem { // Set the next request to be cancellable // The cancellation token will cancel the request the third time // isCancellationRequested() is called. - requestToCancel = session.getNextSeq(); - isCancellationRequestedCount = 0; + cancellationToken.setRequestToCancel(session.getNextSeq()); operationCanceledExceptionThrown = false; try { session.executeCommandSeq(request); - } catch (e) { + } + catch (e) { assert(e instanceof OperationCanceledException); operationCanceledExceptionThrown = true; } - assert(operationCanceledExceptionThrown); + assert(operationCanceledExceptionThrown, "Operation Canceled Exception not thrown for request: " + JSON.stringify(request)); } }); }); diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 37b6bedbd5b..2910a3528d0 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -14,21 +14,24 @@ namespace ts.NavigationBar { indent: number; // # of parents } - export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarItem[] { + export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationBarItem[] { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - const result = map(topLevelItems(rootNavigationBarNode(sourceFile, cancellationToken)), convertToTopLevelItem); + const result = runWithCancellationToken(() => map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem), () => curSourceFile = undefined); curSourceFile = undefined; return result; } - export function getNavigationTree(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationTree { + export function getNavigationTree(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationTree { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - const result = convertToTree(rootNavigationBarNode(sourceFile, cancellationToken)); + const result = runWithCancellationToken(() => convertToTree(rootNavigationBarNode(sourceFile)), () => curSourceFile = undefined); curSourceFile = undefined; return result; } // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. + let curCancellationToken: ThrottledCancellationToken; let curSourceFile: SourceFile; function nodeText(node: Node): string { return node.getText(curSourceFile); @@ -55,12 +58,12 @@ namespace ts.NavigationBar { const parentsStack: NavigationBarNode[] = []; let parent: NavigationBarNode; - function rootNavigationBarNode(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarNode { + function rootNavigationBarNode(sourceFile: SourceFile): NavigationBarNode { Debug.assert(!parentsStack.length); const root: NavigationBarNode = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; parent = root; for (const statement of sourceFile.statements) { - addChildrenRecursively(statement, cancellationToken); + addChildrenRecursively(statement, curCancellationToken); } endNode(); Debug.assert(!parent && !parentsStack.length); @@ -110,7 +113,7 @@ namespace ts.NavigationBar { } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ - function addChildrenRecursively(node: Node, cancellationToken: CancellationToken): void { + function addChildrenRecursively(node: Node, cancellationToken: ThrottledCancellationToken): void { function addChildrenRecursively(node: Node): void { cancellationToken.throwIfCancellationRequested(); diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 96a7c9a3c4a..1b7618c0327 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.OutliningElementsCollector { - export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { + export function collectElements(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; const collapseText = "..."; diff --git a/src/services/services.ts b/src/services/services.ts index cef307eb8fd..6cf50940fb7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -958,7 +958,12 @@ namespace ts { } class CancellationTokenObject implements CancellationToken { + throttleWaitMilliseconds?: number; + constructor(private cancellationToken: HostCancellationToken) { + if (cancellationToken.throttleWaitMilliseconds !== undefined) { + this.throttleWaitMilliseconds = cancellationToken.throttleWaitMilliseconds; + } } public isCancellationRequested() { @@ -972,6 +977,42 @@ namespace ts { } } + /** A cancellation that throttles calls to the host */ + export class ThrottledCancellationToken implements CancellationToken { + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + private lastCancellationCheckTime = 0; + // The minuimum duration to wait in milliseconds before querying host. + // The default of 10 milliseconds will be used unless throttleWaitMilliseconds + // is specified in the host cancellation token. + throttleWaitMilliseconds: number = 10; + + constructor(private hostCancellationToken: HostCancellationToken) { + if (hostCancellationToken.throttleWaitMilliseconds !== undefined) { + this.throttleWaitMilliseconds = hostCancellationToken.throttleWaitMilliseconds; + } + } + + public isCancellationRequested(): boolean { + const time = timestamp(); + const duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration >= this.throttleWaitMilliseconds) { + // Check no more than the min wait in milliseconds + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + + return false; + } + + public throwIfCancellationRequested(): void { + if (this.isCancellationRequested()) { + throw new OperationCanceledException(); + } + } + } + export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { @@ -984,6 +1025,7 @@ namespace ts { const useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); const cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); + const throttledCancellationToken = new ThrottledCancellationToken(cancellationToken); const currentDirectory = host.getCurrentDirectory(); // Check if the localized messages json is set, otherwise query the host for it @@ -1541,11 +1583,11 @@ namespace ts { } function getNavigationBarItems(fileName: string): NavigationBarItem[] { - return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); + return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), throttledCancellationToken); } function getNavigationTree(fileName: string): NavigationTree { - return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); + return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), throttledCancellationToken); } function isTsOrTsxFile(fileName: string): boolean { @@ -1584,7 +1626,7 @@ namespace ts { function getOutliningSpans(fileName: string): OutliningSpan[] { // doesn't use compiler - no need to synchronize with host const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return OutliningElementsCollector.collectElements(sourceFile, cancellationToken); + return OutliningElementsCollector.collectElements(sourceFile, throttledCancellationToken); } function getBraceMatchingAtPosition(fileName: string, position: number) { diff --git a/src/services/shims.ts b/src/services/shims.ts index 6fe9aed144e..de2fd39b8a8 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -469,29 +469,6 @@ namespace ts { } } - /** A cancellation that throttles calls to the host */ - class ThrottledCancellationToken implements HostCancellationToken { - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - private lastCancellationCheckTime = 0; - - constructor(private hostCancellationToken: HostCancellationToken) { - } - - public isCancellationRequested(): boolean { - const time = timestamp(); - const duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - // Check no more than once every 10 ms. - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - - return false; - } - } - export class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { public directoryExists: (directoryName: string) => boolean; diff --git a/src/services/types.ts b/src/services/types.ts index a6ca3852597..f9c33e15dfe 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -121,6 +121,7 @@ namespace ts { export interface HostCancellationToken { isCancellationRequested(): boolean; + throttleWaitMilliseconds?: number; } // From 497d8d3a58f40729941d08de64ee082e9b0d8154 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 22 Feb 2017 15:33:57 -0800 Subject: [PATCH 026/207] Updates from CR comments --- src/compiler/program.ts | 38 ++++++++++++++++++++++------------- src/services/navigationBar.ts | 26 +++++++++++++++--------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 083c812464d..b94efe18222 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -887,18 +887,28 @@ namespace ts { return sourceFile.parseDiagnostics; } - function onCancel() { - // Because our type checker might be a bad state, we need to throw it away. - // Note: we are overly aggressive here. We do not actually *have* to throw away - // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep - // the lifetimes of these two TypeCheckers the same. Also, we generally only - // cancel when the user has made a change anyways. And, in that case, we (the - // program instance) will get thrown away anyways. So trying to keep one of - // these type checkers alive doesn't serve much purpose. - noDiagnosticsTypeChecker = undefined; - diagnosticsProducingTypeChecker = undefined; - } + function runWithCancellationToken(func: () => T): T { + try { + return func(); + } + catch (e) { + if (e instanceof OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + // + // Note: we are overly aggressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } function getSemanticDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { return runWithCancellationToken(() => { @@ -914,7 +924,7 @@ namespace ts { const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - }, onCancel); + }); } function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { @@ -1093,7 +1103,7 @@ namespace ts { function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number): Diagnostic { return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2); } - }, onCancel); + }); } function getDeclarationDiagnosticsWorker(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { @@ -1101,7 +1111,7 @@ namespace ts { const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. return ts.getDeclarationDiagnostics(getEmitHost(noop), resolver, sourceFile); - }, onCancel); + }); } function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 2910a3528d0..62ead677d8b 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -17,21 +17,27 @@ namespace ts.NavigationBar { export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationBarItem[] { curCancellationToken = cancellationToken; curSourceFile = sourceFile; - const result = runWithCancellationToken(() => map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem), () => curSourceFile = undefined); - curSourceFile = undefined; - return result; + try { + return map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + } + finally { + curSourceFile = undefined; + } } export function getNavigationTree(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationTree { curCancellationToken = cancellationToken; curSourceFile = sourceFile; - const result = runWithCancellationToken(() => convertToTree(rootNavigationBarNode(sourceFile)), () => curSourceFile = undefined); - curSourceFile = undefined; - return result; + try { + return convertToTree(rootNavigationBarNode(sourceFile)); + } + finally { + curSourceFile = undefined; + } } // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. - let curCancellationToken: ThrottledCancellationToken; + let curCancellationToken: CancellationToken; let curSourceFile: SourceFile; function nodeText(node: Node): string { return node.getText(curSourceFile); @@ -63,7 +69,7 @@ namespace ts.NavigationBar { const root: NavigationBarNode = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; parent = root; for (const statement of sourceFile.statements) { - addChildrenRecursively(statement, curCancellationToken); + addChildrenRecursively(statement); } endNode(); Debug.assert(!parent && !parentsStack.length); @@ -113,9 +119,9 @@ namespace ts.NavigationBar { } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ - function addChildrenRecursively(node: Node, cancellationToken: ThrottledCancellationToken): void { + function addChildrenRecursively(node: Node): void { function addChildrenRecursively(node: Node): void { - cancellationToken.throwIfCancellationRequested(); + curCancellationToken.throwIfCancellationRequested(); if (!node || isToken(node)) { return; From 84b9ebd0d7c40b9987f2ee8c7b821ac550eb5b2a Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Wed, 22 Feb 2017 15:42:22 -0800 Subject: [PATCH 027/207] Return empty string instead to prevent exception downstream particularly in writeReferencePath --- src/compiler/utilities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 66bf693d831..528544e46d0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2653,7 +2653,7 @@ namespace ts { if (sourceFiles.length) { const jsFilePath = options.outFile || options.out; const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : undefined; + const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath, sourceMapFilePath, declarationFilePath }, createBundle(sourceFiles), emitOnlyDtsFiles); } } From e62108cf9b5dbf678bf596def315ab766b82fa25 Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 22 Feb 2017 17:33:11 -0800 Subject: [PATCH 028/207] Removing throttling until tests prove it is required --- src/compiler/program.ts | 14 - src/compiler/types.ts | 2 - .../unittests/tsserverProjectSystem.ts | 9 +- src/services/navigationBar.ts | 258 +++++++++--------- src/services/outliningElementsCollector.ts | 2 +- src/services/services.ts | 48 +--- src/services/shims.ts | 23 ++ src/services/types.ts | 1 - 8 files changed, 156 insertions(+), 201 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b94efe18222..62f3c066442 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -72,20 +72,6 @@ namespace ts { return getNormalizedPathFromPathComponents(commonPathComponents); } - /* @internal */ - export function runWithCancellationToken(func: () => T, onCancel?: () => void): T { - try { - return func(); - } - catch (e) { - if (e instanceof OperationCanceledException && onCancel) { - // We were canceled while performing the operation. - onCancel(); - } - throw e; - } - } - interface OutputFingerprint { hash: string; byteOrderMark: boolean; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 17adbd2ea3f..7fc77b48708 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2262,8 +2262,6 @@ /** @throws OperationCanceledException if isCancellationRequested is true */ throwIfCancellationRequested(): void; - - throttleWaitMilliseconds?: number; } export interface Program extends ScriptReferenceHost { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index ee4273c3d2e..d9abb0a9078 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -555,11 +555,6 @@ namespace ts.projectSystem { constructor(private cancelAfterRequest = 0) { } - get throttleWaitMilliseconds() { - // For testing purposes disable the throttle - return 0; - } - setRequest(requestId: number) { this.currentId = requestId; } @@ -3495,8 +3490,6 @@ namespace ts.projectSystem { compilerOptions: {} }) }; - - let operationCanceledExceptionThrown = false; const cancellationToken = new TestServerCancellationToken(/*cancelAfterRequest*/ 3); const host = createServerHost([f1, config]); const session = createSession(host, /*typingsInstaller*/ undefined, () => { }, cancellationToken); @@ -3536,7 +3529,7 @@ namespace ts.projectSystem { // The cancellation token will cancel the request the third time // isCancellationRequested() is called. cancellationToken.setRequestToCancel(session.getNextSeq()); - operationCanceledExceptionThrown = false; + let operationCanceledExceptionThrown = false; try { session.executeCommandSeq(request); diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 62ead677d8b..811762fb736 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -14,7 +14,7 @@ namespace ts.NavigationBar { indent: number; // # of parents } - export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationBarItem[] { + export function getNavigationBarItems(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationBarItem[] { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { @@ -22,10 +22,11 @@ namespace ts.NavigationBar { } finally { curSourceFile = undefined; + curCancellationToken = undefined; } } - export function getNavigationTree(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): NavigationTree { + export function getNavigationTree(sourceFile: SourceFile, cancellationToken: CancellationToken): NavigationTree { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { @@ -33,6 +34,7 @@ namespace ts.NavigationBar { } finally { curSourceFile = undefined; + curCancellationToken = undefined; } } @@ -112,7 +114,7 @@ namespace ts.NavigationBar { parent = parentsStack.pop(); } - function addNodeWithRecursiveChild(node: Node, child: Node, addChildrenRecursively: (node: Node) => void): void { + function addNodeWithRecursiveChild(node: Node, child: Node): void { startNode(node); addChildrenRecursively(child); endNode(); @@ -120,136 +122,132 @@ namespace ts.NavigationBar { /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node: Node): void { - function addChildrenRecursively(node: Node): void { - curCancellationToken.throwIfCancellationRequested(); + curCancellationToken.throwIfCancellationRequested(); - if (!node || isToken(node)) { - return; - } - - switch (node.kind) { - case SyntaxKind.Constructor: - // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. - const ctr = node; - addNodeWithRecursiveChild(ctr, ctr.body, addChildrenRecursively); - - // Parameter properties are children of the class, not the constructor. - for (const param of ctr.parameters) { - if (isParameterPropertyDeclaration(param)) { - addLeafNode(param); - } - } - break; - - case SyntaxKind.MethodDeclaration: - case SyntaxKind.GetAccessor: - case SyntaxKind.SetAccessor: - case SyntaxKind.MethodSignature: - if (!hasDynamicName((node))) { - addNodeWithRecursiveChild(node, (node).body, addChildrenRecursively); - } - break; - - case SyntaxKind.PropertyDeclaration: - case SyntaxKind.PropertySignature: - if (!hasDynamicName((node))) { - addLeafNode(node); - } - break; - - case SyntaxKind.ImportClause: - const importClause = node; - // Handle default import case e.g.: - // import d from "mod"; - if (importClause.name) { - addLeafNode(importClause); - } - - // Handle named bindings in imports e.g.: - // import * as NS from "mod"; - // import {a, b as B} from "mod"; - const {namedBindings} = importClause; - if (namedBindings) { - if (namedBindings.kind === SyntaxKind.NamespaceImport) { - addLeafNode(namedBindings); - } - else { - for (const element of (namedBindings).elements) { - addLeafNode(element); - } - } - } - break; - - case SyntaxKind.BindingElement: - case SyntaxKind.VariableDeclaration: - const decl = node; - const name = decl.name; - if (isBindingPattern(name)) { - addChildrenRecursively(name); - } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - // For `const x = function() {}`, just use the function node, not the const. - addChildrenRecursively(decl.initializer); - } - else { - addNodeWithRecursiveChild(decl, decl.initializer, addChildrenRecursively); - } - break; - - case SyntaxKind.ArrowFunction: - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.FunctionExpression: - addNodeWithRecursiveChild(node, (node).body, addChildrenRecursively); - break; - - case SyntaxKind.EnumDeclaration: - startNode(node); - for (const member of (node).members) { - if (!isComputedProperty(member)) { - addLeafNode(member); - } - } - endNode(); - break; - - case SyntaxKind.ClassDeclaration: - case SyntaxKind.ClassExpression: - case SyntaxKind.InterfaceDeclaration: - startNode(node); - for (const member of (node).members) { - addChildrenRecursively(member); - } - endNode(); - break; - - case SyntaxKind.ModuleDeclaration: - addNodeWithRecursiveChild(node, getInteriorModule(node).body, addChildrenRecursively); - break; - - case SyntaxKind.ExportSpecifier: - case SyntaxKind.ImportEqualsDeclaration: - case SyntaxKind.IndexSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.TypeAliasDeclaration: - addLeafNode(node); - break; - - default: - forEach(node.jsDoc, jsDoc => { - forEach(jsDoc.tags, tag => { - if (tag.kind === SyntaxKind.JSDocTypedefTag) { - addLeafNode(tag); - } - }); - }); - - forEachChild(node, addChildrenRecursively); - } + if (!node || isToken(node)) { + return; } - addChildrenRecursively(node); + switch (node.kind) { + case SyntaxKind.Constructor: + // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. + const ctr = node; + addNodeWithRecursiveChild(ctr, ctr.body); + + // Parameter properties are children of the class, not the constructor. + for (const param of ctr.parameters) { + if (isParameterPropertyDeclaration(param)) { + addLeafNode(param); + } + } + break; + + case SyntaxKind.MethodDeclaration: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.MethodSignature: + if (!hasDynamicName((node))) { + addNodeWithRecursiveChild(node, (node).body); + } + break; + + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.PropertySignature: + if (!hasDynamicName((node))) { + addLeafNode(node); + } + break; + + case SyntaxKind.ImportClause: + const importClause = node; + // Handle default import case e.g.: + // import d from "mod"; + if (importClause.name) { + addLeafNode(importClause); + } + + // Handle named bindings in imports e.g.: + // import * as NS from "mod"; + // import {a, b as B} from "mod"; + const {namedBindings} = importClause; + if (namedBindings) { + if (namedBindings.kind === SyntaxKind.NamespaceImport) { + addLeafNode(namedBindings); + } + else { + for (const element of (namedBindings).elements) { + addLeafNode(element); + } + } + } + break; + + case SyntaxKind.BindingElement: + case SyntaxKind.VariableDeclaration: + const decl = node; + const name = decl.name; + if (isBindingPattern(name)) { + addChildrenRecursively(name); + } + else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { + // For `const x = function() {}`, just use the function node, not the const. + addChildrenRecursively(decl.initializer); + } + else { + addNodeWithRecursiveChild(decl, decl.initializer); + } + break; + + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + addNodeWithRecursiveChild(node, (node).body); + break; + + case SyntaxKind.EnumDeclaration: + startNode(node); + for (const member of (node).members) { + if (!isComputedProperty(member)) { + addLeafNode(member); + } + } + endNode(); + break; + + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ClassExpression: + case SyntaxKind.InterfaceDeclaration: + startNode(node); + for (const member of (node).members) { + addChildrenRecursively(member); + } + endNode(); + break; + + case SyntaxKind.ModuleDeclaration: + addNodeWithRecursiveChild(node, getInteriorModule(node).body); + break; + + case SyntaxKind.ExportSpecifier: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.IndexSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.TypeAliasDeclaration: + addLeafNode(node); + break; + + default: + forEach(node.jsDoc, jsDoc => { + forEach(jsDoc.tags, tag => { + if (tag.kind === SyntaxKind.JSDocTypedefTag) { + addLeafNode(tag); + } + }); + }); + + forEachChild(node, addChildrenRecursively); + } } /** Merge declarations of the same kind. */ diff --git a/src/services/outliningElementsCollector.ts b/src/services/outliningElementsCollector.ts index 1b7618c0327..96a7c9a3c4a 100644 --- a/src/services/outliningElementsCollector.ts +++ b/src/services/outliningElementsCollector.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.OutliningElementsCollector { - export function collectElements(sourceFile: SourceFile, cancellationToken: ThrottledCancellationToken): OutliningSpan[] { + export function collectElements(sourceFile: SourceFile, cancellationToken: CancellationToken): OutliningSpan[] { const elements: OutliningSpan[] = []; const collapseText = "..."; diff --git a/src/services/services.ts b/src/services/services.ts index 6cf50940fb7..cef307eb8fd 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -958,12 +958,7 @@ namespace ts { } class CancellationTokenObject implements CancellationToken { - throttleWaitMilliseconds?: number; - constructor(private cancellationToken: HostCancellationToken) { - if (cancellationToken.throttleWaitMilliseconds !== undefined) { - this.throttleWaitMilliseconds = cancellationToken.throttleWaitMilliseconds; - } } public isCancellationRequested() { @@ -977,42 +972,6 @@ namespace ts { } } - /** A cancellation that throttles calls to the host */ - export class ThrottledCancellationToken implements CancellationToken { - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - private lastCancellationCheckTime = 0; - // The minuimum duration to wait in milliseconds before querying host. - // The default of 10 milliseconds will be used unless throttleWaitMilliseconds - // is specified in the host cancellation token. - throttleWaitMilliseconds: number = 10; - - constructor(private hostCancellationToken: HostCancellationToken) { - if (hostCancellationToken.throttleWaitMilliseconds !== undefined) { - this.throttleWaitMilliseconds = hostCancellationToken.throttleWaitMilliseconds; - } - } - - public isCancellationRequested(): boolean { - const time = timestamp(); - const duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration >= this.throttleWaitMilliseconds) { - // Check no more than the min wait in milliseconds - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - - return false; - } - - public throwIfCancellationRequested(): void { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - } - } - export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { @@ -1025,7 +984,6 @@ namespace ts { const useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); const cancellationToken = new CancellationTokenObject(host.getCancellationToken && host.getCancellationToken()); - const throttledCancellationToken = new ThrottledCancellationToken(cancellationToken); const currentDirectory = host.getCurrentDirectory(); // Check if the localized messages json is set, otherwise query the host for it @@ -1583,11 +1541,11 @@ namespace ts { } function getNavigationBarItems(fileName: string): NavigationBarItem[] { - return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), throttledCancellationToken); + return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function getNavigationTree(fileName: string): NavigationTree { - return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), throttledCancellationToken); + return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function isTsOrTsxFile(fileName: string): boolean { @@ -1626,7 +1584,7 @@ namespace ts { function getOutliningSpans(fileName: string): OutliningSpan[] { // doesn't use compiler - no need to synchronize with host const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return OutliningElementsCollector.collectElements(sourceFile, throttledCancellationToken); + return OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } function getBraceMatchingAtPosition(fileName: string, position: number) { diff --git a/src/services/shims.ts b/src/services/shims.ts index de2fd39b8a8..6fe9aed144e 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -469,6 +469,29 @@ namespace ts { } } + /** A cancellation that throttles calls to the host */ + class ThrottledCancellationToken implements HostCancellationToken { + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + private lastCancellationCheckTime = 0; + + constructor(private hostCancellationToken: HostCancellationToken) { + } + + public isCancellationRequested(): boolean { + const time = timestamp(); + const duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + + return false; + } + } + export class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { public directoryExists: (directoryName: string) => boolean; diff --git a/src/services/types.ts b/src/services/types.ts index f9c33e15dfe..a6ca3852597 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -121,7 +121,6 @@ namespace ts { export interface HostCancellationToken { isCancellationRequested(): boolean; - throttleWaitMilliseconds?: number; } // From 91571f05d31b968d30ef358f505ae2c837c30faf Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 23 Feb 2017 15:58:49 -0800 Subject: [PATCH 029/207] Add support for handeling .js file correctelly in fixAddMissingMember code fix --- src/compiler/diagnosticMessages.json | 5 ++ src/services/codefixes/fixAddMissingMember.ts | 86 ++++++++++++------- 2 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b9572b2b0f4..d1c7f82eadc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3351,6 +3351,11 @@ "category": "Message", "code": 90017 }, + "Initialize property '{0}' in the constructor.": { + "category": "Message", + "code": 90018 + }, + "Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": { "category": "Error", "code": 8017 diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 6ae2ba3f51c..fe4176a766a 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -23,45 +23,67 @@ namespace ts.codefix { return undefined; } - if (!(token.parent && token.parent.kind === SyntaxKind.PropertyAccessExpression)) { + if (!isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== SyntaxKind.ThisKeyword) { return undefined; } - if ((token.parent as PropertyAccessExpression).expression.kind !== SyntaxKind.ThisKeyword) { - return undefined; + return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); + + + function getActionsForAddMissingMemberInTypeScriptFile(): CodeAction[] | undefined { + let typeString = "any"; + + if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { + const binaryExpression = token.parent.parent as BinaryExpression; + + const checker = context.program.getTypeChecker(); + const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); + typeString = checker.typeToString(widenedType); + } + + const startPos = classDeclaration.members.pos; + + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: `${token.getFullText(sourceFile)}: ${typeString};` + }] + }] + }, + { + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: `[name: string]: ${typeString};` + }] + }] + }]; } - let typeString = "any"; + function getActionsForAddMissingMemberInJavaScriptFile(): CodeAction[] | undefined { + const classConstructor = getFirstConstructorWithBody(classDeclaration); + if (!classConstructor) { + return undefined; + } - if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { - const binaryExpression = token.parent.parent as BinaryExpression; + const memberName = token.getText(); + const startPos = classConstructor.body.getEnd() - 1; - const checker = context.program.getTypeChecker(); - const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); - typeString = checker.typeToString(widenedType); + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: `this.${memberName} = undefined;` + }] + }] + }]; } - - const startPos = classDeclaration.members.pos; - - return [{ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `${token.getFullText(sourceFile)}: ${typeString};` - }] - }] - }, - { - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `[name: string]: ${typeString};` - }] - }] - }]; } } \ No newline at end of file From ed7a3d00b985193f9d5469e4dd88137b2d799c53 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 24 Feb 2017 16:46:21 -0800 Subject: [PATCH 030/207] Issue an error when class is used before class declaration --- src/compiler/checker.ts | 38 +++++++++++++++------------- src/compiler/diagnosticMessages.json | 8 +++--- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 83fea11c993..57905315d73 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1056,9 +1056,9 @@ namespace ts { // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped - if (meaning & SymbolFlags.BlockScopedVariable) { + if (meaning & SymbolFlags.BlockScopedVariable || (meaning & SymbolFlags.Class && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) { const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable) { + if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } @@ -1171,14 +1171,19 @@ namespace ts { } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { - Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); + Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class)); // Block-scoped variables cannot be used before their definition - const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) ? d : undefined); + const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) ? d : undefined); Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { - error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); + if (result.flags & SymbolFlags.BlockScopedVariable) { + error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); + } + else { + error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(declaration.name)); + } } } @@ -13171,10 +13176,17 @@ namespace ts { } return unknownType; } - if (prop.valueDeclaration && - isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + if (prop.valueDeclaration) { + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } + if (prop.valueDeclaration.kind === SyntaxKind.ClassDeclaration && + node.parent && node.parent.kind !== SyntaxKind.TypeReference && + !isInAmbientContext(prop.valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, Diagnostics.Class_0_used_before_its_declaration, right.text); + } } markPropertyAsReferenced(prop); @@ -19421,14 +19433,6 @@ namespace ts { error(node.name || node, Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (baseType.symbol && baseType.symbol.valueDeclaration && - !isInAmbientContext(baseType.symbol.valueDeclaration) && - baseType.symbol.valueDeclaration.kind === SyntaxKind.ClassDeclaration) { - if (!isBlockScopedNameDeclaredBeforeUse(baseType.symbol.valueDeclaration, node)) { - error(baseTypeNode, Diagnostics.A_class_must_be_declared_after_its_base_class); - } - } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class) && !(baseConstructorType.flags & TypeFlags.TypeVariable)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b9572b2b0f4..691f8e8d31b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1435,6 +1435,10 @@ "category": "Error", "code": 2448 }, + "Class '{0}' used before its declaration.": { + "category": "Error", + "code": 2449 + }, "Cannot redeclare block-scoped variable '{0}'.": { "category": "Error", "code": 2451 @@ -2019,10 +2023,6 @@ "category": "Error", "code": 2689 }, - "A class must be declared after its base class.": { - "category": "Error", - "code": 2690 - }, "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.": { "category": "Error", "code": 2691 From d511884cd9810e788259eadb254d28285e5008bb Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 24 Feb 2017 16:47:10 -0800 Subject: [PATCH 031/207] Update baselines from issueing an error for class used before declaration --- ...dClassWithSameNameAndCommonRoot.errors.txt | 5 +- .../reference/circularImportAlias.errors.txt | 6 +- .../classAbstractInstantiations2.errors.txt | 5 +- .../classExtendsItselfIndirectly.errors.txt | 8 +- .../classExtendsItselfIndirectly2.errors.txt | 8 +- .../reference/classInheritence.errors.txt | 4 +- .../reference/classOrder2.errors.txt | 4 +- .../classSideInheritance2.errors.txt | 4 +- .../complexClassRelationships.errors.txt | 4 +- .../reference/derivedClasses.errors.txt | 4 +- ...xtendBaseClassBeforeItsDeclared.errors.txt | 4 +- ...sConstructorFromNonGenericClass.errors.txt | 10 +- .../indirectSelfReference.errors.txt | 5 +- .../indirectSelfReferenceGeneric.errors.txt | 5 +- .../reference/parserRealSource10.errors.txt | 5 +- ...ivacyClassExtendsClauseDeclFile.errors.txt | 12 +- .../reference/recursiveBaseCheck3.errors.txt | 5 +- ...arationWhenInBaseTypeResolution.errors.txt | 144 +++++++++--------- .../reference/symbolProperty33.errors.txt | 4 +- .../reference/symbolProperty34.errors.txt | 4 +- 20 files changed, 140 insertions(+), 110 deletions(-) diff --git a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt index 2a464e88268..0da61368eee 100644 --- a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt +++ b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.errors.txt @@ -1,5 +1,6 @@ tests/cases/conformance/internalModules/DeclarationMerging/module.ts(2,19): error TS2433: A namespace declaration cannot be in a different file from a class or function with which it is merged. tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(1,8): error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged. +tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(2,31): error TS2449: Class 'A' used before its declaration. ==== tests/cases/conformance/internalModules/DeclarationMerging/module.ts (1 errors) ==== @@ -24,11 +25,13 @@ tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(1,8): error } } -==== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts (1 errors) ==== +==== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts (2 errors) ==== module A { ~ !!! error TS2434: A namespace declaration cannot be located prior to a class or function with which it is merged. export var Instance = new A(); + ~ +!!! error TS2449: Class 'A' used before its declaration. } // duplicate identifier diff --git a/tests/baselines/reference/circularImportAlias.errors.txt b/tests/baselines/reference/circularImportAlias.errors.txt index 82c9205ae54..13ff1d8c7c9 100644 --- a/tests/baselines/reference/circularImportAlias.errors.txt +++ b/tests/baselines/reference/circularImportAlias.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts(5,28): error TS2690: A class must be declared after its base class. +tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts(5,30): error TS2449: Class 'C' used before its declaration. ==== tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.ts (1 errors) ==== @@ -7,8 +7,8 @@ tests/cases/conformance/internalModules/importDeclarations/circularImportAlias.t module B { export import a = A; export class D extends a.C { - ~~~ -!!! error TS2690: A class must be declared after its base class. + ~ +!!! error TS2449: Class 'C' used before its declaration. id: number; } } diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt index bf4cd851fb3..15b63a6d3e8 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -3,13 +3,14 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst Cannot assign an abstract constructor type to a non-abstract constructor type. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(23,15): error TS2449: Class 'C' used before its declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or non-abstract. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (8 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (9 errors) ==== class A { // ... } @@ -42,6 +43,8 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst !!! error TS2511: Cannot create an instance of the abstract class 'B'. var x : any = C; + ~ +!!! error TS2449: Class 'C' used before its declaration. new x; // okay -- undefined behavior at runtime class C extends B { } // error -- not declared abstract diff --git a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt index c0f35f0388f..8f54ef18051 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly.errors.txt @@ -1,15 +1,19 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(1,17): error TS2449: Class 'E' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(3,7): error TS2506: 'D' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(5,7): error TS2506: 'E' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,7): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(7,21): error TS2449: Class 'E2' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(9,7): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts(11,7): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (6 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly.ts (8 errors) ==== class C extends E { foo: string; } // error ~ !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'E' used before its declaration. class D extends C { bar: string; } ~ @@ -22,6 +26,8 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C2 extends E2 { foo: T; } // error ~~ !!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. + ~~ +!!! error TS2449: Class 'E2' used before its declaration. class D2 extends C2 { bar: T; } ~~ diff --git a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt index 061770f9b79..48c787b54d9 100644 --- a/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt +++ b/tests/baselines/reference/classExtendsItselfIndirectly2.errors.txt @@ -1,15 +1,19 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(1,19): error TS2449: Class 'E' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(4,18): error TS2506: 'D' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(9,18): error TS2506: 'E' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,11): error TS2506: 'C2' is referenced directly or indirectly in its own base expression. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(13,27): error TS2449: Class 'E2' used before its declaration. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(16,22): error TS2506: 'D2' is referenced directly or indirectly in its own base expression. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts(20,22): error TS2506: 'E2' is referenced directly or indirectly in its own base expression. -==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (6 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsItselfIndirectly2.ts (8 errors) ==== class C extends N.E { foo: string; } // error ~ !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'E' used before its declaration. module M { export class D extends C { bar: string; } @@ -28,6 +32,8 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C2 extends Q.E2 { foo: T; } // error ~~ !!! error TS2506: 'C2' is referenced directly or indirectly in its own base expression. + ~~ +!!! error TS2449: Class 'E2' used before its declaration. module P { export class D2 extends C2 { bar: T; } diff --git a/tests/baselines/reference/classInheritence.errors.txt b/tests/baselines/reference/classInheritence.errors.txt index cd95dedbfcf..3bad3caf3d2 100644 --- a/tests/baselines/reference/classInheritence.errors.txt +++ b/tests/baselines/reference/classInheritence.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/classInheritence.ts(1,17): error TS2690: A class must be declared after its base class. +tests/cases/compiler/classInheritence.ts(1,17): error TS2449: Class 'A' used before its declaration. tests/cases/compiler/classInheritence.ts(2,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. ==== tests/cases/compiler/classInheritence.ts (2 errors) ==== class B extends A { } ~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'A' used before its declaration. class A extends A { } ~ !!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/classOrder2.errors.txt b/tests/baselines/reference/classOrder2.errors.txt index a1b8dc6346e..59184e6a5e6 100644 --- a/tests/baselines/reference/classOrder2.errors.txt +++ b/tests/baselines/reference/classOrder2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/classOrder2.ts(2,17): error TS2690: A class must be declared after its base class. +tests/cases/compiler/classOrder2.ts(2,17): error TS2449: Class 'B' used before its declaration. ==== tests/cases/compiler/classOrder2.ts (1 errors) ==== class A extends B { ~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'B' used before its declaration. foo() { this.bar(); } diff --git a/tests/baselines/reference/classSideInheritance2.errors.txt b/tests/baselines/reference/classSideInheritance2.errors.txt index e286594ec2d..7b27ee7c0f9 100644 --- a/tests/baselines/reference/classSideInheritance2.errors.txt +++ b/tests/baselines/reference/classSideInheritance2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2690: A class must be declared after its base class. +tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2449: Class 'TextBase' used before its declaration. ==== tests/cases/compiler/classSideInheritance2.ts (1 errors) ==== @@ -10,7 +10,7 @@ tests/cases/compiler/classSideInheritance2.ts(7,23): error TS2690: A class must class SubText extends TextBase { ~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'TextBase' used before its declaration. constructor(text: IText, span: TextSpan) { super(); diff --git a/tests/baselines/reference/complexClassRelationships.errors.txt b/tests/baselines/reference/complexClassRelationships.errors.txt index 33413e496d4..c978a36c036 100644 --- a/tests/baselines/reference/complexClassRelationships.errors.txt +++ b/tests/baselines/reference/complexClassRelationships.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/complexClassRelationships.ts(2,23): error TS2690: A class must be declared after its base class. +tests/cases/compiler/complexClassRelationships.ts(2,23): error TS2449: Class 'Base' used before its declaration. ==== tests/cases/compiler/complexClassRelationships.ts (1 errors) ==== // There should be no errors in this file class Derived extends Base { ~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'Base' used before its declaration. public static createEmpty(): Derived { var item = new Derived(); return item; diff --git a/tests/baselines/reference/derivedClasses.errors.txt b/tests/baselines/reference/derivedClasses.errors.txt index fdd38d8c060..ff6946df2ca 100644 --- a/tests/baselines/reference/derivedClasses.errors.txt +++ b/tests/baselines/reference/derivedClasses.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/derivedClasses.ts(1,19): error TS2690: A class must be declared after its base class. +tests/cases/compiler/derivedClasses.ts(1,19): error TS2449: Class 'Color' used before its declaration. ==== tests/cases/compiler/derivedClasses.ts (1 errors) ==== class Red extends Color { ~~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'Color' used before its declaration. public shade() { var getHue = () => { return this.hue(); }; return getHue() + " red"; diff --git a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt index 2678fdf8667..64e5c7d3ef3 100644 --- a/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt +++ b/tests/baselines/reference/extendBaseClassBeforeItsDeclared.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts(1,23): error TS2690: A class must be declared after its base class. +tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts(1,23): error TS2449: Class 'base' used before its declaration. ==== tests/cases/compiler/extendBaseClassBeforeItsDeclared.ts (1 errors) ==== class derived extends base { } ~~~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'base' used before its declaration. class base { constructor (public n: number) { } } \ No newline at end of file diff --git a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt index 1962576abcd..d259a2d2e27 100644 --- a/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt +++ b/tests/baselines/reference/genericClassInheritsConstructorFromNonGenericClass.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(1,17): error TS2690: A class must be declared after its base class. -tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(2,20): error TS2690: A class must be declared after its base class. +tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(1,17): error TS2449: Class 'B' used before its declaration. +tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts(2,20): error TS2449: Class 'C' used before its declaration. ==== tests/cases/compiler/genericClassInheritsConstructorFromNonGenericClass.ts (2 errors) ==== class A extends B { } - ~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~ +!!! error TS2449: Class 'B' used before its declaration. class B extends C { } ~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'C' used before its declaration. class C { constructor(p: string) { } } \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReference.errors.txt b/tests/baselines/reference/indirectSelfReference.errors.txt index 3f7d3d47f12..0339dd8ed08 100644 --- a/tests/baselines/reference/indirectSelfReference.errors.txt +++ b/tests/baselines/reference/indirectSelfReference.errors.txt @@ -1,11 +1,14 @@ tests/cases/compiler/indirectSelfReference.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReference.ts(1,17): error TS2449: Class 'b' used before its declaration. tests/cases/compiler/indirectSelfReference.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReference.ts (2 errors) ==== +==== tests/cases/compiler/indirectSelfReference.ts (3 errors) ==== class a extends b{ } ~ !!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'b' used before its declaration. class b extends a{ } ~ !!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt index 5a6aeed5de1..d1cdbf1da58 100644 --- a/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt +++ b/tests/baselines/reference/indirectSelfReferenceGeneric.errors.txt @@ -1,11 +1,14 @@ tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,7): error TS2506: 'a' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/indirectSelfReferenceGeneric.ts(1,20): error TS2449: Class 'b' used before its declaration. tests/cases/compiler/indirectSelfReferenceGeneric.ts(2,7): error TS2506: 'b' is referenced directly or indirectly in its own base expression. -==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (2 errors) ==== +==== tests/cases/compiler/indirectSelfReferenceGeneric.ts (3 errors) ==== class a extends b { } ~ !!! error TS2506: 'a' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'b' used before its declaration. class b extends a { } ~ !!! error TS2506: 'b' is referenced directly or indirectly in its own base expression. \ No newline at end of file diff --git a/tests/baselines/reference/parserRealSource10.errors.txt b/tests/baselines/reference/parserRealSource10.errors.txt index d6199636e69..ae48cd79b51 100644 --- a/tests/baselines/reference/parserRealSource10.errors.txt +++ b/tests/baselines/reference/parserRealSource10.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. +tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(127,33): error TS2449: Class 'TokenInfo' used before its declaration. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(127,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,36): error TS2304: Cannot find name 'string'. tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(128,42): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. @@ -342,7 +343,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(356,53): error tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. -==== tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts (342 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts (343 errors) ==== // Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. // See LICENSE.txt in the project root for complete license information. @@ -472,6 +473,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource10.ts(449,40): error } export var tokenTable = new TokenInfo[]; + ~~~~~~~~~ +!!! error TS2449: Class 'TokenInfo' used before its declaration. ~~ !!! error TS1150: 'new T[]' cannot be used to create an array. Use 'new Array()' instead. export var nodeTypeTable = new string[]; diff --git a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt index dd44005047e..95378c4c694 100644 --- a/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt +++ b/tests/baselines/reference/privacyClassExtendsClauseDeclFile.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_GlobalFile.ts(16,67): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(17,67): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClassInModule' has or is using private name 'privateClassInPublicModule'. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(20,63): error TS2690: A class must be declared after its base class. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(20,77): error TS2449: Class 'publicClassInPrivateModule' used before its declaration. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,69): error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. -tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,69): error TS2690: A class must be declared after its base class. +tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(22,83): error TS2449: Class 'publicClassInPrivateModule' used before its declaration. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(64,55): error TS4020: 'extends' clause of exported class 'publicClassExtendingPrivateClass' has or is using private name 'privateClass'. tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. @@ -30,14 +30,14 @@ tests/cases/compiler/privacyClassExtendsClauseDeclFile_externalModule.ts(69,65): } class privateClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'publicClassInPrivateModule' used before its declaration. } export class publicClassExtendingFromPrivateModuleClass extends privateModule.publicClassInPrivateModule { // Should error ~~~~~~~~~~~~~ !!! error TS4020: 'extends' clause of exported class 'publicClassExtendingFromPrivateModuleClass' has or is using private name 'privateModule'. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'publicClassInPrivateModule' used before its declaration. } } diff --git a/tests/baselines/reference/recursiveBaseCheck3.errors.txt b/tests/baselines/reference/recursiveBaseCheck3.errors.txt index 97f7cadc3d6..ba0ea669c55 100644 --- a/tests/baselines/reference/recursiveBaseCheck3.errors.txt +++ b/tests/baselines/reference/recursiveBaseCheck3.errors.txt @@ -1,12 +1,15 @@ tests/cases/compiler/recursiveBaseCheck3.ts(1,7): error TS2506: 'A' is referenced directly or indirectly in its own base expression. +tests/cases/compiler/recursiveBaseCheck3.ts(1,20): error TS2449: Class 'C' used before its declaration. tests/cases/compiler/recursiveBaseCheck3.ts(2,7): error TS2506: 'C' is referenced directly or indirectly in its own base expression. tests/cases/compiler/recursiveBaseCheck3.ts(4,9): error TS2339: Property 'blah' does not exist on type 'C<{}>'. -==== tests/cases/compiler/recursiveBaseCheck3.ts (3 errors) ==== +==== tests/cases/compiler/recursiveBaseCheck3.ts (4 errors) ==== class A extends C { } ~ !!! error TS2506: 'A' is referenced directly or indirectly in its own base expression. + ~ +!!! error TS2449: Class 'C' used before its declaration. class C extends A { } ~ !!! error TS2506: 'C' is referenced directly or indirectly in its own base expression. diff --git a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt index b9e650b644b..bfb9a5127f8 100644 --- a/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt +++ b/tests/baselines/reference/resolvingClassDeclarationWhenInBaseTypeResolution.errors.txt @@ -1,34 +1,34 @@ -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(2,35): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(9,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(45,39): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(60,34): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(96,33): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(114,40): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(126,34): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(182,42): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(199,39): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(247,35): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(272,30): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(301,33): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(403,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(436,45): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(469,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(490,34): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(495,39): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(500,38): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(534,42): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(549,41): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(580,45): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(589,44): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(605,46): error TS2690: A class must be declared after its base class. -tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42): error TS2690: A class must be declared after its base class. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(2,45): error TS2449: Class 'nitidus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(9,56): error TS2449: Class 'mixtus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(45,48): error TS2449: Class 'psilurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(60,44): error TS2449: Class 'jugularis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(96,44): error TS2449: Class 'aurata' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(114,48): error TS2449: Class 'gilbertii' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(126,43): error TS2449: Class 'johorensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(182,54): error TS2449: Class 'falconeri' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(199,47): error TS2449: Class 'pygmaea' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(247,46): error TS2449: Class 'ciliolabrum' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(272,35): error TS2449: Class 'coludo' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(301,41): error TS2449: Class 'oreas' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(403,53): error TS2449: Class 'johorensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(436,55): error TS2449: Class 'punicus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(469,52): error TS2449: Class 'stolzmanni' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(490,42): error TS2449: Class 'portoricensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(495,50): error TS2449: Class 'pelurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(500,49): error TS2449: Class 'lasiurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(534,50): error TS2449: Class 'stolzmanni' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(549,53): error TS2449: Class 'daphaenodon' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(580,54): error TS2449: Class 'johorensis' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(589,52): error TS2449: Class 'stolzmanni' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(605,55): error TS2449: Class 'psilurus' used before its declaration. +tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,53): error TS2449: Class 'lasiurus' used before its declaration. ==== tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts (24 errors) ==== module rionegrensis { export class caniventer extends Lanthanum.nitidus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'nitidus' used before its declaration. salomonseni() : caniventer { var x : caniventer; () => { var y = this; }; return x; } uchidai() : lavali.xanthognathus { var x : lavali.xanthognathus; () => { var y = this; }; return x; } raffrayana() : lavali.otion { var x : lavali.otion; () => { var y = this; }; return x; } @@ -36,8 +36,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 nayaur() : gabriellae.amicus { var x : gabriellae.amicus; () => { var y = this; }; return x; } } export class veraecrucis extends trivirgatus.mixtus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~ +!!! error TS2449: Class 'mixtus' used before its declaration. naso() : panamensis.setulosus> { var x : panamensis.setulosus>; () => { var y = this; }; return x; } vancouverensis() : imperfecta.ciliolabrum { var x : imperfecta.ciliolabrum; () => { var y = this; }; return x; } africana() : argurus.gilbertii, sagitta.cinereus> { var x : argurus.gilbertii, sagitta.cinereus>; () => { var y = this; }; return x; } @@ -74,8 +74,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 porcellus() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } } export class oralis extends caurinus.psilurus { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'psilurus' used before its declaration. cepapi() : caurinus.psilurus { var x : caurinus.psilurus; () => { var y = this; }; return x; } porteri() : lavali.thaeleri { var x : lavali.thaeleri; () => { var y = this; }; return x; } bindi() : caurinus.mahaganus> { var x : caurinus.mahaganus>; () => { var y = this; }; return x; } @@ -91,8 +91,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 eisentrauti() : rendalli.zuluensis { var x : rendalli.zuluensis; () => { var y = this; }; return x; } } export class sumatrana extends Lanthanum.jugularis { - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~ +!!! error TS2449: Class 'jugularis' used before its declaration. wolffsohni() : Lanthanum.suillus { var x : Lanthanum.suillus; () => { var y = this; }; return x; } geata() : ruatanica.hector { var x : ruatanica.hector; () => { var y = this; }; return x; } awashensis() : petrophilus.minutilla { var x : petrophilus.minutilla; () => { var y = this; }; return x; } @@ -129,8 +129,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 olchonensis() : rendalli.crenulata { var x : rendalli.crenulata; () => { var y = this; }; return x; } } export class durangae extends dogramacii.aurata { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~ +!!! error TS2449: Class 'aurata' used before its declaration. Californium() : panamensis.setulosus { var x : panamensis.setulosus; () => { var y = this; }; return x; } Flerovium() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } phrudus() : sagitta.stolzmanni { var x : sagitta.stolzmanni; () => { var y = this; }; return x; } @@ -149,8 +149,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 anatolicus() : julianae.steerii { var x : julianae.steerii; () => { var y = this; }; return x; } } export class nitidus extends argurus.gilbertii { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~ +!!! error TS2449: Class 'gilbertii' used before its declaration. granatensis() : quasiater.bobrinskoi { var x : quasiater.bobrinskoi; () => { var y = this; }; return x; } negligens() : minutus.inez { var x : minutus.inez; () => { var y = this; }; return x; } lewisi() : julianae.oralis { var x : julianae.oralis; () => { var y = this; }; return x; } @@ -163,8 +163,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 bicornis() : dogramacii.kaiseri { var x : dogramacii.kaiseri; () => { var y = this; }; return x; } } export class megalonyx extends caurinus.johorensis { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'johorensis' used before its declaration. phillipsii() : macrorhinos.konganensis { var x : macrorhinos.konganensis; () => { var y = this; }; return x; } melanogaster() : rionegrensis.veraecrucis { var x : rionegrensis.veraecrucis; () => { var y = this; }; return x; } elaphus() : nitidus { var x : nitidus; () => { var y = this; }; return x; } @@ -221,8 +221,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 biacensis() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } } export class crenulata extends trivirgatus.falconeri { - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~ +!!! error TS2449: Class 'falconeri' used before its declaration. salvanius() : howi.coludo { var x : howi.coludo; () => { var y = this; }; return x; } maritimus() : ruatanica.americanus { var x : ruatanica.americanus; () => { var y = this; }; return x; } edax() : lutreolus.cor>, rionegrensis.caniventer> { var x : lutreolus.cor>, rionegrensis.caniventer>; () => { var y = this; }; return x; } @@ -240,8 +240,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 vallinus() : sagitta.sicarius { var x : sagitta.sicarius; () => { var y = this; }; return x; } } export class mixtus extends argurus.pygmaea> { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'pygmaea' used before its declaration. ochrogaster() : dogramacii.aurata { var x : dogramacii.aurata; () => { var y = this; }; return x; } bryophilus() : macrorhinos.marmosurus>> { var x : macrorhinos.marmosurus>>; () => { var y = this; }; return x; } liechtensteini() : rendalli.zuluensis { var x : rendalli.zuluensis; () => { var y = this; }; return x; } @@ -290,8 +290,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module ruatanica { export class americanus extends imperfecta.ciliolabrum { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~ +!!! error TS2449: Class 'ciliolabrum' used before its declaration. nasoloi() : macrorhinos.konganensis { var x : macrorhinos.konganensis; () => { var y = this; }; return x; } mystacalis() : howi.angulatus { var x : howi.angulatus; () => { var y = this; }; return x; } fardoulisi() : trivirgatus.oconnelli { var x : trivirgatus.oconnelli; () => { var y = this; }; return x; } @@ -317,8 +317,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 export class beisa { } export class otion extends howi.coludo { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~ +!!! error TS2449: Class 'coludo' used before its declaration. bonaerensis() : provocax.melanoleuca { var x : provocax.melanoleuca; () => { var y = this; }; return x; } dussumieri() : nigra.gracilis { var x : nigra.gracilis; () => { var y = this; }; return x; } osvaldoreigi() : julianae.albidens { var x : julianae.albidens; () => { var y = this; }; return x; } @@ -348,8 +348,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 coyhaiquensis() : caurinus.mahaganus, panglima.abidi>, lutreolus.punicus> { var x : caurinus.mahaganus, panglima.abidi>, lutreolus.punicus>; () => { var y = this; }; return x; } } export class thaeleri extends argurus.oreas { - ~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~ +!!! error TS2449: Class 'oreas' used before its declaration. coromandra() : julianae.galapagoensis { var x : julianae.galapagoensis; () => { var y = this; }; return x; } parvipes() : nigra.dolichurus { var x : nigra.dolichurus; () => { var y = this; }; return x; } sponsorius() : rionegrensis.veraecrucis, julianae.steerii> { var x : rionegrensis.veraecrucis, julianae.steerii>; () => { var y = this; }; return x; } @@ -452,8 +452,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module panglima { export class amphibius extends caurinus.johorensis, Lanthanum.jugularis> { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'johorensis' used before its declaration. bottegi(): macrorhinos.marmosurus, gabriellae.echinatus>, sagitta.stolzmanni> { var x: macrorhinos.marmosurus, gabriellae.echinatus>, sagitta.stolzmanni>; () => { var y = this; }; return x; } jerdoni(): macrorhinos.daphaenodon { var x: macrorhinos.daphaenodon; () => { var y = this; }; return x; } camtschatica(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } @@ -487,8 +487,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module minutus { export class himalayana extends lutreolus.punicus { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'punicus' used before its declaration. simoni(): argurus.netscheri> { var x: argurus.netscheri>; () => { var y = this; }; return x; } lobata(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } rusticus(): dogramacii.aurata { var x: dogramacii.aurata; () => { var y = this; }; return x; } @@ -522,8 +522,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module howi { export class angulatus extends sagitta.stolzmanni { - ~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'stolzmanni' used before its declaration. pennatus(): howi.marcanoi { var x: howi.marcanoi; () => { var y = this; }; return x; } } } @@ -545,22 +545,22 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module sagitta { export class walkeri extends minutus.portoricensis { - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~~~ +!!! error TS2449: Class 'portoricensis' used before its declaration. maracajuensis(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } } } module minutus { export class inez extends samarensis.pelurus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~ +!!! error TS2449: Class 'pelurus' used before its declaration. vexillaris(): samarensis.cahirinus { var x: samarensis.cahirinus; () => { var y = this; }; return x; } } } module macrorhinos { export class konganensis extends imperfecta.lasiurus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'lasiurus' used before its declaration. } } module panamensis { @@ -595,8 +595,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module samarensis { export class pelurus extends sagitta.stolzmanni { - ~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'stolzmanni' used before its declaration. Palladium(): panamensis.linulus { var x: panamensis.linulus; () => { var y = this; }; return x; } castanea(): argurus.netscheri, julianae.oralis> { var x: argurus.netscheri, julianae.oralis>; () => { var y = this; }; return x; } chamek(): argurus.pygmaea { var x: argurus.pygmaea; () => { var y = this; }; return x; } @@ -612,8 +612,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 olitor(): rionegrensis.veraecrucis { var x: rionegrensis.veraecrucis; () => { var y = this; }; return x; } } export class fuscus extends macrorhinos.daphaenodon { - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~~ +!!! error TS2449: Class 'daphaenodon' used before its declaration. planifrons(): nigra.gracilis { var x: nigra.gracilis; () => { var y = this; }; return x; } badia(): julianae.sumatrana { var x: julianae.sumatrana; () => { var y = this; }; return x; } prymnolopha(): sagitta.walkeri { var x: sagitta.walkeri; () => { var y = this; }; return x; } @@ -645,8 +645,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module sagitta { export class leptoceros extends caurinus.johorensis> { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'johorensis' used before its declaration. victus(): rionegrensis.caniventer { var x: rionegrensis.caniventer; () => { var y = this; }; return x; } hoplomyoides(): panglima.fundatus, nigra.gracilis> { var x: panglima.fundatus, nigra.gracilis>; () => { var y = this; }; return x; } gratiosus(): lavali.lepturus { var x: lavali.lepturus; () => { var y = this; }; return x; } @@ -656,8 +656,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module daubentonii { export class nigricans extends sagitta.stolzmanni { - ~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~~~ +!!! error TS2449: Class 'stolzmanni' used before its declaration. woosnami(): dogramacii.robustulus { var x: dogramacii.robustulus; () => { var y = this; }; return x; } } } @@ -674,8 +674,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module chrysaeolus { export class sarasinorum extends caurinus.psilurus { - ~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'psilurus' used before its declaration. belzebul(): samarensis.pallidus { var x: samarensis.pallidus; () => { var y = this; }; return x; } hinpoon(): nigra.caucasica { var x: nigra.caucasica; () => { var y = this; }; return x; } kandti(): quasiater.wattsi { var x: quasiater.wattsi; () => { var y = this; }; return x; } @@ -840,8 +840,8 @@ tests/cases/compiler/resolvingClassDeclarationWhenInBaseTypeResolution.ts(769,42 } module gabriellae { export class klossii extends imperfecta.lasiurus { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2690: A class must be declared after its base class. + ~~~~~~~~ +!!! error TS2449: Class 'lasiurus' used before its declaration. } export class amicus { pirrensis(): argurus.luctuosa { var x: argurus.luctuosa; () => { var y = this; }; return x; } diff --git a/tests/baselines/reference/symbolProperty33.errors.txt b/tests/baselines/reference/symbolProperty33.errors.txt index b1dab90db33..a8e95fc5bd8 100644 --- a/tests/baselines/reference/symbolProperty33.errors.txt +++ b/tests/baselines/reference/symbolProperty33.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/Symbols/symbolProperty33.ts(1,18): error TS2690: A class must be declared after its base class. +tests/cases/conformance/es6/Symbols/symbolProperty33.ts(1,18): error TS2449: Class 'C2' used before its declaration. tests/cases/conformance/es6/Symbols/symbolProperty33.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. ==== tests/cases/conformance/es6/Symbols/symbolProperty33.ts (2 errors) ==== class C1 extends C2 { ~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'C2' used before its declaration. [Symbol.toStringTag]() { return { x: "" }; } diff --git a/tests/baselines/reference/symbolProperty34.errors.txt b/tests/baselines/reference/symbolProperty34.errors.txt index 98a9875bd50..3ff62c12ad1 100644 --- a/tests/baselines/reference/symbolProperty34.errors.txt +++ b/tests/baselines/reference/symbolProperty34.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/es6/Symbols/symbolProperty34.ts(1,18): error TS2690: A class must be declared after its base class. +tests/cases/conformance/es6/Symbols/symbolProperty34.ts(1,18): error TS2449: Class 'C2' used before its declaration. tests/cases/conformance/es6/Symbols/symbolProperty34.ts(7,6): error TS1023: An index signature parameter type must be 'string' or 'number'. ==== tests/cases/conformance/es6/Symbols/symbolProperty34.ts (2 errors) ==== class C1 extends C2 { ~~ -!!! error TS2690: A class must be declared after its base class. +!!! error TS2449: Class 'C2' used before its declaration. [Symbol.toStringTag]() { return { x: "" }; } From 21ef9078adcdbee99c5ebf2041850ea7562cb55c Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Thu, 23 Feb 2017 15:52:38 -0800 Subject: [PATCH 032/207] Wrapping LSHost's cancellationtoken with a throttle --- .../unittests/tsserverProjectSystem.ts | 7 +- src/server/editorServices.ts | 3 +- src/server/lsHost.ts | 1 + src/server/session.ts | 5 +- src/services/navigationBar.ts | 73 ++++++++++--------- src/services/services.ts | 30 ++++++++ src/services/shims.ts | 23 ------ 7 files changed, 80 insertions(+), 62 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index d9abb0a9078..353d0e2e187 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -176,11 +176,11 @@ namespace ts.projectSystem { } }; - export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler, cancellationToken?: server.ServerCancellationToken) { + export function createSession(host: server.ServerHost, typingsInstaller?: server.ITypingsInstaller, projectServiceEventHandler?: server.ProjectServiceEventHandler, cancellationToken?: server.ServerCancellationToken, throttleWaitMilliseconds?: number) { if (typingsInstaller === undefined) { typingsInstaller = new TestTypingsInstaller("/a/data/", /*throttleLimit*/5, host); } - return new TestSession(host, cancellationToken || server.nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler); + return new TestSession(host, cancellationToken || server.nullCancellationToken, /*useSingleInferredProject*/ false, typingsInstaller, Utils.byteLength, process.hrtime, nullLogger, /*canUseEvents*/ projectServiceEventHandler !== undefined, projectServiceEventHandler, throttleWaitMilliseconds); } export interface CreateProjectServiceParameters { @@ -3320,6 +3320,7 @@ namespace ts.projectSystem { }, resetRequest: noop } + const session = createSession(host, /*typingsInstaller*/ undefined, /*projectServiceEventHandler*/ undefined, cancellationToken); expectedRequestId = session.getNextSeq(); @@ -3492,7 +3493,7 @@ namespace ts.projectSystem { }; const cancellationToken = new TestServerCancellationToken(/*cancelAfterRequest*/ 3); const host = createServerHost([f1, config]); - const session = createSession(host, /*typingsInstaller*/ undefined, () => { }, cancellationToken); + const session = createSession(host, /*typingsInstaller*/ undefined, () => { }, cancellationToken, /*throttleWaitMilliseconds*/ 0); { session.executeCommandSeq({ command: "open", diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 36aa3939c83..4067d85fb3f 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -270,7 +270,8 @@ namespace ts.server { public readonly cancellationToken: HostCancellationToken, public readonly useSingleInferredProject: boolean, readonly typingsInstaller: ITypingsInstaller = nullTypingsInstaller, - private readonly eventHandler?: ProjectServiceEventHandler) { + private readonly eventHandler?: ProjectServiceEventHandler, + public readonly throttleWaitMilliseconds?: number) { Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); diff --git a/src/server/lsHost.ts b/src/server/lsHost.ts index eee80d82e7f..ec655c545ea 100644 --- a/src/server/lsHost.ts +++ b/src/server/lsHost.ts @@ -16,6 +16,7 @@ namespace ts.server { readonly realpath?: (path: string) => string; constructor(private readonly host: ServerHost, private readonly project: Project, private readonly cancellationToken: HostCancellationToken) { + this.cancellationToken = new ThrottledCancellationToken(cancellationToken, project.projectService.throttleWaitMilliseconds); this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); if (host.trace) { diff --git a/src/server/session.ts b/src/server/session.ts index 262ba8da1da..e7b4fc4bd47 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -338,7 +338,8 @@ namespace ts.server { private hrtime: (start?: number[]) => number[], protected logger: Logger, protected readonly canUseEvents: boolean, - eventHandler?: ProjectServiceEventHandler) { + eventHandler?: ProjectServiceEventHandler, + private readonly throttleWaitMilliseconds?: number) { this.eventHander = canUseEvents ? eventHandler || (event => this.defaultEventHandler(event)) @@ -353,7 +354,7 @@ namespace ts.server { isCancellationRequested: () => cancellationToken.isCancellationRequested() } this.errorCheck = new MultistepOperation(multistepOperationHost); - this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); + this.projectService = new ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander, this.throttleWaitMilliseconds); this.gcTimer = new GcTimer(host, /*delay*/ 7000, logger); } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 811762fb736..7a2508fcfd6 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -2,6 +2,36 @@ /* @internal */ namespace ts.NavigationBar { + /** + * Matches all whitespace characters in a string. Eg: + * + * "app. + * + * onactivated" + * + * matches because of the newline, whereas + * + * "app.onactivated" + * + * does not match. + */ + const whiteSpaceRegex = /\s+/g; + + // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. + let curCancellationToken: CancellationToken; + let curSourceFile: SourceFile; + + /** + * For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. + * `parent` is the current parent and is *not* stored in parentsStack. + * `startNode` sets a new parent and `endNode` returns to the previous parent. + */ + let parentsStack: NavigationBarNode[] = []; + let parent: NavigationBarNode; + + // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. + let emptyChildItemArray: NavigationBarItem[] = []; + /** * Represents a navigation bar item and its children. * The returned NavigationBarItem is more complicated and doesn't include 'parent', so we use these to do work before converting. @@ -21,8 +51,7 @@ namespace ts.NavigationBar { return map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); } finally { - curSourceFile = undefined; - curCancellationToken = undefined; + reset(); } } @@ -33,14 +62,18 @@ namespace ts.NavigationBar { return convertToTree(rootNavigationBarNode(sourceFile)); } finally { - curSourceFile = undefined; - curCancellationToken = undefined; + reset(); } } - // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. - let curCancellationToken: CancellationToken; - let curSourceFile: SourceFile; + function reset() { + curSourceFile = undefined; + curCancellationToken = undefined; + parentsStack = []; + parent = undefined; + emptyChildItemArray = []; + } + function nodeText(node: Node): string { return node.getText(curSourceFile); } @@ -58,14 +91,6 @@ namespace ts.NavigationBar { } } - /* - For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. - `parent` is the current parent and is *not* stored in parentsStack. - `startNode` sets a new parent and `endNode` returns to the previous parent. - */ - const parentsStack: NavigationBarNode[] = []; - let parent: NavigationBarNode; - function rootNavigationBarNode(sourceFile: SourceFile): NavigationBarNode { Debug.assert(!parentsStack.length); const root: NavigationBarNode = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; @@ -500,9 +525,6 @@ namespace ts.NavigationBar { } } - // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. - const emptyChildItemArray: NavigationBarItem[] = []; - function convertToTree(n: NavigationBarNode): NavigationTree { return { text: getItemName(n.node), @@ -623,19 +645,4 @@ namespace ts.NavigationBar { function isFunctionOrClassExpression(node: Node): boolean { return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction || node.kind === SyntaxKind.ClassExpression; } - - /** - * Matches all whitespace characters in a string. Eg: - * - * "app. - * - * onactivated" - * - * matches because of the newline, whereas - * - * "app.onactivated" - * - * does not match. - */ - const whiteSpaceRegex = /\s+/g; } diff --git a/src/services/services.ts b/src/services/services.ts index cef307eb8fd..d808ed28b72 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -972,6 +972,36 @@ namespace ts { } } + /* @internal */ + /** A cancellation that throttles calls to the host */ + export class ThrottledCancellationToken implements CancellationToken { + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + private lastCancellationCheckTime = 0; + + constructor(private hostCancellationToken: HostCancellationToken, private readonly throttleWaitMilliseconds = 20) { + } + + public isCancellationRequested(): boolean { + const time = timestamp(); + const duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration >= this.throttleWaitMilliseconds) { + // Check no more than once every throttle wait milliseconds + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + + return false; + } + + public throwIfCancellationRequested(): void { + if (this.isCancellationRequested()) { + throw new OperationCanceledException(); + } + } + } + export function createLanguageService(host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { diff --git a/src/services/shims.ts b/src/services/shims.ts index 6fe9aed144e..de2fd39b8a8 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -469,29 +469,6 @@ namespace ts { } } - /** A cancellation that throttles calls to the host */ - class ThrottledCancellationToken implements HostCancellationToken { - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - private lastCancellationCheckTime = 0; - - constructor(private hostCancellationToken: HostCancellationToken) { - } - - public isCancellationRequested(): boolean { - const time = timestamp(); - const duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - // Check no more than once every 10 ms. - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - - return false; - } - } - export class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { public directoryExists: (directoryName: string) => boolean; From 1415cf4ea2dbde9077844537f0ebab549f0f8a98 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Fri, 24 Feb 2017 17:48:06 -0800 Subject: [PATCH 033/207] Update tests and baselines to declare class declaration before use --- .../reference/ES5For-ofTypeCheck10.errors.txt | 13 +++--- .../reference/ES5For-ofTypeCheck10.js | 11 +++-- .../classDoesNotDependOnBaseTypes.js | 24 +++++----- .../classDoesNotDependOnBaseTypes.symbols | 43 +++++++++-------- .../classDoesNotDependOnBaseTypes.types | 33 +++++++------ ...5ExportDefaultClassDeclaration3.errors.txt | 20 ++++++++ .../es5ExportDefaultClassDeclaration3.symbols | 30 ------------ .../es5ExportDefaultClassDeclaration3.types | 33 ------------- .../exportAssignmentOfGenericType1.errors.txt | 17 +++++++ tests/baselines/reference/for-of14.errors.txt | 14 +++--- tests/baselines/reference/for-of14.js | 12 ++--- tests/baselines/reference/for-of15.errors.txt | 14 +++--- tests/baselines/reference/for-of15.js | 12 ++--- tests/baselines/reference/for-of16.errors.txt | 14 +++--- tests/baselines/reference/for-of16.js | 12 ++--- tests/baselines/reference/for-of17.errors.txt | 14 +++--- tests/baselines/reference/for-of17.js | 12 ++--- tests/baselines/reference/for-of18.js | 12 ++--- tests/baselines/reference/for-of18.symbols | 25 +++++----- tests/baselines/reference/for-of18.types | 17 +++---- tests/baselines/reference/for-of19.js | 14 +++--- tests/baselines/reference/for-of19.symbols | 30 ++++++------ tests/baselines/reference/for-of19.types | 18 ++++---- tests/baselines/reference/for-of20.js | 14 +++--- tests/baselines/reference/for-of20.symbols | 30 ++++++------ tests/baselines/reference/for-of20.types | 18 ++++---- tests/baselines/reference/for-of21.js | 14 +++--- tests/baselines/reference/for-of21.symbols | 30 ++++++------ tests/baselines/reference/for-of21.types | 18 ++++---- tests/baselines/reference/for-of22.js | 16 +++---- tests/baselines/reference/for-of22.symbols | 32 ++++++------- tests/baselines/reference/for-of22.types | 20 ++++---- tests/baselines/reference/for-of23.js | 14 +++--- tests/baselines/reference/for-of23.symbols | 30 ++++++------ tests/baselines/reference/for-of23.types | 20 ++++---- tests/baselines/reference/for-of25.js | 12 ++--- tests/baselines/reference/for-of25.symbols | 19 ++++---- tests/baselines/reference/for-of25.types | 17 +++---- tests/baselines/reference/for-of26.js | 12 ++--- tests/baselines/reference/for-of26.symbols | 23 +++++----- tests/baselines/reference/for-of26.types | 17 +++---- tests/baselines/reference/for-of27.js | 8 ++-- tests/baselines/reference/for-of27.symbols | 11 +++-- tests/baselines/reference/for-of27.types | 11 +++-- tests/baselines/reference/for-of28.js | 8 ++-- tests/baselines/reference/for-of28.symbols | 15 +++--- tests/baselines/reference/for-of28.types | 11 +++-- tests/baselines/reference/for-of30.errors.txt | 22 ++++----- tests/baselines/reference/for-of30.js | 8 ++-- tests/baselines/reference/for-of31.errors.txt | 26 +++++------ tests/baselines/reference/for-of31.js | 8 ++-- tests/baselines/reference/for-of33.errors.txt | 14 +++--- tests/baselines/reference/for-of33.js | 8 ++-- tests/baselines/reference/for-of34.errors.txt | 14 +++--- tests/baselines/reference/for-of34.js | 8 ++-- tests/baselines/reference/for-of35.errors.txt | 14 +++--- tests/baselines/reference/for-of35.js | 8 ++-- .../reference/iterableArrayPattern1.js | 7 +-- .../reference/iterableArrayPattern1.symbols | 21 +++++---- .../reference/iterableArrayPattern1.types | 13 +++--- .../iterableArrayPattern10.errors.txt | 15 +++--- .../reference/iterableArrayPattern10.js | 11 +++-- .../reference/iterableArrayPattern11.js | 12 +++-- .../reference/iterableArrayPattern11.symbols | 43 ++++++++--------- .../reference/iterableArrayPattern11.types | 27 +++++------ .../reference/iterableArrayPattern12.js | 11 +++-- .../reference/iterableArrayPattern12.symbols | 43 ++++++++--------- .../reference/iterableArrayPattern12.types | 27 +++++------ .../reference/iterableArrayPattern13.js | 11 +++-- .../reference/iterableArrayPattern13.symbols | 41 +++++++++-------- .../reference/iterableArrayPattern13.types | 23 +++++----- .../iterableArrayPattern14.errors.txt | 13 +++--- .../reference/iterableArrayPattern14.js | 11 +++-- .../iterableArrayPattern15.errors.txt | 13 +++--- .../reference/iterableArrayPattern15.js | 11 +++-- .../iterableArrayPattern16.errors.txt | 5 +- .../iterableArrayPattern17.errors.txt | 21 +++++---- .../reference/iterableArrayPattern17.js | 11 +++-- .../iterableArrayPattern18.errors.txt | 15 +++--- .../reference/iterableArrayPattern18.js | 11 +++-- .../iterableArrayPattern19.errors.txt | 15 +++--- .../reference/iterableArrayPattern19.js | 11 +++-- .../reference/iterableArrayPattern2.js | 7 +-- .../reference/iterableArrayPattern2.symbols | 21 +++++---- .../reference/iterableArrayPattern2.types | 13 +++--- .../iterableArrayPattern20.errors.txt | 13 +++--- .../reference/iterableArrayPattern20.js | 11 +++-- .../reference/iterableArrayPattern3.js | 11 +++-- .../reference/iterableArrayPattern3.symbols | 45 +++++++++--------- .../reference/iterableArrayPattern3.types | 29 ++++++------ .../reference/iterableArrayPattern4.js | 11 +++-- .../reference/iterableArrayPattern4.symbols | 45 +++++++++--------- .../reference/iterableArrayPattern4.types | 31 +++++++------ .../iterableArrayPattern5.errors.txt | 13 +++--- .../reference/iterableArrayPattern5.js | 11 +++-- .../iterableArrayPattern6.errors.txt | 15 +++--- .../reference/iterableArrayPattern6.js | 11 +++-- .../iterableArrayPattern7.errors.txt | 15 +++--- .../reference/iterableArrayPattern7.js | 11 +++-- .../iterableArrayPattern8.errors.txt | 13 +++--- .../reference/iterableArrayPattern8.js | 11 +++-- .../reference/iteratorSpreadInArray.js | 9 ++-- .../reference/iteratorSpreadInArray.symbols | 19 ++++---- .../reference/iteratorSpreadInArray.types | 15 +++--- .../iteratorSpreadInArray10.errors.txt | 12 ++--- .../reference/iteratorSpreadInArray10.js | 8 ++-- .../reference/iteratorSpreadInArray2.js | 9 ++-- .../reference/iteratorSpreadInArray2.symbols | 31 +++++++------ .../reference/iteratorSpreadInArray2.types | 21 +++++---- .../reference/iteratorSpreadInArray3.js | 8 ++-- .../reference/iteratorSpreadInArray3.symbols | 19 ++++---- .../reference/iteratorSpreadInArray3.types | 23 +++++----- .../reference/iteratorSpreadInArray4.js | 8 ++-- .../reference/iteratorSpreadInArray4.symbols | 19 ++++---- .../reference/iteratorSpreadInArray4.types | 19 ++++---- .../iteratorSpreadInArray5.errors.txt | 16 +++---- .../reference/iteratorSpreadInArray5.js | 8 ++-- .../iteratorSpreadInArray6.errors.txt | 18 ++++---- .../reference/iteratorSpreadInArray6.js | 12 ++--- .../reference/iteratorSpreadInArray7.js | 12 ++--- .../reference/iteratorSpreadInArray7.symbols | 29 ++++++------ .../reference/iteratorSpreadInArray7.types | 27 +++++------ .../iteratorSpreadInArray8.errors.txt | 12 ++--- .../reference/iteratorSpreadInArray8.js | 8 ++-- .../iteratorSpreadInArray9.errors.txt | 26 +++++------ .../reference/iteratorSpreadInArray9.js | 8 ++-- .../reference/iteratorSpreadInCall.errors.txt | 12 ++--- .../reference/iteratorSpreadInCall.js | 8 ++-- .../iteratorSpreadInCall10.errors.txt | 13 +++--- .../reference/iteratorSpreadInCall10.js | 9 ++-- .../reference/iteratorSpreadInCall11.js | 9 ++-- .../reference/iteratorSpreadInCall11.symbols | 29 ++++++------ .../reference/iteratorSpreadInCall11.types | 15 +++--- .../reference/iteratorSpreadInCall12.js | 8 ++-- .../reference/iteratorSpreadInCall12.symbols | 39 ++++++++-------- .../reference/iteratorSpreadInCall12.types | 29 ++++++------ .../iteratorSpreadInCall2.errors.txt | 12 ++--- .../reference/iteratorSpreadInCall2.js | 8 ++-- .../reference/iteratorSpreadInCall3.js | 8 ++-- .../reference/iteratorSpreadInCall3.symbols | 23 +++++----- .../reference/iteratorSpreadInCall3.types | 15 +++--- .../iteratorSpreadInCall4.errors.txt | 12 ++--- .../reference/iteratorSpreadInCall4.js | 8 ++-- .../reference/iteratorSpreadInCall5.js | 8 ++-- .../reference/iteratorSpreadInCall5.symbols | 35 +++++++------- .../reference/iteratorSpreadInCall5.types | 21 +++++---- .../iteratorSpreadInCall6.errors.txt | 12 ++--- .../reference/iteratorSpreadInCall6.js | 8 ++-- .../iteratorSpreadInCall7.errors.txt | 14 +++--- .../reference/iteratorSpreadInCall7.js | 8 ++-- .../iteratorSpreadInCall8.errors.txt | 14 +++--- .../reference/iteratorSpreadInCall8.js | 8 ++-- .../iteratorSpreadInCall9.errors.txt | 15 +++--- .../reference/iteratorSpreadInCall9.js | 9 ++-- ...ssInstantiationsWithDefaultConstructors.js | 16 +++---- ...tantiationsWithDefaultConstructors.symbols | 32 ++++++------- ...nstantiationsWithDefaultConstructors.types | 32 ++++++------- .../typeArgumentInferenceOrdering.js | 11 ++--- .../typeArgumentInferenceOrdering.symbols | 46 +++++++++---------- .../typeArgumentInferenceOrdering.types | 36 +++++++-------- ...ssInstantiationsWithDefaultConstructors.ts | 13 +++--- .../compiler/typeArgumentInferenceOrdering.ts | 6 +-- .../destructuring/iterableArrayPattern1.ts | 5 +- .../destructuring/iterableArrayPattern10.ts | 7 +-- .../destructuring/iterableArrayPattern11.ts | 7 +-- .../destructuring/iterableArrayPattern12.ts | 7 +-- .../destructuring/iterableArrayPattern13.ts | 7 +-- .../destructuring/iterableArrayPattern14.ts | 7 +-- .../destructuring/iterableArrayPattern15.ts | 7 +-- .../destructuring/iterableArrayPattern17.ts | 7 +-- .../destructuring/iterableArrayPattern18.ts | 7 +-- .../destructuring/iterableArrayPattern19.ts | 7 +-- .../destructuring/iterableArrayPattern2.ts | 5 +- .../destructuring/iterableArrayPattern20.ts | 7 +-- .../destructuring/iterableArrayPattern3.ts | 7 +-- .../destructuring/iterableArrayPattern4.ts | 7 +-- .../destructuring/iterableArrayPattern5.ts | 7 +-- .../destructuring/iterableArrayPattern6.ts | 7 +-- .../destructuring/iterableArrayPattern7.ts | 7 +-- .../destructuring/iterableArrayPattern8.ts | 7 +-- .../es6/for-ofStatements/for-of14.ts | 8 ++-- .../es6/for-ofStatements/for-of15.ts | 8 ++-- .../es6/for-ofStatements/for-of16.ts | 8 ++-- .../es6/for-ofStatements/for-of17.ts | 8 ++-- .../es6/for-ofStatements/for-of18.ts | 8 ++-- .../es6/for-ofStatements/for-of19.ts | 8 ++-- .../es6/for-ofStatements/for-of20.ts | 8 ++-- .../es6/for-ofStatements/for-of21.ts | 8 ++-- .../es6/for-ofStatements/for-of22.ts | 10 ++-- .../es6/for-ofStatements/for-of23.ts | 8 ++-- .../es6/for-ofStatements/for-of25.ts | 8 ++-- .../es6/for-ofStatements/for-of26.ts | 8 ++-- .../es6/for-ofStatements/for-of27.ts | 6 +-- .../es6/for-ofStatements/for-of28.ts | 6 +-- .../es6/for-ofStatements/for-of30.ts | 6 +-- .../es6/for-ofStatements/for-of31.ts | 6 +-- .../es6/for-ofStatements/for-of33.ts | 6 +-- .../es6/for-ofStatements/for-of34.ts | 6 +-- .../es6/for-ofStatements/for-of35.ts | 6 +-- .../es6/spread/iteratorSpreadInArray.ts | 6 +-- .../es6/spread/iteratorSpreadInArray10.ts | 6 +-- .../es6/spread/iteratorSpreadInArray2.ts | 6 +-- .../es6/spread/iteratorSpreadInArray3.ts | 6 +-- .../es6/spread/iteratorSpreadInArray4.ts | 6 +-- .../es6/spread/iteratorSpreadInArray5.ts | 6 +-- .../es6/spread/iteratorSpreadInArray6.ts | 8 ++-- .../es6/spread/iteratorSpreadInArray7.ts | 8 ++-- .../es6/spread/iteratorSpreadInArray8.ts | 6 +-- .../es6/spread/iteratorSpreadInArray9.ts | 6 +-- .../es6/spread/iteratorSpreadInCall.ts | 6 +-- .../es6/spread/iteratorSpreadInCall10.ts | 7 ++- .../es6/spread/iteratorSpreadInCall11.ts | 7 ++- .../es6/spread/iteratorSpreadInCall12.ts | 6 +-- .../es6/spread/iteratorSpreadInCall2.ts | 6 +-- .../es6/spread/iteratorSpreadInCall3.ts | 6 +-- .../es6/spread/iteratorSpreadInCall4.ts | 6 +-- .../es6/spread/iteratorSpreadInCall5.ts | 6 +-- .../es6/spread/iteratorSpreadInCall6.ts | 6 +-- .../es6/spread/iteratorSpreadInCall7.ts | 6 +-- .../es6/spread/iteratorSpreadInCall8.ts | 6 +-- .../es6/spread/iteratorSpreadInCall9.ts | 6 +-- .../for-ofStatements/ES5For-ofTypeCheck10.ts | 5 +- .../classDoesNotDependOnBaseTypes.ts | 14 +++--- 223 files changed, 1628 insertions(+), 1561 deletions(-) create mode 100644 tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt delete mode 100644 tests/baselines/reference/es5ExportDefaultClassDeclaration3.symbols delete mode 100644 tests/baselines/reference/es5ExportDefaultClassDeclaration3.types create mode 100644 tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt diff --git a/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt index b762db8a04b..7839958ba54 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck10.errors.txt @@ -1,11 +1,8 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(1,15): error TS2495: Type 'StringIterator' is not an array type or a string type. -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6): error TS2304: Cannot find name 'Symbol'. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(10,6): error TS2304: Cannot find name 'Symbol'. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(15,15): error TS2495: Type 'StringIterator' is not an array type or a string type. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2495: Type 'StringIterator' is not an array type or a string type. // In ES3/5, you cannot for...of over an arbitrary iterable. class StringIterator { @@ -20,4 +17,8 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts(11,6 !!! error TS2304: Cannot find name 'Symbol'. return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2495: Type 'StringIterator' is not an array type or a string type. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-ofTypeCheck10.js b/tests/baselines/reference/ES5For-ofTypeCheck10.js index 0fe92e289a6..9b197c2d206 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck10.js +++ b/tests/baselines/reference/ES5For-ofTypeCheck10.js @@ -1,5 +1,4 @@ //// [ES5For-ofTypeCheck10.ts] -for (var v of new StringIterator) { } // In ES3/5, you cannot for...of over an arbitrary iterable. class StringIterator { @@ -12,12 +11,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [ES5For-ofTypeCheck10.js] -for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) { - var v = _a[_i]; -} // In ES3/5, you cannot for...of over an arbitrary iterable. var StringIterator = (function () { function StringIterator() { @@ -33,3 +31,6 @@ var StringIterator = (function () { }; return StringIterator; }()); +for (var _i = 0, _a = new StringIterator; _i < _a.length; _i++) { + var v = _a[_i]; +} diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js index c1642125fe9..5b9892b9ab8 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.js +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.js @@ -1,16 +1,16 @@ //// [classDoesNotDependOnBaseTypes.ts] -var x: StringTree; -if (typeof x !== "string") { - x[0] = ""; - x[0] = new StringTreeCollection; -} - type StringTree = string | StringTreeCollection; class StringTreeCollectionBase { [n: number]: StringTree; } -class StringTreeCollection extends StringTreeCollectionBase { } +class StringTreeCollection extends StringTreeCollectionBase { } + +var x: StringTree; +if (typeof x !== "string") { + x[0] = ""; + x[0] = new StringTreeCollection; +} //// [classDoesNotDependOnBaseTypes.js] var __extends = (this && this.__extends) || (function () { @@ -23,11 +23,6 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var x; -if (typeof x !== "string") { - x[0] = ""; - x[0] = new StringTreeCollection; -} var StringTreeCollectionBase = (function () { function StringTreeCollectionBase() { } @@ -40,3 +35,8 @@ var StringTreeCollection = (function (_super) { } return StringTreeCollection; }(StringTreeCollectionBase)); +var x; +if (typeof x !== "string") { + x[0] = ""; + x[0] = new StringTreeCollection; +} diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols b/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols index e45b00f1e8a..a7a421ebf55 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.symbols @@ -1,32 +1,31 @@ === tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts === -var x: StringTree; ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) ->StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1)) - -if (typeof x !== "string") { ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) - - x[0] = ""; ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) - - x[0] = new StringTreeCollection; ->x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 0, 3)) ->StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1)) -} - type StringTree = string | StringTreeCollection; ->StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1)) ->StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1)) +>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0)) +>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1)) class StringTreeCollectionBase { ->StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 6, 48)) +>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 0, 48)) [n: number]: StringTree; ->n : Symbol(n, Decl(classDoesNotDependOnBaseTypes.ts, 8, 5)) ->StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 4, 1)) +>n : Symbol(n, Decl(classDoesNotDependOnBaseTypes.ts, 2, 5)) +>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0)) } class StringTreeCollection extends StringTreeCollectionBase { } ->StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 9, 1)) ->StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 6, 48)) +>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1)) +>StringTreeCollectionBase : Symbol(StringTreeCollectionBase, Decl(classDoesNotDependOnBaseTypes.ts, 0, 48)) +var x: StringTree; +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) +>StringTree : Symbol(StringTree, Decl(classDoesNotDependOnBaseTypes.ts, 0, 0)) + +if (typeof x !== "string") { +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) + + x[0] = ""; +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) + + x[0] = new StringTreeCollection; +>x : Symbol(x, Decl(classDoesNotDependOnBaseTypes.ts, 7, 3)) +>StringTreeCollection : Symbol(StringTreeCollection, Decl(classDoesNotDependOnBaseTypes.ts, 3, 1)) +} diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types index 54b67dfd6a7..16dc984dc8c 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types @@ -1,4 +1,20 @@ === tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts === +type StringTree = string | StringTreeCollection; +>StringTree : StringTree +>StringTreeCollection : StringTreeCollection + +class StringTreeCollectionBase { +>StringTreeCollectionBase : StringTreeCollectionBase + + [n: number]: StringTree; +>n : number +>StringTree : StringTree +} + +class StringTreeCollection extends StringTreeCollectionBase { } +>StringTreeCollection : StringTreeCollection +>StringTreeCollectionBase : StringTreeCollectionBase + var x: StringTree; >x : StringTree >StringTree : StringTree @@ -24,20 +40,3 @@ if (typeof x !== "string") { >new StringTreeCollection : StringTreeCollection >StringTreeCollection : typeof StringTreeCollection } - -type StringTree = string | StringTreeCollection; ->StringTree : StringTree ->StringTreeCollection : StringTreeCollection - -class StringTreeCollectionBase { ->StringTreeCollectionBase : StringTreeCollectionBase - - [n: number]: StringTree; ->n : number ->StringTree : StringTree -} - -class StringTreeCollection extends StringTreeCollectionBase { } ->StringTreeCollection : StringTreeCollection ->StringTreeCollectionBase : StringTreeCollectionBase - diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt new file mode 100644 index 00000000000..951e8bbffd1 --- /dev/null +++ b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts(2,21): error TS2449: Class 'C' used before its declaration. + + +==== tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts (1 errors) ==== + + var before: C = new C(); + ~ +!!! error TS2449: Class 'C' used before its declaration. + + export default class C { + method(): C { + return new C(); + } + } + + var after: C = new C(); + + var t: typeof C = C; + + \ No newline at end of file diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.symbols b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.symbols deleted file mode 100644 index d5c8243161b..00000000000 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.symbols +++ /dev/null @@ -1,30 +0,0 @@ -=== tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts === - -var before: C = new C(); ->before : Symbol(before, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 3)) ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) - -export default class C { ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) - - method(): C { ->method : Symbol(C.method, Decl(es5ExportDefaultClassDeclaration3.ts, 3, 24)) ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) - - return new C(); ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) - } -} - -var after: C = new C(); ->after : Symbol(after, Decl(es5ExportDefaultClassDeclaration3.ts, 9, 3)) ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) - -var t: typeof C = C; ->t : Symbol(t, Decl(es5ExportDefaultClassDeclaration3.ts, 11, 3)) ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) ->C : Symbol(C, Decl(es5ExportDefaultClassDeclaration3.ts, 1, 24)) - - diff --git a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.types b/tests/baselines/reference/es5ExportDefaultClassDeclaration3.types deleted file mode 100644 index 1ed302ac45e..00000000000 --- a/tests/baselines/reference/es5ExportDefaultClassDeclaration3.types +++ /dev/null @@ -1,33 +0,0 @@ -=== tests/cases/compiler/es5ExportDefaultClassDeclaration3.ts === - -var before: C = new C(); ->before : C ->C : C ->new C() : C ->C : typeof C - -export default class C { ->C : C - - method(): C { ->method : () => C ->C : C - - return new C(); ->new C() : C ->C : typeof C - } -} - -var after: C = new C(); ->after : C ->C : C ->new C() : C ->C : typeof C - -var t: typeof C = C; ->t : typeof C ->C : typeof C ->C : typeof C - - diff --git a/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt b/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt new file mode 100644 index 00000000000..e484d4096bb --- /dev/null +++ b/tests/baselines/reference/exportAssignmentOfGenericType1.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/exportAssignmentOfGenericType1_0.ts(1,10): error TS2449: Class 'T' used before its declaration. + + +==== tests/cases/compiler/exportAssignmentOfGenericType1_1.ts (0 errors) ==== + /// + import q = require("exportAssignmentOfGenericType1_0"); + + class M extends q { } + var m: M; + var r: string = m.foo; + +==== tests/cases/compiler/exportAssignmentOfGenericType1_0.ts (1 errors) ==== + export = T; + ~ +!!! error TS2449: Class 'T' used before its declaration. + class T { foo: X; } + \ No newline at end of file diff --git a/tests/baselines/reference/for-of14.errors.txt b/tests/baselines/reference/for-of14.errors.txt index ab95d042689..d4ec79620d9 100644 --- a/tests/baselines/reference/for-of14.errors.txt +++ b/tests/baselines/reference/for-of14.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. +tests/cases/conformance/es6/for-ofStatements/for-of14.ts(8,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. ==== tests/cases/conformance/es6/for-ofStatements/for-of14.ts (1 errors) ==== - var v: string; - for (v of new StringIterator) { } // Should fail because the iterator is not iterable - ~~~~~~~~~~~~~~~~~~ -!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. - class StringIterator { next() { return ""; } - } \ No newline at end of file + } + + var v: string; + for (v of new StringIterator) { } // Should fail because the iterator is not iterable + ~~~~~~~~~~~~~~~~~~ +!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. \ No newline at end of file diff --git a/tests/baselines/reference/for-of14.js b/tests/baselines/reference/for-of14.js index 42832f8e58e..ac3af1ff1db 100644 --- a/tests/baselines/reference/for-of14.js +++ b/tests/baselines/reference/for-of14.js @@ -1,18 +1,18 @@ //// [for-of14.ts] -var v: string; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable - class StringIterator { next() { return ""; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable //// [for-of14.js] -var v; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable class StringIterator { next() { return ""; } } +var v; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable diff --git a/tests/baselines/reference/for-of15.errors.txt b/tests/baselines/reference/for-of15.errors.txt index 20a4abe4bd0..6d990aa01fc 100644 --- a/tests/baselines/reference/for-of15.errors.txt +++ b/tests/baselines/reference/for-of15.errors.txt @@ -1,12 +1,7 @@ -tests/cases/conformance/es6/for-ofStatements/for-of15.ts(2,11): error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. +tests/cases/conformance/es6/for-ofStatements/for-of15.ts(11,11): error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. ==== tests/cases/conformance/es6/for-ofStatements/for-of15.ts (1 errors) ==== - var v: string; - for (v of new StringIterator) { } // Should fail - ~~~~~~~~~~~~~~~~~~ -!!! error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. - class StringIterator { next() { return ""; @@ -14,4 +9,9 @@ tests/cases/conformance/es6/for-ofStatements/for-of15.ts(2,11): error TS2490: Th [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var v: string; + for (v of new StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~ +!!! error TS2490: The type returned by the 'next()' method of an iterator must have a 'value' property. \ No newline at end of file diff --git a/tests/baselines/reference/for-of15.js b/tests/baselines/reference/for-of15.js index 62232745c8c..f88c8640168 100644 --- a/tests/baselines/reference/for-of15.js +++ b/tests/baselines/reference/for-of15.js @@ -1,7 +1,4 @@ //// [for-of15.ts] -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { next() { return ""; @@ -9,11 +6,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should fail //// [for-of15.js] -var v; -for (v of new StringIterator) { } // Should fail class StringIterator { next() { return ""; @@ -22,3 +20,5 @@ class StringIterator { return this; } } +var v; +for (v of new StringIterator) { } // Should fail diff --git a/tests/baselines/reference/for-of16.errors.txt b/tests/baselines/reference/for-of16.errors.txt index 20e3e876537..7574f98e3d8 100644 --- a/tests/baselines/reference/for-of16.errors.txt +++ b/tests/baselines/reference/for-of16.errors.txt @@ -1,14 +1,14 @@ -tests/cases/conformance/es6/for-ofStatements/for-of16.ts(2,11): error TS2489: An iterator must have a 'next()' method. +tests/cases/conformance/es6/for-ofStatements/for-of16.ts(8,11): error TS2489: An iterator must have a 'next()' method. ==== tests/cases/conformance/es6/for-ofStatements/for-of16.ts (1 errors) ==== - var v: string; - for (v of new StringIterator) { } // Should fail - ~~~~~~~~~~~~~~~~~~ -!!! error TS2489: An iterator must have a 'next()' method. - class StringIterator { [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var v: string; + for (v of new StringIterator) { } // Should fail + ~~~~~~~~~~~~~~~~~~ +!!! error TS2489: An iterator must have a 'next()' method. \ No newline at end of file diff --git a/tests/baselines/reference/for-of16.js b/tests/baselines/reference/for-of16.js index 974be239fd7..2219e15a6f9 100644 --- a/tests/baselines/reference/for-of16.js +++ b/tests/baselines/reference/for-of16.js @@ -1,18 +1,18 @@ //// [for-of16.ts] -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should fail //// [for-of16.js] -var v; -for (v of new StringIterator) { } // Should fail class StringIterator { [Symbol.iterator]() { return this; } } +var v; +for (v of new StringIterator) { } // Should fail diff --git a/tests/baselines/reference/for-of17.errors.txt b/tests/baselines/reference/for-of17.errors.txt index dfdeb8db007..5a77815369f 100644 --- a/tests/baselines/reference/for-of17.errors.txt +++ b/tests/baselines/reference/for-of17.errors.txt @@ -1,12 +1,7 @@ -tests/cases/conformance/es6/for-ofStatements/for-of17.ts(2,6): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/es6/for-ofStatements/for-of17.ts(14,6): error TS2322: Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/es6/for-ofStatements/for-of17.ts (1 errors) ==== - var v: string; - for (v of new NumberIterator) { } // Should succeed - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. - class NumberIterator { next() { return { @@ -17,4 +12,9 @@ tests/cases/conformance/es6/for-ofStatements/for-of17.ts(2,6): error TS2322: Typ [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var v: string; + for (v of new NumberIterator) { } // Should succeed + ~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of17.js b/tests/baselines/reference/for-of17.js index a3927647005..2cd6bbe0d2e 100644 --- a/tests/baselines/reference/for-of17.js +++ b/tests/baselines/reference/for-of17.js @@ -1,7 +1,4 @@ //// [for-of17.ts] -var v: string; -for (v of new NumberIterator) { } // Should succeed - class NumberIterator { next() { return { @@ -12,11 +9,12 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new NumberIterator) { } // Should succeed //// [for-of17.js] -var v; -for (v of new NumberIterator) { } // Should succeed class NumberIterator { next() { return { @@ -28,3 +26,5 @@ class NumberIterator { return this; } } +var v; +for (v of new NumberIterator) { } // Should succeed diff --git a/tests/baselines/reference/for-of18.js b/tests/baselines/reference/for-of18.js index c31e6b6e8ca..fb7a684098a 100644 --- a/tests/baselines/reference/for-of18.js +++ b/tests/baselines/reference/for-of18.js @@ -1,7 +1,4 @@ //// [for-of18.ts] -var v: string; -for (v of new StringIterator) { } // Should succeed - class StringIterator { next() { return { @@ -12,11 +9,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var v: string; +for (v of new StringIterator) { } // Should succeed //// [for-of18.js] -var v; -for (v of new StringIterator) { } // Should succeed class StringIterator { next() { return { @@ -28,3 +26,5 @@ class StringIterator { return this; } } +var v; +for (v of new StringIterator) { } // Should succeed diff --git a/tests/baselines/reference/for-of18.symbols b/tests/baselines/reference/for-of18.symbols index b9d32662713..8f552c2757c 100644 --- a/tests/baselines/reference/for-of18.symbols +++ b/tests/baselines/reference/for-of18.symbols @@ -1,23 +1,16 @@ === tests/cases/conformance/es6/for-ofStatements/for-of18.ts === -var v: string; ->v : Symbol(v, Decl(for-of18.ts, 0, 3)) - -for (v of new StringIterator) { } // Should succeed ->v : Symbol(v, Decl(for-of18.ts, 0, 3)) ->StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) +>StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of18.ts, 3, 22)) +>next : Symbol(StringIterator.next, Decl(for-of18.ts, 0, 22)) return { value: "", ->value : Symbol(value, Decl(for-of18.ts, 5, 16)) +>value : Symbol(value, Decl(for-of18.ts, 2, 16)) done: false ->done : Symbol(done, Decl(for-of18.ts, 6, 22)) +>done : Symbol(done, Decl(for-of18.ts, 3, 22)) }; } @@ -27,6 +20,14 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of18.ts, 1, 33)) +>this : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) } } + +var v: string; +>v : Symbol(v, Decl(for-of18.ts, 12, 3)) + +for (v of new StringIterator) { } // Should succeed +>v : Symbol(v, Decl(for-of18.ts, 12, 3)) +>StringIterator : Symbol(StringIterator, Decl(for-of18.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of18.types b/tests/baselines/reference/for-of18.types index 86978b62cc7..8b70c446254 100644 --- a/tests/baselines/reference/for-of18.types +++ b/tests/baselines/reference/for-of18.types @@ -1,12 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of18.ts === -var v: string; ->v : string - -for (v of new StringIterator) { } // Should succeed ->v : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -35,3 +27,12 @@ class StringIterator { >this : this } } + +var v: string; +>v : string + +for (v of new StringIterator) { } // Should succeed +>v : string +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of19.js b/tests/baselines/reference/for-of19.js index d0f95caa1e2..c0000d8d107 100644 --- a/tests/baselines/reference/for-of19.js +++ b/tests/baselines/reference/for-of19.js @@ -1,8 +1,4 @@ //// [for-of19.ts] -for (var v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (var v of new FooIterator) { + v; } //// [for-of19.js] -for (var v of new FooIterator) { - v; -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (var v of new FooIterator) { + v; +} diff --git a/tests/baselines/reference/for-of19.symbols b/tests/baselines/reference/for-of19.symbols index e1a129aa324..f36dd74f9b9 100644 --- a/tests/baselines/reference/for-of19.symbols +++ b/tests/baselines/reference/for-of19.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of19.ts === -for (var v of new FooIterator) { ->v : Symbol(v, Decl(for-of19.ts, 0, 8)) ->FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) - - v; ->v : Symbol(v, Decl(for-of19.ts, 0, 8)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of19.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of19.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of19.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of19.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of19.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of19.ts, 2, 1)) +>value : Symbol(value, Decl(for-of19.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of19.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of19.ts, 8, 27)) +>done : Symbol(done, Decl(for-of19.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of19.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of19.ts, 0, 13)) } } + +for (var v of new FooIterator) { +>v : Symbol(v, Decl(for-of19.ts, 13, 8)) +>FooIterator : Symbol(FooIterator, Decl(for-of19.ts, 0, 13)) + + v; +>v : Symbol(v, Decl(for-of19.ts, 13, 8)) +} diff --git a/tests/baselines/reference/for-of19.types b/tests/baselines/reference/for-of19.types index a2882ccf1ac..a62b2d64c8e 100644 --- a/tests/baselines/reference/for-of19.types +++ b/tests/baselines/reference/for-of19.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of19.ts === -for (var v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - v; ->v : Foo -} - class Foo { } >Foo : Foo @@ -40,3 +31,12 @@ class FooIterator { >this : this } } + +for (var v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} diff --git a/tests/baselines/reference/for-of20.js b/tests/baselines/reference/for-of20.js index c098abd2f73..97259778d26 100644 --- a/tests/baselines/reference/for-of20.js +++ b/tests/baselines/reference/for-of20.js @@ -1,8 +1,4 @@ //// [for-of20.ts] -for (let v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (let v of new FooIterator) { + v; } //// [for-of20.js] -for (let v of new FooIterator) { - v; -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (let v of new FooIterator) { + v; +} diff --git a/tests/baselines/reference/for-of20.symbols b/tests/baselines/reference/for-of20.symbols index 20b444e6bcc..5fff9fd7871 100644 --- a/tests/baselines/reference/for-of20.symbols +++ b/tests/baselines/reference/for-of20.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of20.ts === -for (let v of new FooIterator) { ->v : Symbol(v, Decl(for-of20.ts, 0, 8)) ->FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) - - v; ->v : Symbol(v, Decl(for-of20.ts, 0, 8)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of20.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of20.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of20.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of20.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of20.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of20.ts, 2, 1)) +>value : Symbol(value, Decl(for-of20.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of20.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of20.ts, 8, 27)) +>done : Symbol(done, Decl(for-of20.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of20.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of20.ts, 0, 13)) } } + +for (let v of new FooIterator) { +>v : Symbol(v, Decl(for-of20.ts, 13, 8)) +>FooIterator : Symbol(FooIterator, Decl(for-of20.ts, 0, 13)) + + v; +>v : Symbol(v, Decl(for-of20.ts, 13, 8)) +} diff --git a/tests/baselines/reference/for-of20.types b/tests/baselines/reference/for-of20.types index 9274c7f4b96..e620b603107 100644 --- a/tests/baselines/reference/for-of20.types +++ b/tests/baselines/reference/for-of20.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of20.ts === -for (let v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - v; ->v : Foo -} - class Foo { } >Foo : Foo @@ -40,3 +31,12 @@ class FooIterator { >this : this } } + +for (let v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} diff --git a/tests/baselines/reference/for-of21.js b/tests/baselines/reference/for-of21.js index 27da28e3b4f..66791de89b3 100644 --- a/tests/baselines/reference/for-of21.js +++ b/tests/baselines/reference/for-of21.js @@ -1,8 +1,4 @@ //// [for-of21.ts] -for (const v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + v; } //// [for-of21.js] -for (const v of new FooIterator) { - v; -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (const v of new FooIterator) { + v; +} diff --git a/tests/baselines/reference/for-of21.symbols b/tests/baselines/reference/for-of21.symbols index 71403edfc9e..0068c9ef4a8 100644 --- a/tests/baselines/reference/for-of21.symbols +++ b/tests/baselines/reference/for-of21.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of21.ts === -for (const v of new FooIterator) { ->v : Symbol(v, Decl(for-of21.ts, 0, 10)) ->FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) - - v; ->v : Symbol(v, Decl(for-of21.ts, 0, 10)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of21.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of21.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of21.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of21.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of21.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of21.ts, 2, 1)) +>value : Symbol(value, Decl(for-of21.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of21.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of21.ts, 8, 27)) +>done : Symbol(done, Decl(for-of21.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of21.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of21.ts, 0, 13)) } } + +for (const v of new FooIterator) { +>v : Symbol(v, Decl(for-of21.ts, 13, 10)) +>FooIterator : Symbol(FooIterator, Decl(for-of21.ts, 0, 13)) + + v; +>v : Symbol(v, Decl(for-of21.ts, 13, 10)) +} diff --git a/tests/baselines/reference/for-of21.types b/tests/baselines/reference/for-of21.types index 1366cb1a420..59c66b2a41e 100644 --- a/tests/baselines/reference/for-of21.types +++ b/tests/baselines/reference/for-of21.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of21.ts === -for (const v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - v; ->v : Foo -} - class Foo { } >Foo : Foo @@ -40,3 +31,12 @@ class FooIterator { >this : this } } + +for (const v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + v; +>v : Foo +} diff --git a/tests/baselines/reference/for-of22.js b/tests/baselines/reference/for-of22.js index 886e8dba7c3..767ed1cc15d 100644 --- a/tests/baselines/reference/for-of22.js +++ b/tests/baselines/reference/for-of22.js @@ -1,9 +1,4 @@ //// [for-of22.ts] -v; -for (var v of new FooIterator) { - -} - class Foo { } class FooIterator { next() { @@ -15,12 +10,14 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +v; +for (var v of new FooIterator) { + } //// [for-of22.js] -v; -for (var v of new FooIterator) { -} class Foo { } class FooIterator { @@ -34,3 +31,6 @@ class FooIterator { return this; } } +v; +for (var v of new FooIterator) { +} diff --git a/tests/baselines/reference/for-of22.symbols b/tests/baselines/reference/for-of22.symbols index 36a522759cf..929cae4ed77 100644 --- a/tests/baselines/reference/for-of22.symbols +++ b/tests/baselines/reference/for-of22.symbols @@ -1,29 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of22.ts === -v; ->v : Symbol(v, Decl(for-of22.ts, 1, 8)) - -for (var v of new FooIterator) { ->v : Symbol(v, Decl(for-of22.ts, 1, 8)) ->FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) - -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of22.ts, 3, 1)) +>Foo : Symbol(Foo, Decl(for-of22.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of22.ts, 6, 19)) +>next : Symbol(FooIterator.next, Decl(for-of22.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of22.ts, 8, 16)) ->Foo : Symbol(Foo, Decl(for-of22.ts, 3, 1)) +>value : Symbol(value, Decl(for-of22.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of22.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of22.ts, 9, 27)) +>done : Symbol(done, Decl(for-of22.ts, 4, 27)) }; } @@ -33,6 +24,15 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of22.ts, 5, 13)) +>this : Symbol(FooIterator, Decl(for-of22.ts, 0, 13)) } } + +v; +>v : Symbol(v, Decl(for-of22.ts, 14, 8)) + +for (var v of new FooIterator) { +>v : Symbol(v, Decl(for-of22.ts, 14, 8)) +>FooIterator : Symbol(FooIterator, Decl(for-of22.ts, 0, 13)) + +} diff --git a/tests/baselines/reference/for-of22.types b/tests/baselines/reference/for-of22.types index 80cd42b2b33..e1449875da5 100644 --- a/tests/baselines/reference/for-of22.types +++ b/tests/baselines/reference/for-of22.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of22.ts === -v; ->v : Foo - -for (var v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - -} - class Foo { } >Foo : Foo @@ -41,3 +31,13 @@ class FooIterator { >this : this } } + +v; +>v : Foo + +for (var v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + +} diff --git a/tests/baselines/reference/for-of23.js b/tests/baselines/reference/for-of23.js index f5649128c11..9ad03c0109a 100644 --- a/tests/baselines/reference/for-of23.js +++ b/tests/baselines/reference/for-of23.js @@ -1,8 +1,4 @@ //// [for-of23.ts] -for (const v of new FooIterator) { - const v = 0; // new scope -} - class Foo { } class FooIterator { next() { @@ -14,12 +10,13 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + const v = 0; // new scope } //// [for-of23.js] -for (const v of new FooIterator) { - const v = 0; // new scope -} class Foo { } class FooIterator { @@ -33,3 +30,6 @@ class FooIterator { return this; } } +for (const v of new FooIterator) { + const v = 0; // new scope +} diff --git a/tests/baselines/reference/for-of23.symbols b/tests/baselines/reference/for-of23.symbols index 3be07f4fd4a..7a57e38baf7 100644 --- a/tests/baselines/reference/for-of23.symbols +++ b/tests/baselines/reference/for-of23.symbols @@ -1,28 +1,20 @@ === tests/cases/conformance/es6/for-ofStatements/for-of23.ts === -for (const v of new FooIterator) { ->v : Symbol(v, Decl(for-of23.ts, 0, 10)) ->FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) - - const v = 0; // new scope ->v : Symbol(v, Decl(for-of23.ts, 1, 9)) -} - class Foo { } ->Foo : Symbol(Foo, Decl(for-of23.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(for-of23.ts, 0, 0)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) +>FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 0, 13)) next() { ->next : Symbol(FooIterator.next, Decl(for-of23.ts, 5, 19)) +>next : Symbol(FooIterator.next, Decl(for-of23.ts, 1, 19)) return { value: new Foo, ->value : Symbol(value, Decl(for-of23.ts, 7, 16)) ->Foo : Symbol(Foo, Decl(for-of23.ts, 2, 1)) +>value : Symbol(value, Decl(for-of23.ts, 3, 16)) +>Foo : Symbol(Foo, Decl(for-of23.ts, 0, 0)) done: false ->done : Symbol(done, Decl(for-of23.ts, 8, 27)) +>done : Symbol(done, Decl(for-of23.ts, 4, 27)) }; } @@ -32,6 +24,14 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(for-of23.ts, 4, 13)) +>this : Symbol(FooIterator, Decl(for-of23.ts, 0, 13)) } } + +for (const v of new FooIterator) { +>v : Symbol(v, Decl(for-of23.ts, 13, 10)) +>FooIterator : Symbol(FooIterator, Decl(for-of23.ts, 0, 13)) + + const v = 0; // new scope +>v : Symbol(v, Decl(for-of23.ts, 14, 9)) +} diff --git a/tests/baselines/reference/for-of23.types b/tests/baselines/reference/for-of23.types index ed74156f514..427eb57f5a1 100644 --- a/tests/baselines/reference/for-of23.types +++ b/tests/baselines/reference/for-of23.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of23.ts === -for (const v of new FooIterator) { ->v : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - - const v = 0; // new scope ->v : 0 ->0 : 0 -} - class Foo { } >Foo : Foo @@ -41,3 +31,13 @@ class FooIterator { >this : this } } + +for (const v of new FooIterator) { +>v : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + + const v = 0; // new scope +>v : 0 +>0 : 0 +} diff --git a/tests/baselines/reference/for-of25.js b/tests/baselines/reference/for-of25.js index 5715f6e8a3a..032efa52ae3 100644 --- a/tests/baselines/reference/for-of25.js +++ b/tests/baselines/reference/for-of25.js @@ -1,18 +1,18 @@ //// [for-of25.ts] -var x: any; -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return x; } -} +} + +var x: any; +for (var v of new StringIterator) { } //// [for-of25.js] -var x; -for (var v of new StringIterator) { } class StringIterator { [Symbol.iterator]() { return x; } } +var x; +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of25.symbols b/tests/baselines/reference/for-of25.symbols index e21348ba565..e9304e517bd 100644 --- a/tests/baselines/reference/for-of25.symbols +++ b/tests/baselines/reference/for-of25.symbols @@ -1,13 +1,6 @@ === tests/cases/conformance/es6/for-ofStatements/for-of25.ts === -var x: any; ->x : Symbol(x, Decl(for-of25.ts, 0, 3)) - -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of25.ts, 1, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 1, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 0, 0)) [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -15,6 +8,14 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return x; ->x : Symbol(x, Decl(for-of25.ts, 0, 3)) +>x : Symbol(x, Decl(for-of25.ts, 6, 3)) } } + +var x: any; +>x : Symbol(x, Decl(for-of25.ts, 6, 3)) + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of25.ts, 7, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of25.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of25.types b/tests/baselines/reference/for-of25.types index c4d6b32aebc..7a11b7acf67 100644 --- a/tests/baselines/reference/for-of25.types +++ b/tests/baselines/reference/for-of25.types @@ -1,12 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of25.ts === -var x: any; ->x : any - -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -19,3 +11,12 @@ class StringIterator { >x : any } } + +var x: any; +>x : any + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of26.js b/tests/baselines/reference/for-of26.js index 33319f50efa..ab9c4fdca92 100644 --- a/tests/baselines/reference/for-of26.js +++ b/tests/baselines/reference/for-of26.js @@ -1,7 +1,4 @@ //// [for-of26.ts] -var x: any; -for (var v of new StringIterator) { } - class StringIterator { next() { return x; @@ -9,11 +6,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +var x: any; +for (var v of new StringIterator) { } //// [for-of26.js] -var x; -for (var v of new StringIterator) { } class StringIterator { next() { return x; @@ -22,3 +20,5 @@ class StringIterator { return this; } } +var x; +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of26.symbols b/tests/baselines/reference/for-of26.symbols index 947240bf8e3..20473898253 100644 --- a/tests/baselines/reference/for-of26.symbols +++ b/tests/baselines/reference/for-of26.symbols @@ -1,19 +1,12 @@ === tests/cases/conformance/es6/for-ofStatements/for-of26.ts === -var x: any; ->x : Symbol(x, Decl(for-of26.ts, 0, 3)) - -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of26.ts, 1, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) next() { ->next : Symbol(StringIterator.next, Decl(for-of26.ts, 3, 22)) +>next : Symbol(StringIterator.next, Decl(for-of26.ts, 0, 22)) return x; ->x : Symbol(x, Decl(for-of26.ts, 0, 3)) +>x : Symbol(x, Decl(for-of26.ts, 9, 3)) } [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -21,6 +14,14 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of26.ts, 1, 37)) +>this : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) } } + +var x: any; +>x : Symbol(x, Decl(for-of26.ts, 9, 3)) + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of26.ts, 10, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of26.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of26.types b/tests/baselines/reference/for-of26.types index fe930e2e57f..b0cfd891741 100644 --- a/tests/baselines/reference/for-of26.types +++ b/tests/baselines/reference/for-of26.types @@ -1,12 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of26.ts === -var x: any; ->x : any - -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -25,3 +17,12 @@ class StringIterator { >this : this } } + +var x: any; +>x : any + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of27.js b/tests/baselines/reference/for-of27.js index 1ac3a1dfc42..6adc66e241b 100644 --- a/tests/baselines/reference/for-of27.js +++ b/tests/baselines/reference/for-of27.js @@ -1,11 +1,11 @@ //// [for-of27.ts] -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]: any; -} +} + +for (var v of new StringIterator) { } //// [for-of27.js] -for (var v of new StringIterator) { } class StringIterator { } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of27.symbols b/tests/baselines/reference/for-of27.symbols index b2b733ab13b..4799a138351 100644 --- a/tests/baselines/reference/for-of27.symbols +++ b/tests/baselines/reference/for-of27.symbols @@ -1,13 +1,14 @@ === tests/cases/conformance/es6/for-ofStatements/for-of27.ts === -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of27.ts, 0, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 0)) [Symbol.iterator]: any; >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) } + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of27.ts, 4, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of27.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of27.types b/tests/baselines/reference/for-of27.types index 8e9130ce272..f6115ccf8ce 100644 --- a/tests/baselines/reference/for-of27.types +++ b/tests/baselines/reference/for-of27.types @@ -1,9 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of27.ts === -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -12,3 +7,9 @@ class StringIterator { >Symbol : SymbolConstructor >iterator : symbol } + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of28.js b/tests/baselines/reference/for-of28.js index 78e86774813..e06e2fc6abc 100644 --- a/tests/baselines/reference/for-of28.js +++ b/tests/baselines/reference/for-of28.js @@ -1,17 +1,17 @@ //// [for-of28.ts] -for (var v of new StringIterator) { } - class StringIterator { next: any; [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of28.js] -for (var v of new StringIterator) { } class StringIterator { [Symbol.iterator]() { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of28.symbols b/tests/baselines/reference/for-of28.symbols index 52ed4fd7459..ad5ea53a80e 100644 --- a/tests/baselines/reference/for-of28.symbols +++ b/tests/baselines/reference/for-of28.symbols @@ -1,13 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of28.ts === -for (var v of new StringIterator) { } ->v : Symbol(v, Decl(for-of28.ts, 0, 8)) ->StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) - class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) +>StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) next: any; ->next : Symbol(StringIterator.next, Decl(for-of28.ts, 2, 22)) +>next : Symbol(StringIterator.next, Decl(for-of28.ts, 0, 22)) [Symbol.iterator]() { >Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) @@ -15,6 +11,11 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(for-of28.ts, 0, 37)) +>this : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) } } + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(for-of28.ts, 7, 8)) +>StringIterator : Symbol(StringIterator, Decl(for-of28.ts, 0, 0)) + diff --git a/tests/baselines/reference/for-of28.types b/tests/baselines/reference/for-of28.types index 882d2df6186..a454a0c4485 100644 --- a/tests/baselines/reference/for-of28.types +++ b/tests/baselines/reference/for-of28.types @@ -1,9 +1,4 @@ === tests/cases/conformance/es6/for-ofStatements/for-of28.ts === -for (var v of new StringIterator) { } ->v : any ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class StringIterator { >StringIterator : StringIterator @@ -19,3 +14,9 @@ class StringIterator { >this : this } } + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/for-of30.errors.txt b/tests/baselines/reference/for-of30.errors.txt index 6434b5294d5..b0091c90b57 100644 --- a/tests/baselines/reference/for-of30.errors.txt +++ b/tests/baselines/reference/for-of30.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/for-ofStatements/for-of30.ts(16,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. Type '() => StringIterator' is not assignable to type '() => Iterator'. Type 'StringIterator' is not assignable to type 'Iterator'. @@ -7,15 +7,6 @@ tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Ty ==== tests/cases/conformance/es6/for-ofStatements/for-of30.ts (1 errors) ==== - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. -!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. -!!! error TS2322: Types of property 'return' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult'. - class StringIterator { next() { return { @@ -29,4 +20,13 @@ tests/cases/conformance/es6/for-ofStatements/for-of30.ts(1,15): error TS2322: Ty [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'return' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type '(value?: any) => IteratorResult'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of30.js b/tests/baselines/reference/for-of30.js index 37316774c95..935944db640 100644 --- a/tests/baselines/reference/for-of30.js +++ b/tests/baselines/reference/for-of30.js @@ -1,6 +1,4 @@ //// [for-of30.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -14,10 +12,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of30.js] -for (var v of new StringIterator) { } class StringIterator { constructor() { this.return = 0; @@ -32,3 +31,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of31.errors.txt b/tests/baselines/reference/for-of31.errors.txt index 6d5f6e816be..bf38e0f5008 100644 --- a/tests/baselines/reference/for-of31.errors.txt +++ b/tests/baselines/reference/for-of31.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/for-ofStatements/for-of31.ts(14,15): error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. Type '() => StringIterator' is not assignable to type '() => Iterator'. Type 'StringIterator' is not assignable to type 'Iterator'. @@ -9,17 +9,6 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty ==== tests/cases/conformance/es6/for-ofStatements/for-of31.ts (1 errors) ==== - for (var v of new StringIterator) { } - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. -!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. -!!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult'. -!!! error TS2322: Property 'done' is missing in type '{ value: string; }'. - class StringIterator { next() { return { @@ -31,4 +20,15 @@ tests/cases/conformance/es6/for-ofStatements/for-of31.ts(1,15): error TS2322: Ty [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => StringIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'StringIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '() => { value: string; }' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type '{ value: string; }' is not assignable to type 'IteratorResult'. +!!! error TS2322: Property 'done' is missing in type '{ value: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/for-of31.js b/tests/baselines/reference/for-of31.js index a92e827b91e..84e24bed5a9 100644 --- a/tests/baselines/reference/for-of31.js +++ b/tests/baselines/reference/for-of31.js @@ -1,6 +1,4 @@ //// [for-of31.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -12,10 +10,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of31.js] -for (var v of new StringIterator) { } class StringIterator { next() { return { @@ -27,3 +26,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of33.errors.txt b/tests/baselines/reference/for-of33.errors.txt index ff1feacd7b3..eba30ce9bf9 100644 --- a/tests/baselines/reference/for-of33.errors.txt +++ b/tests/baselines/reference/for-of33.errors.txt @@ -1,16 +1,16 @@ -tests/cases/conformance/es6/for-ofStatements/for-of33.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/es6/for-ofStatements/for-of33.ts(4,5): error TS7023: '[Symbol.iterator]' 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. +tests/cases/conformance/es6/for-ofStatements/for-of33.ts(2,5): error TS7023: '[Symbol.iterator]' 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. +tests/cases/conformance/es6/for-ofStatements/for-of33.ts(7,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. ==== tests/cases/conformance/es6/for-ofStatements/for-of33.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~ -!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - class StringIterator { [Symbol.iterator]() { ~~~~~~~~~~~~~~~~~ !!! error TS7023: '[Symbol.iterator]' 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. return v; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of33.js b/tests/baselines/reference/for-of33.js index b63aeedf774..e77d3cf5de8 100644 --- a/tests/baselines/reference/for-of33.js +++ b/tests/baselines/reference/for-of33.js @@ -1,16 +1,16 @@ //// [for-of33.ts] -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return v; } -} +} + +for (var v of new StringIterator) { } //// [for-of33.js] -for (var v of new StringIterator) { } class StringIterator { [Symbol.iterator]() { return v; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of34.errors.txt b/tests/baselines/reference/for-of34.errors.txt index c378a8f5bb8..2d53ecb0a20 100644 --- a/tests/baselines/reference/for-of34.errors.txt +++ b/tests/baselines/reference/for-of34.errors.txt @@ -1,12 +1,8 @@ -tests/cases/conformance/es6/for-ofStatements/for-of34.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/es6/for-ofStatements/for-of34.ts(4,5): error TS7023: 'next' 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. +tests/cases/conformance/es6/for-ofStatements/for-of34.ts(2,5): error TS7023: 'next' 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. +tests/cases/conformance/es6/for-ofStatements/for-of34.ts(11,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. ==== tests/cases/conformance/es6/for-ofStatements/for-of34.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~ -!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - class StringIterator { next() { ~~~~ @@ -17,4 +13,8 @@ tests/cases/conformance/es6/for-ofStatements/for-of34.ts(4,5): error TS7023: 'ne [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of34.js b/tests/baselines/reference/for-of34.js index f61f04ea955..2d9af61d1a3 100644 --- a/tests/baselines/reference/for-of34.js +++ b/tests/baselines/reference/for-of34.js @@ -1,6 +1,4 @@ //// [for-of34.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return v; @@ -9,10 +7,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of34.js] -for (var v of new StringIterator) { } class StringIterator { next() { return v; @@ -21,3 +20,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/for-of35.errors.txt b/tests/baselines/reference/for-of35.errors.txt index 58fb5056fd7..6f14a24fb96 100644 --- a/tests/baselines/reference/for-of35.errors.txt +++ b/tests/baselines/reference/for-of35.errors.txt @@ -1,12 +1,8 @@ -tests/cases/conformance/es6/for-ofStatements/for-of35.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -tests/cases/conformance/es6/for-ofStatements/for-of35.ts(4,5): error TS7023: 'next' 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. +tests/cases/conformance/es6/for-ofStatements/for-of35.ts(2,5): error TS7023: 'next' 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. +tests/cases/conformance/es6/for-ofStatements/for-of35.ts(14,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. ==== tests/cases/conformance/es6/for-ofStatements/for-of35.ts (2 errors) ==== - for (var v of new StringIterator) { } - ~ -!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - class StringIterator { next() { ~~~~ @@ -20,4 +16,8 @@ tests/cases/conformance/es6/for-ofStatements/for-of35.ts(4,5): error TS7023: 'ne [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + for (var v of new StringIterator) { } + ~ +!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. \ No newline at end of file diff --git a/tests/baselines/reference/for-of35.js b/tests/baselines/reference/for-of35.js index c7d7c5890dd..a73f873d7ce 100644 --- a/tests/baselines/reference/for-of35.js +++ b/tests/baselines/reference/for-of35.js @@ -1,6 +1,4 @@ //// [for-of35.ts] -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -12,10 +10,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +for (var v of new StringIterator) { } //// [for-of35.js] -for (var v of new StringIterator) { } class StringIterator { next() { return { @@ -27,3 +26,4 @@ class StringIterator { return this; } } +for (var v of new StringIterator) { } diff --git a/tests/baselines/reference/iterableArrayPattern1.js b/tests/baselines/reference/iterableArrayPattern1.js index b45ac92d1fd..6061b9950da 100644 --- a/tests/baselines/reference/iterableArrayPattern1.js +++ b/tests/baselines/reference/iterableArrayPattern1.js @@ -1,5 +1,4 @@ //// [iterableArrayPattern1.ts] -var [a, b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var [a, b] = new SymbolIterator; //// [iterableArrayPattern1.js] -var [a, b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -26,3 +26,4 @@ class SymbolIterator { return this; } } +var [a, b] = new SymbolIterator; diff --git a/tests/baselines/reference/iterableArrayPattern1.symbols b/tests/baselines/reference/iterableArrayPattern1.symbols index 4921fc8ec9c..b901b43b7b9 100644 --- a/tests/baselines/reference/iterableArrayPattern1.symbols +++ b/tests/baselines/reference/iterableArrayPattern1.symbols @@ -1,22 +1,17 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts === -var [a, b] = new SymbolIterator; ->a : Symbol(a, Decl(iterableArrayPattern1.ts, 0, 5)) ->b : Symbol(b, Decl(iterableArrayPattern1.ts, 0, 7)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern1.ts, 1, 22)) +>next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern1.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iterableArrayPattern1.ts, 3, 16)) +>value : Symbol(value, Decl(iterableArrayPattern1.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iterableArrayPattern1.ts, 4, 28)) +>done : Symbol(done, Decl(iterableArrayPattern1.ts, 3, 28)) }; } @@ -27,6 +22,12 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 32)) +>this : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 0)) } } + +var [a, b] = new SymbolIterator; +>a : Symbol(a, Decl(iterableArrayPattern1.ts, 13, 5)) +>b : Symbol(b, Decl(iterableArrayPattern1.ts, 13, 7)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern1.ts, 0, 0)) + diff --git a/tests/baselines/reference/iterableArrayPattern1.types b/tests/baselines/reference/iterableArrayPattern1.types index 816ce7ac6cf..e7d307b2cb9 100644 --- a/tests/baselines/reference/iterableArrayPattern1.types +++ b/tests/baselines/reference/iterableArrayPattern1.types @@ -1,10 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts === -var [a, b] = new SymbolIterator; ->a : symbol ->b : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -35,3 +29,10 @@ class SymbolIterator { >this : this } } + +var [a, b] = new SymbolIterator; +>a : symbol +>b : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iterableArrayPattern10.errors.txt b/tests/baselines/reference/iterableArrayPattern10.errors.txt index f06c4d7de17..f0b3e14c9fd 100644 --- a/tests/baselines/reference/iterableArrayPattern10.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern10.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(17,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. Property '0' is missing in type 'FooIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts (1 errors) ==== - function fun([a, b]) { } - fun(new FooIterator); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. -!!! error TS2345: Property '0' is missing in type 'FooIterator'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun([a, b]) { } + fun(new FooIterator); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'. +!!! error TS2345: Property '0' is missing in type 'FooIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern10.js b/tests/baselines/reference/iterableArrayPattern10.js index c8d37e3f894..530a21d6a16 100644 --- a/tests/baselines/reference/iterableArrayPattern10.js +++ b/tests/baselines/reference/iterableArrayPattern10.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern10.ts] -function fun([a, b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, b]) { } +fun(new FooIterator); //// [iterableArrayPattern10.js] -function fun([a, b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern11.js b/tests/baselines/reference/iterableArrayPattern11.js index 85ed4ab9710..92a9d9e200a 100644 --- a/tests/baselines/reference/iterableArrayPattern11.js +++ b/tests/baselines/reference/iterableArrayPattern11.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern11.ts] -function fun([a, b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,13 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, b] = new FooIterator) { } +fun(new FooIterator); + //// [iterableArrayPattern11.js] -function fun([a, b] = new FooIterator) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +34,5 @@ class FooIterator { return this; } } +function fun([a, b] = new FooIterator) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern11.symbols b/tests/baselines/reference/iterableArrayPattern11.symbols index e1b3713f9dd..36871283fbf 100644 --- a/tests/baselines/reference/iterableArrayPattern11.symbols +++ b/tests/baselines/reference/iterableArrayPattern11.symbols @@ -1,36 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts === -function fun([a, b] = new FooIterator) { } ->fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 0, 0)) ->a : Symbol(a, Decl(iterableArrayPattern11.ts, 0, 14)) ->b : Symbol(b, Decl(iterableArrayPattern11.ts, 0, 16)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) - -fun(new FooIterator); ->fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 0, 0)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 1, 21)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern11.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern11.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 1, 21)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern11.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern11.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern11.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern11.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern11.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern11.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern11.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern11.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern11.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern11.ts, 5, 27)) }; } @@ -41,6 +31,17 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) } } + +function fun([a, b] = new FooIterator) { } +>fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 13, 1)) +>a : Symbol(a, Decl(iterableArrayPattern11.ts, 15, 14)) +>b : Symbol(b, Decl(iterableArrayPattern11.ts, 15, 16)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) + +fun(new FooIterator); +>fun : Symbol(fun, Decl(iterableArrayPattern11.ts, 13, 1)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern11.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern11.types b/tests/baselines/reference/iterableArrayPattern11.types index 0acadd7cfc8..d3fa43d2f1b 100644 --- a/tests/baselines/reference/iterableArrayPattern11.types +++ b/tests/baselines/reference/iterableArrayPattern11.types @@ -1,17 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts === -function fun([a, b] = new FooIterator) { } ->fun : ([a, b]?: FooIterator) => void ->a : Foo ->b : Foo ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - -fun(new FooIterator); ->fun(new FooIterator) : void ->fun : ([a, b]?: FooIterator) => void ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -51,3 +38,17 @@ class FooIterator { >this : this } } + +function fun([a, b] = new FooIterator) { } +>fun : ([a, b]?: FooIterator) => void +>a : Foo +>b : Foo +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + +fun(new FooIterator); +>fun(new FooIterator) : void +>fun : ([a, b]?: FooIterator) => void +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern12.js b/tests/baselines/reference/iterableArrayPattern12.js index 4856af9cb48..89694ffa0cd 100644 --- a/tests/baselines/reference/iterableArrayPattern12.js +++ b/tests/baselines/reference/iterableArrayPattern12.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern12.ts] -function fun([a, ...b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, ...b] = new FooIterator) { } +fun(new FooIterator); //// [iterableArrayPattern12.js] -function fun([a, ...b] = new FooIterator) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, ...b] = new FooIterator) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern12.symbols b/tests/baselines/reference/iterableArrayPattern12.symbols index 4044544d17b..cb876370876 100644 --- a/tests/baselines/reference/iterableArrayPattern12.symbols +++ b/tests/baselines/reference/iterableArrayPattern12.symbols @@ -1,36 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts === -function fun([a, ...b] = new FooIterator) { } ->fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 0, 0)) ->a : Symbol(a, Decl(iterableArrayPattern12.ts, 0, 14)) ->b : Symbol(b, Decl(iterableArrayPattern12.ts, 0, 16)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) - -fun(new FooIterator); ->fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 0, 0)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 1, 21)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern12.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern12.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 1, 21)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern12.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern12.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern12.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern12.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern12.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern12.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern12.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern12.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern12.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern12.ts, 5, 27)) }; } @@ -41,6 +31,17 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) } } + +function fun([a, ...b] = new FooIterator) { } +>fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 13, 1)) +>a : Symbol(a, Decl(iterableArrayPattern12.ts, 15, 14)) +>b : Symbol(b, Decl(iterableArrayPattern12.ts, 15, 16)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) + +fun(new FooIterator); +>fun : Symbol(fun, Decl(iterableArrayPattern12.ts, 13, 1)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern12.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern12.types b/tests/baselines/reference/iterableArrayPattern12.types index c00e1daae81..3c50058b3e0 100644 --- a/tests/baselines/reference/iterableArrayPattern12.types +++ b/tests/baselines/reference/iterableArrayPattern12.types @@ -1,17 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts === -function fun([a, ...b] = new FooIterator) { } ->fun : ([a, ...b]?: FooIterator) => void ->a : Foo ->b : Foo[] ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - -fun(new FooIterator); ->fun(new FooIterator) : void ->fun : ([a, ...b]?: FooIterator) => void ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -51,3 +38,17 @@ class FooIterator { >this : this } } + +function fun([a, ...b] = new FooIterator) { } +>fun : ([a, ...b]?: FooIterator) => void +>a : Foo +>b : Foo[] +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + +fun(new FooIterator); +>fun(new FooIterator) : void +>fun : ([a, ...b]?: FooIterator) => void +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern13.js b/tests/baselines/reference/iterableArrayPattern13.js index 06f9901a851..efbce2bfd13 100644 --- a/tests/baselines/reference/iterableArrayPattern13.js +++ b/tests/baselines/reference/iterableArrayPattern13.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern13.ts] -function fun([a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, ...b]) { } +fun(new FooIterator); //// [iterableArrayPattern13.js] -function fun([a, ...b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, ...b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern13.symbols b/tests/baselines/reference/iterableArrayPattern13.symbols index c04d66fa6d4..25241ab24b8 100644 --- a/tests/baselines/reference/iterableArrayPattern13.symbols +++ b/tests/baselines/reference/iterableArrayPattern13.symbols @@ -1,35 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts === -function fun([a, ...b]) { } ->fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 0, 0)) ->a : Symbol(a, Decl(iterableArrayPattern13.ts, 0, 14)) ->b : Symbol(b, Decl(iterableArrayPattern13.ts, 0, 16)) - -fun(new FooIterator); ->fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 0, 0)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 1, 21)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern13.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern13.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 1, 21)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern13.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern13.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern13.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern13.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern13.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern13.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern13.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern13.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern13.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern13.ts, 5, 27)) }; } @@ -40,6 +31,16 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 1, 27)) } } + +function fun([a, ...b]) { } +>fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 13, 1)) +>a : Symbol(a, Decl(iterableArrayPattern13.ts, 15, 14)) +>b : Symbol(b, Decl(iterableArrayPattern13.ts, 15, 16)) + +fun(new FooIterator); +>fun : Symbol(fun, Decl(iterableArrayPattern13.ts, 13, 1)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern13.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern13.types b/tests/baselines/reference/iterableArrayPattern13.types index 04dab57748d..724a0795efa 100644 --- a/tests/baselines/reference/iterableArrayPattern13.types +++ b/tests/baselines/reference/iterableArrayPattern13.types @@ -1,15 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts === -function fun([a, ...b]) { } ->fun : ([a, ...b]: Iterable) => void ->a : any ->b : any[] - -fun(new FooIterator); ->fun(new FooIterator) : void ->fun : ([a, ...b]: Iterable) => void ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -49,3 +38,15 @@ class FooIterator { >this : this } } + +function fun([a, ...b]) { } +>fun : ([a, ...b]: Iterable) => void +>a : any +>b : any[] + +fun(new FooIterator); +>fun(new FooIterator) : void +>fun : ([a, ...b]: Iterable) => void +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern14.errors.txt b/tests/baselines/reference/iterableArrayPattern14.errors.txt index a14ddc45022..664f73e13a0 100644 --- a/tests/baselines/reference/iterableArrayPattern14.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern14.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts (1 errors) ==== - function fun(...[a, ...b]) { } - ~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts(1,17): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[a, ...b]) { } + ~~~~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(new FooIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern14.js b/tests/baselines/reference/iterableArrayPattern14.js index a3595b0df0c..bb1d416f4f2 100644 --- a/tests/baselines/reference/iterableArrayPattern14.js +++ b/tests/baselines/reference/iterableArrayPattern14.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern14.ts] -function fun(...[a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[a, ...b]) { } +fun(new FooIterator); //// [iterableArrayPattern14.js] -function fun(...[a, ...b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun(...[a, ...b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern15.errors.txt b/tests/baselines/reference/iterableArrayPattern15.errors.txt index bb2d1eb096d..ce7559de94f 100644 --- a/tests/baselines/reference/iterableArrayPattern15.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern15.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts (1 errors) ==== - function fun(...[a, b]: Bar[]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(...new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts(1,17): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[a, b]: Bar[]) { } + ~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(...new FooIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern15.js b/tests/baselines/reference/iterableArrayPattern15.js index 1c2050129ce..d14fd1b364e 100644 --- a/tests/baselines/reference/iterableArrayPattern15.js +++ b/tests/baselines/reference/iterableArrayPattern15.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern15.ts] -function fun(...[a, b]: Bar[]) { } -fun(...new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[a, b]: Bar[]) { } +fun(...new FooIterator); //// [iterableArrayPattern15.js] -function fun(...[a, b]) { } -fun(...new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun(...[a, b]) { } +fun(...new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern16.errors.txt b/tests/baselines/reference/iterableArrayPattern16.errors.txt index e03d0a799da..ba5531a0a54 100644 --- a/tests/baselines/reference/iterableArrayPattern16.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern16.errors.txt @@ -1,9 +1,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'. Property '0' is missing in type 'FooIterator'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,12): error TS2449: Class 'FooIteratorIterator' used before its declaration. -==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (2 errors) ==== +==== tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts (3 errors) ==== function fun(...[a, b]: [Bar, Bar][]) { } ~~~~~~ !!! error TS2501: A rest element cannot contain a binding pattern. @@ -11,6 +12,8 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern16.ts(2,5): error ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[Bar, Bar]'. !!! error TS2345: Property '0' is missing in type 'FooIterator'. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'FooIteratorIterator' used before its declaration. class Bar { x } class Foo extends Bar { y } class FooIterator { diff --git a/tests/baselines/reference/iterableArrayPattern17.errors.txt b/tests/baselines/reference/iterableArrayPattern17.errors.txt index 3cc04fadd11..d22d8580c71 100644 --- a/tests/baselines/reference/iterableArrayPattern17.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern17.errors.txt @@ -1,16 +1,9 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. -tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(17,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. Property 'x' is missing in type 'FooIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts (2 errors) ==== - function fun(...[a, b]: Bar[]) { } - ~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(new FooIterator); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. -!!! error TS2345: Property 'x' is missing in type 'FooIterator'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -24,4 +17,12 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[a, b]: Bar[]) { } + ~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(new FooIterator); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar'. +!!! error TS2345: Property 'x' is missing in type 'FooIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern17.js b/tests/baselines/reference/iterableArrayPattern17.js index c6274aabcd9..e9979380af6 100644 --- a/tests/baselines/reference/iterableArrayPattern17.js +++ b/tests/baselines/reference/iterableArrayPattern17.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern17.ts] -function fun(...[a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[a, b]: Bar[]) { } +fun(new FooIterator); //// [iterableArrayPattern17.js] -function fun(...[a, b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun(...[a, b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern18.errors.txt b/tests/baselines/reference/iterableArrayPattern18.errors.txt index c6f8c5e28bd..a3f8b6f840f 100644 --- a/tests/baselines/reference/iterableArrayPattern18.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern18.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts(17,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. Property 'length' is missing in type 'FooIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts (1 errors) ==== - function fun([a, b]: Bar[]) { } - fun(new FooIterator); - ~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. -!!! error TS2345: Property 'length' is missing in type 'FooIterator'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun([a, b]: Bar[]) { } + fun(new FooIterator); + ~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type 'Bar[]'. +!!! error TS2345: Property 'length' is missing in type 'FooIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern18.js b/tests/baselines/reference/iterableArrayPattern18.js index e2016c47690..93b038cd32d 100644 --- a/tests/baselines/reference/iterableArrayPattern18.js +++ b/tests/baselines/reference/iterableArrayPattern18.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern18.ts] -function fun([a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([a, b]: Bar[]) { } +fun(new FooIterator); //// [iterableArrayPattern18.js] -function fun([a, b]) { } -fun(new FooIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +function fun([a, b]) { } +fun(new FooIterator); diff --git a/tests/baselines/reference/iterableArrayPattern19.errors.txt b/tests/baselines/reference/iterableArrayPattern19.errors.txt index 3f8b550d287..f4a9fac0a06 100644 --- a/tests/baselines/reference/iterableArrayPattern19.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern19.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts(2,5): error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts(17,5): error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. Property 'length' is missing in type 'FooArrayIterator'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts (1 errors) ==== - function fun([[a], b]: Bar[][]) { } - fun(new FooArrayIterator); - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. -!!! error TS2345: Property 'length' is missing in type 'FooArrayIterator'. class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts(2,5): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun([[a], b]: Bar[][]) { } + fun(new FooArrayIterator); + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'FooArrayIterator' is not assignable to parameter of type 'Bar[][]'. +!!! error TS2345: Property 'length' is missing in type 'FooArrayIterator'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern19.js b/tests/baselines/reference/iterableArrayPattern19.js index bc3cf33afc2..3c930957f4d 100644 --- a/tests/baselines/reference/iterableArrayPattern19.js +++ b/tests/baselines/reference/iterableArrayPattern19.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern19.ts] -function fun([[a], b]: Bar[][]) { } -fun(new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,11 +12,12 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} +} + +function fun([[a], b]: Bar[][]) { } +fun(new FooArrayIterator); //// [iterableArrayPattern19.js] -function fun([[a], b]) { } -fun(new FooArrayIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooArrayIterator { return this; } } +function fun([[a], b]) { } +fun(new FooArrayIterator); diff --git a/tests/baselines/reference/iterableArrayPattern2.js b/tests/baselines/reference/iterableArrayPattern2.js index 7392db7d6b2..aab7ad9ec60 100644 --- a/tests/baselines/reference/iterableArrayPattern2.js +++ b/tests/baselines/reference/iterableArrayPattern2.js @@ -1,5 +1,4 @@ //// [iterableArrayPattern2.ts] -var [a, ...b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var [a, ...b] = new SymbolIterator; //// [iterableArrayPattern2.js] -var [a, ...b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -26,3 +26,4 @@ class SymbolIterator { return this; } } +var [a, ...b] = new SymbolIterator; diff --git a/tests/baselines/reference/iterableArrayPattern2.symbols b/tests/baselines/reference/iterableArrayPattern2.symbols index 50d3352b9e7..db700cdd572 100644 --- a/tests/baselines/reference/iterableArrayPattern2.symbols +++ b/tests/baselines/reference/iterableArrayPattern2.symbols @@ -1,22 +1,17 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts === -var [a, ...b] = new SymbolIterator; ->a : Symbol(a, Decl(iterableArrayPattern2.ts, 0, 5)) ->b : Symbol(b, Decl(iterableArrayPattern2.ts, 0, 7)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern2.ts, 1, 22)) +>next : Symbol(SymbolIterator.next, Decl(iterableArrayPattern2.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iterableArrayPattern2.ts, 3, 16)) +>value : Symbol(value, Decl(iterableArrayPattern2.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iterableArrayPattern2.ts, 4, 28)) +>done : Symbol(done, Decl(iterableArrayPattern2.ts, 3, 28)) }; } @@ -27,6 +22,12 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 35)) +>this : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 0)) } } + +var [a, ...b] = new SymbolIterator; +>a : Symbol(a, Decl(iterableArrayPattern2.ts, 13, 5)) +>b : Symbol(b, Decl(iterableArrayPattern2.ts, 13, 7)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iterableArrayPattern2.ts, 0, 0)) + diff --git a/tests/baselines/reference/iterableArrayPattern2.types b/tests/baselines/reference/iterableArrayPattern2.types index 63786a1d351..6a1bc9eb6f0 100644 --- a/tests/baselines/reference/iterableArrayPattern2.types +++ b/tests/baselines/reference/iterableArrayPattern2.types @@ -1,10 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts === -var [a, ...b] = new SymbolIterator; ->a : symbol ->b : symbol[] ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -35,3 +29,10 @@ class SymbolIterator { >this : this } } + +var [a, ...b] = new SymbolIterator; +>a : symbol +>b : symbol[] +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iterableArrayPattern20.errors.txt b/tests/baselines/reference/iterableArrayPattern20.errors.txt index 4451a814bd5..23f133238ce 100644 --- a/tests/baselines/reference/iterableArrayPattern20.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern20.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(1,17): error TS2501: A rest element cannot contain a binding pattern. +tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(16,17): error TS2501: A rest element cannot contain a binding pattern. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts (1 errors) ==== - function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2501: A rest element cannot contain a binding pattern. - fun(...new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts(1,17): error [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2501: A rest element cannot contain a binding pattern. + fun(...new FooArrayIterator); \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern20.js b/tests/baselines/reference/iterableArrayPattern20.js index 489f97a29f3..a327cb3e477 100644 --- a/tests/baselines/reference/iterableArrayPattern20.js +++ b/tests/baselines/reference/iterableArrayPattern20.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern20.ts] -function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } -fun(...new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,11 +12,12 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} +} + +function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } +fun(...new FooArrayIterator); //// [iterableArrayPattern20.js] -function fun(...[[a = new Foo], b = [new Foo]]) { } -fun(...new FooArrayIterator); class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooArrayIterator { return this; } } +function fun(...[[a = new Foo], b = [new Foo]]) { } +fun(...new FooArrayIterator); diff --git a/tests/baselines/reference/iterableArrayPattern3.js b/tests/baselines/reference/iterableArrayPattern3.js index 7136c6ab209..e29a67af731 100644 --- a/tests/baselines/reference/iterableArrayPattern3.js +++ b/tests/baselines/reference/iterableArrayPattern3.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern3.ts] -var a: Bar, b: Bar; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: Bar; +[a, b] = new FooIterator; //// [iterableArrayPattern3.js] -var a, b; -[a, b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern3.symbols b/tests/baselines/reference/iterableArrayPattern3.symbols index 6cf09801382..a82c5f5e025 100644 --- a/tests/baselines/reference/iterableArrayPattern3.symbols +++ b/tests/baselines/reference/iterableArrayPattern3.symbols @@ -1,37 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts === -var a: Bar, b: Bar; ->a : Symbol(a, Decl(iterableArrayPattern3.ts, 0, 3)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) ->b : Symbol(b, Decl(iterableArrayPattern3.ts, 0, 11)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) - -[a, b] = new FooIterator; ->a : Symbol(a, Decl(iterableArrayPattern3.ts, 0, 3)) ->b : Symbol(b, Decl(iterableArrayPattern3.ts, 0, 11)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern3.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern3.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 1, 25)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern3.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern3.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern3.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern3.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern3.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern3.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern3.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern3.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern3.ts, 5, 27)) }; } @@ -42,6 +31,18 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 1, 27)) } } + +var a: Bar, b: Bar; +>a : Symbol(a, Decl(iterableArrayPattern3.ts, 15, 3)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) +>b : Symbol(b, Decl(iterableArrayPattern3.ts, 15, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern3.ts, 0, 0)) + +[a, b] = new FooIterator; +>a : Symbol(a, Decl(iterableArrayPattern3.ts, 15, 3)) +>b : Symbol(b, Decl(iterableArrayPattern3.ts, 15, 11)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern3.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern3.types b/tests/baselines/reference/iterableArrayPattern3.types index a21e702526b..b138c8629d4 100644 --- a/tests/baselines/reference/iterableArrayPattern3.types +++ b/tests/baselines/reference/iterableArrayPattern3.types @@ -1,18 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts === -var a: Bar, b: Bar; ->a : Bar ->Bar : Bar ->b : Bar ->Bar : Bar - -[a, b] = new FooIterator; ->[a, b] = new FooIterator : FooIterator ->[a, b] : [Bar, Bar] ->a : Bar ->b : Bar ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -52,3 +38,18 @@ class FooIterator { >this : this } } + +var a: Bar, b: Bar; +>a : Bar +>Bar : Bar +>b : Bar +>Bar : Bar + +[a, b] = new FooIterator; +>[a, b] = new FooIterator : FooIterator +>[a, b] : [Bar, Bar] +>a : Bar +>b : Bar +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern4.js b/tests/baselines/reference/iterableArrayPattern4.js index 6e60dadbd7a..c53b6ef4162 100644 --- a/tests/baselines/reference/iterableArrayPattern4.js +++ b/tests/baselines/reference/iterableArrayPattern4.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern4.ts] -var a: Bar, b: Bar[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: Bar[]; +[a, ...b] = new FooIterator //// [iterableArrayPattern4.js] -var a, b; -[a, ...b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, ...b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern4.symbols b/tests/baselines/reference/iterableArrayPattern4.symbols index 651c60cf08f..6a3526a3482 100644 --- a/tests/baselines/reference/iterableArrayPattern4.symbols +++ b/tests/baselines/reference/iterableArrayPattern4.symbols @@ -1,37 +1,26 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts === -var a: Bar, b: Bar[]; ->a : Symbol(a, Decl(iterableArrayPattern4.ts, 0, 3)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) ->b : Symbol(b, Decl(iterableArrayPattern4.ts, 0, 11)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) - -[a, ...b] = new FooIterator; ->a : Symbol(a, Decl(iterableArrayPattern4.ts, 0, 3)) ->b : Symbol(b, Decl(iterableArrayPattern4.ts, 0, 11)) ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) - class Bar { x } ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) ->x : Symbol(Bar.x, Decl(iterableArrayPattern4.ts, 2, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) +>x : Symbol(Bar.x, Decl(iterableArrayPattern4.ts, 0, 11)) class Foo extends Bar { y } ->Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 2, 15)) ->Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 1, 28)) ->y : Symbol(Foo.y, Decl(iterableArrayPattern4.ts, 3, 23)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 0, 15)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) +>y : Symbol(Foo.y, Decl(iterableArrayPattern4.ts, 1, 23)) class FooIterator { ->FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 1, 27)) next() { ->next : Symbol(FooIterator.next, Decl(iterableArrayPattern4.ts, 4, 19)) +>next : Symbol(FooIterator.next, Decl(iterableArrayPattern4.ts, 2, 19)) return { value: new Foo, ->value : Symbol(value, Decl(iterableArrayPattern4.ts, 6, 16)) ->Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 2, 15)) +>value : Symbol(value, Decl(iterableArrayPattern4.ts, 4, 16)) +>Foo : Symbol(Foo, Decl(iterableArrayPattern4.ts, 0, 15)) done: false ->done : Symbol(done, Decl(iterableArrayPattern4.ts, 7, 27)) +>done : Symbol(done, Decl(iterableArrayPattern4.ts, 5, 27)) }; } @@ -42,6 +31,18 @@ class FooIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 3, 27)) +>this : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 1, 27)) } } + +var a: Bar, b: Bar[]; +>a : Symbol(a, Decl(iterableArrayPattern4.ts, 15, 3)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) +>b : Symbol(b, Decl(iterableArrayPattern4.ts, 15, 11)) +>Bar : Symbol(Bar, Decl(iterableArrayPattern4.ts, 0, 0)) + +[a, ...b] = new FooIterator +>a : Symbol(a, Decl(iterableArrayPattern4.ts, 15, 3)) +>b : Symbol(b, Decl(iterableArrayPattern4.ts, 15, 11)) +>FooIterator : Symbol(FooIterator, Decl(iterableArrayPattern4.ts, 1, 27)) + diff --git a/tests/baselines/reference/iterableArrayPattern4.types b/tests/baselines/reference/iterableArrayPattern4.types index a3be4114498..1024f4c9670 100644 --- a/tests/baselines/reference/iterableArrayPattern4.types +++ b/tests/baselines/reference/iterableArrayPattern4.types @@ -1,19 +1,4 @@ === tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts === -var a: Bar, b: Bar[]; ->a : Bar ->Bar : Bar ->b : Bar[] ->Bar : Bar - -[a, ...b] = new FooIterator; ->[a, ...b] = new FooIterator : FooIterator ->[a, ...b] : Bar[] ->a : Bar ->...b : Bar ->b : Bar[] ->new FooIterator : FooIterator ->FooIterator : typeof FooIterator - class Bar { x } >Bar : Bar >x : any @@ -53,3 +38,19 @@ class FooIterator { >this : this } } + +var a: Bar, b: Bar[]; +>a : Bar +>Bar : Bar +>b : Bar[] +>Bar : Bar + +[a, ...b] = new FooIterator +>[a, ...b] = new FooIterator : FooIterator +>[a, ...b] : Bar[] +>a : Bar +>...b : Bar +>b : Bar[] +>new FooIterator : FooIterator +>FooIterator : typeof FooIterator + diff --git a/tests/baselines/reference/iterableArrayPattern5.errors.txt b/tests/baselines/reference/iterableArrayPattern5.errors.txt index ca540d805be..1bbbe268e6c 100644 --- a/tests/baselines/reference/iterableArrayPattern5.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern5.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts(2,5): error TS2322: Type 'Foo' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts(17,5): error TS2322: Type 'Foo' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts (1 errors) ==== - var a: Bar, b: string; - [a, b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo' is not assignable to type 'string'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts(2,5): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string; + [a, b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern5.js b/tests/baselines/reference/iterableArrayPattern5.js index 77e71cac6d3..56ed70b1379 100644 --- a/tests/baselines/reference/iterableArrayPattern5.js +++ b/tests/baselines/reference/iterableArrayPattern5.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern5.ts] -var a: Bar, b: string; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string; +[a, b] = new FooIterator; //// [iterableArrayPattern5.js] -var a, b; -[a, b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern6.errors.txt b/tests/baselines/reference/iterableArrayPattern6.errors.txt index e0a546d154c..3a20f1f52c5 100644 --- a/tests/baselines/reference/iterableArrayPattern6.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern6.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts(2,8): error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts(17,8): error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. Type 'Foo' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts (1 errors) ==== - var a: Bar, b: string[]; - [a, ...b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. -!!! error TS2322: Type 'Foo' is not assignable to type 'string'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts(2,8): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string[]; + [a, ...b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo[]' is not assignable to type 'string[]'. +!!! error TS2322: Type 'Foo' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern6.js b/tests/baselines/reference/iterableArrayPattern6.js index 8c797e819f5..1053cced9cb 100644 --- a/tests/baselines/reference/iterableArrayPattern6.js +++ b/tests/baselines/reference/iterableArrayPattern6.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern6.ts] -var a: Bar, b: string[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string[]; +[a, ...b] = new FooIterator; //// [iterableArrayPattern6.js] -var a, b; -[a, ...b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, ...b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern7.errors.txt b/tests/baselines/reference/iterableArrayPattern7.errors.txt index 997cc21f38b..972de74039f 100644 --- a/tests/baselines/reference/iterableArrayPattern7.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern7.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts(2,5): error TS2322: Type 'Foo' is not assignable to type 'string[]'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts(17,5): error TS2322: Type 'Foo' is not assignable to type 'string[]'. Property 'length' is missing in type 'Foo'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts (1 errors) ==== - var a: Bar, b: string[]; - [a, b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo' is not assignable to type 'string[]'. -!!! error TS2322: Property 'length' is missing in type 'Foo'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -21,4 +16,10 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts(2,5): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string[]; + [a, b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo' is not assignable to type 'string[]'. +!!! error TS2322: Property 'length' is missing in type 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern7.js b/tests/baselines/reference/iterableArrayPattern7.js index 3f79e6bfba8..74b25f1ec62 100644 --- a/tests/baselines/reference/iterableArrayPattern7.js +++ b/tests/baselines/reference/iterableArrayPattern7.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern7.ts] -var a: Bar, b: string[]; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string[]; +[a, b] = new FooIterator; //// [iterableArrayPattern7.js] -var a, b; -[a, b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, b] = new FooIterator; diff --git a/tests/baselines/reference/iterableArrayPattern8.errors.txt b/tests/baselines/reference/iterableArrayPattern8.errors.txt index c06e0c9543f..94c6e9593ef 100644 --- a/tests/baselines/reference/iterableArrayPattern8.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern8.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts(2,8): error TS2322: Type 'Foo[]' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts(17,8): error TS2322: Type 'Foo[]' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts (1 errors) ==== - var a: Bar, b: string; - [a, ...b] = new FooIterator; - ~ -!!! error TS2322: Type 'Foo[]' is not assignable to type 'string'. class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -19,4 +15,9 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts(2,8): error T [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var a: Bar, b: string; + [a, ...b] = new FooIterator; + ~ +!!! error TS2322: Type 'Foo[]' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iterableArrayPattern8.js b/tests/baselines/reference/iterableArrayPattern8.js index dd1c76c1f51..b943953b152 100644 --- a/tests/baselines/reference/iterableArrayPattern8.js +++ b/tests/baselines/reference/iterableArrayPattern8.js @@ -1,6 +1,4 @@ //// [iterableArrayPattern8.ts] -var a: Bar, b: string; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,11 +12,12 @@ class FooIterator { [Symbol.iterator]() { return this; } -} +} + +var a: Bar, b: string; +[a, ...b] = new FooIterator; //// [iterableArrayPattern8.js] -var a, b; -[a, ...b] = new FooIterator; class Bar { } class Foo extends Bar { @@ -34,3 +33,5 @@ class FooIterator { return this; } } +var a, b; +[a, ...b] = new FooIterator; diff --git a/tests/baselines/reference/iteratorSpreadInArray.js b/tests/baselines/reference/iteratorSpreadInArray.js index 8e25a2e7ecf..0b64eb4b409 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.js +++ b/tests/baselines/reference/iteratorSpreadInArray.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,12 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new SymbolIterator]; + //// [iteratorSpreadInArray.js] -var array = [...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +27,4 @@ class SymbolIterator { return this; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray.symbols b/tests/baselines/reference/iteratorSpreadInArray.symbols index 7fc2d469eae..6d6656f0f71 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray.symbols @@ -1,21 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts === -var array = [...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray.ts, 0, 3)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray.ts, 3, 28)) }; } @@ -26,6 +22,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 36)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 0)) } } + +var array = [...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray.ts, 13, 3)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray.types b/tests/baselines/reference/iteratorSpreadInArray.types index 4b5a63e5d57..9d43fa57b07 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.types +++ b/tests/baselines/reference/iteratorSpreadInArray.types @@ -1,11 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts === -var array = [...new SymbolIterator]; ->array : symbol[] ->[...new SymbolIterator] : symbol[] ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -36,3 +29,11 @@ class SymbolIterator { >this : this } } + +var array = [...new SymbolIterator]; +>array : symbol[] +>[...new SymbolIterator] : symbol[] +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray10.errors.txt b/tests/baselines/reference/iteratorSpreadInArray10.errors.txt index 90cde7d03b1..28a878ac431 100644 --- a/tests/baselines/reference/iteratorSpreadInArray10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray10.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts(1,17): error TS2489: An iterator must have a 'next()' method. +tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts(7,17): error TS2489: An iterator must have a 'next()' method. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts (1 errors) ==== - var array = [...new SymbolIterator]; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2489: An iterator must have a 'next()' method. - class SymbolIterator { [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array = [...new SymbolIterator]; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2489: An iterator must have a 'next()' method. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray10.js b/tests/baselines/reference/iteratorSpreadInArray10.js index 1004dbd7b34..196ca7c714b 100644 --- a/tests/baselines/reference/iteratorSpreadInArray10.js +++ b/tests/baselines/reference/iteratorSpreadInArray10.js @@ -1,16 +1,16 @@ //// [iteratorSpreadInArray10.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new SymbolIterator]; //// [iteratorSpreadInArray10.js] -var array = [...new SymbolIterator]; class SymbolIterator { [Symbol.iterator]() { return this; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray2.js b/tests/baselines/reference/iteratorSpreadInArray2.js index aa4a1099a40..e766016389e 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.js +++ b/tests/baselines/reference/iteratorSpreadInArray2.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray2.ts] -var array = [...new NumberIterator, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -25,10 +23,12 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new NumberIterator, ...new SymbolIterator]; + //// [iteratorSpreadInArray2.js] -var array = [...new NumberIterator, ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -51,3 +51,4 @@ class NumberIterator { return this; } } +var array = [...new NumberIterator, ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray2.symbols b/tests/baselines/reference/iteratorSpreadInArray2.symbols index 8d39834c17f..6fd22547ee6 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray2.symbols @@ -1,22 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts === -var array = [...new NumberIterator, ...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray2.ts, 0, 3)) ->NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray2.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray2.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 3, 28)) }; } @@ -27,22 +22,22 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 59)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 0)) } } class NumberIterator { ->NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) +>NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 11, 1)) next() { ->next : Symbol(NumberIterator.next, Decl(iteratorSpreadInArray2.ts, 15, 22)) +>next : Symbol(NumberIterator.next, Decl(iteratorSpreadInArray2.ts, 13, 22)) return { value: 0, ->value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 17, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray2.ts, 15, 16)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 18, 21)) +>done : Symbol(done, Decl(iteratorSpreadInArray2.ts, 16, 21)) }; } @@ -53,6 +48,12 @@ class NumberIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 13, 1)) +>this : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 11, 1)) } } + +var array = [...new NumberIterator, ...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray2.ts, 26, 3)) +>NumberIterator : Symbol(NumberIterator, Decl(iteratorSpreadInArray2.ts, 11, 1)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray2.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray2.types b/tests/baselines/reference/iteratorSpreadInArray2.types index 19bf5eab004..440a2bebcf8 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.types +++ b/tests/baselines/reference/iteratorSpreadInArray2.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts === -var array = [...new NumberIterator, ...new SymbolIterator]; ->array : (number | symbol)[] ->[...new NumberIterator, ...new SymbolIterator] : (number | symbol)[] ->...new NumberIterator : number ->new NumberIterator : NumberIterator ->NumberIterator : typeof NumberIterator ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -69,3 +59,14 @@ class NumberIterator { >this : this } } + +var array = [...new NumberIterator, ...new SymbolIterator]; +>array : (number | symbol)[] +>[...new NumberIterator, ...new SymbolIterator] : (number | symbol)[] +>...new NumberIterator : number +>new NumberIterator : NumberIterator +>NumberIterator : typeof NumberIterator +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray3.js b/tests/baselines/reference/iteratorSpreadInArray3.js index 1d468e4483e..239a95020f0 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.js +++ b/tests/baselines/reference/iteratorSpreadInArray3.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray3.ts] -var array = [...[0, 1], ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...[0, 1], ...new SymbolIterator]; //// [iteratorSpreadInArray3.js] -var array = [...[0, 1], ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +26,4 @@ class SymbolIterator { return this; } } +var array = [...[0, 1], ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray3.symbols b/tests/baselines/reference/iteratorSpreadInArray3.symbols index c110733dd66..ff6bc66e9d3 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray3.symbols @@ -1,21 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts === -var array = [...[0, 1], ...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray3.ts, 0, 3)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray3.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray3.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray3.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray3.ts, 3, 28)) }; } @@ -26,6 +22,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 47)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 0)) } } + +var array = [...[0, 1], ...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray3.ts, 13, 3)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray3.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray3.types b/tests/baselines/reference/iteratorSpreadInArray3.types index 1fd29bb2381..b4c8f36f6de 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.types +++ b/tests/baselines/reference/iteratorSpreadInArray3.types @@ -1,15 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts === -var array = [...[0, 1], ...new SymbolIterator]; ->array : (number | symbol)[] ->[...[0, 1], ...new SymbolIterator] : (number | symbol)[] ->...[0, 1] : number ->[0, 1] : number[] ->0 : 0 ->1 : 1 ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -40,3 +29,15 @@ class SymbolIterator { >this : this } } + +var array = [...[0, 1], ...new SymbolIterator]; +>array : (number | symbol)[] +>[...[0, 1], ...new SymbolIterator] : (number | symbol)[] +>...[0, 1] : number +>[0, 1] : number[] +>0 : 0 +>1 : 1 +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray4.js b/tests/baselines/reference/iteratorSpreadInArray4.js index 82a08bfa964..95443f760cd 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.js +++ b/tests/baselines/reference/iteratorSpreadInArray4.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray4.ts] -var array = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [0, 1, ...new SymbolIterator]; //// [iteratorSpreadInArray4.js] -var array = [0, 1, ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +26,4 @@ class SymbolIterator { return this; } } +var array = [0, 1, ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray4.symbols b/tests/baselines/reference/iteratorSpreadInArray4.symbols index e1159ee0e96..16fa1c62c6c 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray4.symbols @@ -1,21 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts === -var array = [0, 1, ...new SymbolIterator]; ->array : Symbol(array, Decl(iteratorSpreadInArray4.ts, 0, 3)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray4.ts, 2, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray4.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 4, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray4.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 5, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray4.ts, 3, 28)) }; } @@ -26,6 +22,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 42)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 0)) } } + +var array = [0, 1, ...new SymbolIterator]; +>array : Symbol(array, Decl(iteratorSpreadInArray4.ts, 13, 3)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray4.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray4.types b/tests/baselines/reference/iteratorSpreadInArray4.types index 6024e79dee5..d473416113f 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.types +++ b/tests/baselines/reference/iteratorSpreadInArray4.types @@ -1,13 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts === -var array = [0, 1, ...new SymbolIterator]; ->array : (number | symbol)[] ->[0, 1, ...new SymbolIterator] : (number | symbol)[] ->0 : 0 ->1 : 1 ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -38,3 +29,13 @@ class SymbolIterator { >this : this } } + +var array = [0, 1, ...new SymbolIterator]; +>array : (number | symbol)[] +>[0, 1, ...new SymbolIterator] : (number | symbol)[] +>0 : 0 +>1 : 1 +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray5.errors.txt b/tests/baselines/reference/iteratorSpreadInArray5.errors.txt index 498cc7d48ef..02049824c4f 100644 --- a/tests/baselines/reference/iteratorSpreadInArray5.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray5.errors.txt @@ -1,15 +1,9 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts(1,5): error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. +tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts(14,5): error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. Type 'number | symbol' is not assignable to type 'number'. Type 'symbol' is not assignable to type 'number'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts (1 errors) ==== - var array: number[] = [0, 1, ...new SymbolIterator]; - ~~~~~ -!!! error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. -!!! error TS2322: Type 'number | symbol' is not assignable to type 'number'. -!!! error TS2322: Type 'symbol' is not assignable to type 'number'. - class SymbolIterator { next() { return { @@ -21,4 +15,10 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts(1,5): error TS2322: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array: number[] = [0, 1, ...new SymbolIterator]; + ~~~~~ +!!! error TS2322: Type '(number | symbol)[]' is not assignable to type 'number[]'. +!!! error TS2322: Type 'number | symbol' is not assignable to type 'number'. +!!! error TS2322: Type 'symbol' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray5.js b/tests/baselines/reference/iteratorSpreadInArray5.js index 0aa158a5dc2..ee0bf116760 100644 --- a/tests/baselines/reference/iteratorSpreadInArray5.js +++ b/tests/baselines/reference/iteratorSpreadInArray5.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray5.ts] -var array: number[] = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,10 +10,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array: number[] = [0, 1, ...new SymbolIterator]; //// [iteratorSpreadInArray5.js] -var array = [0, 1, ...new SymbolIterator]; class SymbolIterator { next() { return { @@ -27,3 +26,4 @@ class SymbolIterator { return this; } } +var array = [0, 1, ...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt index 8148ce43de7..e9b6954e6e3 100644 --- a/tests/baselines/reference/iteratorSpreadInArray6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray6.errors.txt @@ -1,16 +1,9 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(2,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. +tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(15,14): error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. Type 'symbol[]' is not assignable to type 'number[]'. Type 'symbol' is not assignable to type 'number'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts (1 errors) ==== - var array: number[] = [0, 1]; - array.concat([...new SymbolIterator]); - ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. -!!! error TS2345: Type 'symbol[]' is not assignable to type 'number[]'. -!!! error TS2345: Type 'symbol' is not assignable to type 'number'. - class SymbolIterator { next() { return { @@ -22,4 +15,11 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts(2,14): error TS2345 [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array: number[] = [0, 1]; + array.concat([...new SymbolIterator]); + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'symbol[]' is not assignable to parameter of type 'number | number[]'. +!!! error TS2345: Type 'symbol[]' is not assignable to type 'number[]'. +!!! error TS2345: Type 'symbol' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray6.js b/tests/baselines/reference/iteratorSpreadInArray6.js index 02d1c435b8c..36b5fcf5cfc 100644 --- a/tests/baselines/reference/iteratorSpreadInArray6.js +++ b/tests/baselines/reference/iteratorSpreadInArray6.js @@ -1,7 +1,4 @@ //// [iteratorSpreadInArray6.ts] -var array: number[] = [0, 1]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,11 +10,12 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array: number[] = [0, 1]; +array.concat([...new SymbolIterator]); //// [iteratorSpreadInArray6.js] -var array = [0, 1]; -array.concat([...new SymbolIterator]); class SymbolIterator { next() { return { @@ -29,3 +27,5 @@ class SymbolIterator { return this; } } +var array = [0, 1]; +array.concat([...new SymbolIterator]); diff --git a/tests/baselines/reference/iteratorSpreadInArray7.js b/tests/baselines/reference/iteratorSpreadInArray7.js index 72a614ae4ec..aa209609b21 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.js +++ b/tests/baselines/reference/iteratorSpreadInArray7.js @@ -1,7 +1,4 @@ //// [iteratorSpreadInArray7.ts] -var array: symbol[]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,11 +10,12 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array: symbol[]; +array.concat([...new SymbolIterator]); //// [iteratorSpreadInArray7.js] -var array; -array.concat([...new SymbolIterator]); class SymbolIterator { next() { return { @@ -29,3 +27,5 @@ class SymbolIterator { return this; } } +var array; +array.concat([...new SymbolIterator]); diff --git a/tests/baselines/reference/iteratorSpreadInArray7.symbols b/tests/baselines/reference/iteratorSpreadInArray7.symbols index 57774bcd7ee..534741a62a6 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.symbols +++ b/tests/baselines/reference/iteratorSpreadInArray7.symbols @@ -1,26 +1,17 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts === -var array: symbol[]; ->array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3)) - -array.concat([...new SymbolIterator]); ->array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 0, 3)) ->concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) - class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 0, 0)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray7.ts, 3, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInArray7.ts, 0, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 5, 16)) +>value : Symbol(value, Decl(iteratorSpreadInArray7.ts, 2, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 6, 28)) +>done : Symbol(done, Decl(iteratorSpreadInArray7.ts, 3, 28)) }; } @@ -31,6 +22,16 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 1, 38)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 0, 0)) } } + +var array: symbol[]; +>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 13, 3)) + +array.concat([...new SymbolIterator]); +>array.concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>array : Symbol(array, Decl(iteratorSpreadInArray7.ts, 13, 3)) +>concat : Symbol(Array.concat, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInArray7.ts, 0, 0)) + diff --git a/tests/baselines/reference/iteratorSpreadInArray7.types b/tests/baselines/reference/iteratorSpreadInArray7.types index ef0e3898e0f..b102c72486b 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.types +++ b/tests/baselines/reference/iteratorSpreadInArray7.types @@ -1,17 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts === -var array: symbol[]; ->array : symbol[] - -array.concat([...new SymbolIterator]); ->array.concat([...new SymbolIterator]) : symbol[] ->array.concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } ->array : symbol[] ->concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } ->[...new SymbolIterator] : symbol[] ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - class SymbolIterator { >SymbolIterator : SymbolIterator @@ -42,3 +29,17 @@ class SymbolIterator { >this : this } } + +var array: symbol[]; +>array : symbol[] + +array.concat([...new SymbolIterator]); +>array.concat([...new SymbolIterator]) : symbol[] +>array.concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } +>array : symbol[] +>concat : { (...items: symbol[][]): symbol[]; (...items: (symbol | symbol[])[]): symbol[]; } +>[...new SymbolIterator] : symbol[] +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInArray8.errors.txt b/tests/baselines/reference/iteratorSpreadInArray8.errors.txt index 365bc8db9c2..1f8c9629424 100644 --- a/tests/baselines/reference/iteratorSpreadInArray8.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray8.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts(1,17): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. +tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts(10,17): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts (1 errors) ==== - var array = [...new SymbolIterator]; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. - class SymbolIterator { next() { return { @@ -13,4 +9,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts(1,17): error TS2488 done: false }; } - } \ No newline at end of file + } + + var array = [...new SymbolIterator]; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray8.js b/tests/baselines/reference/iteratorSpreadInArray8.js index 08378699129..c2a0becb0d3 100644 --- a/tests/baselines/reference/iteratorSpreadInArray8.js +++ b/tests/baselines/reference/iteratorSpreadInArray8.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray8.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -8,10 +6,11 @@ class SymbolIterator { done: false }; } -} +} + +var array = [...new SymbolIterator]; //// [iteratorSpreadInArray8.js] -var array = [...new SymbolIterator]; class SymbolIterator { next() { return { @@ -20,3 +19,4 @@ class SymbolIterator { }; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt index 90b8bdbeb46..5f43bb4f5ae 100644 --- a/tests/baselines/reference/iteratorSpreadInArray9.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInArray9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. +tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(13,17): error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. Types of property '[Symbol.iterator]' are incompatible. Type '() => SymbolIterator' is not assignable to type '() => Iterator'. Type 'SymbolIterator' is not assignable to type 'Iterator'. @@ -9,17 +9,6 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322 ==== tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts (1 errors) ==== - var array = [...new SymbolIterator]; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. -!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. -!!! error TS2322: Type '() => SymbolIterator' is not assignable to type '() => Iterator'. -!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterator'. -!!! error TS2322: Types of property 'next' are incompatible. -!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. -!!! error TS2322: Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. -!!! error TS2322: Property 'done' is missing in type '{ value: symbol; }'. - class SymbolIterator { next() { return { @@ -30,4 +19,15 @@ tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts(1,17): error TS2322 [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + var array = [...new SymbolIterator]; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterable'. +!!! error TS2322: Types of property '[Symbol.iterator]' are incompatible. +!!! error TS2322: Type '() => SymbolIterator' is not assignable to type '() => Iterator'. +!!! error TS2322: Type 'SymbolIterator' is not assignable to type 'Iterator'. +!!! error TS2322: Types of property 'next' are incompatible. +!!! error TS2322: Type '() => { value: symbol; }' is not assignable to type '(value?: any) => IteratorResult'. +!!! error TS2322: Type '{ value: symbol; }' is not assignable to type 'IteratorResult'. +!!! error TS2322: Property 'done' is missing in type '{ value: symbol; }'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInArray9.js b/tests/baselines/reference/iteratorSpreadInArray9.js index ed0a9b4ebe9..8b3a02e5e18 100644 --- a/tests/baselines/reference/iteratorSpreadInArray9.js +++ b/tests/baselines/reference/iteratorSpreadInArray9.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInArray9.ts] -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -11,10 +9,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +var array = [...new SymbolIterator]; //// [iteratorSpreadInArray9.js] -var array = [...new SymbolIterator]; class SymbolIterator { next() { return { @@ -25,3 +24,4 @@ class SymbolIterator { return this; } } +var array = [...new SymbolIterator]; diff --git a/tests/baselines/reference/iteratorSpreadInCall.errors.txt b/tests/baselines/reference/iteratorSpreadInCall.errors.txt index 614153192d7..d26f9ab6447 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s: symbol) { } class SymbolIterator { next() { @@ -18,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts(1,1): error TS2346: S [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall.js b/tests/baselines/reference/iteratorSpreadInCall.js index f3bf17c0327..a4b17cfb5ef 100644 --- a/tests/baselines/reference/iteratorSpreadInCall.js +++ b/tests/baselines/reference/iteratorSpreadInCall.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall.ts] -foo(...new SymbolIterator); - function foo(s: symbol) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall.js] -foo(...new SymbolIterator); function foo(s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt index 04d9045e86c..bf478012c5d 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall10.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -19,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts(1,1): error TS2346: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall10.js b/tests/baselines/reference/iteratorSpreadInCall10.js index 14a08c97009..9fb1cf20a6e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall10.js +++ b/tests/baselines/reference/iteratorSpreadInCall10.js @@ -1,8 +1,5 @@ //// [iteratorSpreadInCall10.ts] -foo(...new SymbolIterator); - function foo(s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall10.js] -foo(...new SymbolIterator); function foo(s) { return s[0]; } class SymbolIterator { next() { @@ -30,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall11.js b/tests/baselines/reference/iteratorSpreadInCall11.js index d01eb259ef3..adfbb03d71c 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.js +++ b/tests/baselines/reference/iteratorSpreadInCall11.js @@ -1,8 +1,5 @@ //// [iteratorSpreadInCall11.ts] -foo(...new SymbolIterator); - function foo(...s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall11.js] -foo(...new SymbolIterator); function foo(...s) { return s[0]; } class SymbolIterator { next() { @@ -30,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall11.symbols b/tests/baselines/reference/iteratorSpreadInCall11.symbols index 098a7b9b9ce..b6db07942d0 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall11.symbols @@ -1,28 +1,24 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts === -foo(...new SymbolIterator); ->foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 27)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) - function foo(...s: T[]) { return s[0] } ->foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 27)) ->T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 2, 13)) ->s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 2, 16)) ->T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 2, 13)) ->s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 2, 16)) +>foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 0)) +>T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 0, 13)) +>s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 0, 16)) +>T : Symbol(T, Decl(iteratorSpreadInCall11.ts, 0, 13)) +>s : Symbol(s, Decl(iteratorSpreadInCall11.ts, 0, 16)) class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 0, 42)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall11.ts, 4, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall11.ts, 1, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 6, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall11.ts, 3, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 7, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall11.ts, 4, 28)) }; } @@ -33,6 +29,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 2, 42)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 0, 42)) } } + +foo(...new SymbolIterator); +>foo : Symbol(foo, Decl(iteratorSpreadInCall11.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall11.ts, 0, 42)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall11.types b/tests/baselines/reference/iteratorSpreadInCall11.types index 5990b26df64..4a3d73d36d0 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.types +++ b/tests/baselines/reference/iteratorSpreadInCall11.types @@ -1,11 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts === -foo(...new SymbolIterator); ->foo(...new SymbolIterator) : symbol ->foo : (...s: T[]) => T ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - function foo(...s: T[]) { return s[0] } >foo : (...s: T[]) => T >T : T @@ -45,3 +38,11 @@ class SymbolIterator { >this : this } } + +foo(...new SymbolIterator); +>foo(...new SymbolIterator) : symbol +>foo : (...s: T[]) => T +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall12.js b/tests/baselines/reference/iteratorSpreadInCall12.js index b138192826d..ba8149e29d6 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.js +++ b/tests/baselines/reference/iteratorSpreadInCall12.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall12.ts] -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); - class Foo { constructor(...s: T[]) { } } @@ -29,10 +27,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); //// [iteratorSpreadInCall12.js] -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); class Foo { constructor(...s) { } } @@ -58,3 +57,4 @@ class StringIterator { return this; } } +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); diff --git a/tests/baselines/reference/iteratorSpreadInCall12.symbols b/tests/baselines/reference/iteratorSpreadInCall12.symbols index f989860f04e..983ab8fcd90 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall12.symbols @@ -1,31 +1,26 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts === -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); ->Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 64)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) - class Foo { ->Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 64)) ->T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 2, 10)) +>Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 0)) +>T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 0, 10)) constructor(...s: T[]) { } ->s : Symbol(s, Decl(iteratorSpreadInCall12.ts, 3, 16)) ->T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 2, 10)) +>s : Symbol(s, Decl(iteratorSpreadInCall12.ts, 1, 16)) +>T : Symbol(T, Decl(iteratorSpreadInCall12.ts, 0, 10)) } class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 2, 1)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall12.ts, 6, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall12.ts, 4, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 8, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 6, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 9, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 7, 28)) }; } @@ -36,22 +31,22 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 4, 1)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 2, 1)) } } class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall12.ts, 19, 22)) +>next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall12.ts, 17, 22)) return { value: "", ->value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 21, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall12.ts, 19, 16)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 22, 22)) +>done : Symbol(done, Decl(iteratorSpreadInCall12.ts, 20, 22)) }; } @@ -62,6 +57,12 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 17, 1)) +>this : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) } } + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); +>Foo : Symbol(Foo, Decl(iteratorSpreadInCall12.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall12.ts, 2, 1)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall12.ts, 15, 1)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall12.types b/tests/baselines/reference/iteratorSpreadInCall12.types index b614fdde16b..55986b57645 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.types +++ b/tests/baselines/reference/iteratorSpreadInCall12.types @@ -1,18 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts === -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); ->new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo ->Foo : typeof Foo ->...[...new SymbolIterator, ...[...new StringIterator]] : string | symbol ->[...new SymbolIterator, ...[...new StringIterator]] : (string | symbol)[] ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator ->...[...new StringIterator] : string ->[...new StringIterator] : string[] ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - class Foo { >Foo : Foo >T : T @@ -82,3 +68,18 @@ class StringIterator { >this : this } } + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); +>new Foo(...[...new SymbolIterator, ...[...new StringIterator]]) : Foo +>Foo : typeof Foo +>...[...new SymbolIterator, ...[...new StringIterator]] : string | symbol +>[...new SymbolIterator, ...[...new StringIterator]] : (string | symbol)[] +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator +>...[...new StringIterator] : string +>[...new StringIterator] : string[] +>...new StringIterator : string +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt index bd994ab37b0..abf8fc71ed7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall2.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s: symbol[]) { } class SymbolIterator { next() { @@ -18,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts(1,1): error TS2346: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall2.js b/tests/baselines/reference/iteratorSpreadInCall2.js index 6c3517857d5..e858a7cd721 100644 --- a/tests/baselines/reference/iteratorSpreadInCall2.js +++ b/tests/baselines/reference/iteratorSpreadInCall2.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall2.ts] -foo(...new SymbolIterator); - function foo(s: symbol[]) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall2.js] -foo(...new SymbolIterator); function foo(s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall3.js b/tests/baselines/reference/iteratorSpreadInCall3.js index b33ceae7bfd..9dd0c23add7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.js +++ b/tests/baselines/reference/iteratorSpreadInCall3.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall3.ts] -foo(...new SymbolIterator); - function foo(...s: symbol[]) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall3.js] -foo(...new SymbolIterator); function foo(...s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall3.symbols b/tests/baselines/reference/iteratorSpreadInCall3.symbols index 8557b6c8319..d8f414bcd72 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall3.symbols @@ -1,25 +1,21 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts === -foo(...new SymbolIterator); ->foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 27)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) - function foo(...s: symbol[]) { } ->foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 27)) ->s : Symbol(s, Decl(iteratorSpreadInCall3.ts, 2, 13)) +>foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 0)) +>s : Symbol(s, Decl(iteratorSpreadInCall3.ts, 0, 13)) class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 0, 32)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall3.ts, 3, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall3.ts, 1, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 5, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall3.ts, 3, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 6, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall3.ts, 4, 28)) }; } @@ -30,6 +26,11 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 2, 32)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 0, 32)) } } + +foo(...new SymbolIterator); +>foo : Symbol(foo, Decl(iteratorSpreadInCall3.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall3.ts, 0, 32)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall3.types b/tests/baselines/reference/iteratorSpreadInCall3.types index 56b7f6db6d1..fef9f7dcab7 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.types +++ b/tests/baselines/reference/iteratorSpreadInCall3.types @@ -1,11 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts === -foo(...new SymbolIterator); ->foo(...new SymbolIterator) : void ->foo : (...s: symbol[]) => void ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator - function foo(...s: symbol[]) { } >foo : (...s: symbol[]) => void >s : symbol[] @@ -40,3 +33,11 @@ class SymbolIterator { >this : this } } + +foo(...new SymbolIterator); +>foo(...new SymbolIterator) : void +>foo : (...s: symbol[]) => void +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt index 0e0a40a512f..3beaf2ce65c 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall4.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(1,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(15,1): error TS2346: Supplied parameters do not match any signature of call target. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts (1 errors) ==== - foo(...new SymbolIterator); - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2346: Supplied parameters do not match any signature of call target. - function foo(s1: symbol, ...s: symbol[]) { } class SymbolIterator { next() { @@ -18,4 +14,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts(1,1): error TS2346: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall4.js b/tests/baselines/reference/iteratorSpreadInCall4.js index 7819a1ba6f9..a0d655c25a8 100644 --- a/tests/baselines/reference/iteratorSpreadInCall4.js +++ b/tests/baselines/reference/iteratorSpreadInCall4.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall4.ts] -foo(...new SymbolIterator); - function foo(s1: symbol, ...s: symbol[]) { } class SymbolIterator { next() { @@ -13,10 +11,11 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator); //// [iteratorSpreadInCall4.js] -foo(...new SymbolIterator); function foo(s1, ...s) { } class SymbolIterator { next() { @@ -29,3 +28,4 @@ class SymbolIterator { return this; } } +foo(...new SymbolIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall5.js b/tests/baselines/reference/iteratorSpreadInCall5.js index a4a30ee0166..b17054363ed 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.js +++ b/tests/baselines/reference/iteratorSpreadInCall5.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall5.ts] -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | string)[]) { } class SymbolIterator { next() { @@ -26,10 +24,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall5.js] -foo(...new SymbolIterator, ...new StringIterator); function foo(...s) { } class SymbolIterator { next() { @@ -53,3 +52,4 @@ class StringIterator { return this; } } +foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall5.symbols b/tests/baselines/reference/iteratorSpreadInCall5.symbols index 0ed608e0589..81143b79f29 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.symbols +++ b/tests/baselines/reference/iteratorSpreadInCall5.symbols @@ -1,26 +1,21 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts === -foo(...new SymbolIterator, ...new StringIterator); ->foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 50)) ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) - function foo(...s: (symbol | string)[]) { } ->foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 50)) ->s : Symbol(s, Decl(iteratorSpreadInCall5.ts, 2, 13)) +>foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 0)) +>s : Symbol(s, Decl(iteratorSpreadInCall5.ts, 0, 13)) class SymbolIterator { ->SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 0, 43)) next() { ->next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall5.ts, 3, 22)) +>next : Symbol(SymbolIterator.next, Decl(iteratorSpreadInCall5.ts, 1, 22)) return { value: Symbol(), ->value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 5, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 3, 16)) >Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 6, 28)) +>done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 4, 28)) }; } @@ -31,22 +26,22 @@ class SymbolIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 2, 43)) +>this : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 0, 43)) } } class StringIterator { ->StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) next() { ->next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall5.ts, 16, 22)) +>next : Symbol(StringIterator.next, Decl(iteratorSpreadInCall5.ts, 14, 22)) return { value: "", ->value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 18, 16)) +>value : Symbol(value, Decl(iteratorSpreadInCall5.ts, 16, 16)) done: false ->done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 19, 22)) +>done : Symbol(done, Decl(iteratorSpreadInCall5.ts, 17, 22)) }; } @@ -57,6 +52,12 @@ class StringIterator { >iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --)) return this; ->this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 14, 1)) +>this : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) } } + +foo(...new SymbolIterator, ...new StringIterator); +>foo : Symbol(foo, Decl(iteratorSpreadInCall5.ts, 0, 0)) +>SymbolIterator : Symbol(SymbolIterator, Decl(iteratorSpreadInCall5.ts, 0, 43)) +>StringIterator : Symbol(StringIterator, Decl(iteratorSpreadInCall5.ts, 12, 1)) + diff --git a/tests/baselines/reference/iteratorSpreadInCall5.types b/tests/baselines/reference/iteratorSpreadInCall5.types index 9542a76daf1..a4f16829d52 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.types +++ b/tests/baselines/reference/iteratorSpreadInCall5.types @@ -1,14 +1,4 @@ === tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts === -foo(...new SymbolIterator, ...new StringIterator); ->foo(...new SymbolIterator, ...new StringIterator) : void ->foo : (...s: (string | symbol)[]) => void ->...new SymbolIterator : symbol ->new SymbolIterator : SymbolIterator ->SymbolIterator : typeof SymbolIterator ->...new StringIterator : string ->new StringIterator : StringIterator ->StringIterator : typeof StringIterator - function foo(...s: (symbol | string)[]) { } >foo : (...s: (string | symbol)[]) => void >s : (string | symbol)[] @@ -73,3 +63,14 @@ class StringIterator { >this : this } } + +foo(...new SymbolIterator, ...new StringIterator); +>foo(...new SymbolIterator, ...new StringIterator) : void +>foo : (...s: (string | symbol)[]) => void +>...new SymbolIterator : symbol +>new SymbolIterator : SymbolIterator +>SymbolIterator : typeof SymbolIterator +>...new StringIterator : string +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt index 93aaec8c330..2c89c7bb493 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall6.errors.txt @@ -1,11 +1,7 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(1,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. +tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(28,28): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts (1 errors) ==== - foo(...new SymbolIterator, ...new StringIterator); - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. - function foo(...s: (symbol | number)[]) { } class SymbolIterator { next() { @@ -31,4 +27,8 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts(1,28): error TS2345: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator, ...new StringIterator); + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number | symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall6.js b/tests/baselines/reference/iteratorSpreadInCall6.js index 8ad60be911e..161f420ce0e 100644 --- a/tests/baselines/reference/iteratorSpreadInCall6.js +++ b/tests/baselines/reference/iteratorSpreadInCall6.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall6.ts] -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | number)[]) { } class SymbolIterator { next() { @@ -26,10 +24,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall6.js] -foo(...new SymbolIterator, ...new StringIterator); function foo(...s) { } class SymbolIterator { next() { @@ -53,3 +52,4 @@ class StringIterator { return this; } } +foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall7.errors.txt b/tests/baselines/reference/iteratorSpreadInCall7.errors.txt index 51cae1d72b2..30096c90db6 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall7.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(1,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(28,1): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts (1 errors) ==== - foo(...new SymbolIterator, ...new StringIterator); - ~~~ -!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. - function foo(...s: T[]) { return s[0]; } class SymbolIterator { next() { @@ -33,4 +28,9 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts(1,1): error TS2453: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + foo(...new SymbolIterator, ...new StringIterator); + ~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall7.js b/tests/baselines/reference/iteratorSpreadInCall7.js index 4a56b75d236..e7c354413df 100644 --- a/tests/baselines/reference/iteratorSpreadInCall7.js +++ b/tests/baselines/reference/iteratorSpreadInCall7.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall7.ts] -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: T[]) { return s[0]; } class SymbolIterator { next() { @@ -26,10 +24,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall7.js] -foo(...new SymbolIterator, ...new StringIterator); function foo(...s) { return s[0]; } class SymbolIterator { next() { @@ -53,3 +52,4 @@ class StringIterator { return this; } } +foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall8.errors.txt b/tests/baselines/reference/iteratorSpreadInCall8.errors.txt index d7913458b6a..5fd0b43ce5a 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall8.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(1,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(31,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts (1 errors) ==== - new Foo(...new SymbolIterator, ...new StringIterator); - ~~~ -!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. - class Foo { constructor(...s: T[]) { } } @@ -36,4 +31,9 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts(1,5): error TS2453: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + new Foo(...new SymbolIterator, ...new StringIterator); + ~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall8.js b/tests/baselines/reference/iteratorSpreadInCall8.js index 3871ff83bc6..a591fd363ab 100644 --- a/tests/baselines/reference/iteratorSpreadInCall8.js +++ b/tests/baselines/reference/iteratorSpreadInCall8.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall8.ts] -new Foo(...new SymbolIterator, ...new StringIterator); - class Foo { constructor(...s: T[]) { } } @@ -29,10 +27,11 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +new Foo(...new SymbolIterator, ...new StringIterator); //// [iteratorSpreadInCall8.js] -new Foo(...new SymbolIterator, ...new StringIterator); class Foo { constructor(...s) { } } @@ -58,3 +57,4 @@ class StringIterator { return this; } } +new Foo(...new SymbolIterator, ...new StringIterator); diff --git a/tests/baselines/reference/iteratorSpreadInCall9.errors.txt b/tests/baselines/reference/iteratorSpreadInCall9.errors.txt index da2ee7f8efc..59854bd36ad 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.errors.txt +++ b/tests/baselines/reference/iteratorSpreadInCall9.errors.txt @@ -1,13 +1,8 @@ -tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(1,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(31,5): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. ==== tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts (1 errors) ==== - new Foo(...new SymbolIterator, ...[...new StringIterator]); - ~~~ -!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. -!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. - class Foo { constructor(...s: T[]) { } } @@ -36,4 +31,10 @@ tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts(1,5): error TS2453: [Symbol.iterator]() { return this; } - } \ No newline at end of file + } + + new Foo(...new SymbolIterator, ...[...new StringIterator]); + ~~~ +!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. +!!! error TS2453: Type argument candidate 'symbol' is not a valid type argument because it is not a supertype of candidate 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/iteratorSpreadInCall9.js b/tests/baselines/reference/iteratorSpreadInCall9.js index da80c461b1b..3f54728fd88 100644 --- a/tests/baselines/reference/iteratorSpreadInCall9.js +++ b/tests/baselines/reference/iteratorSpreadInCall9.js @@ -1,6 +1,4 @@ //// [iteratorSpreadInCall9.ts] -new Foo(...new SymbolIterator, ...[...new StringIterator]); - class Foo { constructor(...s: T[]) { } } @@ -29,10 +27,12 @@ class StringIterator { [Symbol.iterator]() { return this; } -} +} + +new Foo(...new SymbolIterator, ...[...new StringIterator]); + //// [iteratorSpreadInCall9.js] -new Foo(...new SymbolIterator, ...[...new StringIterator]); class Foo { constructor(...s) { } } @@ -58,3 +58,4 @@ class StringIterator { return this; } } +new Foo(...new SymbolIterator, ...[...new StringIterator]); diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js index 704c39891e6..616d5392c8b 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.js @@ -1,13 +1,13 @@ //// [recursiveClassInstantiationsWithDefaultConstructors.ts] -var a = new TypeScript2.MemberNameArray() module TypeScript2 { -export class MemberName { -public prefix: string = ""; + export class MemberName { + public prefix: string = ""; + } + export class MemberNameArray extends MemberName { + } } -export class MemberNameArray extends MemberName { -} -} - + +var a = new TypeScript2.MemberNameArray() //// [recursiveClassInstantiationsWithDefaultConstructors.js] var __extends = (this && this.__extends) || (function () { @@ -20,7 +20,6 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var a = new TypeScript2.MemberNameArray(); var TypeScript2; (function (TypeScript2) { var MemberName = (function () { @@ -39,3 +38,4 @@ var TypeScript2; }(MemberName)); TypeScript2.MemberNameArray = MemberNameArray; })(TypeScript2 || (TypeScript2 = {})); +var a = new TypeScript2.MemberNameArray(); diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols index c722d8ef8f7..7d87f5ec91f 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.symbols @@ -1,22 +1,22 @@ === tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts === -var a = new TypeScript2.MemberNameArray() ->a : Symbol(a, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 3)) ->TypeScript2.MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 4, 1)) ->TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 41)) ->MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 4, 1)) - module TypeScript2 { ->TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 41)) +>TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 0)) -export class MemberName { ->MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 1, 20)) + export class MemberName { +>MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 20)) -public prefix: string = ""; ->prefix : Symbol(MemberName.prefix, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 2, 25)) -} -export class MemberNameArray extends MemberName { ->MemberNameArray : Symbol(MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 4, 1)) ->MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 1, 20)) -} + public prefix: string = ""; +>prefix : Symbol(MemberName.prefix, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 1, 29)) + } + export class MemberNameArray extends MemberName { +>MemberNameArray : Symbol(MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 3, 5)) +>MemberName : Symbol(MemberName, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 20)) + } } +var a = new TypeScript2.MemberNameArray() +>a : Symbol(a, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 8, 3)) +>TypeScript2.MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 3, 5)) +>TypeScript2 : Symbol(TypeScript2, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 0, 0)) +>MemberNameArray : Symbol(TypeScript2.MemberNameArray, Decl(recursiveClassInstantiationsWithDefaultConstructors.ts, 3, 5)) + diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types index 3e74ba7f57b..f1cf5894cde 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types @@ -1,4 +1,20 @@ === tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts === +module TypeScript2 { +>TypeScript2 : typeof TypeScript2 + + export class MemberName { +>MemberName : MemberName + + public prefix: string = ""; +>prefix : string +>"" : "" + } + export class MemberNameArray extends MemberName { +>MemberNameArray : MemberNameArray +>MemberName : MemberName + } +} + var a = new TypeScript2.MemberNameArray() >a : TypeScript2.MemberNameArray >new TypeScript2.MemberNameArray() : TypeScript2.MemberNameArray @@ -6,19 +22,3 @@ var a = new TypeScript2.MemberNameArray() >TypeScript2 : typeof TypeScript2 >MemberNameArray : typeof TypeScript2.MemberNameArray -module TypeScript2 { ->TypeScript2 : typeof TypeScript2 - -export class MemberName { ->MemberName : MemberName - -public prefix: string = ""; ->prefix : string ->"" : "" -} -export class MemberNameArray extends MemberName { ->MemberNameArray : MemberNameArray ->MemberName : MemberName -} -} - diff --git a/tests/baselines/reference/typeArgumentInferenceOrdering.js b/tests/baselines/reference/typeArgumentInferenceOrdering.js index d6e5666b550..f7a46c84385 100644 --- a/tests/baselines/reference/typeArgumentInferenceOrdering.js +++ b/tests/baselines/reference/typeArgumentInferenceOrdering.js @@ -1,7 +1,4 @@ //// [typeArgumentInferenceOrdering.ts] -function foo(f: { y: T }): T { return null } -var x = foo(new C()).x; // was Error that property x does not exist on type {} - class C { y: I; } @@ -13,13 +10,15 @@ interface I { interface Goo { p: string; } - + +function foo(f: { y: T }): T { return null } +var x = foo(new C()).x; // was Error that property x does not exist on type {} //// [typeArgumentInferenceOrdering.js] -function foo(f) { return null; } -var x = foo(new C()).x; // was Error that property x does not exist on type {} var C = (function () { function C() { } return C; }()); +function foo(f) { return null; } +var x = foo(new C()).x; // was Error that property x does not exist on type {} diff --git a/tests/baselines/reference/typeArgumentInferenceOrdering.symbols b/tests/baselines/reference/typeArgumentInferenceOrdering.symbols index 630aebcf185..0c01b4d8a5d 100644 --- a/tests/baselines/reference/typeArgumentInferenceOrdering.symbols +++ b/tests/baselines/reference/typeArgumentInferenceOrdering.symbols @@ -1,39 +1,39 @@ === tests/cases/compiler/typeArgumentInferenceOrdering.ts === -function foo(f: { y: T }): T { return null } ->foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) ->T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 0, 13)) ->f : Symbol(f, Decl(typeArgumentInferenceOrdering.ts, 0, 16)) ->y : Symbol(y, Decl(typeArgumentInferenceOrdering.ts, 0, 20)) ->T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 0, 13)) ->T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 0, 13)) - -var x = foo(new C()).x; // was Error that property x does not exist on type {} ->x : Symbol(x, Decl(typeArgumentInferenceOrdering.ts, 1, 3)) ->foo(new C()).x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 7, 13)) ->foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) ->C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 1, 23)) ->x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 7, 13)) - class C { ->C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 1, 23)) +>C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) y: I; ->y : Symbol(C.y, Decl(typeArgumentInferenceOrdering.ts, 3, 9)) ->I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 5, 1)) +>y : Symbol(C.y, Decl(typeArgumentInferenceOrdering.ts, 0, 9)) +>I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 2, 1)) } interface I { ->I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 5, 1)) +>I : Symbol(I, Decl(typeArgumentInferenceOrdering.ts, 2, 1)) x(): Goo; ->x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 7, 13)) ->Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 9, 1)) +>x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 4, 13)) +>Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 6, 1)) } interface Goo { ->Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 9, 1)) +>Goo : Symbol(Goo, Decl(typeArgumentInferenceOrdering.ts, 6, 1)) p: string; ->p : Symbol(Goo.p, Decl(typeArgumentInferenceOrdering.ts, 11, 15)) +>p : Symbol(Goo.p, Decl(typeArgumentInferenceOrdering.ts, 8, 15)) } +function foo(f: { y: T }): T { return null } +>foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 10, 1)) +>T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 12, 13)) +>f : Symbol(f, Decl(typeArgumentInferenceOrdering.ts, 12, 16)) +>y : Symbol(y, Decl(typeArgumentInferenceOrdering.ts, 12, 20)) +>T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 12, 13)) +>T : Symbol(T, Decl(typeArgumentInferenceOrdering.ts, 12, 13)) + +var x = foo(new C()).x; // was Error that property x does not exist on type {} +>x : Symbol(x, Decl(typeArgumentInferenceOrdering.ts, 13, 3)) +>foo(new C()).x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 4, 13)) +>foo : Symbol(foo, Decl(typeArgumentInferenceOrdering.ts, 10, 1)) +>C : Symbol(C, Decl(typeArgumentInferenceOrdering.ts, 0, 0)) +>x : Symbol(I.x, Decl(typeArgumentInferenceOrdering.ts, 4, 13)) + diff --git a/tests/baselines/reference/typeArgumentInferenceOrdering.types b/tests/baselines/reference/typeArgumentInferenceOrdering.types index 1bbeadcf4d5..788ab2285a3 100644 --- a/tests/baselines/reference/typeArgumentInferenceOrdering.types +++ b/tests/baselines/reference/typeArgumentInferenceOrdering.types @@ -1,22 +1,4 @@ === tests/cases/compiler/typeArgumentInferenceOrdering.ts === -function foo(f: { y: T }): T { return null } ->foo : (f: { y: T; }) => T ->T : T ->f : { y: T; } ->y : T ->T : T ->T : T ->null : null - -var x = foo(new C()).x; // was Error that property x does not exist on type {} ->x : () => Goo ->foo(new C()).x : () => Goo ->foo(new C()) : I ->foo : (f: { y: T; }) => T ->new C() : C ->C : typeof C ->x : () => Goo - class C { >C : C @@ -40,3 +22,21 @@ interface Goo { >p : string } +function foo(f: { y: T }): T { return null } +>foo : (f: { y: T; }) => T +>T : T +>f : { y: T; } +>y : T +>T : T +>T : T +>null : null + +var x = foo(new C()).x; // was Error that property x does not exist on type {} +>x : () => Goo +>foo(new C()).x : () => Goo +>foo(new C()) : I +>foo : (f: { y: T; }) => T +>new C() : C +>C : typeof C +>x : () => Goo + diff --git a/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts b/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts index 1f76e4e6b56..9f008cd2b1e 100644 --- a/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts +++ b/tests/cases/compiler/recursiveClassInstantiationsWithDefaultConstructors.ts @@ -1,8 +1,9 @@ -var a = new TypeScript2.MemberNameArray() module TypeScript2 { -export class MemberName { -public prefix: string = ""; -} -export class MemberNameArray extends MemberName { -} + export class MemberName { + public prefix: string = ""; + } + export class MemberNameArray extends MemberName { + } } + +var a = new TypeScript2.MemberNameArray() \ No newline at end of file diff --git a/tests/cases/compiler/typeArgumentInferenceOrdering.ts b/tests/cases/compiler/typeArgumentInferenceOrdering.ts index 6887f7455d6..faa7b45a4ac 100644 --- a/tests/cases/compiler/typeArgumentInferenceOrdering.ts +++ b/tests/cases/compiler/typeArgumentInferenceOrdering.ts @@ -1,6 +1,3 @@ -function foo(f: { y: T }): T { return null } -var x = foo(new C()).x; // was Error that property x does not exist on type {} - class C { y: I; } @@ -12,3 +9,6 @@ interface I { interface Goo { p: string; } + +function foo(f: { y: T }): T { return null } +var x = foo(new C()).x; // was Error that property x does not exist on type {} \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts index 7b3be0365e9..7a4cd1a2e4c 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts @@ -1,5 +1,4 @@ //@target: ES6 -var [a, b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var [a, b] = new SymbolIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts index 35d05ef1f9c..591cdd2b6a5 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, b]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts index ed93b5175d0..83ab94decec 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, b] = new FooIterator) { } +fun(new FooIterator); diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts index b7e763694ea..079eb25df4a 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, ...b] = new FooIterator) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, ...b] = new FooIterator) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts index f0b9b142f40..f4909547e26 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern13.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, ...b]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts index c327efa3ec2..976c5148232 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern14.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[a, ...b]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[a, ...b]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts index 21d632fd541..ecc686b634a 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern15.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[a, b]: Bar[]) { } -fun(...new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[a, b]: Bar[]) { } +fun(...new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts index 90db0e5edb5..b81114cab23 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern17.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[a, b]: Bar[]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts index e6e5ad617b2..a03713037d6 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern18.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([a, b]: Bar[]) { } -fun(new FooIterator); class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([a, b]: Bar[]) { } +fun(new FooIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts index 8513dd07649..32024e83b1b 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern19.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun([[a], b]: Bar[][]) { } -fun(new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,4 +12,7 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun([[a], b]: Bar[][]) { } +fun(new FooArrayIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts index 587f1f0b056..d5543c0aed6 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern2.ts @@ -1,5 +1,4 @@ //@target: ES6 -var [a, ...b] = new SymbolIterator; class SymbolIterator { next() { return { @@ -11,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var [a, ...b] = new SymbolIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts index b5be67b393f..6a0e9126734 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern20.ts @@ -1,6 +1,4 @@ //@target: ES6 -function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } -fun(...new FooArrayIterator); class Bar { x } class Foo extends Bar { y } class FooArrayIterator { @@ -14,4 +12,7 @@ class FooArrayIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +function fun(...[[a = new Foo], b = [new Foo]]: Bar[][]) { } +fun(...new FooArrayIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts index 31656b5661f..ff63aa74179 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern3.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: Bar; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: Bar; +[a, b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts index edd95be1598..b5aef9003b1 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern4.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: Bar[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: Bar[]; +[a, ...b] = new FooIterator \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts index b51d0f09d08..a3911b1f5ef 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern5.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string; +[a, b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts index fc9395ed6a4..057b9aeaffe 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern6.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string[]; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string[]; +[a, ...b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts index 85b2f2e54e3..965b7157670 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern7.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string[]; -[a, b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string[]; +[a, b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts b/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts index dd49205d6e0..5638b4c49c6 100644 --- a/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts +++ b/tests/cases/conformance/es6/destructuring/iterableArrayPattern8.ts @@ -1,6 +1,4 @@ //@target: ES6 -var a: Bar, b: string; -[a, ...b] = new FooIterator; class Bar { x } class Foo extends Bar { y } class FooIterator { @@ -14,4 +12,7 @@ class FooIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var a: Bar, b: string; +[a, ...b] = new FooIterator; \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts index 84fbda4825c..f79794d59d5 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of14.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of14.ts @@ -1,9 +1,9 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should fail because the iterator is not iterable - class StringIterator { next() { return ""; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should fail because the iterator is not iterable \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts index 1973e7ff95e..b2e788bdef2 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of15.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of15.ts @@ -1,7 +1,4 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { next() { return ""; @@ -9,4 +6,7 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should fail \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts index 8f7bd6d8486..fe78bae2aef 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of16.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of16.ts @@ -1,9 +1,9 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should fail - class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should fail \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of17.ts b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts index 431f066d477..b7270cbb813 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of17.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of17.ts @@ -1,7 +1,4 @@ //@target: ES6 -var v: string; -for (v of new NumberIterator) { } // Should succeed - class NumberIterator { next() { return { @@ -12,4 +9,7 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new NumberIterator) { } // Should succeed \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts index 407ad7f0ed8..647ae314b4d 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of18.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of18.ts @@ -1,7 +1,4 @@ //@target: ES6 -var v: string; -for (v of new StringIterator) { } // Should succeed - class StringIterator { next() { return { @@ -12,4 +9,7 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var v: string; +for (v of new StringIterator) { } // Should succeed \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts index ff80b2690ef..be51d219dc0 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of19.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of19.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (var v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (var v of new FooIterator) { + v; } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of20.ts b/tests/cases/conformance/es6/for-ofStatements/for-of20.ts index 615f5149375..3aa537a9f6f 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of20.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of20.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (let v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (let v of new FooIterator) { + v; } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of21.ts b/tests/cases/conformance/es6/for-ofStatements/for-of21.ts index 4e4621034e1..ab1e6fff269 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of21.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of21.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (const v of new FooIterator) { - v; -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + v; } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of22.ts b/tests/cases/conformance/es6/for-ofStatements/for-of22.ts index 10a96502cdd..c9a88340792 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of22.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of22.ts @@ -1,9 +1,4 @@ //@target: ES6 -v; -for (var v of new FooIterator) { - -} - class Foo { } class FooIterator { next() { @@ -15,4 +10,9 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +v; +for (var v of new FooIterator) { + } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of23.ts b/tests/cases/conformance/es6/for-ofStatements/for-of23.ts index 81227cd0665..df734181077 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of23.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of23.ts @@ -1,8 +1,4 @@ //@target: ES6 -for (const v of new FooIterator) { - const v = 0; // new scope -} - class Foo { } class FooIterator { next() { @@ -14,4 +10,8 @@ class FooIterator { [Symbol.iterator]() { return this; } +} + +for (const v of new FooIterator) { + const v = 0; // new scope } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of25.ts b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts index a1698bd2824..61e6a58ce30 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of25.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of25.ts @@ -1,9 +1,9 @@ //@target: ES6 -var x: any; -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return x; } -} \ No newline at end of file +} + +var x: any; +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of26.ts b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts index 0ab564a4f52..4414fdc1592 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of26.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of26.ts @@ -1,7 +1,4 @@ //@target: ES6 -var x: any; -for (var v of new StringIterator) { } - class StringIterator { next() { return x; @@ -9,4 +6,7 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var x: any; +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of27.ts b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts index 8f2b84cbe1d..f7244eed34c 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of27.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of27.ts @@ -1,6 +1,6 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]: any; -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of28.ts b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts index 8c693193b08..e1b86f6135f 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of28.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of28.ts @@ -1,9 +1,9 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { next: any; [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of30.ts b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts index 03b97c23136..67e1e3da70a 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of30.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of30.ts @@ -1,6 +1,4 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -14,4 +12,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of31.ts b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts index 307f9b7cd43..701fcb50ed0 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of31.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of31.ts @@ -1,6 +1,4 @@ //@target: ES6 -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -12,4 +10,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of33.ts b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts index b73d2daee8a..f0af5c4a408 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of33.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of33.ts @@ -1,9 +1,9 @@ //@target: ES6 //@noImplicitAny: true -for (var v of new StringIterator) { } - class StringIterator { [Symbol.iterator]() { return v; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of34.ts b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts index d00f5ccde2e..63b88223996 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of34.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of34.ts @@ -1,7 +1,5 @@ //@target: ES6 //@noImplicitAny: true -for (var v of new StringIterator) { } - class StringIterator { next() { return v; @@ -10,4 +8,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of35.ts b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts index 0d66ce39edf..ab6e26d6d60 100644 --- a/tests/cases/conformance/es6/for-ofStatements/for-of35.ts +++ b/tests/cases/conformance/es6/for-ofStatements/for-of35.ts @@ -1,7 +1,5 @@ //@target: ES6 //@noImplicitAny: true -for (var v of new StringIterator) { } - class StringIterator { next() { return { @@ -13,4 +11,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts index 4b4f3e8cc1c..88a85a4b883 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts index f8549b82b76..56ff08e79f3 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray10.ts @@ -1,8 +1,8 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts index 9db5d010874..e267386a509 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray2.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new NumberIterator, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -25,4 +23,6 @@ class NumberIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new NumberIterator, ...new SymbolIterator]; diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts index 174c97de7cc..8ef12250ce5 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray3.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...[0, 1], ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...[0, 1], ...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts index 47c2e633702..ec9faa78fe6 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray4.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [0, 1, ...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts index e6a8041a961..d4df51739c9 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray5.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array: number[] = [0, 1, ...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -12,4 +10,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array: number[] = [0, 1, ...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts index 7495ca6aac6..1d021ca6122 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray6.ts @@ -1,7 +1,4 @@ //@target: ES6 -var array: number[] = [0, 1]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,4 +10,7 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array: number[] = [0, 1]; +array.concat([...new SymbolIterator]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts index 12ca478c738..2f96507c093 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray7.ts @@ -1,7 +1,4 @@ //@target: ES6 -var array: symbol[]; -array.concat([...new SymbolIterator]); - class SymbolIterator { next() { return { @@ -13,4 +10,7 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array: symbol[]; +array.concat([...new SymbolIterator]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts index 0e2258aa5ea..8cc56068f84 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray8.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -8,4 +6,6 @@ class SymbolIterator { done: false }; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts index 2b8d93c9ccb..5bb80fd0c71 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInArray9.ts @@ -1,6 +1,4 @@ //@target: ES6 -var array = [...new SymbolIterator]; - class SymbolIterator { next() { return { @@ -11,4 +9,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +var array = [...new SymbolIterator]; \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts index 85d07e56996..34f6a7eb8f0 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s: symbol) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts index bf8ad336fbf..aeb9aabde50 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall10.ts @@ -1,8 +1,5 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts index 182e454cfc8..795e9603be4 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall11.ts @@ -1,8 +1,5 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(...s: T[]) { return s[0] } - class SymbolIterator { next() { return { @@ -14,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts index a0bd1ede193..06bceec84f5 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall12.ts @@ -1,6 +1,4 @@ //@target: ES6 -new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); - class Foo { constructor(...s: T[]) { } } @@ -29,4 +27,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +new Foo(...[...new SymbolIterator, ...[...new StringIterator]]); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts index 4a8fd9ff389..e6d72775943 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall2.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s: symbol[]) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts index b6e8fe0c86b..0391dfdad0f 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall3.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(...s: symbol[]) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts index 2a73fd6f3c9..f3747f25869 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall4.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator); - function foo(s1: symbol, ...s: symbol[]) { } class SymbolIterator { next() { @@ -13,4 +11,6 @@ class SymbolIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts index c17c4156e65..53b0e660379 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall5.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | string)[]) { } class SymbolIterator { next() { @@ -26,4 +24,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts index 2c6150f8040..c48260e97ea 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall6.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: (symbol | number)[]) { } class SymbolIterator { next() { @@ -26,4 +24,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts index 56fb7936eb7..6893cd9d8a4 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall7.ts @@ -1,6 +1,4 @@ //@target: ES6 -foo(...new SymbolIterator, ...new StringIterator); - function foo(...s: T[]) { return s[0]; } class SymbolIterator { next() { @@ -26,4 +24,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts index e5b969456b7..c81a475d7de 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall8.ts @@ -1,6 +1,4 @@ //@target: ES6 -new Foo(...new SymbolIterator, ...new StringIterator); - class Foo { constructor(...s: T[]) { } } @@ -29,4 +27,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +new Foo(...new SymbolIterator, ...new StringIterator); \ No newline at end of file diff --git a/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts b/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts index 470f99844ba..41ee21a5645 100644 --- a/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts +++ b/tests/cases/conformance/es6/spread/iteratorSpreadInCall9.ts @@ -1,6 +1,4 @@ //@target: ES6 -new Foo(...new SymbolIterator, ...[...new StringIterator]); - class Foo { constructor(...s: T[]) { } } @@ -29,4 +27,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +new Foo(...new SymbolIterator, ...[...new StringIterator]); diff --git a/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts b/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts index 185641d0804..b832d57855e 100644 --- a/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts +++ b/tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts @@ -1,5 +1,4 @@ //@target: ES5 -for (var v of new StringIterator) { } // In ES3/5, you cannot for...of over an arbitrary iterable. class StringIterator { @@ -12,4 +11,6 @@ class StringIterator { [Symbol.iterator]() { return this; } -} \ No newline at end of file +} + +for (var v of new StringIterator) { } \ No newline at end of file diff --git a/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts b/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts index 98f94718f30..4cc3a723951 100644 --- a/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts +++ b/tests/cases/conformance/types/typeAliases/classDoesNotDependOnBaseTypes.ts @@ -1,12 +1,12 @@ -var x: StringTree; -if (typeof x !== "string") { - x[0] = ""; - x[0] = new StringTreeCollection; -} - type StringTree = string | StringTreeCollection; class StringTreeCollectionBase { [n: number]: StringTree; } -class StringTreeCollection extends StringTreeCollectionBase { } \ No newline at end of file +class StringTreeCollection extends StringTreeCollectionBase { } + +var x: StringTree; +if (typeof x !== "string") { + x[0] = ""; + x[0] = new StringTreeCollection; +} \ No newline at end of file From f7df4e00cc515e326dfdd9afdab518a80524a7cd Mon Sep 17 00:00:00 2001 From: Yui T Date: Sat, 25 Feb 2017 22:40:47 -0800 Subject: [PATCH 034/207] Update baselines --- .../reference/exportImport.errors.txt | 22 +++++++++++++++++++ ...eExportAssignmentOfGenericClass.errors.txt | 20 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/baselines/reference/exportImport.errors.txt create mode 100644 tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt diff --git a/tests/baselines/reference/exportImport.errors.txt b/tests/baselines/reference/exportImport.errors.txt new file mode 100644 index 00000000000..fb5a41fe1eb --- /dev/null +++ b/tests/baselines/reference/exportImport.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/w1.ts(2,1): error TS2449: Class 'Widget1' used before its declaration. +tests/cases/compiler/w1.ts(2,10): error TS2449: Class 'Widget1' used before its declaration. + + +==== tests/cases/compiler/consumer.ts (0 errors) ==== + import e = require('./exporter'); + + export function w(): e.w { // Should be OK + return new e.w(); + } +==== tests/cases/compiler/w1.ts (2 errors) ==== + + export = Widget1 + ~~~~~~~~~~~~~~~~ +!!! error TS2449: Class 'Widget1' used before its declaration. + ~~~~~~~ +!!! error TS2449: Class 'Widget1' used before its declaration. + class Widget1 { name = 'one'; } + +==== tests/cases/compiler/exporter.ts (0 errors) ==== + export import w = require('./w1'); + \ No newline at end of file diff --git a/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt new file mode 100644 index 00000000000..2945950068a --- /dev/null +++ b/tests/baselines/reference/privacyCheckExternalModuleExportAssignmentOfGenericClass.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,1): error TS2449: Class 'Foo' used before its declaration. +tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts(1,10): error TS2449: Class 'Foo' used before its declaration. + + +==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_1.ts (0 errors) ==== + import Foo = require("./privacyCheckExternalModuleExportAssignmentOfGenericClass_0"); + export = Bar; + interface Bar { + foo: Foo; + } +==== tests/cases/compiler/privacyCheckExternalModuleExportAssignmentOfGenericClass_0.ts (2 errors) ==== + export = Foo; + ~~~~~~~~~~~~~ +!!! error TS2449: Class 'Foo' used before its declaration. + ~~~ +!!! error TS2449: Class 'Foo' used before its declaration. + class Foo { + constructor(public a: A) { } + } + \ No newline at end of file From 5d46d434e0fc21b4533f1cd9f3c64648204d85b2 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 27 Feb 2017 11:21:12 -0800 Subject: [PATCH 035/207] Error when used enum before declaration --- src/compiler/checker.ts | 16 ++++++++++------ src/compiler/diagnosticMessages.json | 4 ++++ .../enumUsedBeforeDeclaration.errors.txt | 15 +++++++++++++++ .../reference/enumUsedBeforeDeclaration.js | 17 +++++++++++++++++ .../cases/compiler/enumUsedBeforeDeclaration.ts | 5 +++++ 5 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt create mode 100644 tests/baselines/reference/enumUsedBeforeDeclaration.js create mode 100644 tests/cases/compiler/enumUsedBeforeDeclaration.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 57905315d73..ca1ff705413 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1056,9 +1056,10 @@ namespace ts { // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped - if (meaning & SymbolFlags.BlockScopedVariable || (meaning & SymbolFlags.Class && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) { + if (meaning & SymbolFlags.BlockScopedVariable || + ((meaning & SymbolFlags.Class || meaning & SymbolFlags.Enum) && (meaning & SymbolFlags.Value) === SymbolFlags.Value)) { const exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class) { + if (exportOrLocalSymbol.flags & SymbolFlags.BlockScopedVariable || exportOrLocalSymbol.flags & SymbolFlags.Class || exportOrLocalSymbol.flags & SymbolFlags.Enum) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } @@ -1171,19 +1172,22 @@ namespace ts { } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { - Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class)); + Debug.assert(!!(result.flags & SymbolFlags.BlockScopedVariable || result.flags & SymbolFlags.Class || result.flags & SymbolFlags.Enum)); // Block-scoped variables cannot be used before their definition - const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) ? d : undefined); + const declaration = forEach(result.declarations, d => isBlockOrCatchScoped(d) || isClassLike(d) || (d.kind === SyntaxKind.EnumDeclaration) ? d : undefined); - Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); + Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { if (result.flags & SymbolFlags.BlockScopedVariable) { error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); } - else { + else if (result.flags & SymbolFlags.Class) { error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(declaration.name)); } + else if (result.flags & SymbolFlags.Enum) { + error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(declaration.name)); + } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 691f8e8d31b..24cd0c9e671 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1439,6 +1439,10 @@ "category": "Error", "code": 2449 }, + "Enum '{0}' used before its declaration.": { + "category": "Error", + "code": 2450 + }, "Cannot redeclare block-scoped variable '{0}'.": { "category": "Error", "code": 2451 diff --git a/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt b/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt new file mode 100644 index 00000000000..aea5366389b --- /dev/null +++ b/tests/baselines/reference/enumUsedBeforeDeclaration.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/enumUsedBeforeDeclaration.ts(1,18): error TS2450: Enum 'Color' used before its declaration. +tests/cases/compiler/enumUsedBeforeDeclaration.ts(2,24): error TS2450: Enum 'ConstColor' used before its declaration. + + +==== tests/cases/compiler/enumUsedBeforeDeclaration.ts (2 errors) ==== + const v: Color = Color.Green; + ~~~~~ +!!! error TS2450: Enum 'Color' used before its declaration. + const v2: ConstColor = ConstColor.Green; + ~~~~~~~~~~ +!!! error TS2450: Enum 'ConstColor' used before its declaration. + enum Color { Red, Green, Blue } + const enum ConstColor { Red, Green, Blue } + + \ No newline at end of file diff --git a/tests/baselines/reference/enumUsedBeforeDeclaration.js b/tests/baselines/reference/enumUsedBeforeDeclaration.js new file mode 100644 index 00000000000..63fc38471b2 --- /dev/null +++ b/tests/baselines/reference/enumUsedBeforeDeclaration.js @@ -0,0 +1,17 @@ +//// [enumUsedBeforeDeclaration.ts] +const v: Color = Color.Green; +const v2: ConstColor = ConstColor.Green; +enum Color { Red, Green, Blue } +const enum ConstColor { Red, Green, Blue } + + + +//// [enumUsedBeforeDeclaration.js] +var v = Color.Green; +var v2 = 1 /* Green */; +var Color; +(function (Color) { + Color[Color["Red"] = 0] = "Red"; + Color[Color["Green"] = 1] = "Green"; + Color[Color["Blue"] = 2] = "Blue"; +})(Color || (Color = {})); diff --git a/tests/cases/compiler/enumUsedBeforeDeclaration.ts b/tests/cases/compiler/enumUsedBeforeDeclaration.ts new file mode 100644 index 00000000000..98f5fca86f1 --- /dev/null +++ b/tests/cases/compiler/enumUsedBeforeDeclaration.ts @@ -0,0 +1,5 @@ +const v: Color = Color.Green; +const v2: ConstColor = ConstColor.Green; +enum Color { Red, Green, Blue } +const enum ConstColor { Red, Green, Blue } + From d7e62bb9f7d08907ef8abfd807b018faf9a2b069 Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 3 Mar 2017 13:50:58 -0800 Subject: [PATCH 036/207] initial revision of infrastructure to produce text changes that uses existing node factory, formatter and printer --- Jakefile.js | 5 +- src/compiler/emitter.ts | 33 +- src/compiler/factory.ts | 4 + src/compiler/scanner.ts | 2 +- src/compiler/types.ts | 12 + src/compiler/utilities.ts | 14 +- src/compiler/visitor.ts | 150 ++--- src/harness/fourslash.ts | 11 +- src/harness/tsconfig.json | 3 +- src/harness/unittests/textChanges.ts | 520 ++++++++++++++++++ src/server/session.ts | 3 +- src/services/codeFixProvider.ts | 1 + .../fixClassSuperMustPrecedeThisAccess.ts | 17 +- .../fixConstructorForDerivedNeedSuperCall.ts | 7 +- .../fixExtendsInterfaceBecomesImplements.ts | 14 +- .../fixForgottenThisPropertyAccess.ts | 8 +- .../codefixes/unusedIdentifierFixes.ts | 133 ++--- src/services/formatting/formatting.ts | 50 +- src/services/formatting/formattingContext.ts | 2 +- src/services/formatting/formattingScanner.ts | 6 +- src/services/formatting/rulesProvider.ts | 4 + src/services/formatting/smartIndenter.ts | 87 +-- src/services/services.ts | 14 +- src/services/textChanges.ts | 475 ++++++++++++++++ src/services/tsconfig.json | 1 + src/services/types.ts | 10 +- src/services/utilities.ts | 14 +- .../reference/textChanges/deleteNode1.js | 13 + .../reference/textChanges/deleteNode2.js | 12 + .../reference/textChanges/deleteNode3.js | 14 + .../reference/textChanges/deleteNode4.js | 13 + .../reference/textChanges/deleteNode5.js | 16 + .../textChanges/deleteNodeInList1.js | 4 + .../textChanges/deleteNodeInList10.js | 10 + .../textChanges/deleteNodeInList11.js | 10 + .../textChanges/deleteNodeInList12.js | 10 + .../textChanges/deleteNodeInList13.js | 15 + .../textChanges/deleteNodeInList14.js | 15 + .../textChanges/deleteNodeInList15.js | 15 + .../textChanges/deleteNodeInList1_1.js | 4 + .../textChanges/deleteNodeInList2.js | 4 + .../textChanges/deleteNodeInList2_1.js | 4 + .../textChanges/deleteNodeInList3.js | 4 + .../textChanges/deleteNodeInList3_1.js | 4 + .../textChanges/deleteNodeInList4.js | 13 + .../textChanges/deleteNodeInList4_1.js | 17 + .../textChanges/deleteNodeInList5.js | 13 + .../textChanges/deleteNodeInList5_1.js | 16 + .../textChanges/deleteNodeInList6.js | 13 + .../textChanges/deleteNodeInList6_1.js | 16 + .../textChanges/deleteNodeInList7.js | 10 + .../textChanges/deleteNodeInList8.js | 10 + .../textChanges/deleteNodeInList9.js | 10 + .../reference/textChanges/deleteNodeRange1.js | 16 + .../reference/textChanges/deleteNodeRange2.js | 15 + .../reference/textChanges/deleteNodeRange3.js | 17 + .../reference/textChanges/deleteNodeRange4.js | 16 + .../reference/textChanges/deleteRange1.js | 15 + .../textChanges/extractMethodLike.js | 49 ++ .../reference/textChanges/insertNodeAfter1.js | 26 + .../reference/textChanges/insertNodeAfter2.js | 26 + .../insertNodeAfter3-block with newline.js | 16 + .../reference/textChanges/insertNodeAfter3.js | 14 + .../reference/textChanges/insertNodeAfter4.js | 16 + .../reference/textChanges/insertNodeAt1.js | 22 + .../reference/textChanges/insertNodeAt2.js | 20 + .../textChanges/insertNodeBefore1.js | 26 + .../textChanges/insertNodeBefore2.js | 26 + .../reference/textChanges/replaceNode1.js | 20 + .../replaceNode1NoLineBreakBefore.js | 13 + .../reference/textChanges/replaceNode2.js | 20 + .../reference/textChanges/replaceNode3.js | 21 + .../reference/textChanges/replaceNode4.js | 19 + .../reference/textChanges/replaceNode5.js | 19 + .../textChanges/replaceNodeRange1.js | 19 + .../textChanges/replaceNodeRange2.js | 19 + .../textChanges/replaceNodeRange3.js | 20 + .../textChanges/replaceNodeRange4.js | 18 + .../reference/textChanges/replaceRange.js | 19 + .../replaceRangeNoLineBreakBefore.js | 6 + .../replaceRangeWithForcedIndentation.js | 19 + .../fourslash/codeFixAddForgottenThis01.ts | 10 +- .../cases/fourslash/codeFixSuperAfterThis.ts | 10 +- tests/cases/fourslash/codeFixSuperCall.ts | 11 +- .../fourslash/unusedFunctionInNamespace1.ts | 1 - .../fourslash/unusedVariableInForLoop7FS.ts | 18 +- 86 files changed, 2208 insertions(+), 279 deletions(-) create mode 100644 src/harness/unittests/textChanges.ts create mode 100644 src/services/textChanges.ts create mode 100644 tests/baselines/reference/textChanges/deleteNode1.js create mode 100644 tests/baselines/reference/textChanges/deleteNode2.js create mode 100644 tests/baselines/reference/textChanges/deleteNode3.js create mode 100644 tests/baselines/reference/textChanges/deleteNode4.js create mode 100644 tests/baselines/reference/textChanges/deleteNode5.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList10.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList11.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList12.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList13.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList14.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList15.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList1_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList2_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList3.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList3_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList4.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList4_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList5.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList5_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList6.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList6_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList7.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList8.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList9.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange3.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange4.js create mode 100644 tests/baselines/reference/textChanges/deleteRange1.js create mode 100644 tests/baselines/reference/textChanges/extractMethodLike.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter3.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter4.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAt1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAt2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeBefore1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeBefore2.js create mode 100644 tests/baselines/reference/textChanges/replaceNode1.js create mode 100644 tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js create mode 100644 tests/baselines/reference/textChanges/replaceNode2.js create mode 100644 tests/baselines/reference/textChanges/replaceNode3.js create mode 100644 tests/baselines/reference/textChanges/replaceNode4.js create mode 100644 tests/baselines/reference/textChanges/replaceNode5.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange1.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange2.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange3.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange4.js create mode 100644 tests/baselines/reference/textChanges/replaceRange.js create mode 100644 tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js create mode 100644 tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js diff --git a/Jakefile.js b/Jakefile.js index f8be7c2b671..489bf62bd97 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -11,11 +11,7 @@ var ts = require("./lib/typescript"); // Variables var compilerDirectory = "src/compiler/"; -var servicesDirectory = "src/services/"; var serverDirectory = "src/server/"; -var typingsInstallerDirectory = "src/server/typingsInstaller"; -var cancellationTokenDirectory = "src/server/cancellationToken"; -var watchGuardDirectory = "src/server/watchGuard"; var harnessDirectory = "src/harness/"; var libraryDirectory = "src/lib/"; var scriptsDirectory = "scripts/"; @@ -131,6 +127,7 @@ var harnessSources = harnessCoreSources.concat([ "matchFiles.ts", "initializeTSConfig.ts", "printer.ts", + "textChanges.ts", "transform.ts", "customTransforms.ts", ].map(function (f) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ee224befd45..c286eb9df19 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -199,6 +199,8 @@ namespace ts { onEmitHelpers, onSetSourceFile, substituteNode, + onBeforeEmitNodeArray, + onAfterEmitNodeArray } = handlers; const newLine = getNewLineCharacter(printerOptions); @@ -631,6 +633,11 @@ namespace ts { if (isExpression(node)) { return pipelineEmitExpression(trySubstituteNode(EmitHint.Expression, node)); } + + if (isToken(node)) { + writeTokenText(kind); + return; + } } function pipelineEmitExpression(node: Node): void { @@ -1553,6 +1560,10 @@ namespace ts { emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint: EmitHint, body: Node): void { + emitBlockFunctionBody(body); + } + function emitSignatureAndBody(node: FunctionLikeDeclaration, emitSignatureHead: (node: SignatureDeclaration) => void) { const body = node.body; if (body) { @@ -1564,12 +1575,22 @@ namespace ts { if (getEmitFlags(node) & EmitFlags.ReuseTempVariableScope) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(EmitHint.Unspecified, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(EmitHint.Unspecified, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } @@ -2200,6 +2221,10 @@ namespace ts { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (isEmpty) { // Write a line terminator if the parent node was multi-line if (format & ListFormat.MultiLine) { @@ -2315,6 +2340,10 @@ namespace ts { } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } + if (format & ListFormat.BracketsMask) { write(getClosingBracket(format)); } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index cfafaabebff..530b0a240c3 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1099,6 +1099,10 @@ namespace ts { : node; } + export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode { + return createSynthesizedNode(kind); + } + export function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.FunctionDeclaration); node.decorators = asNodeArray(decorators); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index fb91b0ff5b7..b7a3f35d728 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -333,7 +333,7 @@ namespace ts { } /* @internal */ - export function getLineStarts(sourceFile: SourceFile): number[] { + export function getLineStarts(sourceFile: SourceFileLike): number[] { return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 53d84118609..90b1d2cec81 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2204,6 +2204,16 @@ name: string; } + /* @internal */ + /** + * Subset of properties from SourceFile that are used in multiple utility functions + */ + export interface SourceFileLike { + readonly text: string; + lineMap: number[]; + } + + // Source files are declarations when they are external modules. export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; @@ -4129,6 +4139,8 @@ /*@internal*/ onEmitSourceMapOfPosition?: (pos: number) => void; /*@internal*/ onEmitHelpers?: (node: Node, writeLines: (text: string) => void) => void; /*@internal*/ onSetSourceFile?: (node: SourceFile) => void; + /*@internal*/ onBeforeEmitNodeArray?: (nodes: NodeArray) => void; + /*@internal*/ onAfterEmitNodeArray?: (nodes: NodeArray) => void; } export interface PrinterOptions { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e107c4b669b..f37048a55d7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -184,7 +184,7 @@ namespace ts { return false; } - export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number { + export function getStartPositionOfLine(line: number, sourceFile: SourceFileLike): number { Debug.assert(line >= 0); return getLineStarts(sourceFile)[line]; } @@ -204,7 +204,7 @@ namespace ts { return value !== undefined; } - export function getEndLinePosition(line: number, sourceFile: SourceFile): number { + export function getEndLinePosition(line: number, sourceFile: SourceFileLike): number { Debug.assert(line >= 0); const lineStarts = getLineStarts(sourceFile); @@ -255,7 +255,11 @@ namespace ts { return !nodeIsMissing(node); } - export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number { + export function isToken(n: Node): boolean { + return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; + } + + export function getTokenPosOfNode(node: Node, sourceFile?: SourceFileLike, includeJsDoc?: boolean): number { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. if (nodeIsMissing(node)) { @@ -289,7 +293,7 @@ namespace ts { return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; } - export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number { + export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number { if (nodeIsMissing(node) || !node.decorators) { return getTokenPosOfNode(node, sourceFile); } @@ -2476,7 +2480,7 @@ namespace ts { return indentStrings[1].length; } - export function createTextWriter(newLine: String): EmitTextWriter { + export function createTextWriter(newLine: string): EmitTextWriter { let output: string; let indent: number; let lineStart: boolean; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 2d75d646128..db504847e27 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -154,9 +154,9 @@ namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext) { + export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes) { context.startLexicalEnvironment(); - const updated = visitNodes(nodes, visitor, isParameterDeclaration); + const updated = nodesVisitor(nodes, visitor, isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -204,9 +204,9 @@ namespace ts { * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ - export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext): T | undefined; + export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): T | undefined; - export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext): Node { + export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes): Node { if (node === undefined) { return undefined; } @@ -243,8 +243,8 @@ namespace ts { // Signature elements case SyntaxKind.Parameter: return updateParameter(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).dotDotDotToken, visitNode((node).name, visitor, isBindingName), visitNode((node).type, visitor, isTypeNode), @@ -257,55 +257,55 @@ namespace ts { // Type member case SyntaxKind.PropertyDeclaration: return updateProperty(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); case SyntaxKind.MethodDeclaration: return updateMethod(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isPropertyName), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.Constructor: return updateConstructor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.GetAccessor: return updateGetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.SetAccessor: return updateSetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitFunctionBody((node).body, visitor, context)); // Binding patterns case SyntaxKind.ObjectBindingPattern: return updateObjectBindingPattern(node, - visitNodes((node).elements, visitor, isBindingElement)); + nodesVisitor((node).elements, visitor, isBindingElement)); case SyntaxKind.ArrayBindingPattern: return updateArrayBindingPattern(node, - visitNodes((node).elements, visitor, isArrayBindingElement)); + nodesVisitor((node).elements, visitor, isArrayBindingElement)); case SyntaxKind.BindingElement: return updateBindingElement(node, @@ -317,11 +317,11 @@ namespace ts { // Expression case SyntaxKind.ArrayLiteralExpression: return updateArrayLiteral(node, - visitNodes((node).elements, visitor, isExpression)); + nodesVisitor((node).elements, visitor, isExpression)); case SyntaxKind.ObjectLiteralExpression: return updateObjectLiteral(node, - visitNodes((node).properties, visitor, isObjectLiteralElementLike)); + nodesVisitor((node).properties, visitor, isObjectLiteralElementLike)); case SyntaxKind.PropertyAccessExpression: return updatePropertyAccess(node, @@ -336,14 +336,14 @@ namespace ts { case SyntaxKind.CallExpression: return updateCall(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); + nodesVisitor((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).arguments, visitor, isExpression)); case SyntaxKind.NewExpression: return updateNew(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); + nodesVisitor((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).arguments, visitor, isExpression)); case SyntaxKind.TaggedTemplateExpression: return updateTaggedTemplate(node, @@ -361,19 +361,19 @@ namespace ts { case SyntaxKind.FunctionExpression: return updateFunctionExpression(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.ArrowFunction: return updateArrowFunction(node, - visitNodes((node).modifiers, visitor, isModifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).modifiers, visitor, isModifier), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); @@ -415,7 +415,7 @@ namespace ts { case SyntaxKind.TemplateExpression: return updateTemplateExpression(node, visitNode((node).head, visitor, isTemplateHead), - visitNodes((node).templateSpans, visitor, isTemplateSpan)); + nodesVisitor((node).templateSpans, visitor, isTemplateSpan)); case SyntaxKind.YieldExpression: return updateYield(node, @@ -428,15 +428,15 @@ namespace ts { case SyntaxKind.ClassExpression: return updateClassExpression(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).heritageClauses, visitor, isHeritageClause), + nodesVisitor((node).members, visitor, isClassElement)); case SyntaxKind.ExpressionWithTypeArguments: return updateExpressionWithTypeArguments(node, - visitNodes((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).typeArguments, visitor, isTypeNode), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.AsExpression: @@ -457,11 +457,11 @@ namespace ts { // Element case SyntaxKind.Block: return updateBlock(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.VariableStatement: return updateVariableStatement(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).declarationList, visitor, isVariableDeclarationList)); case SyntaxKind.ExpressionStatement: @@ -549,61 +549,61 @@ namespace ts { case SyntaxKind.VariableDeclarationList: return updateVariableDeclarationList(node, - visitNodes((node).declarations, visitor, isVariableDeclaration)); + nodesVisitor((node).declarations, visitor, isVariableDeclaration)); case SyntaxKind.FunctionDeclaration: return updateFunctionDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.ClassDeclaration: return updateClassDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).heritageClauses, visitor, isHeritageClause), + nodesVisitor((node).members, visitor, isClassElement)); case SyntaxKind.EnumDeclaration: return updateEnumDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).members, visitor, isEnumMember)); + nodesVisitor((node).members, visitor, isEnumMember)); case SyntaxKind.ModuleDeclaration: return updateModuleDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), visitNode((node).body, visitor, isModuleBody)); case SyntaxKind.ModuleBlock: return updateModuleBlock(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.CaseBlock: return updateCaseBlock(node, - visitNodes((node).clauses, visitor, isCaseOrDefaultClause)); + nodesVisitor((node).clauses, visitor, isCaseOrDefaultClause)); case SyntaxKind.ImportEqualsDeclaration: return updateImportEqualsDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), visitNode((node).moduleReference, visitor, isModuleReference)); case SyntaxKind.ImportDeclaration: return updateImportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).importClause, visitor, isImportClause), visitNode((node).moduleSpecifier, visitor, isExpression)); @@ -618,7 +618,7 @@ namespace ts { case SyntaxKind.NamedImports: return updateNamedImports(node, - visitNodes((node).elements, visitor, isImportSpecifier)); + nodesVisitor((node).elements, visitor, isImportSpecifier)); case SyntaxKind.ImportSpecifier: return updateImportSpecifier(node, @@ -627,20 +627,20 @@ namespace ts { case SyntaxKind.ExportAssignment: return updateExportAssignment(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.ExportDeclaration: return updateExportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).exportClause, visitor, isNamedExports), visitNode((node).moduleSpecifier, visitor, isExpression)); case SyntaxKind.NamedExports: return updateNamedExports(node, - visitNodes((node).elements, visitor, isExportSpecifier)); + nodesVisitor((node).elements, visitor, isExportSpecifier)); case SyntaxKind.ExportSpecifier: return updateExportSpecifier(node, @@ -656,12 +656,12 @@ namespace ts { case SyntaxKind.JsxElement: return updateJsxElement(node, visitNode((node).openingElement, visitor, isJsxOpeningElement), - visitNodes((node).children, visitor, isJsxChild), + nodesVisitor((node).children, visitor, isJsxChild), visitNode((node).closingElement, visitor, isJsxClosingElement)); case SyntaxKind.JsxAttributes: return updateJsxAttributes(node, - visitNodes((node).properties, visitor, isJsxAttributeLike)); + nodesVisitor((node).properties, visitor, isJsxAttributeLike)); case SyntaxKind.JsxSelfClosingElement: return updateJsxSelfClosingElement(node, @@ -694,15 +694,15 @@ namespace ts { case SyntaxKind.CaseClause: return updateCaseClause(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.DefaultClause: return updateDefaultClause(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.HeritageClause: return updateHeritageClause(node, - visitNodes((node).types, visitor, isExpressionWithTypeArguments)); + nodesVisitor((node).types, visitor, isExpressionWithTypeArguments)); case SyntaxKind.CatchClause: return updateCatchClause(node, diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2532a1875d9..9f949041866 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -22,6 +22,10 @@ namespace FourSlash { ts.disableIncrementalParsing = false; + function normalizeNewLines(s: string) { + return s.replace(/\r\n/g, "\n"); + } + // Represents a parsed source file with metadata export interface FourSlashFile { // The contents of the file (with markers, etc stripped out) @@ -1958,8 +1962,7 @@ namespace FourSlash { public verifyCurrentFileContent(text: string) { const actual = this.getFileContent(this.activeFile.fileName); - const replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); - if (replaceNewlines(actual) !== replaceNewlines(text)) { + if (normalizeNewLines(actual) !== normalizeNewLines(text)) { throw new Error("verifyCurrentFileContent\n" + "\tExpected: \"" + text + "\"\n" + "\t Actual: \"" + actual + "\""); @@ -2135,7 +2138,7 @@ namespace FourSlash { const actualText = this.rangeText(ranges[0]); const result = includeWhiteSpace - ? actualText === expectedText + ? normalizeNewLines(actualText) === normalizeNewLines(expectedText) : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText); if (!result) { @@ -2185,7 +2188,7 @@ namespace FourSlash { continue; } - const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]); + const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code], this.formatCodeSettings); if (newActions && newActions.length) { actions = actions ? actions.concat(newActions) : newActions; } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 32af0eb2601..ce98261a0c1 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -121,6 +121,7 @@ "./unittests/projectErrors.ts", "./unittests/printer.ts", "./unittests/transform.ts", - "./unittests/customTransforms.ts" + "./unittests/customTransforms.ts", + "./unittests/textChanges.ts" ] } diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts new file mode 100644 index 00000000000..b8c9a8e873d --- /dev/null +++ b/src/harness/unittests/textChanges.ts @@ -0,0 +1,520 @@ +/// +/// +/// + +namespace ts { + describe("textChanges", () => { + function findChild(name: string, n: Node) { + return find(n); + + function find(node: Node): Node { + if (isDeclaration(node) && node.name && isIdentifier(node.name) && node.name.text === name) { + return node; + } + else { + return forEachChild(node, find); + } + } + } + + const printerOptions = { newLine: NewLineKind.LineFeed }; + const newLineCharacter = getNewLineCharacter(printerOptions); + + function getRuleProvider(action?: (opts: FormatCodeSettings) => void) { + const options = { + indentSize: 4, + tabSize: 4, + newLineCharacter, + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + if (action) { + action(options); + } + const rulesProvider = new formatting.RulesProvider(); + rulesProvider.ensureUpToDate(options); + return rulesProvider; + } + + // validate that positions that were recovered from the printed text actually match positions that will be created if the same text is parsed. + function verifyPositions({ text, node }: textChanges.NonFormattedText): void { + const nodeList = flattenNodes(node); + const sourceFile = createSourceFile("f.ts", text, ScriptTarget.ES2015); + const parsedNodeList = flattenNodes(sourceFile.statements[0]); + Debug.assert(nodeList.length === parsedNodeList.length); + for (let i = 0; i < nodeList.length; i++) { + const left = nodeList[i]; + const right = parsedNodeList[i]; + Debug.assert(left.pos === right.pos); + Debug.assert(left.end === right.end); + } + + function flattenNodes(n: Node) { + const data: (Node | NodeArray)[] = []; + walk(n); + return data; + + function walk(n: Node | Node[]): void { + data.push(n); + return isArray(n) ? forEach(n, walk) : forEachChild(n, walk, walk); + } + } + } + + function runSingleFileTest(caption: string, setupFormatOptions: (opts: FormatCodeSettings) => void, text: string, validateNodes: boolean, testBlock: (sourceFile: SourceFile, changeTracker: textChanges.ChangeTracker) => void) { + it(caption, () => { + Harness.Baseline.runBaseline(`textChanges/${caption}.js`, () => { + const sourceFile = createSourceFile("source.ts", text, ScriptTarget.ES2015, /*setParentNodes*/ true); + const rulesProvider = getRuleProvider(setupFormatOptions); + const changeTracker = new textChanges.ChangeTracker(printerOptions.newLine, rulesProvider, validateNodes ? verifyPositions : undefined); + testBlock(sourceFile, changeTracker); + const changes = changeTracker.getChanges(); + assert.equal(changes.length, 1); + assert.equal(changes[0].fileName, sourceFile.fileName); + const modified = textChanges.applyChanges(sourceFile.text, changes[0].textChanges); + return `===ORIGINAL===${newLineCharacter}${text}${newLineCharacter}===MODIFIED===${newLineCharacter}${modified}`; + }); + }); + } + + function setNewLineForOpenBraceInFunctions(opts: FormatCodeSettings) { + opts.placeOpenBraceOnNewLineForFunctions = true; + } + + { + const text = ` +namespace M +{ + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() { + return 100; + } + const y = 2; // comment 3 + return 1; + } + } +}`; + runSingleFileTest("extractMethodLike", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + const statements = ((findChild("foo", sourceFile)).body).statements.slice(1); + const newFunction = createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ "bar", + /*typeParameters*/ undefined, + /*parameters*/ emptyArray, + /*type*/ createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*body */ createBlock(statements) + ); + + changeTracker.insertNodeBefore(sourceFile, /*before*/findChild("M2", sourceFile), newFunction, { insertTrailingNewLine: true }); + + // replace statements with return statement + const newStatement = createReturn( + createCall( + /*expression*/ newFunction.name, + /*typeArguments*/ undefined, + /*argumentsArray*/ emptyArray + )); + changeTracker.replaceNodeRange(sourceFile, statements[0], lastOrUndefined(statements), newStatement, { insertTrailingNewLine: true }); + }); + } + { + const text = ` +function foo() { + return 1; +} + +function bar() { + return 2; +} +`; + runSingleFileTest("deleteRange1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteRange(sourceFile, { pos: text.indexOf("function foo"), end: text.indexOf("function bar") }); + }); + } + function findVariableStatementContaining(name: string, sourceFile: SourceFile) { + const varDecl = findChild(name, sourceFile); + assert.equal(varDecl.kind, SyntaxKind.VariableDeclaration); + const varStatement = varDecl.parent.parent; + assert.equal(varStatement.kind, SyntaxKind.VariableStatement); + return varStatement; + } + { + const text = ` +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 +`; + runSingleFileTest("deleteNode1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile)); + }); + runSingleFileTest("deleteNode2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true }); + }); + runSingleFileTest("deleteNode3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNode4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNode5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("x", sourceFile)); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +`; + runSingleFileTest("deleteNodeRange1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile)); + }); + runSingleFileTest("deleteNodeRange2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedStartPosition: true }); + }); + runSingleFileTest("deleteNodeRange3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNodeRange4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + function createTestVariableDeclaration(name: string) { + return createVariableDeclaration(name, /*type*/ undefined, createObjectLiteral([createPropertyAssignment("p1", createLiteral(1))], /*multiline*/ true)); + } + function createTestClass() { + return createClassDeclaration( + /*decorators*/ undefined, + [ + createToken(SyntaxKind.PublicKeyword) + ], + "class1", + /*typeParameters*/ undefined, + [ + createHeritageClause( + SyntaxKind.ImplementsKeyword, + [ + createExpressionWithTypeArguments(/*typeArguments*/ undefined, createIdentifier("interface1")) + ] + ) + ], + [ + createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + "property1", + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.BooleanKeyword), + /*initializer*/ undefined + ) + ] + ); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceRange", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { insertTrailingNewLine: true }); + }); + runSingleFileTest("replaceRangeWithForcedIndentation", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { insertTrailingNewLine: true, indentation: 8, delta: 0 }); + }); + + runSingleFileTest("replaceRangeNoLineBreakBefore", setNewLineForOpenBraceInFunctions, `const x = 1, y = "2";`, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createTestVariableDeclaration("z1"); + changeTracker.replaceRange(sourceFile, { pos: sourceFile.text.indexOf("y"), end: sourceFile.text.indexOf(";") }, newNode); + }); + } + { + const text = ` +namespace A { + const x = 1, y = "2"; +} +`; + runSingleFileTest("replaceNode1NoLineBreakBefore", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createTestVariableDeclaration("z1"); + changeTracker.replaceNode(sourceFile, findChild("y", sourceFile), newNode); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceNode1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + }); + runSingleFileTest("replaceNode2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, insertTrailingNewLine: true, insertLeadingNewLine: true }); + }); + runSingleFileTest("replaceNode3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, insertTrailingNewLine: true }); + }); + runSingleFileTest("replaceNode4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("replaceNode5", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("x", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceNodeRange1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + }); + runSingleFileTest("replaceNodeRange2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, insertTrailingNewLine: true, insertLeadingNewLine: true }); + }); + runSingleFileTest("replaceNodeRange3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, insertTrailingNewLine: true }); + }); + runSingleFileTest("replaceNodeRange4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("insertNodeAt1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAt(sourceFile, text.indexOf("var y"), createTestClass(), { insertTrailingNewLine: true }); + }); + runSingleFileTest("insertNodeAt2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAt(sourceFile, text.indexOf("; // comment 4"), createTestVariableDeclaration("z1")); + }); + } + { + const text = ` +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +}`; + runSingleFileTest("insertNodeBefore1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeBefore(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + }); + runSingleFileTest("insertNodeBefore2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeBefore(sourceFile, findChild("M", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + }); + runSingleFileTest("insertNodeAfter1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + }); + runSingleFileTest("insertNodeAfter2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("M", sourceFile), createTestClass(), { insertLeadingNewLine: true }); + }); + } + { + function findOpenBraceForConstructor(sourceFile: SourceFile) { + const classDecl = sourceFile.statements[0]; + const constructorDecl = forEach(classDecl.members, m => m.kind === SyntaxKind.Constructor && (m).body && m); + return constructorDecl.body.getFirstToken(); + } + function createTestSuperCall() { + const superCall = createCall( + createSuper(), + /*typeArguments*/ undefined, + /*argumentsArray*/ emptyArray + ); + return createStatement(superCall); + } + const text1 = ` +class A { + constructor() { + } +} +`; + runSingleFileTest("insertNodeAfter3", noop, text1, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { insertTrailingNewLine: true }); + }); + const text2 = ` +class A { + constructor() { + var x = 1; + } +} +`; + runSingleFileTest("insertNodeAfter4", noop, text2, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), createTestSuperCall(), { insertTrailingNewLine: true }); + }); + const text3 = ` +class A { + constructor() { + + } +} +`; + runSingleFileTest("insertNodeAfter3-block with newline", noop, text3, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { insertTrailingNewLine: true }); + }); + } + { + const text = `var a = 1, b = 2, c = 3;`; + runSingleFileTest("deleteNodeInList1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = `var a = 1,b = 2,c = 3;`; + runSingleFileTest("deleteNodeInList1_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList2_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList3_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +namespace M { + var a = 1, + b = 2, + c = 3; +}`; + runSingleFileTest("deleteNodeInList4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList6", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +}`; + runSingleFileTest("deleteNodeInList4_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList5_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList6_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo(a: number, b: string, c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList7", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList8", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList9", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo(a: number,b: string,c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } +{ + const text = ` +function foo( + a: number, + b: string, + c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + }); +} \ No newline at end of file diff --git a/src/server/session.ts b/src/server/session.ts index b5e7e44970d..64fce61a095 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1420,8 +1420,9 @@ namespace ts.server { const scriptInfo = project.getScriptInfoForNormalizedPath(file); const startPosition = getStartPosition(); const endPosition = getEndPosition(); + const formatOptions = this.projectService.getFormatCodeOptions(file); - const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, formatOptions); if (!codeActions) { return undefined; } diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index 10d0b8eef34..c48c5a2460c 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -13,6 +13,7 @@ namespace ts { newLineCharacter: string; host: LanguageServiceHost; cancellationToken: CancellationToken; + rulesProvider: formatting.RulesProvider; } export namespace codefix { diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 4528c48774d..207d039df8e 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -26,22 +26,13 @@ namespace ts.codefix { } } } - - const newPosition = getOpenBraceEnd(constructor, sourceFile); - const changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(constructor, sourceFile), superCall, { insertTrailingNewLine: true }); + changeTracker.deleteNode(sourceFile, superCall); return [{ description: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes + changes: changeTracker.getChanges() }]; function findSuperCall(n: Node): ExpressionStatement { diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 0dede87cf28..27b655f19ce 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -10,10 +10,13 @@ namespace ts.codefix { return undefined; } - const newPosition = getOpenBraceEnd(token.parent, sourceFile); + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const superCall = createStatement(createCall(createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ emptyArray)); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(token.parent, sourceFile), superCall, { insertTrailingNewLine: true }); + return [{ description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index 1e72700ec01..80d4345a943 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -21,26 +21,20 @@ namespace ts.codefix { return undefined; } - let changeStart = extendsToken.getStart(sourceFile); - let changeEnd = extendsToken.getEnd(); - const textChanges: TextChange[] = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, extendsToken, createToken(SyntaxKind.ImplementsKeyword)); // We replace existing keywords with commas. for (let i = 1; i < heritageClauses.length; i++) { const keywordToken = heritageClauses[i].getFirstToken(); if (keywordToken) { - changeStart = keywordToken.getStart(sourceFile); - changeEnd = keywordToken.getEnd(); - textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + changeTracker.replaceNode(sourceFile, keywordToken, createToken(SyntaxKind.CommaToken)); } } const result = [{ description: getLocaleSpecificMessage(Diagnostics.Change_extends_to_implements), - changes: [{ - fileName: sourceFile.fileName, - textChanges: textChanges - }] + changes: changeTracker.getChanges() }]; return result; diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index c9d59dd8337..711a3289a27 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -5,11 +5,15 @@ namespace ts.codefix { getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - const start = token.getStart(sourceFile); + if (token.kind !== SyntaxKind.Identifier) { + return undefined; + } + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index a45a3c26dba..e2561e208f9 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -25,17 +25,17 @@ namespace ts.codefix { const forStatement = token.parent.parent.parent; const forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFixToRemoveNode(forInitializer); + return deleteNode(forInitializer); } else { - return removeSingleItem(forInitializer.declarations, token); + return deleteNodeInList(token.parent); } case SyntaxKind.ForOfStatement: const forOfStatement = token.parent.parent.parent; if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { const forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + return replaceNode(forOfInitializer.declarations[0], createObjectLiteral()); } break; @@ -47,51 +47,59 @@ namespace ts.codefix { case SyntaxKind.CatchClause: const catchClause = token.parent.parent; const parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFixToRemoveNode(parameter); + return deleteNode(parameter); default: const variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFixToRemoveNode(variableStatement); + return deleteNode(variableStatement); } else { - const declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); + return deleteNodeInList(token.parent); } } case SyntaxKind.TypeParameter: const typeParameters = (token.parent.parent).typeParameters; if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) { + return deleteRange(typeParameters); + } + const nextToken = getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); } else { - return removeSingleItem(typeParameters, token); + return deleteNodeInList(token.parent); } case ts.SyntaxKind.Parameter: const functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else { - return removeSingleItem(functionDeclaration.parameters, token); + return deleteNodeInList(token.parent); } // handle case where 'import a = A;' case SyntaxKind.ImportEqualsDeclaration: - const importEquals = findImportDeclaration(token); - return createCodeFixToRemoveNode(importEquals); + const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration); + return deleteNode(importEquals); case SyntaxKind.ImportSpecifier: const namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. - const importSpec = findImportDeclaration(token); - return createCodeFixToRemoveNode(importSpec); + const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration); + return deleteNode(importSpec); } else { - return removeSingleItem(namedImports.elements, token); + // delete import specifier + return deleteNodeInList(token.parent); } // handle case where "import d, * as ns from './file'" @@ -99,98 +107,79 @@ namespace ts.codefix { case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' const importClause = token.parent; if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| - const importDecl = findImportDeclaration(importClause); - return createCodeFixToRemoveNode(importDecl); + const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); } else { // import |d,| * as ns from './file' - const start = importClause.name.getStart(); - let end = findFirstNonSpaceCharPosStarting(importClause.name.end); - if (sourceFile.text.charCodeAt(end) === CharacterCodes.comma) { - end = findFirstNonSpaceCharPosStarting(end + 1); + const start = importClause.name.getStart(sourceFile); + const nextToken = getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === SyntaxKind.CommaToken) { + // shift first non-whitespace position after comma to the start position of the node + return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/true) }); + } + else { + return deleteNode(importClause.name); } - - return createCodeFix("", start, end - start); } case SyntaxKind.NamespaceImport: const namespaceImport = token.parent; if (namespaceImport.name == token && !(namespaceImport.parent).name) { - const importDecl = findImportDeclaration(namespaceImport); - return createCodeFixToRemoveNode(importDecl); + const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); } else { - const start = (namespaceImport.parent).name.end; - return createCodeFix("", start, (namespaceImport.parent).namedBindings.end - start); + const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === SyntaxKind.CommaToken) { + const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, /*forDeleteOperation*/ true); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); } } break; case SyntaxKind.PropertyDeclaration: case SyntaxKind.NamespaceImport: - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } if (isDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else if (isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent.parent); + return deleteNode(token.parent.parent); } else { return undefined; } - function findImportDeclaration(token: Node): Node { - let importDecl = token; - while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) { - importDecl = importDecl.parent; - } - - return importDecl; + function deleteNode(n: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); } - function createCodeFixToRemoveNode(node: Node) { - let end = node.getEnd(); - const endCharCode = sourceFile.text.charCodeAt(end); - const afterEndCharCode = sourceFile.text.charCodeAt(end + 1); - if (isLineBreak(endCharCode)) { - end += 1; - } - // in the case of CR LF, you could have two consecutive new line characters for one new line. - // this needs to be differenciated from two LF LF chars that actually mean two new lines. - if (isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { - end += 1; - } - - const start = node.getStart(); - return createCodeFix("", start, end - start); + function deleteRange(range: TextRange) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); } - function findFirstNonSpaceCharPosStarting(start: number) { - while (isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; + function deleteNodeInList(n: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); } - function createCodeFix(newText: string, start: number, length: number): CodeAction[] { + function deleteNodeRange(start: Node, end: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + } + + function replaceNode(n: Node, newNode: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + } + + function makeChange(changeTracker: textChanges.ChangeTracker) { return [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText, span: { start, length } }] - }] + changes: changeTracker.getChanges() }]; } - - function removeSingleItem(elements: NodeArray, token: T): CodeAction[] { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } } }); } \ No newline at end of file diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 201d64e4d7e..4fa3b71a3a2 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -314,24 +314,55 @@ namespace ts.formatting { return 0; } + /* @internal */ + export function formatNode(node: Node, sourceFileLike: SourceFileLike, languageVariant: LanguageVariant, initialIndentation: number, delta: number, rulesProvider: RulesProvider): TextChange[] { + const range = { pos: 0, end: sourceFileLike.text.length }; + return formatSpanWorker( + range, + node, + initialIndentation, + delta, + getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), + rulesProvider.getFormatOptions(), + rulesProvider, + FormattingRequestKind.FormatSelection, + _ => false, // assume that node does not have any errors + sourceFileLike); + } + function formatSpan(originalRange: TextRange, sourceFile: SourceFile, options: FormatCodeSettings, rulesProvider: RulesProvider, requestKind: FormattingRequestKind): TextChange[] { + // find the smallest node that fully wraps the range and compute the initial indentation for the node + const enclosingNode = findEnclosingNode(originalRange, sourceFile); + return formatSpanWorker( + originalRange, + enclosingNode, + SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), + getOwnOrInheritedDelta(enclosingNode, options, sourceFile), + getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), + options, + rulesProvider, + requestKind, + prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), + sourceFile); + } - const rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); + function formatSpanWorker(originalRange: TextRange, + enclosingNode: Node, + initialIndentation: number, + delta: number, + formattingScanner: FormattingScanner, + options: FormatCodeSettings, + rulesProvider: RulesProvider, + requestKind: FormattingRequestKind, + rangeContainsError: (r: TextRange) => boolean, + sourceFile: SourceFileLike): TextChange[] { // formatting context is used by rules provider const formattingContext = new FormattingContext(sourceFile, requestKind); - - // find the smallest node that fully wraps the range and compute the initial indentation for the node - const enclosingNode = findEnclosingNode(originalRange, sourceFile); - - const formattingScanner = getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - - const initialIndentation = SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); - let previousRangeHasError: boolean; let previousRange: TextRangeWithKind; let previousParent: Node; @@ -351,7 +382,6 @@ namespace ts.formatting { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - const delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } diff --git a/src/services/formatting/formattingContext.ts b/src/services/formatting/formattingContext.ts index bd5ca352476..26b538dfc5e 100644 --- a/src/services/formatting/formattingContext.ts +++ b/src/services/formatting/formattingContext.ts @@ -15,7 +15,7 @@ namespace ts.formatting { private contextNodeBlockIsOnOneLine: boolean; private nextNodeBlockIsOnOneLine: boolean; - constructor(public sourceFile: SourceFile, public formattingRequestKind: FormattingRequestKind) { + constructor(public readonly sourceFile: SourceFileLike, public formattingRequestKind: FormattingRequestKind) { } public updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node) { diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 2020352f86b..981ae09b2b2 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -30,11 +30,11 @@ namespace ts.formatting { RescanJsxText, } - export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner { + export function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number): FormattingScanner { Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; + scanner = languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); + scanner.setText(text); scanner.setTextPos(startPos); let wasNewLine = true; diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 14e08e4857a..660d5f34a0e 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -24,6 +24,10 @@ namespace ts.formatting { return this.rulesMap; } + public getFormatOptions(): Readonly { + return this.options; + } + public ensureUpToDate(options: ts.FormatCodeSettings) { if (!this.options || !ts.compareDataObjects(this.options, options)) { const activeRules = this.createActiveRules(options); diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index eb9e1ba04c5..b5c901482a7 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -8,7 +8,19 @@ namespace ts.formatting { Unknown = -1 } - export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number { + /** + * Computed indentation for a given position in source file + * @param position - position in file + * @param sourceFile - target source file + * @param options - set of editor options that control indentation + * @param assumeNewLineBeforeCloseBrace - false when getIndentation is called on the text from the real source file. + * true - when we need to assume that position is on the newline. This is usefult for codefixes, i.e. + * function f() { + * |} + * when inserting some text after open brace we would like to get the value of indentation as if newline was already there. + * However by default indentation at position | will be 0 so 'assumeNewLineBeforeCloseBrace' allows to override this behavior, + */ + export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings, assumeNewLineBeforeCloseBrace = false): number { if (position > sourceFile.text.length) { return getBaseIndentation(options); // past EOF } @@ -71,13 +83,14 @@ namespace ts.formatting { if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; + const nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); + if (nextTokenKind !== NextTokenKind.Unknown) { + // handle cases when codefix is about to be inserted before the close brace + indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === NextTokenKind.CloseBrace ? options.indentSize : 0; } else { indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } - break; } @@ -218,15 +231,21 @@ namespace ts.formatting { return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): boolean { + const enum NextTokenKind { + Unknown, + OpenBrace, + CloseBrace + } + + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): NextTokenKind { const nextToken = findNextToken(precedingToken, current); if (!nextToken) { - return false; + return NextTokenKind.Unknown; } if (nextToken.kind === SyntaxKind.OpenBraceToken) { // open braces are always indented at the parent level - return true; + return NextTokenKind.OpenBrace; } else if (nextToken.kind === SyntaxKind.CloseBraceToken) { // close braces are indented at the parent level if they are located on the same line with cursor @@ -239,17 +258,17 @@ namespace ts.formatting { // $} const nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + return lineAtPosition === nextTokenStartLine ? NextTokenKind.CloseBrace : NextTokenKind.Unknown; } - return false; + return NextTokenKind.Unknown; } - function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter { + function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFileLike): LineAndCharacter { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } - export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean { + export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean { if (parent.kind === SyntaxKind.IfStatement && (parent).elseStatement === child) { const elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile); Debug.assert(elseKeyword !== undefined); @@ -261,15 +280,15 @@ namespace ts.formatting { return false; } - function getContainingList(node: Node, sourceFile: SourceFile): NodeArray { + function getListIfStartEndIsInListRange(list: NodeArray, start: number, end: number) { + return list && rangeContainsStartEnd(list, start, end) ? list : undefined; + } + + export function getContainingList(node: Node, sourceFile: SourceFile): NodeArray { if (node.parent) { switch (node.parent.kind) { case SyntaxKind.TypeReference: - if ((node.parent).typeArguments && - rangeContainsStartEnd((node.parent).typeArguments, node.getStart(sourceFile), node.getEnd())) { - return (node.parent).typeArguments; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeArguments, node.getStart(sourceFile), node.getEnd()); case SyntaxKind.ObjectLiteralExpression: return (node.parent).properties; case SyntaxKind.ArrayLiteralExpression: @@ -280,30 +299,26 @@ namespace ts.formatting { case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: + case SyntaxKind.Constructor: + case SyntaxKind.ConstructorType: case SyntaxKind.ConstructSignature: { const start = node.getStart(sourceFile); - if ((node.parent).typeParameters && - rangeContainsStartEnd((node.parent).typeParameters, start, node.getEnd())) { - return (node.parent).typeParameters; - } - if (rangeContainsStartEnd((node.parent).parameters, start, node.getEnd())) { - return (node.parent).parameters; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeParameters, start, node.getEnd()) || + getListIfStartEndIsInListRange((node.parent).parameters, start, node.getEnd()); } + case SyntaxKind.ClassDeclaration: + return getListIfStartEndIsInListRange((node.parent).typeParameters, node.getStart(sourceFile), node.getEnd()); case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: { const start = node.getStart(sourceFile); - if ((node.parent).typeArguments && - rangeContainsStartEnd((node.parent).typeArguments, start, node.getEnd())) { - return (node.parent).typeArguments; - } - if ((node.parent).arguments && - rangeContainsStartEnd((node.parent).arguments, start, node.getEnd())) { - return (node.parent).arguments; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeArguments, start, node.getEnd()) || + getListIfStartEndIsInListRange((node.parent).arguments, start, node.getEnd()); } + case SyntaxKind.VariableDeclarationList: + return getListIfStartEndIsInListRange((node.parent).declarations, node.getStart(sourceFile), node.getEnd()); + case SyntaxKind.NamedImports: + case SyntaxKind.NamedExports: + return getListIfStartEndIsInListRange((node.parent).elements, node.getStart(sourceFile), node.getEnd()); } } return undefined; @@ -400,7 +415,7 @@ namespace ts.formatting { value of 'character' for '$' is 3 value of 'column' for '$' is 6 (assuming that tab size is 4) */ - export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings) { + export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings) { let character = 0; let column = 0; for (let pos = startPos; pos < endPos; pos++) { @@ -421,7 +436,7 @@ namespace ts.formatting { return { column, character }; } - export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number { + export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings): number { return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } diff --git a/src/services/services.ts b/src/services/services.ts index f122e39bcc6..beb52f70110 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -24,6 +24,7 @@ /// /// /// +/// /// /// @@ -63,7 +64,7 @@ namespace ts { return getSourceFileOfNode(this); } - public getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number { + public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number { return getTokenPosOfNode(this, sourceFile, includeJsDocComment); } @@ -129,7 +130,7 @@ namespace ts { return list; } - private createChildren(sourceFile?: SourceFile) { + private createChildren(sourceFile?: SourceFileLike) { let children: Node[]; if (this.kind >= SyntaxKind.FirstNode) { scanner.setText((sourceFile || this.getSourceFile()).text); @@ -182,7 +183,7 @@ namespace ts { return this._children[index]; } - public getChildren(sourceFile?: SourceFile): Node[] { + public getChildren(sourceFile?: SourceFileLike): Node[] { if (!this._children) this.createChildren(sourceFile); return this._children; } @@ -231,7 +232,7 @@ namespace ts { return getSourceFileOfNode(this); } - public getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number { + public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number { return getTokenPosOfNode(this, sourceFile, includeJsDocComment); } @@ -1682,7 +1683,7 @@ namespace ts { return []; } - function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const span = { start, length: end - start }; @@ -1700,7 +1701,8 @@ namespace ts { program: program, newLineCharacter: newLineChar, host: host, - cancellationToken: cancellationToken + cancellationToken: cancellationToken, + rulesProvider: getRuleProvider(formatOptions) }; const fixes = codefix.getFixes(context); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts new file mode 100644 index 00000000000..5c345e6e4e4 --- /dev/null +++ b/src/services/textChanges.ts @@ -0,0 +1,475 @@ +/* @internal */ +namespace ts.textChanges { + + /** + * Currently for simplicity we store recovered positions on the node itself. + * It can be changed to side-table later if we decide that current design is too invasive. + */ + function getPos(n: TextRange) { + return (n)["__pos"]; + } + + function setPos(n: TextRange, pos: number) { + (n)["__pos"] = pos; + } + + function getEnd(n: TextRange) { + return (n)["__end"]; + } + + function setEnd(n: TextRange, end: number) { + (n)["__end"] = end; + } + + export interface ConfigurableStart { + useNonAdjustedStartPosition?: boolean; + } + export interface ConfigurableEnd { + useNonAdjustedEndPosition?: boolean; + } + + /** + * Usually node.pos points to a position immediately after the previous token. + * If this position is used as a beginning of the span to remove - it might lead to removing the trailing trivia of the previous node, i.e: + * const x; // this is x + * ^ - pos for the next variable declaration will point here + * const y; // this is y + * ^ - end for previous variable declaration + * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding + * variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline). + * By default when removing nodes we adjust start and end positions to respect specification of the trivia above. + * If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true + */ + export type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd; + + export interface InsertNodeOptions { + /** + * Set this value to true to make sure that node text of newly inserted node ends with new line + */ + insertTrailingNewLine?: boolean; + /** + * Set this value to true to make sure that node text of newly inserted node starts with new line + */ + insertLeadingNewLine?: boolean; + /** + * Text of inserted node will be formatted with this indentation, otherwise indentation will be inferred from the old node + */ + indentation?: number; + /** + * Text of inserted node will be formatted with this delta, otherwise delta will be inferred from the new node kind + */ + delta?: number; + } + + export type ChangeNodeOptions = ConfigurableStartEnd & InsertNodeOptions; + + interface Change { + readonly sourceFile: SourceFile; + readonly range: TextRange; + readonly oldNode?: Node; + readonly node?: Node; + readonly options?: ChangeNodeOptions; + } + + export function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, forDeleteOperation: boolean) { + if (options.useNonAdjustedStartPosition) { + return node.getFullStart(); + } + const fullStart = node.getFullStart(); + const start = node.getStart(sourceFile); + if (fullStart === start) { + return start; + } + const fullStartLine = getLineStartPositionForPosition(fullStart, sourceFile); + const startLine = getLineStartPositionForPosition(start, sourceFile); + if (startLine === fullStartLine) { + // full start and start of the node are on the same line + // a, b; + // ^ ^ + // | start + // fullstart + // when b is replaced - we usually want to keep the leading trvia + // when b is deleted - we delete it + return forDeleteOperation ? fullStart : start; + } + // get start position of the line following the line that contains fullstart position + let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // skip whitespaces/newlines + adjustedStartPosition = skipTrivia(sourceFile.text, adjustedStartPosition, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); + } + + export function getAdjustedEndPosition(sourceFile: SourceFile, node: Node, options: ConfigurableEnd) { + if (options.useNonAdjustedEndPosition) { + return node.getEnd(); + } + const end = node.getEnd(); + const newEnd = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); + // check if last character before newPos is linebreak + // if yes - considered all skipped trivia to be trailing trivia of the node + return newEnd !== end && isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) + ? newEnd + : end; + } + + function isSeparator(node: Node, separator: Node): boolean { + return node.parent && (separator.kind === SyntaxKind.CommaToken || (separator.kind === SyntaxKind.SemicolonToken && node.parent.kind === SyntaxKind.ObjectLiteralExpression)); + } + + export class ChangeTracker { + private changes: Change[] = []; + private readonly newLineCharacter: string; + + public static fromCodeFixContext(context: CodeFixContext) { + return new ChangeTracker(context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.rulesProvider); + } + + constructor( + private readonly newLine: NewLineKind, + private readonly rulesProvider: formatting.RulesProvider, + private readonly validator?: (text: NonFormattedText) => void) { + this.newLineCharacter = getNewLineCharacter({ newLine }); + } + + public deleteNode(sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, node, options, /*forDeleteOperation*/ true); + const endPosition = getAdjustedEndPosition(sourceFile, node, options); + this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public deleteRange(sourceFile: SourceFile, range: TextRange) { + this.changes.push({ sourceFile, range }); + return this; + } + + public deleteNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options: ConfigurableStartEnd = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, /*forDeleteOperation*/ true); + const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public deleteNodeInList(sourceFile: SourceFile, node: Node) { + const containingList = formatting.SmartIndenter.getContainingList(node, sourceFile); + if (!containingList) { + return; + } + const index = containingList.indexOf(node); + if (index < 0) { + return this; + } + if (containingList.length === 1) { + this.deleteNode(sourceFile, node); + return this; + } + if (index !== containingList.length - 1) { + const nextToken = getTokenAtPosition(sourceFile, node.end); + if (nextToken && isSeparator(node, nextToken)) { + // find first non-whitespace position in the leading trivia of the node + const startPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, /*forDeleteOperation*/ true), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + const nextElement = containingList[index + 1]; + /// find first non-whitespace position in the leading trivia of the next node + const endPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, /*forDeleteOperation*/ true), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + } + else { + const previousToken = getTokenAtPosition(sourceFile, containingList[index - 1].end); + if (previousToken && isSeparator(node, previousToken)) { + this.deleteNodeRange(sourceFile, previousToken, node); + } + } + return this; + } + + public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: InsertNodeOptions = {}) { + this.changes.push({ sourceFile, range, options, node: newNode }); + return this; + } + + public replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, /*forDeleteOperation*/ false); + const endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + this.changes.push({ sourceFile, options, oldNode, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, /*forDeleteOperation*/ false); + const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile, options, oldNode: startNode, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { + this.changes.push({ sourceFile, options, node: newNode, range: { pos: pos, end: pos } }); + return this; + } + + public insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, options: InsertNodeOptions & ConfigurableStart = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, before, options, /*forDeleteOperation*/ false); + this.changes.push({ sourceFile, options, oldNode: before, node: newNode, range: { pos: startPosition, end: startPosition } }); + return this; + } + + public insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node, options: InsertNodeOptions & ConfigurableEnd = {}) { + const endPosition = getAdjustedEndPosition(sourceFile, after, options); + this.changes.push({ sourceFile, options, oldNode: after, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + } + + public getChanges(): FileTextChanges[] { + const changesPerFile = createFileMap(); + // group changes per file + for (const c of this.changes) { + let changesInFile = changesPerFile.get(c.sourceFile.path); + if (!changesInFile) { + changesPerFile.set(c.sourceFile.path, changesInFile = []); + }; + changesInFile.push(c); + } + // convert changes + const fileChangesList: FileTextChanges[] = []; + changesPerFile.forEachValue(path => { + const changesInFile = changesPerFile.get(path); + const sourceFile = changesInFile[0].sourceFile; + ChangeTracker.normalize(changesInFile); + + const fileTextChanges: FileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; + for (const c of changesInFile) { + fileTextChanges.textChanges.push({ + span: this.computeSpan(c, sourceFile), + newText: this.computeNewText(c, sourceFile) + }); + } + fileChangesList.push(fileTextChanges); + }); + + return fileChangesList; + } + + private computeSpan(change: Change, _sourceFile: SourceFile): TextSpan { + return createTextSpanFromBounds(change.range.pos, change.range.end); + } + + private computeNewText(change: Change, sourceFile: SourceFile): string { + if (!change.node) { + // deletion case + return ""; + } + const options = change.options || {}; + const nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonFormattedText); + } + + const formatOptions = this.rulesProvider.getFormatOptions(); + const pos = change.range.pos; + const posStartsLine = getLineStartPositionForPosition(pos, sourceFile) === pos; + + const initialIndentation = + change.options.indentation !== undefined + ? change.options.indentation + : change.oldNode + ? formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || change.options.insertLeadingNewLine) + : 0; + const delta = + change.options.delta !== undefined + ? change.options.delta + : formatting.SmartIndenter.shouldIndentChildNode(change.node) + ? formatOptions.indentSize + : 0; + + let text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line + text = posStartsLine ? text : text.replace(/^\s+/, ""); + + if (options.insertLeadingNewLine) { + text = this.newLineCharacter + text; + } + if (options.insertTrailingNewLine) { + text = text + this.newLineCharacter; + } + return text; + } + + private static normalize(changes: Change[]) { + // order changes by start position + changes.sort((a, b) => a.range.pos - b.range.pos); + // verify that end position of the change is less than start position of the next change + for (let i = 0; i < changes.length - 2; i++) { + Debug.assert(changes[i].range.end <= changes[i + 1].range.pos); + } + } + } + + export interface NonFormattedText { + readonly text: string; + readonly node: Node; + } + + export function getNonformattedText(node: Node, sourceFile: SourceFile, newLine: NewLineKind): NonFormattedText { + const options = { newLine, target: sourceFile.languageVersion }; + const writer = new Writer(getNewLineCharacter(options)); + const printer = createPrinter(options, writer); + printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer); + return { text: writer.getText(), node: assignPositionsToNode(node) }; + } + + export function applyFormatting(nonFormattedText: NonFormattedText, sourceFile: SourceFile, initialIndentation: number, delta: number, rulesProvider: formatting.RulesProvider) { + const lineMap = computeLineStarts(nonFormattedText.text); + const file: SourceFileLike = { + text: nonFormattedText.text, + lineMap, + getLineAndCharacterOfPosition: pos => computeLineAndCharacterOfPosition(lineMap, pos) + }; + const changes = formatting.formatNode(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); + return applyChanges(nonFormattedText.text, changes); + } + + export function applyChanges(text: string, changes: TextChange[]): string { + for (let i = changes.length - 1; i >= 0; i--) { + const change = changes[i]; + text = `${text.substring(0, change.span.start)}${change.newText}${text.substring(textSpanEnd(change.span))}`; + } + return text; + } + + function isTrivia(s: string) { + return skipTrivia(s, 0) === s.length; + } + + const nullTransformationContext: TransformationContext = { + enableEmitNotification: noop, + enableSubstitution: noop, + endLexicalEnvironment: () => undefined, + getCompilerOptions: notImplemented, + getEmitHost: notImplemented, + getEmitResolver: notImplemented, + hoistFunctionDeclaration: noop, + hoistVariableDeclaration: noop, + isEmitNotificationEnabled: notImplemented, + isSubstitutionEnabled: notImplemented, + onEmitNode: noop, + onSubstituteNode: notImplemented, + readEmitHelpers: notImplemented, + requestEmitHelper: noop, + resumeLexicalEnvironment: noop, + startLexicalEnvironment: noop, + suspendLexicalEnvironment: noop + }; + + function assignPositionsToNode(node: Node): Node { + const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray); + // create proxy node for non synthesized nodes + const newNode = nodeIsSynthesized(visited) + ? visited + : (Proxy.prototype = visited, new (Proxy)()); + newNode.pos = getPos(node); + newNode.end = getEnd(node); + return newNode; + + function Proxy() { } + } + + function assignPositionsToNodeArray(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) { + const visited = visitNodes(nodes, visitor, test, start, count); + if (!visited) { + return visited; + } + // clone nodearray if necessary + const nodeArray = visited === nodes ? createNodeArray(visited) : visited; + nodeArray.pos = getPos(nodes); + nodeArray.end = getEnd(nodes); + return nodeArray; + } + + class Writer implements EmitTextWriter, PrintHandlers { + private lastNonTriviaPosition = 0; + private readonly writer: EmitTextWriter; + + public readonly onEmitNode: PrintHandlers["onEmitNode"]; + public readonly onBeforeEmitNodeArray: PrintHandlers["onBeforeEmitNodeArray"]; + public readonly onAfterEmitNodeArray: PrintHandlers["onAfterEmitNodeArray"]; + + constructor(newLine: string) { + this.writer = createTextWriter(newLine); + this.onEmitNode = (hint, node, printCallback) => { + setPos(node, this.lastNonTriviaPosition); + printCallback(hint, node); + setEnd(node, this.lastNonTriviaPosition); + }; + this.onBeforeEmitNodeArray = nodes => { + if (nodes) { + setPos(nodes, this.lastNonTriviaPosition); + } + }; + this.onAfterEmitNodeArray = nodes => { + if (nodes) { + setEnd(nodes, this.lastNonTriviaPosition); + } + }; + } + + private setLastNonTriviaPosition(s: string, force: boolean) { + if (force || !isTrivia(s)) { + this.lastNonTriviaPosition = this.writer.getTextPos(); + let i = 0; + while (isWhiteSpace(s.charCodeAt(s.length - i - 1))) { + i++; + } + // trim trailing whitespaces + this.lastNonTriviaPosition -= i; + } + } + + write(s: string): void { + this.writer.write(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + } + writeTextOfNode(text: string, node: Node): void { + this.writer.writeTextOfNode(text, node); + } + writeLine(): void { + this.writer.writeLine(); + } + increaseIndent(): void { + this.writer.increaseIndent(); + } + decreaseIndent(): void { + this.writer.decreaseIndent(); + } + getText(): string { + return this.writer.getText(); + } + rawWrite(s: string): void { + this.writer.rawWrite(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + } + writeLiteral(s: string): void { + this.writer.writeLiteral(s); + this.setLastNonTriviaPosition(s, /*force*/ true); + } + getTextPos(): number { + return this.writer.getTextPos(); + } + getLine(): number { + return this.writer.getLine(); + } + getColumn(): number { + return this.writer.getColumn(); + } + getIndent(): number { + return this.writer.getIndent(); + } + isAtStartOfLine(): boolean { + return this.writer.isAtStartOfLine(); + } + reset(): void { + this.writer.reset(); + this.lastNonTriviaPosition = 0; + } + } +} \ No newline at end of file diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index ae2150d981d..f5cd2cd475f 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -62,6 +62,7 @@ "shims.ts", "signatureHelp.ts", "symbolDisplay.ts", + "textChanges.ts", "formatting/formatting.ts", "formatting/formattingContext.ts", "formatting/formattingRequestKind.ts", diff --git a/src/services/types.ts b/src/services/types.ts index c7852db6d6e..149bb4340dc 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -4,7 +4,11 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; + /* @internal */ + getChildren(sourceFile?: SourceFileLike): Node[]; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; + /* @internal */ + getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; getWidth(sourceFile?: SourceFile): number; @@ -59,6 +63,10 @@ namespace ts { update(newText: string, textChangeRange: TextChangeRange): SourceFile; } + export interface SourceFileLike { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + } + /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the * snapshot is observably immutable. i.e. the same calls with the same parameters will return @@ -248,7 +256,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index a4f574b9c28..0ffd5d27bc6 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -394,8 +394,8 @@ namespace ts { list: Node; } - export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number { - const lineStarts = sourceFile.getLineStarts(); + export function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): number { + const lineStarts = getLineStarts(sourceFile); const line = sourceFile.getLineAndCharacterOfPosition(position).line; return lineStarts[line]; } @@ -604,7 +604,7 @@ namespace ts { return !!findChildOfKind(n, kind, sourceFile); } - export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined { + export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFileLike): Node | undefined { return forEach(n.getChildren(sourceFile), c => c.kind === kind && c); } @@ -1003,10 +1003,6 @@ namespace ts { return undefined; } - export function isToken(n: Node): boolean { - return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; - } - export function isWord(kind: SyntaxKind): boolean { return kind === SyntaxKind.Identifier || isKeyword(kind); } @@ -1384,8 +1380,8 @@ namespace ts { }; } - export function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { + export function getOpenBrace(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); + return constructor.body.getFirstToken(sourceFile); } } diff --git a/tests/baselines/reference/textChanges/deleteNode1.js b/tests/baselines/reference/textChanges/deleteNode1.js new file mode 100644 index 00000000000..c73c0eaf9f9 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode1.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // some comment - 1 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode2.js b/tests/baselines/reference/textChanges/deleteNode2.js new file mode 100644 index 00000000000..828a9b5b8fa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1;var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode3.js b/tests/baselines/reference/textChanges/deleteNode3.js new file mode 100644 index 00000000000..acb26c7daa7 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode3.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // some comment - 1 + // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode4.js b/tests/baselines/reference/textChanges/deleteNode4.js new file mode 100644 index 00000000000..b6edb25bc5c --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode4.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode5.js b/tests/baselines/reference/textChanges/deleteNode5.js new file mode 100644 index 00000000000..6f896535f0f --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode5.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNodeInList1.js b/tests/baselines/reference/textChanges/deleteNodeInList1.js new file mode 100644 index 00000000000..b603913566d --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var b = 2, c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList10.js b/tests/baselines/reference/textChanges/deleteNodeInList10.js new file mode 100644 index 00000000000..46da605a71a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList10.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(b: string,c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList11.js b/tests/baselines/reference/textChanges/deleteNodeInList11.js new file mode 100644 index 00000000000..f5aa666e527 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList11.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number,c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList12.js b/tests/baselines/reference/textChanges/deleteNodeInList12.js new file mode 100644 index 00000000000..db05ef06db9 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList12.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number,b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList13.js b/tests/baselines/reference/textChanges/deleteNodeInList13.js new file mode 100644 index 00000000000..599d3a31d43 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList13.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + b: string, + c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList14.js b/tests/baselines/reference/textChanges/deleteNodeInList14.js new file mode 100644 index 00000000000..da3596b38b2 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList14.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + a: number, + c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList15.js b/tests/baselines/reference/textChanges/deleteNodeInList15.js new file mode 100644 index 00000000000..02f649dabd2 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList15.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + a: number, + b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList1_1.js b/tests/baselines/reference/textChanges/deleteNodeInList1_1.js new file mode 100644 index 00000000000..87709601c42 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList1_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var b = 2,c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList2.js b/tests/baselines/reference/textChanges/deleteNodeInList2.js new file mode 100644 index 00000000000..18e4a0cd304 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList2.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var a = 1, c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList2_1.js b/tests/baselines/reference/textChanges/deleteNodeInList2_1.js new file mode 100644 index 00000000000..b4098a89302 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList2_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var a = 1,c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList3.js b/tests/baselines/reference/textChanges/deleteNodeInList3.js new file mode 100644 index 00000000000..1c6ff4aa294 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList3.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var a = 1, b = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList3_1.js b/tests/baselines/reference/textChanges/deleteNodeInList3_1.js new file mode 100644 index 00000000000..ead2a1a42f8 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList3_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var a = 1,b = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList4.js b/tests/baselines/reference/textChanges/deleteNodeInList4.js new file mode 100644 index 00000000000..61bdf9159cb --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList4.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var b = 2, + c = 3; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList4_1.js b/tests/baselines/reference/textChanges/deleteNodeInList4_1.js new file mode 100644 index 00000000000..19ff5475d1a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList4_1.js @@ -0,0 +1,17 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList5.js b/tests/baselines/reference/textChanges/deleteNodeInList5.js new file mode 100644 index 00000000000..0ed65877d27 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList5.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var a = 1, + c = 3; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList5_1.js b/tests/baselines/reference/textChanges/deleteNodeInList5_1.js new file mode 100644 index 00000000000..224b92481d3 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList5_1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var a = 1, // comment 1 + // comment 4 + c = 3; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList6.js b/tests/baselines/reference/textChanges/deleteNodeInList6.js new file mode 100644 index 00000000000..4093329023f --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList6.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var a = 1, + b = 2; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList6_1.js b/tests/baselines/reference/textChanges/deleteNodeInList6_1.js new file mode 100644 index 00000000000..6acc20aa826 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList6_1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList7.js b/tests/baselines/reference/textChanges/deleteNodeInList7.js new file mode 100644 index 00000000000..564ff3f86aa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList7.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(b: string, c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList8.js b/tests/baselines/reference/textChanges/deleteNodeInList8.js new file mode 100644 index 00000000000..b3a0a0f4c47 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList8.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number, c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList9.js b/tests/baselines/reference/textChanges/deleteNodeInList9.js new file mode 100644 index 00000000000..96878a6086d --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList9.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number, b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeRange1.js b/tests/baselines/reference/textChanges/deleteNodeRange1.js new file mode 100644 index 00000000000..f9fa45ebb1a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange2.js b/tests/baselines/reference/textChanges/deleteNodeRange2.js new file mode 100644 index 00000000000..aacea6ff5ee --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange2.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1;// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange3.js b/tests/baselines/reference/textChanges/deleteNodeRange3.js new file mode 100644 index 00000000000..bb2bb36ca2c --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange3.js @@ -0,0 +1,17 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 + // comment 5 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange4.js b/tests/baselines/reference/textChanges/deleteNodeRange4.js new file mode 100644 index 00000000000..3e9ad960b13 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange4.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 5 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteRange1.js b/tests/baselines/reference/textChanges/deleteRange1.js new file mode 100644 index 00000000000..362e678452e --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteRange1.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo() { + return 1; +} + +function bar() { + return 2; +} + +===MODIFIED=== + +function bar() { + return 2; +} diff --git a/tests/baselines/reference/textChanges/extractMethodLike.js b/tests/baselines/reference/textChanges/extractMethodLike.js new file mode 100644 index 00000000000..fa1d625dc4d --- /dev/null +++ b/tests/baselines/reference/textChanges/extractMethodLike.js @@ -0,0 +1,49 @@ +===ORIGINAL=== + +namespace M +{ + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() { + return 100; + } + const y = 2; // comment 3 + return 1; + } + } +} +===MODIFIED=== + +namespace M +{ + function bar(): any + { + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() + { + return 100; + } + const y = 2; // comment 3 + return 1; + } + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + return bar(); + } + } +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter1.js b/tests/baselines/reference/textChanges/insertNodeAfter1.js new file mode 100644 index 00000000000..e6d7387f6bc --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter1.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + public class class1 implements interface1 + { + property1: boolean; + } + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter2.js b/tests/baselines/reference/textChanges/insertNodeAfter2.js new file mode 100644 index 00000000000..7c027e35b50 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter2.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +public class class1 implements interface1 +{ + property1: boolean; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js b/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js new file mode 100644 index 00000000000..41bfb72b574 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +class A { + constructor() { + + } +} + +===MODIFIED=== + +class A { + constructor() { + super(); + + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfter3.js b/tests/baselines/reference/textChanges/insertNodeAfter3.js new file mode 100644 index 00000000000..3765bbaf032 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter3.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +class A { + constructor() { + } +} + +===MODIFIED=== + +class A { + constructor() { + super(); + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfter4.js b/tests/baselines/reference/textChanges/insertNodeAfter4.js new file mode 100644 index 00000000000..3ca51db4989 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter4.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +class A { + constructor() { + var x = 1; + } +} + +===MODIFIED=== + +class A { + constructor() { + var x = 1; + super(); + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAt1.js b/tests/baselines/reference/textChanges/insertNodeAt1.js new file mode 100644 index 00000000000..9c7ac46f8a8 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAt1.js @@ -0,0 +1,22 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +public class class1 implements interface1 +{ + property1: boolean; +} +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAt2.js b/tests/baselines/reference/textChanges/insertNodeAt2.js new file mode 100644 index 00000000000..81c3e2afc35 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAt2.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var yz1 = { + p1: 1 +}; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeBefore1.js b/tests/baselines/reference/textChanges/insertNodeBefore1.js new file mode 100644 index 00000000000..deebe10b694 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeBefore1.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + public class class1 implements interface1 + { + property1: boolean; + } + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeBefore2.js b/tests/baselines/reference/textChanges/insertNodeBefore2.js new file mode 100644 index 00000000000..1792cd5e69c --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeBefore2.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +public class class1 implements interface1 +{ + property1: boolean; +} +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode1.js b/tests/baselines/reference/textChanges/replaceNode1.js new file mode 100644 index 00000000000..8511d510385 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode1.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js b/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js new file mode 100644 index 00000000000..44183d402ab --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace A { + const x = 1, y = "2"; +} + +===MODIFIED=== + +namespace A { + const x = 1, z1 = { + p1: 1 + }; +} diff --git a/tests/baselines/reference/textChanges/replaceNode2.js b/tests/baselines/reference/textChanges/replaceNode2.js new file mode 100644 index 00000000000..66a17f7c910 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode2.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; +public class class1 implements interface1 +{ + property1: boolean; +} +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode3.js b/tests/baselines/reference/textChanges/replaceNode3.js new file mode 100644 index 00000000000..9f321a97431 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode3.js @@ -0,0 +1,21 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} + // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode4.js b/tests/baselines/reference/textChanges/replaceNode4.js new file mode 100644 index 00000000000..e5bbf0e306d --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode4.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1;public class class1 implements interface1 +{ + property1: boolean; +} // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode5.js b/tests/baselines/reference/textChanges/replaceNode5.js new file mode 100644 index 00000000000..ad3ec0ab0ea --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode5.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== +public class class1 implements interface1 +{ + property1: boolean; +} // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange1.js b/tests/baselines/reference/textChanges/replaceNodeRange1.js new file mode 100644 index 00000000000..5fc16960a8a --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange1.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange2.js b/tests/baselines/reference/textChanges/replaceNodeRange2.js new file mode 100644 index 00000000000..e8f9506d608 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange2.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; +public class class1 implements interface1 +{ + property1: boolean; +} +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange3.js b/tests/baselines/reference/textChanges/replaceNodeRange3.js new file mode 100644 index 00000000000..a20dddc53fe --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange3.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} + // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange4.js b/tests/baselines/reference/textChanges/replaceNodeRange4.js new file mode 100644 index 00000000000..ad50a1f01fc --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange4.js @@ -0,0 +1,18 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1;public class class1 implements interface1 +{ + property1: boolean; +} // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRange.js b/tests/baselines/reference/textChanges/replaceRange.js new file mode 100644 index 00000000000..8cb83286169 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRange.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +public class class1 implements interface1 +{ + property1: boolean; +} +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js b/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js new file mode 100644 index 00000000000..72a45ee56e2 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js @@ -0,0 +1,6 @@ +===ORIGINAL=== +const x = 1, y = "2"; +===MODIFIED=== +const x = 1, z1 = { + p1: 1 +}; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js b/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js new file mode 100644 index 00000000000..304b81b1359 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 + public class class1 implements interface1 + { + property1: boolean; + } +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddForgottenThis01.ts b/tests/cases/fourslash/codeFixAddForgottenThis01.ts index 90d191b6ba5..07f06348212 100644 --- a/tests/cases/fourslash/codeFixAddForgottenThis01.ts +++ b/tests/cases/fourslash/codeFixAddForgottenThis01.ts @@ -2,9 +2,11 @@ ////class C { //// foo: number; -//// constructor() { -//// [|foo = 10|]; -//// } +//// constructor() {[| +//// foo = 10; +//// |]} ////} -verify.rangeAfterCodeFix("this.foo = 10"); \ No newline at end of file +verify.rangeAfterCodeFix(` + this.foo = 10; + `, /*includeWhitespace*/ true); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixSuperAfterThis.ts b/tests/cases/fourslash/codeFixSuperAfterThis.ts index 2bff98ceca0..55b44b07881 100644 --- a/tests/cases/fourslash/codeFixSuperAfterThis.ts +++ b/tests/cases/fourslash/codeFixSuperAfterThis.ts @@ -6,8 +6,10 @@ //// private a:number; //// constructor() {[| //// this.a = 12; -//// super();|] -//// } +//// super(); +//// |]} ////} - -verify.rangeAfterCodeFix("super(); this.a = 12;"); \ No newline at end of file +verify.rangeAfterCodeFix(` + super(); + this.a = 12; + `, /*includeWhiteSpace*/ true); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixSuperCall.ts b/tests/cases/fourslash/codeFixSuperCall.ts index c918e74dc38..f7584050a15 100644 --- a/tests/cases/fourslash/codeFixSuperCall.ts +++ b/tests/cases/fourslash/codeFixSuperCall.ts @@ -1,10 +1,11 @@ -/// +/// ////class Base{ ////} ////class C extends Base{ -//// constructor() {[| |] -//// } +//// constructor() {[| +//// |]} ////} - -verify.rangeAfterCodeFix('super();'); +verify.rangeAfterCodeFix(` + super(); + `, /*includeWhitespace*/ true); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index 288573608f2..7a63ff13caa 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -8,5 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { - // some legit comments }`); diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index 5aa3251c0b4..7f99863ba46 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -1,12 +1,16 @@ /// // @noUnusedLocals: true -//// function f1 () { -//// for (const elem of ["a", "b", "c"]) { -//// elem; -//// [|var x = 20; -//// }|] -////} +////function f1 () [|{ +//// for (const elem of ["a", "b", "c"]) { +//// elem; +//// var x = 20; +//// } +////}|] //// -verify.rangeAfterCodeFix("}"); +verify.rangeAfterCodeFix(`{ + for (const elem of ["a", "b", "c"]) { + elem; + } +}`, /*includeWhiteSpace*/ true); From 0b1fff7e66a93b6e887895725f8c10b4b1b9b28e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 6 Jan 2017 17:15:39 -0800 Subject: [PATCH 037/207] Add `--checkJsFiles` --- src/compiler/commandLineParser.ts | 6 ++++++ src/compiler/diagnosticMessages.json | 4 ++++ src/compiler/program.ts | 2 +- src/compiler/types.ts | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index dc692972891..85a099c6dca 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -481,6 +481,12 @@ namespace ts { name: "plugin", type: "object" } + }, + { + name: "checkJsFiles", + type: "boolean", + experimental: true, + description: Diagnostics.Report_errors_in_js_files } ]; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 318f06ceeaa..83b4cb961a4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3362,5 +3362,9 @@ "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'.": { "category": "Error", "code": 8018 + }, + "Report errors in .js files.": { + "category": "Message", + "code": 8019 } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d9ddf486e0d..ecef2377bae 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -907,7 +907,7 @@ namespace ts { // For JavaScript files, we don't want to report semantic errors. // Instead, we'll report errors for using TypeScript-only constructs from within a // JavaScript file when we get syntactic diagnostics for the file. - const checkDiagnostics = isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + const checkDiagnostics = !options.checkJsFiles && isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f96f8623885..02d0a784b3d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3312,6 +3312,7 @@ alwaysStrict?: boolean; // Always combine with strict property baseUrl?: string; charset?: string; + checkJsFiles?: boolean; /* @internal */ configFilePath?: string; declaration?: boolean; declarationDir?: string; From 9f0c5ce1418df7ffb14eb7fefca4910a436dd3d2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 6 Jan 2017 19:03:17 -0800 Subject: [PATCH 038/207] Add support for `//@check` directives --- src/compiler/parser.ts | 5 +++++ src/compiler/program.ts | 3 ++- src/compiler/types.ts | 1 + src/services/services.ts | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 308d3a317f9..48fe3ce5426 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5817,6 +5817,7 @@ namespace ts { const typeReferenceDirectives: FileReference[] = []; const amdDependencies: { path: string; name: string }[] = []; let amdModuleName: string; + let hasCheckDirective = false; // Keep scanning all the leading trivia in the file until we get to something that // isn't trivia. Any single line comment will be analyzed to see if it is a @@ -5878,6 +5879,9 @@ namespace ts { amdDependencies.push(amdDependency); } } + + const checkDirectiveRegEx = /^\/\/\s*@check\s*/gim; + hasCheckDirective = hasCheckDirective || !!checkDirectiveRegEx.exec(comment); } } @@ -5885,6 +5889,7 @@ namespace ts { sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; + sourceFile.hasCheckDirective = hasCheckDirective; } function setExternalModuleIndicator(sourceFile: SourceFile) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ecef2377bae..64da4f6de71 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -907,7 +907,8 @@ namespace ts { // For JavaScript files, we don't want to report semantic errors. // Instead, we'll report errors for using TypeScript-only constructs from within a // JavaScript file when we get syntactic diagnostics for the file. - const checkDiagnostics = !options.checkJsFiles && isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + const includeCheckDiagnostics = options.checkJsFiles || sourceFile.hasCheckDirective || !isSourceFileJavaScript(sourceFile); + const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 02d0a784b3d..3028b295d27 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2272,6 +2272,7 @@ /* @internal */ moduleAugmentations: LiteralExpression[]; /* @internal */ patternAmbientModules?: PatternAmbientModule[]; /* @internal */ ambientModuleNames: string[]; + /* @internal */ hasCheckDirective: boolean; } export interface Bundle extends Node { diff --git a/src/services/services.ts b/src/services/services.ts index f122e39bcc6..037894661ff 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -473,6 +473,7 @@ namespace ts { public moduleAugmentations: LiteralExpression[]; private namedDeclarations: Map; public ambientModuleNames: string[]; + public hasCheckDirective: boolean; constructor(kind: SyntaxKind, pos: number, end: number) { super(kind, pos, end); From 0b247b12a35b004f90489fcd9bc05bdc210a6394 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 6 Mar 2017 14:49:50 -0800 Subject: [PATCH 039/207] Add tests --- tests/baselines/reference/checkJsFiles.errors.txt | 13 +++++++++++++ tests/baselines/reference/checkJsFiles2.errors.txt | 14 ++++++++++++++ tests/baselines/reference/checkJsFiles3.errors.txt | 14 ++++++++++++++ tests/cases/compiler/checkJsFiles.ts | 6 ++++++ tests/cases/compiler/checkJsFiles2.ts | 7 +++++++ tests/cases/compiler/checkJsFiles3.ts | 6 ++++++ 6 files changed, 60 insertions(+) create mode 100644 tests/baselines/reference/checkJsFiles.errors.txt create mode 100644 tests/baselines/reference/checkJsFiles2.errors.txt create mode 100644 tests/baselines/reference/checkJsFiles3.errors.txt create mode 100644 tests/cases/compiler/checkJsFiles.ts create mode 100644 tests/cases/compiler/checkJsFiles2.ts create mode 100644 tests/cases/compiler/checkJsFiles3.ts diff --git a/tests/baselines/reference/checkJsFiles.errors.txt b/tests/baselines/reference/checkJsFiles.errors.txt new file mode 100644 index 00000000000..8371e101dd1 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles.errors.txt @@ -0,0 +1,13 @@ +error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. + Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +tests/cases/compiler/a.js(3,1): error TS2322: Type '0' is not assignable to type 'string'. + + +!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. +!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +==== tests/cases/compiler/a.js (1 errors) ==== + + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles2.errors.txt b/tests/baselines/reference/checkJsFiles2.errors.txt new file mode 100644 index 00000000000..566ba3786b8 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles2.errors.txt @@ -0,0 +1,14 @@ +error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. + Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. + + +!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. +!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +==== tests/cases/compiler/a.js (1 errors) ==== + + // @check + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles3.errors.txt b/tests/baselines/reference/checkJsFiles3.errors.txt new file mode 100644 index 00000000000..566ba3786b8 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles3.errors.txt @@ -0,0 +1,14 @@ +error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. + Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. + + +!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. +!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. +==== tests/cases/compiler/a.js (1 errors) ==== + + // @check + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles.ts b/tests/cases/compiler/checkJsFiles.ts new file mode 100644 index 00000000000..c36673b0239 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles.ts @@ -0,0 +1,6 @@ +// @allowJs: true +// @checkJsFiles: true + +// @fileName: a.js +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles2.ts b/tests/cases/compiler/checkJsFiles2.ts new file mode 100644 index 00000000000..fe8978666b0 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles2.ts @@ -0,0 +1,7 @@ +// @allowJs: true +// @checkJsFiles: false + +// @fileName: a.js +// @check +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles3.ts b/tests/cases/compiler/checkJsFiles3.ts new file mode 100644 index 00000000000..964f909bc6f --- /dev/null +++ b/tests/cases/compiler/checkJsFiles3.ts @@ -0,0 +1,6 @@ +// @allowJs: true + +// @fileName: a.js +// @check +var x = "string"; +x = 0; \ No newline at end of file From 1f9bb693ec389ae740da78106f46794a4653645a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 6 Mar 2017 21:01:47 -0800 Subject: [PATCH 040/207] Add --noEmit to tests --- tests/baselines/reference/checkJsFiles.errors.txt | 4 ---- tests/baselines/reference/checkJsFiles2.errors.txt | 4 ---- tests/baselines/reference/checkJsFiles3.errors.txt | 4 ---- tests/cases/compiler/checkJsFiles.ts | 1 + tests/cases/compiler/checkJsFiles2.ts | 1 + tests/cases/compiler/checkJsFiles3.ts | 1 + 6 files changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/checkJsFiles.errors.txt b/tests/baselines/reference/checkJsFiles.errors.txt index 8371e101dd1..41344dc384a 100644 --- a/tests/baselines/reference/checkJsFiles.errors.txt +++ b/tests/baselines/reference/checkJsFiles.errors.txt @@ -1,10 +1,6 @@ -error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. tests/cases/compiler/a.js(3,1): error TS2322: Type '0' is not assignable to type 'string'. -!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. ==== tests/cases/compiler/a.js (1 errors) ==== var x = "string"; diff --git a/tests/baselines/reference/checkJsFiles2.errors.txt b/tests/baselines/reference/checkJsFiles2.errors.txt index 566ba3786b8..5c1a211a646 100644 --- a/tests/baselines/reference/checkJsFiles2.errors.txt +++ b/tests/baselines/reference/checkJsFiles2.errors.txt @@ -1,10 +1,6 @@ -error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. -!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. ==== tests/cases/compiler/a.js (1 errors) ==== // @check diff --git a/tests/baselines/reference/checkJsFiles3.errors.txt b/tests/baselines/reference/checkJsFiles3.errors.txt index 566ba3786b8..5c1a211a646 100644 --- a/tests/baselines/reference/checkJsFiles3.errors.txt +++ b/tests/baselines/reference/checkJsFiles3.errors.txt @@ -1,10 +1,6 @@ -error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. - Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. -!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file. -!!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. ==== tests/cases/compiler/a.js (1 errors) ==== // @check diff --git a/tests/cases/compiler/checkJsFiles.ts b/tests/cases/compiler/checkJsFiles.ts index c36673b0239..0f196539737 100644 --- a/tests/cases/compiler/checkJsFiles.ts +++ b/tests/cases/compiler/checkJsFiles.ts @@ -1,5 +1,6 @@ // @allowJs: true // @checkJsFiles: true +// @noEmit: true // @fileName: a.js var x = "string"; diff --git a/tests/cases/compiler/checkJsFiles2.ts b/tests/cases/compiler/checkJsFiles2.ts index fe8978666b0..e18eecb0393 100644 --- a/tests/cases/compiler/checkJsFiles2.ts +++ b/tests/cases/compiler/checkJsFiles2.ts @@ -1,5 +1,6 @@ // @allowJs: true // @checkJsFiles: false +// @noEmit: true // @fileName: a.js // @check diff --git a/tests/cases/compiler/checkJsFiles3.ts b/tests/cases/compiler/checkJsFiles3.ts index 964f909bc6f..a0a9a152fee 100644 --- a/tests/cases/compiler/checkJsFiles3.ts +++ b/tests/cases/compiler/checkJsFiles3.ts @@ -1,4 +1,5 @@ // @allowJs: true +// @noEmit: true // @fileName: a.js // @check From b015c1d9b0181bcb499af1e801d9acb70d5a6d4f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 6 Mar 2017 21:39:32 -0800 Subject: [PATCH 041/207] Allow @check directives to switch on/off checking in a file --- src/compiler/parser.ts | 15 +++++++++++---- src/compiler/program.ts | 7 +++---- src/compiler/types.ts | 6 +++++- src/harness/harness.ts | 2 +- src/services/services.ts | 2 +- .../baselines/reference/checkJsFiles4.errors.txt | 10 ++++++++++ tests/baselines/reference/checkJsFiles5.symbols | 9 +++++++++ tests/baselines/reference/checkJsFiles5.types | 12 ++++++++++++ tests/cases/compiler/checkJsFiles4.ts | 8 ++++++++ tests/cases/compiler/checkJsFiles5.ts | 8 ++++++++ 10 files changed, 68 insertions(+), 11 deletions(-) create mode 100644 tests/baselines/reference/checkJsFiles4.errors.txt create mode 100644 tests/baselines/reference/checkJsFiles5.symbols create mode 100644 tests/baselines/reference/checkJsFiles5.types create mode 100644 tests/cases/compiler/checkJsFiles4.ts create mode 100644 tests/cases/compiler/checkJsFiles5.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 48fe3ce5426..ef23ee175fd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5817,7 +5817,7 @@ namespace ts { const typeReferenceDirectives: FileReference[] = []; const amdDependencies: { path: string; name: string }[] = []; let amdModuleName: string; - let hasCheckDirective = false; + let checkJsDirective: CheckJsDirective = undefined; // Keep scanning all the leading trivia in the file until we get to something that // isn't trivia. Any single line comment will be analyzed to see if it is a @@ -5880,8 +5880,15 @@ namespace ts { } } - const checkDirectiveRegEx = /^\/\/\s*@check\s*/gim; - hasCheckDirective = hasCheckDirective || !!checkDirectiveRegEx.exec(comment); + const checkJsDirectiveRegEx = /^\/\/\/?\s*@check(\s+(true|false))?/gim; + const checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); + if (checkJsDirectiveMatchResult) { + checkJsDirective = { + enabled: compareStrings(checkJsDirectiveMatchResult[2], "false", /*ignoreCase*/ true) !== Comparison.EqualTo, + end: range.end, + pos: range.pos + }; + } } } @@ -5889,7 +5896,7 @@ namespace ts { sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; - sourceFile.hasCheckDirective = hasCheckDirective; + sourceFile.checkJsDirective = checkJsDirective; } function setExternalModuleIndicator(sourceFile: SourceFile) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 64da4f6de71..29559c12191 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -904,10 +904,9 @@ namespace ts { Debug.assert(!!sourceFile.bindDiagnostics); const bindDiagnostics = sourceFile.bindDiagnostics; - // For JavaScript files, we don't want to report semantic errors. - // Instead, we'll report errors for using TypeScript-only constructs from within a - // JavaScript file when we get syntactic diagnostics for the file. - const includeCheckDiagnostics = options.checkJsFiles || sourceFile.hasCheckDirective || !isSourceFileJavaScript(sourceFile); + // For JavaScript files, we don't want to report semantic errors unless ecplicitlly requested. + const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || + (sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : options.checkJsFiles); const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3028b295d27..beb68a015b0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1940,6 +1940,10 @@ fileName: string; } + export interface CheckJsDirective extends TextRange { + enabled: boolean; + } + export type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; export interface CommentRange extends TextRange { @@ -2272,7 +2276,7 @@ /* @internal */ moduleAugmentations: LiteralExpression[]; /* @internal */ patternAmbientModules?: PatternAmbientModule[]; /* @internal */ ambientModuleNames: string[]; - /* @internal */ hasCheckDirective: boolean; + /* @internal */ checkJsDirective: CheckJsDirective | undefined; } export interface Bundle extends Node { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 23e8106864a..9304940ce1f 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -202,7 +202,7 @@ namespace Utils { for (const childName in node) { if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator" || // for now ignore jsdoc comments - childName === "jsDocComment") { + childName === "jsDocComment" || childName === "checkJsDirective") { continue; } const child = (node)[childName]; diff --git a/src/services/services.ts b/src/services/services.ts index 037894661ff..a77bacb9a86 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -473,7 +473,7 @@ namespace ts { public moduleAugmentations: LiteralExpression[]; private namedDeclarations: Map; public ambientModuleNames: string[]; - public hasCheckDirective: boolean; + public checkJsDirective: CheckJsDirective | undefined; constructor(kind: SyntaxKind, pos: number, end: number) { super(kind, pos, end); diff --git a/tests/baselines/reference/checkJsFiles4.errors.txt b/tests/baselines/reference/checkJsFiles4.errors.txt new file mode 100644 index 00000000000..87eb0f3b7d4 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles4.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type 'string'. + + +==== tests/cases/compiler/a.js (1 errors) ==== + + // @check true + var x = "string"; + x = 0; + ~ +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/checkJsFiles5.symbols b/tests/baselines/reference/checkJsFiles5.symbols new file mode 100644 index 00000000000..cdb53964aa5 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles5.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/a.js === + +// @check false +var x = "string"; +>x : Symbol(x, Decl(a.js, 2, 3)) + +x = 0; +>x : Symbol(x, Decl(a.js, 2, 3)) + diff --git a/tests/baselines/reference/checkJsFiles5.types b/tests/baselines/reference/checkJsFiles5.types new file mode 100644 index 00000000000..bd1ab8d942c --- /dev/null +++ b/tests/baselines/reference/checkJsFiles5.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/a.js === + +// @check false +var x = "string"; +>x : string +>"string" : "string" + +x = 0; +>x = 0 : 0 +>x : string +>0 : 0 + diff --git a/tests/cases/compiler/checkJsFiles4.ts b/tests/cases/compiler/checkJsFiles4.ts new file mode 100644 index 00000000000..364397a3e8a --- /dev/null +++ b/tests/cases/compiler/checkJsFiles4.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJsFiles: false +// @noEmit: true + +// @fileName: a.js +// @check true +var x = "string"; +x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles5.ts b/tests/cases/compiler/checkJsFiles5.ts new file mode 100644 index 00000000000..572f6b3b5f8 --- /dev/null +++ b/tests/cases/compiler/checkJsFiles5.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJsFiles: true +// @noEmit: true + +// @fileName: a.js +// @check false +var x = "string"; +x = 0; \ No newline at end of file From 9305d4d99e9799afb998bd34aede02ec0f4f1401 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Mar 2017 13:48:37 -0800 Subject: [PATCH 042/207] Change flag name to `checkJs` --- src/compiler/commandLineParser.ts | 2 +- src/compiler/program.ts | 2 +- src/compiler/types.ts | 2 +- tests/cases/compiler/checkJsFiles.ts | 2 +- tests/cases/compiler/checkJsFiles2.ts | 2 +- tests/cases/compiler/checkJsFiles4.ts | 2 +- tests/cases/compiler/checkJsFiles5.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 85a099c6dca..70966c48e7c 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -483,7 +483,7 @@ namespace ts { } }, { - name: "checkJsFiles", + name: "checkJs", type: "boolean", experimental: true, description: Diagnostics.Report_errors_in_js_files diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 29559c12191..5fd178a891f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -906,7 +906,7 @@ namespace ts { const bindDiagnostics = sourceFile.bindDiagnostics; // For JavaScript files, we don't want to report semantic errors unless ecplicitlly requested. const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || - (sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : options.checkJsFiles); + (sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : options.checkJs); const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index beb68a015b0..7e7fe7c28e4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3317,7 +3317,7 @@ alwaysStrict?: boolean; // Always combine with strict property baseUrl?: string; charset?: string; - checkJsFiles?: boolean; + checkJs?: boolean; /* @internal */ configFilePath?: string; declaration?: boolean; declarationDir?: string; diff --git a/tests/cases/compiler/checkJsFiles.ts b/tests/cases/compiler/checkJsFiles.ts index 0f196539737..62e2eb3301d 100644 --- a/tests/cases/compiler/checkJsFiles.ts +++ b/tests/cases/compiler/checkJsFiles.ts @@ -1,5 +1,5 @@ // @allowJs: true -// @checkJsFiles: true +// @checkJs: true // @noEmit: true // @fileName: a.js diff --git a/tests/cases/compiler/checkJsFiles2.ts b/tests/cases/compiler/checkJsFiles2.ts index e18eecb0393..36bc2cbd255 100644 --- a/tests/cases/compiler/checkJsFiles2.ts +++ b/tests/cases/compiler/checkJsFiles2.ts @@ -1,5 +1,5 @@ // @allowJs: true -// @checkJsFiles: false +// @checkJs: false // @noEmit: true // @fileName: a.js diff --git a/tests/cases/compiler/checkJsFiles4.ts b/tests/cases/compiler/checkJsFiles4.ts index 364397a3e8a..8bebedf55e7 100644 --- a/tests/cases/compiler/checkJsFiles4.ts +++ b/tests/cases/compiler/checkJsFiles4.ts @@ -1,5 +1,5 @@ // @allowJs: true -// @checkJsFiles: false +// @checkJs: false // @noEmit: true // @fileName: a.js diff --git a/tests/cases/compiler/checkJsFiles5.ts b/tests/cases/compiler/checkJsFiles5.ts index 572f6b3b5f8..c28114f570b 100644 --- a/tests/cases/compiler/checkJsFiles5.ts +++ b/tests/cases/compiler/checkJsFiles5.ts @@ -1,5 +1,5 @@ // @allowJs: true -// @checkJsFiles: true +// @checkJs: true // @noEmit: true // @fileName: a.js From fb218b789746f2c8e12ea8919e4951a7403e9525 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Mar 2017 13:49:52 -0800 Subject: [PATCH 043/207] Error if `--checkJs` is used without `--allowJs` --- src/compiler/program.ts | 4 ++++ tests/baselines/reference/checkJsFiles6.errors.txt | 9 +++++++++ tests/cases/compiler/checkJsFiles6.ts | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 tests/baselines/reference/checkJsFiles6.errors.txt create mode 100644 tests/cases/compiler/checkJsFiles6.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 5fd178a891f..f524a549859 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1685,6 +1685,10 @@ namespace ts { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } + if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); diff --git a/tests/baselines/reference/checkJsFiles6.errors.txt b/tests/baselines/reference/checkJsFiles6.errors.txt new file mode 100644 index 00000000000..89063e50698 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles6.errors.txt @@ -0,0 +1,9 @@ +error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. + + +!!! error TS5052: Option 'checkJs' cannot be specified without specifying option 'allowJs'. +!!! error TS6054: File 'tests/cases/compiler/a.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +==== tests/cases/compiler/a.js (0 errors) ==== + + var x; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles6.ts b/tests/cases/compiler/checkJsFiles6.ts new file mode 100644 index 00000000000..358704ae22e --- /dev/null +++ b/tests/cases/compiler/checkJsFiles6.ts @@ -0,0 +1,6 @@ +// @allowJs: false +// @checkJs: true +// @noEmit: true + +// @fileName: a.js +var x; \ No newline at end of file From cedad974d21065a748c2597953052108dafa6ee4 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Thu, 5 Jan 2017 11:07:27 +0800 Subject: [PATCH 044/207] fix: add generic info for methods with thisArg of built-in classes when enabling `noImplicitThis`, if assing this argument for methods like `array.forEach` will cause compilation error. This commit fixes it. fix #12548 --- src/lib/es2015.core.d.ts | 20 +- src/lib/es2015.iterable.d.ts | 58 +++++- src/lib/es5.d.ts | 366 ++++++++++++++++++++++++++--------- 3 files changed, 342 insertions(+), 102 deletions(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index eb23ce7901f..88f70758e5a 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -10,7 +10,9 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -21,7 +23,9 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Returns the this object after filling the section identified by start and end with value @@ -52,7 +56,9 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** @@ -357,7 +363,9 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: undefined, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -368,7 +376,9 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; } interface RegExp { diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 247017bae7d..fe56c6e8bfb 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -54,7 +54,9 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): Array; + from(iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): Array; + from(iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): Array; + from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** * Creates an array from an iterable object. @@ -180,7 +182,11 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: Iterable): Int8Array; } /** @@ -212,7 +218,11 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: Iterable): Uint8Array; } /** @@ -247,7 +257,11 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: Iterable): Uint8ClampedArray; } /** @@ -281,7 +295,11 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: Iterable): Int16Array; } /** @@ -313,7 +331,11 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: Iterable): Uint16Array; } /** @@ -345,7 +367,11 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: Iterable): Int32Array; } /** @@ -377,7 +403,11 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: Iterable): Uint32Array; } /** @@ -409,7 +439,11 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: Iterable): Float32Array; } /** @@ -441,5 +475,9 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; + from(arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: Iterable): Float64Array; } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 04743f7d77f..61f8e396471 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1050,37 +1050,49 @@ interface ReadonlyArray { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: T, index: number, array: ReadonlyArray) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => void): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => void, thisArg: Z): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => U): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => U, thisArg: Z): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => value is S, thisArg?: any): S[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => value is S): S[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: undefined): S[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: Z): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => any, thisArg?: any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: ReadonlyArray) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => any, thisArg: Z): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1197,55 +1209,73 @@ interface Array { * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean): boolean; + every(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): boolean; /** * Determines whether the specified callback function returns true for any element of an array. * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean): boolean; + some(callbackfn: (this: undefined, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): boolean; /** * Performs the specified action for each element in an array. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: T[]) => void): void; + forEach(callbackfn: (this: undefined, value: T, index: number, array: T[]) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: T[]) => void, thisArg: Z): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; + map(this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; + map(this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; + map(this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; + map(callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: T[]) => any): T[]; + filter(callbackfn: (this: undefined, value: T, index: number, array: T[]) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: T[]) => any, thisArg: Z): T[]; /** * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. @@ -1590,7 +1620,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1609,7 +1641,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => any): Int8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => any, thisArg: undefined): Int8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => any, thisArg: Z): Int8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1620,7 +1654,9 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1631,7 +1667,9 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1640,7 +1678,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1678,7 +1718,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => number): Int8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => number, thisArg: undefined): Int8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => number, thisArg: Z): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1762,7 +1804,9 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -1814,7 +1858,11 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: ArrayLike): Int8Array; } declare const Int8Array: Int8ArrayConstructor; @@ -1863,7 +1911,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1882,7 +1932,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => any): Uint8Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => any, thisArg: undefined): Uint8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => any, thisArg: Z): Uint8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1893,7 +1945,9 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1904,7 +1958,9 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1913,7 +1969,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1951,7 +2009,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => number): Uint8Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => number, thisArg: undefined): Uint8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => number, thisArg: Z): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2035,7 +2095,9 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2088,7 +2150,11 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: ArrayLike): Uint8Array; } declare const Uint8Array: Uint8ArrayConstructor; @@ -2137,7 +2203,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2156,7 +2224,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => any): Uint8ClampedArray; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: undefined): Uint8ClampedArray; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: Z): Uint8ClampedArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2167,7 +2237,9 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2178,7 +2250,9 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2187,7 +2261,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2225,7 +2301,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => number): Uint8ClampedArray; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: undefined): Uint8ClampedArray; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: Z): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2309,7 +2387,9 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2362,7 +2442,11 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: ArrayLike): Uint8ClampedArray; } declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2410,7 +2494,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2429,7 +2515,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => any): Int16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => any, thisArg: undefined): Int16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => any, thisArg: Z): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2440,7 +2528,9 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2451,7 +2541,9 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2460,7 +2552,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2498,7 +2592,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => number): Int16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => number, thisArg: undefined): Int16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => number, thisArg: Z): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2582,7 +2678,9 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2635,7 +2733,11 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: ArrayLike): Int16Array; } declare const Int16Array: Int16ArrayConstructor; @@ -2684,7 +2786,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2703,7 +2807,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => any): Uint16Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => any, thisArg: undefined): Uint16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => any, thisArg: Z): Uint16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2714,7 +2820,9 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2725,7 +2833,9 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2734,7 +2844,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2772,7 +2884,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => number): Uint16Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => number, thisArg: undefined): Uint16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => number, thisArg: Z): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2856,7 +2970,9 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2909,7 +3025,11 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: ArrayLike): Uint16Array; } declare const Uint16Array: Uint16ArrayConstructor; @@ -2957,7 +3077,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2976,7 +3098,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => any): Int32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => any, thisArg: undefined): Int32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => any, thisArg: Z): Int32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2987,7 +3111,9 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2998,7 +3124,9 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3007,7 +3135,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3045,7 +3175,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => number): Int32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => number, thisArg: undefined): Int32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => number, thisArg: Z): Int32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3129,7 +3261,9 @@ interface Int32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3182,7 +3316,11 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: ArrayLike): Int32Array; } declare const Int32Array: Int32ArrayConstructor; @@ -3230,7 +3368,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3249,7 +3389,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => any): Uint32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => any, thisArg: undefined): Uint32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => any, thisArg: Z): Uint32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3260,7 +3402,9 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3271,7 +3415,9 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3280,7 +3426,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3318,7 +3466,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => number): Uint32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => number, thisArg: undefined): Uint32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => number, thisArg: Z): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3402,7 +3552,9 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3455,7 +3607,11 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: ArrayLike): Uint32Array; } declare const Uint32Array: Uint32ArrayConstructor; @@ -3503,7 +3659,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3522,7 +3680,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => any): Float32Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => any, thisArg: undefined): Float32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => any, thisArg: Z): Float32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3533,7 +3693,9 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3544,7 +3706,9 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3553,7 +3717,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3591,7 +3757,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => number): Float32Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => number, thisArg: undefined): Float32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => number, thisArg: Z): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3675,7 +3843,9 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3728,7 +3898,11 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: ArrayLike): Float32Array; } declare const Float32Array: Float32ArrayConstructor; @@ -3777,7 +3951,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean): boolean; + every(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3796,7 +3972,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => any): Float64Array; + filter(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => any, thisArg: undefined): Float64Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => any, thisArg: Z): Float64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3807,7 +3985,9 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3818,7 +3998,9 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: undefined, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3827,7 +4009,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => void): void; + forEach(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3865,7 +4049,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => number): Float64Array; + map(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => number, thisArg: undefined): Float64Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => number, thisArg: Z): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3949,7 +4135,9 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean): boolean; + some(callbackfn: (this: undefined, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -4002,7 +4190,11 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: ArrayLike): Float64Array; } declare const Float64Array: Float64ArrayConstructor; From 18154fe11110e44084f1b6b26f3ed1b7d70c55fc Mon Sep 17 00:00:00 2001 From: e-cloud Date: Thu, 5 Jan 2017 11:08:28 +0800 Subject: [PATCH 045/207] test: add tests for this type in native-this-assignable methods --- .../thisTypeInNativeThisAssignableMethods.js | 710 ++++++ ...sTypeInNativeThisAssignableMethods.symbols | 1569 +++++++++++++ ...hisTypeInNativeThisAssignableMethods.types | 1932 +++++++++++++++++ .../thisTypeInNativeThisAssignableMethods.ts | 398 ++++ 4 files changed, 4609 insertions(+) create mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js create mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols create mode 100644 tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types create mode 100644 tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js new file mode 100644 index 00000000000..d9020c79e29 --- /dev/null +++ b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.js @@ -0,0 +1,710 @@ +//// [thisTypeInNativeThisAssignableMethods.ts] + +class A { + options: string[]; + + addOptions(options: string[]) { + if (!this.options) { + this.options = []; + } + options.forEach(function (item) { + this.options.push(item); + }, this); + return this; + } + + testUndefined(options: string[]) { + const undefinedArr: Array = [] + options.forEach(function () { + undefinedArr.push(this); + }); // case1 + options.forEach(function () { + undefinedArr.push(this); + }, undefined); // case2 + options.forEach(function () { + undefinedArr.push(this); + }, null); // case3 + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + } + + test(options: string[]) { + const thisObject = { + options: [] as string[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this.options[item].length + }, thisObject) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this.options[item].length + }, thisObject) + } + + test1(options: string[]) { + const thisObject = { + options: [] as ReadonlyArray + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test2(options: Int8Array[]) { + const thisObject = { + options: [] as Int8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test3(options: Uint8Array[]) { + const thisObject = { + options: [] as Uint8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test4(options: Float32Array[]) { + const thisObject = { + options: [] as Float32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test5(options: Uint8ClampedArray[]) { + const thisObject = { + options: [] as Uint8ClampedArray[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test6(options: Int16Array[]) { + const thisObject = { + options: [] as Int16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test7(options: Uint16Array[]) { + const thisObject = { + options: [] as Uint16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test8(options: Uint32Array[]) { + const thisObject = { + options: [] as Uint32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test9(options: Float64Array[]) { + const thisObject = { + options: [] as Float64Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } +} + + +//// [thisTypeInNativeThisAssignableMethods.js] +class A { + addOptions(options) { + if (!this.options) { + this.options = []; + } + options.forEach(function (item) { + this.options.push(item); + }, this); + return this; + } + testUndefined(options) { + const undefinedArr = []; + options.forEach(function () { + undefinedArr.push(this); + }); // case1 + options.forEach(function () { + undefinedArr.push(this); + }, undefined); // case2 + options.forEach(function () { + undefinedArr.push(this); + }, null); // case3 + const arrLike = {}; + Array.from(arrLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined); + const iterLike = []; + Array.from(iterLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined); + } + test(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + const arrLike = {}; + Array.from(arrLike, function (item) { + return this.options[item].length; + }, thisObject); + const iterLike = []; + Array.from(iterLike, function (item) { + return this.options[item].length; + }, thisObject); + } + test1(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test2(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test3(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test4(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test5(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test6(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test7(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test8(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + test9(options) { + const thisObject = { + options: [] + }; + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } +} diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols new file mode 100644 index 00000000000..2ff555baa54 --- /dev/null +++ b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.symbols @@ -0,0 +1,1569 @@ +=== tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts === + +class A { +>A : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) + + options: string[]; +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) + + addOptions(options: string[]) { +>addOptions : Symbol(A.addOptions, Decl(thisTypeInNativeThisAssignableMethods.ts, 2, 22)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 4, 15)) + + if (!this.options) { +>this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) + + this.options = []; +>this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) + } + options.forEach(function (item) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 4, 15)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 8, 34)) + + this.options.push(item); +>this.options.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this.options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(A.options, Decl(thisTypeInNativeThisAssignableMethods.ts, 1, 9)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 8, 34)) + + }, this); +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) + + return this; +>this : Symbol(A, Decl(thisTypeInNativeThisAssignableMethods.ts, 0, 0)) + } + + testUndefined(options: string[]) { +>testUndefined : Symbol(A.testUndefined, Decl(thisTypeInNativeThisAssignableMethods.ts, 12, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) + + const undefinedArr: Array = [] +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) + + options.forEach(function () { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + undefinedArr.push(this); +>undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) + + }); // case1 + options.forEach(function () { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + undefinedArr.push(this); +>undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) + + }, undefined); // case2 +>undefined : Symbol(undefined) + + options.forEach(function () { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 14, 18)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + undefinedArr.push(this); +>undefinedArr.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>undefinedArr : Symbol(undefinedArr, Decl(thisTypeInNativeThisAssignableMethods.ts, 15, 13)) +>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) + + }, null); // case3 + + const arrLike = {} as ArrayLike +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 26, 13)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) + + Array.from(arrLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 26, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 27, 38)) + + return this === undefined ? 2 : 1; +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>undefined : Symbol(undefined) + + }, undefined) +>undefined : Symbol(undefined) + + const iterLike = [] as Iterable +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 31, 13)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + + Array.from(iterLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 31, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 32, 39)) + + return this === undefined ? 2 : 1; +>this : Symbol(this, Decl(lib.es2015.iterable.d.ts, --, --)) +>undefined : Symbol(undefined) + + }, undefined) +>undefined : Symbol(undefined) + } + + test(options: string[]) { +>test : Symbol(A.test, Decl(thisTypeInNativeThisAssignableMethods.ts, 35, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options: [] as string[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 42, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 46, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 50, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 54, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 59, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 63, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 37, 9)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 67, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + const arrLike = {} as ArrayLike +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 71, 13)) +>ArrayLike : Symbol(ArrayLike, Decl(lib.es5.d.ts, --, --)) + + Array.from(arrLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>arrLike : Symbol(arrLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 71, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 72, 38)) + + return this.options[item].length +>this.options[item].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 72, 38)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + }, thisObject) +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + + const iterLike = [] as Iterable +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 76, 13)) +>Iterable : Symbol(Iterable, Decl(lib.es2015.iterable.d.ts, --, --)) + + Array.from(iterLike, function (item) { +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>iterLike : Symbol(iterLike, Decl(thisTypeInNativeThisAssignableMethods.ts, 76, 13)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 77, 39)) + + return this.options[item].length +>this.options[item].length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>this : Symbol(this, Decl(lib.es2015.iterable.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 28)) +>item : Symbol(item, Decl(thisTypeInNativeThisAssignableMethods.ts, 77, 39)) +>length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) + + }, thisObject) +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 38, 13)) + } + + test1(options: string[]) { +>test1 : Symbol(A.test1, Decl(thisTypeInNativeThisAssignableMethods.ts, 80, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options: [] as ReadonlyArray +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 87, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 91, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 95, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 99, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 104, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 108, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 82, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 112, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 83, 13)) + } + + test2(options: Int8Array[]) { +>test2 : Symbol(A.test2, Decl(thisTypeInNativeThisAssignableMethods.ts, 115, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>Int8Array : Symbol(Int8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options: [] as Int8Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>Int8Array : Symbol(Int8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 122, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 126, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 130, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 134, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 139, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 143, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 117, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 147, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 118, 13)) + } + + test3(options: Uint8Array[]) { +>test3 : Symbol(A.test3, Decl(thisTypeInNativeThisAssignableMethods.ts, 150, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options: [] as Uint8Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>Uint8Array : Symbol(Uint8Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 157, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 161, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 165, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 169, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 174, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 178, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 152, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 182, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 153, 13)) + } + + test4(options: Float32Array[]) { +>test4 : Symbol(A.test4, Decl(thisTypeInNativeThisAssignableMethods.ts, 185, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>Float32Array : Symbol(Float32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options: [] as Float32Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>Float32Array : Symbol(Float32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 192, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 196, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 200, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 204, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 209, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 213, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 187, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 217, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 188, 13)) + } + + test5(options: Uint8ClampedArray[]) { +>test5 : Symbol(A.test5, Decl(thisTypeInNativeThisAssignableMethods.ts, 220, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options: [] as Uint8ClampedArray[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 227, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 231, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 235, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 239, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 244, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 248, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 222, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 252, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 223, 13)) + } + + test6(options: Int16Array[]) { +>test6 : Symbol(A.test6, Decl(thisTypeInNativeThisAssignableMethods.ts, 255, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>Int16Array : Symbol(Int16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options: [] as Int16Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>Int16Array : Symbol(Int16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 262, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 266, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 270, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 274, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 279, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 283, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 257, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 287, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 258, 13)) + } + + test7(options: Uint16Array[]) { +>test7 : Symbol(A.test7, Decl(thisTypeInNativeThisAssignableMethods.ts, 290, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options: [] as Uint16Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>Uint16Array : Symbol(Uint16Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 297, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 301, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 305, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 309, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 314, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 318, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 292, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 322, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 293, 13)) + } + + test8(options: Uint32Array[]) { +>test8 : Symbol(A.test8, Decl(thisTypeInNativeThisAssignableMethods.ts, 325, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options: [] as Uint32Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>Uint32Array : Symbol(Uint32Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 332, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 336, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 340, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 344, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 349, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 353, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 327, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 357, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 328, 13)) + } + + test9(options: Float64Array[]) { +>test9 : Symbol(A.test9, Decl(thisTypeInNativeThisAssignableMethods.ts, 360, 5)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>Float64Array : Symbol(Float64Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + const thisObject = { +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options: [] as Float64Array[] +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>Float64Array : Symbol(Float64Array, Decl(lib.es2016.array.include.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + }; + + options.find(function (val, index) { +>options.find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>find : Symbol(Array.find, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 367, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.findIndex(function (val, index) { +>options.findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>findIndex : Symbol(Array.findIndex, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 36)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 40)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 36)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es2015.core.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 371, 40)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.forEach(function (val, index) { +>options.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 34)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 38)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 34)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 375, 38)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.map(function (val, index) { +>options.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 30)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 34)) + + if (val === this.options[index]) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 30)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 34)) + + return this.options[index]; +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 379, 34)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.some(function (val, index) { +>options.some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>some : Symbol(Array.some, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 31)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 35)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 31)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 384, 35)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.filter(function (val, index) { +>options.filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 33)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 37)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 33)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 388, 37)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + + options.every(function (val, index) { +>options.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 362, 10)) +>every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 32)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 36)) + + return val === this.options[index]; +>val : Symbol(val, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 32)) +>this.options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>this : Symbol(this, Decl(lib.es5.d.ts, --, --)) +>options : Symbol(options, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 28)) +>index : Symbol(index, Decl(thisTypeInNativeThisAssignableMethods.ts, 392, 36)) + + }, thisObject); +>thisObject : Symbol(thisObject, Decl(thisTypeInNativeThisAssignableMethods.ts, 363, 13)) + } +} + diff --git a/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types new file mode 100644 index 00000000000..e64918181ca --- /dev/null +++ b/tests/baselines/reference/thisTypeInNativeThisAssignableMethods.types @@ -0,0 +1,1932 @@ +=== tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts === + +class A { +>A : A + + options: string[]; +>options : string[] + + addOptions(options: string[]) { +>addOptions : (options: string[]) => this +>options : string[] + + if (!this.options) { +>!this.options : boolean +>this.options : string[] +>this : this +>options : string[] + + this.options = []; +>this.options = [] : undefined[] +>this.options : string[] +>this : this +>options : string[] +>[] : undefined[] + } + options.forEach(function (item) { +>options.forEach(function (item) { this.options.push(item); }, this) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function (item) { this.options.push(item); } : (this: this, item: string) => void +>item : string + + this.options.push(item); +>this.options.push(item) : number +>this.options.push : (...items: string[]) => number +>this.options : string[] +>this : this +>options : string[] +>push : (...items: string[]) => number +>item : string + + }, this); +>this : this + + return this; +>this : this + } + + testUndefined(options: string[]) { +>testUndefined : (options: string[]) => void +>options : string[] + + const undefinedArr: Array = [] +>undefinedArr : undefined[] +>Array : T[] +>[] : undefined[] + + options.forEach(function () { +>options.forEach(function () { undefinedArr.push(this); }) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function () { undefinedArr.push(this); } : (this: undefined) => void + + undefinedArr.push(this); +>undefinedArr.push(this) : number +>undefinedArr.push : (...items: undefined[]) => number +>undefinedArr : undefined[] +>push : (...items: undefined[]) => number +>this : undefined + + }); // case1 + options.forEach(function () { +>options.forEach(function () { undefinedArr.push(this); }, undefined) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function () { undefinedArr.push(this); } : (this: undefined) => void + + undefinedArr.push(this); +>undefinedArr.push(this) : number +>undefinedArr.push : (...items: undefined[]) => number +>undefinedArr : undefined[] +>push : (...items: undefined[]) => number +>this : undefined + + }, undefined); // case2 +>undefined : undefined + + options.forEach(function () { +>options.forEach(function () { undefinedArr.push(this); }, null) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function () { undefinedArr.push(this); } : (this: undefined) => void + + undefinedArr.push(this); +>undefinedArr.push(this) : number +>undefinedArr.push : (...items: undefined[]) => number +>undefinedArr : undefined[] +>push : (...items: undefined[]) => number +>this : undefined + + }, null); // case3 +>null : null + + const arrLike = {} as ArrayLike +>arrLike : ArrayLike +>{} as ArrayLike : ArrayLike +>{} : {} +>ArrayLike : ArrayLike + + Array.from(arrLike, function (item) { +>Array.from(arrLike, function (item) { return this === undefined ? 2 : 1; }, undefined) : (2 | 1)[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>arrLike : ArrayLike +>function (item) { return this === undefined ? 2 : 1; } : (this: undefined, item: number) => 2 | 1 +>item : number + + return this === undefined ? 2 : 1; +>this === undefined ? 2 : 1 : 2 | 1 +>this === undefined : boolean +>this : undefined +>undefined : undefined +>2 : 2 +>1 : 1 + + }, undefined) +>undefined : undefined + + const iterLike = [] as Iterable +>iterLike : Iterable +>[] as Iterable : Iterable +>[] : undefined[] +>Iterable : Iterable + + Array.from(iterLike, function (item) { +>Array.from(iterLike, function (item) { return this === undefined ? 2 : 1; }, undefined) : (2 | 1)[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>iterLike : Iterable +>function (item) { return this === undefined ? 2 : 1; } : (this: undefined, item: number) => 2 | 1 +>item : number + + return this === undefined ? 2 : 1; +>this === undefined ? 2 : 1 : 2 | 1 +>this === undefined : boolean +>this : undefined +>undefined : undefined +>2 : 2 +>1 : 1 + + }, undefined) +>undefined : undefined + } + + test(options: string[]) { +>test : (options: string[]) => void +>options : string[] + + const thisObject = { +>thisObject : { options: string[]; } +>{ options: [] as string[] } : { options: string[]; } + + options: [] as string[] +>options : string[] +>[] as string[] : string[] +>[] : undefined[] + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : string +>options.find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>options : string[] +>find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>options : string[] +>findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : string[] +>options.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>options : string[] +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => string +>val : string +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + return this.options[index]; +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : string[] +>options.filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>options : string[] +>filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: string[]; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>index : number + + }, thisObject); +>thisObject : { options: string[]; } + + const arrLike = {} as ArrayLike +>arrLike : ArrayLike +>{} as ArrayLike : ArrayLike +>{} : {} +>ArrayLike : ArrayLike + + Array.from(arrLike, function (item) { +>Array.from(arrLike, function (item) { return this.options[item].length }, thisObject) : number[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>arrLike : ArrayLike +>function (item) { return this.options[item].length } : (this: { options: string[]; }, item: number) => number +>item : number + + return this.options[item].length +>this.options[item].length : number +>this.options[item] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>item : number +>length : number + + }, thisObject) +>thisObject : { options: string[]; } + + const iterLike = [] as Iterable +>iterLike : Iterable +>[] as Iterable : Iterable +>[] : undefined[] +>Iterable : Iterable + + Array.from(iterLike, function (item) { +>Array.from(iterLike, function (item) { return this.options[item].length }, thisObject) : number[] +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } +>iterLike : Iterable +>function (item) { return this.options[item].length } : (this: { options: string[]; }, item: number) => number +>item : number + + return this.options[item].length +>this.options[item].length : number +>this.options[item] : string +>this.options : string[] +>this : { options: string[]; } +>options : string[] +>item : number +>length : number + + }, thisObject) +>thisObject : { options: string[]; } + } + + test1(options: string[]) { +>test1 : (options: string[]) => void +>options : string[] + + const thisObject = { +>thisObject : { options: ReadonlyArray; } +>{ options: [] as ReadonlyArray } : { options: ReadonlyArray; } + + options: [] as ReadonlyArray +>options : ReadonlyArray +>[] as ReadonlyArray : ReadonlyArray +>[] : undefined[] +>ReadonlyArray : ReadonlyArray + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : string +>options.find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>options : string[] +>find : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): string; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): string; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): string; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>options : string[] +>findIndex : { (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean): number; (predicate: (this: undefined, value: string, index: number, obj: string[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: string, index: number, obj: string[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>options : string[] +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : string[] +>options.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>options : string[] +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => string +>val : string +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + return this.options[index]; +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>some : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : string[] +>options.filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>options : string[] +>filter : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any): string[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => any, thisArg: undefined): string[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => any, thisArg: Z): string[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>options : string[] +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: ReadonlyArray; }, val: string, index: number) => boolean +>val : string +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : string +>this.options[index] : string +>this.options : ReadonlyArray +>this : { options: ReadonlyArray; } +>options : ReadonlyArray +>index : number + + }, thisObject); +>thisObject : { options: ReadonlyArray; } + } + + test2(options: Int8Array[]) { +>test2 : (options: Int8Array[]) => void +>options : Int8Array[] +>Int8Array : Int8Array + + const thisObject = { +>thisObject : { options: Int8Array[]; } +>{ options: [] as Int8Array[] } : { options: Int8Array[]; } + + options: [] as Int8Array[] +>options : Int8Array[] +>[] as Int8Array[] : Int8Array[] +>[] : undefined[] +>Int8Array : Int8Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Int8Array +>options.find : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): Int8Array; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): Int8Array; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): Int8Array; } +>options : Int8Array[] +>find : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): Int8Array; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): Int8Array; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): Int8Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): number; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): number; } +>options : Int8Array[] +>findIndex : { (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean): number; (predicate: (this: undefined, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int8Array, index: number, obj: Int8Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void): void; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: Z): void; } +>options : Int8Array[] +>forEach : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void): void; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Int8Array[] +>options.map : { (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): U[]; } +>options : Int8Array[] +>map : { (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int8Array, Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): [U, U]; (this: [Int8Array, Int8Array], callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => Int8Array +>val : Int8Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + return this.options[index]; +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>options : Int8Array[] +>some : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Int8Array[] +>options.filter : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any): Int8Array[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: undefined): Int8Array[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: Z): Int8Array[]; } +>options : Int8Array[] +>filter : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any): Int8Array[]; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: undefined): Int8Array[]; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => any, thisArg: Z): Int8Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>options : Int8Array[] +>every : { (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int8Array, index: number, array: Int8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int8Array[]; }, val: Int8Array, index: number) => boolean +>val : Int8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int8Array +>this.options[index] : Int8Array +>this.options : Int8Array[] +>this : { options: Int8Array[]; } +>options : Int8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int8Array[]; } + } + + test3(options: Uint8Array[]) { +>test3 : (options: Uint8Array[]) => void +>options : Uint8Array[] +>Uint8Array : Uint8Array + + const thisObject = { +>thisObject : { options: Uint8Array[]; } +>{ options: [] as Uint8Array[] } : { options: Uint8Array[]; } + + options: [] as Uint8Array[] +>options : Uint8Array[] +>[] as Uint8Array[] : Uint8Array[] +>[] : undefined[] +>Uint8Array : Uint8Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8Array +>options.find : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): Uint8Array; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): Uint8Array; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): Uint8Array; } +>options : Uint8Array[] +>find : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): Uint8Array; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): Uint8Array; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): Uint8Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): number; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): number; } +>options : Uint8Array[] +>findIndex : { (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean): number; (predicate: (this: undefined, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8Array, index: number, obj: Uint8Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void): void; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: Z): void; } +>options : Uint8Array[] +>forEach : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void): void; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint8Array[] +>options.map : { (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): U[]; } +>options : Uint8Array[] +>map : { (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8Array, Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint8Array, Uint8Array], callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => Uint8Array +>val : Uint8Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + return this.options[index]; +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint8Array[] +>some : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8Array[] +>options.filter : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any): Uint8Array[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: undefined): Uint8Array[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: Z): Uint8Array[]; } +>options : Uint8Array[] +>filter : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any): Uint8Array[]; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: undefined): Uint8Array[]; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => any, thisArg: Z): Uint8Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint8Array[] +>every : { (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8Array, index: number, array: Uint8Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8Array[]; }, val: Uint8Array, index: number) => boolean +>val : Uint8Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8Array +>this.options[index] : Uint8Array +>this.options : Uint8Array[] +>this : { options: Uint8Array[]; } +>options : Uint8Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8Array[]; } + } + + test4(options: Float32Array[]) { +>test4 : (options: Float32Array[]) => void +>options : Float32Array[] +>Float32Array : Float32Array + + const thisObject = { +>thisObject : { options: Float32Array[]; } +>{ options: [] as Float32Array[] } : { options: Float32Array[]; } + + options: [] as Float32Array[] +>options : Float32Array[] +>[] as Float32Array[] : Float32Array[] +>[] : undefined[] +>Float32Array : Float32Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Float32Array +>options.find : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): Float32Array; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): Float32Array; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): Float32Array; } +>options : Float32Array[] +>find : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): Float32Array; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): Float32Array; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): Float32Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): number; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): number; } +>options : Float32Array[] +>findIndex : { (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean): number; (predicate: (this: undefined, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float32Array, index: number, obj: Float32Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void): void; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: Z): void; } +>options : Float32Array[] +>forEach : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void): void; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Float32Array[] +>options.map : { (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): U[]; } +>options : Float32Array[] +>map : { (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float32Array, Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): [U, U]; (this: [Float32Array, Float32Array], callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => Float32Array +>val : Float32Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + return this.options[index]; +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>options : Float32Array[] +>some : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Float32Array[] +>options.filter : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any): Float32Array[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: undefined): Float32Array[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: Z): Float32Array[]; } +>options : Float32Array[] +>filter : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any): Float32Array[]; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: undefined): Float32Array[]; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => any, thisArg: Z): Float32Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>options : Float32Array[] +>every : { (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float32Array, index: number, array: Float32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float32Array[]; }, val: Float32Array, index: number) => boolean +>val : Float32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float32Array +>this.options[index] : Float32Array +>this.options : Float32Array[] +>this : { options: Float32Array[]; } +>options : Float32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float32Array[]; } + } + + test5(options: Uint8ClampedArray[]) { +>test5 : (options: Uint8ClampedArray[]) => void +>options : Uint8ClampedArray[] +>Uint8ClampedArray : Uint8ClampedArray + + const thisObject = { +>thisObject : { options: Uint8ClampedArray[]; } +>{ options: [] as Uint8ClampedArray[] } : { options: Uint8ClampedArray[]; } + + options: [] as Uint8ClampedArray[] +>options : Uint8ClampedArray[] +>[] as Uint8ClampedArray[] : Uint8ClampedArray[] +>[] : undefined[] +>Uint8ClampedArray : Uint8ClampedArray + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8ClampedArray +>options.find : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): Uint8ClampedArray; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): Uint8ClampedArray; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): Uint8ClampedArray; } +>options : Uint8ClampedArray[] +>find : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): Uint8ClampedArray; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): Uint8ClampedArray; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): Uint8ClampedArray; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): number; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): number; } +>options : Uint8ClampedArray[] +>findIndex : { (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean): number; (predicate: (this: undefined, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint8ClampedArray, index: number, obj: Uint8ClampedArray[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void): void; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: Z): void; } +>options : Uint8ClampedArray[] +>forEach : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void): void; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint8ClampedArray[] +>options.map : { (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): U[]; } +>options : Uint8ClampedArray[] +>map : { (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): [U, U]; (this: [Uint8ClampedArray, Uint8ClampedArray], callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U): U[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => Uint8ClampedArray +>val : Uint8ClampedArray +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + return this.options[index]; +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>options : Uint8ClampedArray[] +>some : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint8ClampedArray[] +>options.filter : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any): Uint8ClampedArray[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: undefined): Uint8ClampedArray[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: Z): Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>filter : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any): Uint8ClampedArray[]; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: undefined): Uint8ClampedArray[]; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => any, thisArg: Z): Uint8ClampedArray[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>options : Uint8ClampedArray[] +>every : { (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint8ClampedArray, index: number, array: Uint8ClampedArray[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint8ClampedArray[]; }, val: Uint8ClampedArray, index: number) => boolean +>val : Uint8ClampedArray +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint8ClampedArray +>this.options[index] : Uint8ClampedArray +>this.options : Uint8ClampedArray[] +>this : { options: Uint8ClampedArray[]; } +>options : Uint8ClampedArray[] +>index : number + + }, thisObject); +>thisObject : { options: Uint8ClampedArray[]; } + } + + test6(options: Int16Array[]) { +>test6 : (options: Int16Array[]) => void +>options : Int16Array[] +>Int16Array : Int16Array + + const thisObject = { +>thisObject : { options: Int16Array[]; } +>{ options: [] as Int16Array[] } : { options: Int16Array[]; } + + options: [] as Int16Array[] +>options : Int16Array[] +>[] as Int16Array[] : Int16Array[] +>[] : undefined[] +>Int16Array : Int16Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Int16Array +>options.find : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): Int16Array; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): Int16Array; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): Int16Array; } +>options : Int16Array[] +>find : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): Int16Array; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): Int16Array; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): Int16Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): number; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): number; } +>options : Int16Array[] +>findIndex : { (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean): number; (predicate: (this: undefined, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Int16Array, index: number, obj: Int16Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void): void; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: Z): void; } +>options : Int16Array[] +>forEach : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void): void; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Int16Array[] +>options.map : { (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): U[]; } +>options : Int16Array[] +>map : { (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Int16Array, Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): [U, U]; (this: [Int16Array, Int16Array], callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => Int16Array +>val : Int16Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + return this.options[index]; +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>options : Int16Array[] +>some : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Int16Array[] +>options.filter : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any): Int16Array[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: undefined): Int16Array[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: Z): Int16Array[]; } +>options : Int16Array[] +>filter : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any): Int16Array[]; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: undefined): Int16Array[]; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => any, thisArg: Z): Int16Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>options : Int16Array[] +>every : { (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Int16Array, index: number, array: Int16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Int16Array[]; }, val: Int16Array, index: number) => boolean +>val : Int16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Int16Array +>this.options[index] : Int16Array +>this.options : Int16Array[] +>this : { options: Int16Array[]; } +>options : Int16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Int16Array[]; } + } + + test7(options: Uint16Array[]) { +>test7 : (options: Uint16Array[]) => void +>options : Uint16Array[] +>Uint16Array : Uint16Array + + const thisObject = { +>thisObject : { options: Uint16Array[]; } +>{ options: [] as Uint16Array[] } : { options: Uint16Array[]; } + + options: [] as Uint16Array[] +>options : Uint16Array[] +>[] as Uint16Array[] : Uint16Array[] +>[] : undefined[] +>Uint16Array : Uint16Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint16Array +>options.find : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): Uint16Array; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): Uint16Array; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): Uint16Array; } +>options : Uint16Array[] +>find : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): Uint16Array; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): Uint16Array; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): Uint16Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): number; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): number; } +>options : Uint16Array[] +>findIndex : { (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean): number; (predicate: (this: undefined, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint16Array, index: number, obj: Uint16Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void): void; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: Z): void; } +>options : Uint16Array[] +>forEach : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void): void; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint16Array[] +>options.map : { (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): U[]; } +>options : Uint16Array[] +>map : { (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint16Array, Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint16Array, Uint16Array], callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => Uint16Array +>val : Uint16Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + return this.options[index]; +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint16Array[] +>some : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint16Array[] +>options.filter : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any): Uint16Array[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: undefined): Uint16Array[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: Z): Uint16Array[]; } +>options : Uint16Array[] +>filter : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any): Uint16Array[]; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: undefined): Uint16Array[]; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => any, thisArg: Z): Uint16Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint16Array[] +>every : { (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint16Array, index: number, array: Uint16Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint16Array[]; }, val: Uint16Array, index: number) => boolean +>val : Uint16Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint16Array +>this.options[index] : Uint16Array +>this.options : Uint16Array[] +>this : { options: Uint16Array[]; } +>options : Uint16Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint16Array[]; } + } + + test8(options: Uint32Array[]) { +>test8 : (options: Uint32Array[]) => void +>options : Uint32Array[] +>Uint32Array : Uint32Array + + const thisObject = { +>thisObject : { options: Uint32Array[]; } +>{ options: [] as Uint32Array[] } : { options: Uint32Array[]; } + + options: [] as Uint32Array[] +>options : Uint32Array[] +>[] as Uint32Array[] : Uint32Array[] +>[] : undefined[] +>Uint32Array : Uint32Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Uint32Array +>options.find : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): Uint32Array; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): Uint32Array; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): Uint32Array; } +>options : Uint32Array[] +>find : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): Uint32Array; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): Uint32Array; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): Uint32Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): number; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): number; } +>options : Uint32Array[] +>findIndex : { (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean): number; (predicate: (this: undefined, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Uint32Array, index: number, obj: Uint32Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void): void; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: Z): void; } +>options : Uint32Array[] +>forEach : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void): void; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Uint32Array[] +>options.map : { (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): U[]; } +>options : Uint32Array[] +>map : { (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Uint32Array, Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): [U, U]; (this: [Uint32Array, Uint32Array], callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U): U[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => Uint32Array +>val : Uint32Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + return this.options[index]; +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint32Array[] +>some : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Uint32Array[] +>options.filter : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any): Uint32Array[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: undefined): Uint32Array[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: Z): Uint32Array[]; } +>options : Uint32Array[] +>filter : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any): Uint32Array[]; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: undefined): Uint32Array[]; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => any, thisArg: Z): Uint32Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>options : Uint32Array[] +>every : { (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Uint32Array, index: number, array: Uint32Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Uint32Array[]; }, val: Uint32Array, index: number) => boolean +>val : Uint32Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Uint32Array +>this.options[index] : Uint32Array +>this.options : Uint32Array[] +>this : { options: Uint32Array[]; } +>options : Uint32Array[] +>index : number + + }, thisObject); +>thisObject : { options: Uint32Array[]; } + } + + test9(options: Float64Array[]) { +>test9 : (options: Float64Array[]) => void +>options : Float64Array[] +>Float64Array : Float64Array + + const thisObject = { +>thisObject : { options: Float64Array[]; } +>{ options: [] as Float64Array[] } : { options: Float64Array[]; } + + options: [] as Float64Array[] +>options : Float64Array[] +>[] as Float64Array[] : Float64Array[] +>[] : undefined[] +>Float64Array : Float64Array + + }; + + options.find(function (val, index) { +>options.find(function (val, index) { return val === this.options[index]; }, thisObject) : Float64Array +>options.find : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): Float64Array; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): Float64Array; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): Float64Array; } +>options : Float64Array[] +>find : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): Float64Array; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): Float64Array; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): Float64Array; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.findIndex(function (val, index) { +>options.findIndex(function (val, index) { return val === this.options[index]; }, thisObject) : number +>options.findIndex : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): number; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): number; } +>options : Float64Array[] +>findIndex : { (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean): number; (predicate: (this: undefined, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: undefined): number; (predicate: (this: Z, value: Float64Array, index: number, obj: Float64Array[]) => boolean, thisArg: Z): number; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.forEach(function (val, index) { +>options.forEach(function (val, index) { return val === this.options[index]; }, thisObject) : void +>options.forEach : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void): void; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: Z): void; } +>options : Float64Array[] +>forEach : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void): void; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => void, thisArg: Z): void; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.map(function (val, index) { +>options.map(function (val, index) { if (val === this.options[index]) return this.options[index]; }, thisObject) : Float64Array[] +>options.map : { (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): U[]; } +>options : Float64Array[] +>map : { (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U, U]; (this: [Float64Array, Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): [U, U]; (this: [Float64Array, Float64Array], callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U): U[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => U, thisArg: Z): U[]; } +>function (val, index) { if (val === this.options[index]) return this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => Float64Array +>val : Float64Array +>index : number + + if (val === this.options[index]) +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + return this.options[index]; +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.some(function (val, index) { +>options.some(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.some : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>options : Float64Array[] +>some : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.filter(function (val, index) { +>options.filter(function (val, index) { return val === this.options[index]; }, thisObject) : Float64Array[] +>options.filter : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any): Float64Array[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: undefined): Float64Array[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: Z): Float64Array[]; } +>options : Float64Array[] +>filter : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any): Float64Array[]; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: undefined): Float64Array[]; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => any, thisArg: Z): Float64Array[]; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + + options.every(function (val, index) { +>options.every(function (val, index) { return val === this.options[index]; }, thisObject) : boolean +>options.every : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>options : Float64Array[] +>every : { (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean): boolean; (callbackfn: (this: undefined, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Float64Array, index: number, array: Float64Array[]) => boolean, thisArg: Z): boolean; } +>function (val, index) { return val === this.options[index]; } : (this: { options: Float64Array[]; }, val: Float64Array, index: number) => boolean +>val : Float64Array +>index : number + + return val === this.options[index]; +>val === this.options[index] : boolean +>val : Float64Array +>this.options[index] : Float64Array +>this.options : Float64Array[] +>this : { options: Float64Array[]; } +>options : Float64Array[] +>index : number + + }, thisObject); +>thisObject : { options: Float64Array[]; } + } +} + diff --git a/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts b/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts new file mode 100644 index 00000000000..17ff41c70a7 --- /dev/null +++ b/tests/cases/compiler/thisTypeInNativeThisAssignableMethods.ts @@ -0,0 +1,398 @@ +// @target: ES2017 + +class A { + options: string[]; + + addOptions(options: string[]) { + if (!this.options) { + this.options = []; + } + options.forEach(function (item) { + this.options.push(item); + }, this); + return this; + } + + testUndefined(options: string[]) { + const undefinedArr: Array = [] + options.forEach(function () { + undefinedArr.push(this); + }); // case1 + options.forEach(function () { + undefinedArr.push(this); + }, undefined); // case2 + options.forEach(function () { + undefinedArr.push(this); + }, null); // case3 + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this === undefined ? 2 : 1; + }, undefined) + } + + test(options: string[]) { + const thisObject = { + options: [] as string[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + + const arrLike = {} as ArrayLike + Array.from(arrLike, function (item) { + return this.options[item].length + }, thisObject) + + const iterLike = [] as Iterable + Array.from(iterLike, function (item) { + return this.options[item].length + }, thisObject) + } + + test1(options: string[]) { + const thisObject = { + options: [] as ReadonlyArray + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test2(options: Int8Array[]) { + const thisObject = { + options: [] as Int8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test3(options: Uint8Array[]) { + const thisObject = { + options: [] as Uint8Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test4(options: Float32Array[]) { + const thisObject = { + options: [] as Float32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test5(options: Uint8ClampedArray[]) { + const thisObject = { + options: [] as Uint8ClampedArray[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test6(options: Int16Array[]) { + const thisObject = { + options: [] as Int16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test7(options: Uint16Array[]) { + const thisObject = { + options: [] as Uint16Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test8(options: Uint32Array[]) { + const thisObject = { + options: [] as Uint32Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } + + test9(options: Float64Array[]) { + const thisObject = { + options: [] as Float64Array[] + }; + + options.find(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.findIndex(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.forEach(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.map(function (val, index) { + if (val === this.options[index]) + return this.options[index]; + }, thisObject); + + options.some(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.filter(function (val, index) { + return val === this.options[index]; + }, thisObject); + + options.every(function (val, index) { + return val === this.options[index]; + }, thisObject); + } +} From 5f5aa208162a9182bd770b60cebcfc5c3892e058 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Wed, 11 Jan 2017 09:23:27 +0800 Subject: [PATCH 046/207] test: adjust test case `completionEntryForUnionMethod` --- tests/cases/fourslash/completionEntryForUnionMethod.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/completionEntryForUnionMethod.ts b/tests/cases/fourslash/completionEntryForUnionMethod.ts index dd0e034cd2d..2dc80e757b2 100644 --- a/tests/cases/fourslash/completionEntryForUnionMethod.ts +++ b/tests/cases/fourslash/completionEntryForUnionMethod.ts @@ -5,7 +5,7 @@ goTo.marker(); verify.quickInfoIs( - "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U];\n (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U];\n (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U];\n (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U];\n (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[];\n}", + "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U];\n (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U];\n (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U];\n (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U];\n (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[];\n}", "Calls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results.\nCalls a defined callback function on each element of an array, and returns an array that contains the results."); -verify.completionListContains('map', "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U];\n (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U];\n (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U];\n (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U];\n (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U];\n (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[];\n}"); +verify.completionListContains('map', "(property) map: {\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U];\n (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U];\n (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U];\n (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U];\n (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[];\n (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[];\n} | {\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U];\n (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U];\n (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U];\n (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U];\n (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U];\n (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U];\n (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[];\n (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[];\n (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[];\n}"); From e9f82145b781f68aa243fb078b8c898552759798 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Mar 2017 23:03:47 -0800 Subject: [PATCH 047/207] Code review comments --- src/compiler/parser.ts | 4 ++-- src/compiler/program.ts | 2 +- tests/baselines/reference/checkJsFiles2.errors.txt | 2 +- tests/baselines/reference/checkJsFiles3.errors.txt | 2 +- tests/baselines/reference/checkJsFiles4.errors.txt | 2 +- tests/baselines/reference/checkJsFiles5.symbols | 2 +- tests/baselines/reference/checkJsFiles5.types | 2 +- tests/cases/compiler/checkJsFiles2.ts | 2 +- tests/cases/compiler/checkJsFiles3.ts | 2 +- tests/cases/compiler/checkJsFiles4.ts | 2 +- tests/cases/compiler/checkJsFiles5.ts | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ef23ee175fd..faff1069594 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5880,11 +5880,11 @@ namespace ts { } } - const checkJsDirectiveRegEx = /^\/\/\/?\s*@check(\s+(true|false))?/gim; + const checkJsDirectiveRegEx = /^\/\/\/?\s*(@ts-check|@ts-nocheck)\s*$/gim; const checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); if (checkJsDirectiveMatchResult) { checkJsDirective = { - enabled: compareStrings(checkJsDirectiveMatchResult[2], "false", /*ignoreCase*/ true) !== Comparison.EqualTo, + enabled: compareStrings(checkJsDirectiveMatchResult[1], "@ts-check", /*ignoreCase*/ true) === Comparison.EqualTo, end: range.end, pos: range.pos }; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f524a549859..d46c3b2479f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -904,7 +904,7 @@ namespace ts { Debug.assert(!!sourceFile.bindDiagnostics); const bindDiagnostics = sourceFile.bindDiagnostics; - // For JavaScript files, we don't want to report semantic errors unless ecplicitlly requested. + // For JavaScript files, we don't want to report semantic errors unless explicitly requested. const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || (sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : options.checkJs); const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; diff --git a/tests/baselines/reference/checkJsFiles2.errors.txt b/tests/baselines/reference/checkJsFiles2.errors.txt index 5c1a211a646..7fc852fba14 100644 --- a/tests/baselines/reference/checkJsFiles2.errors.txt +++ b/tests/baselines/reference/checkJsFiles2.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type ==== tests/cases/compiler/a.js (1 errors) ==== - // @check + // @ts-check var x = "string"; x = 0; ~ diff --git a/tests/baselines/reference/checkJsFiles3.errors.txt b/tests/baselines/reference/checkJsFiles3.errors.txt index 5c1a211a646..7fc852fba14 100644 --- a/tests/baselines/reference/checkJsFiles3.errors.txt +++ b/tests/baselines/reference/checkJsFiles3.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type ==== tests/cases/compiler/a.js (1 errors) ==== - // @check + // @ts-check var x = "string"; x = 0; ~ diff --git a/tests/baselines/reference/checkJsFiles4.errors.txt b/tests/baselines/reference/checkJsFiles4.errors.txt index 87eb0f3b7d4..7fc852fba14 100644 --- a/tests/baselines/reference/checkJsFiles4.errors.txt +++ b/tests/baselines/reference/checkJsFiles4.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/a.js(4,1): error TS2322: Type '0' is not assignable to type ==== tests/cases/compiler/a.js (1 errors) ==== - // @check true + // @ts-check var x = "string"; x = 0; ~ diff --git a/tests/baselines/reference/checkJsFiles5.symbols b/tests/baselines/reference/checkJsFiles5.symbols index cdb53964aa5..76cc21c46a6 100644 --- a/tests/baselines/reference/checkJsFiles5.symbols +++ b/tests/baselines/reference/checkJsFiles5.symbols @@ -1,6 +1,6 @@ === tests/cases/compiler/a.js === -// @check false +// @ts-nocheck var x = "string"; >x : Symbol(x, Decl(a.js, 2, 3)) diff --git a/tests/baselines/reference/checkJsFiles5.types b/tests/baselines/reference/checkJsFiles5.types index bd1ab8d942c..15704315bbe 100644 --- a/tests/baselines/reference/checkJsFiles5.types +++ b/tests/baselines/reference/checkJsFiles5.types @@ -1,6 +1,6 @@ === tests/cases/compiler/a.js === -// @check false +// @ts-nocheck var x = "string"; >x : string >"string" : "string" diff --git a/tests/cases/compiler/checkJsFiles2.ts b/tests/cases/compiler/checkJsFiles2.ts index 36bc2cbd255..2e4d4396e46 100644 --- a/tests/cases/compiler/checkJsFiles2.ts +++ b/tests/cases/compiler/checkJsFiles2.ts @@ -3,6 +3,6 @@ // @noEmit: true // @fileName: a.js -// @check +// @ts-check var x = "string"; x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles3.ts b/tests/cases/compiler/checkJsFiles3.ts index a0a9a152fee..885bf1979f5 100644 --- a/tests/cases/compiler/checkJsFiles3.ts +++ b/tests/cases/compiler/checkJsFiles3.ts @@ -2,6 +2,6 @@ // @noEmit: true // @fileName: a.js -// @check +// @ts-check var x = "string"; x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles4.ts b/tests/cases/compiler/checkJsFiles4.ts index 8bebedf55e7..2e4d4396e46 100644 --- a/tests/cases/compiler/checkJsFiles4.ts +++ b/tests/cases/compiler/checkJsFiles4.ts @@ -3,6 +3,6 @@ // @noEmit: true // @fileName: a.js -// @check true +// @ts-check var x = "string"; x = 0; \ No newline at end of file diff --git a/tests/cases/compiler/checkJsFiles5.ts b/tests/cases/compiler/checkJsFiles5.ts index c28114f570b..10f59aed172 100644 --- a/tests/cases/compiler/checkJsFiles5.ts +++ b/tests/cases/compiler/checkJsFiles5.ts @@ -3,6 +3,6 @@ // @noEmit: true // @fileName: a.js -// @check false +// @ts-nocheck var x = "string"; x = 0; \ No newline at end of file From a202fa4c888b55368d3ecd506ba0594cf84577b0 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 8 Mar 2017 23:08:55 -0800 Subject: [PATCH 048/207] add es6 to buildProtocol --- Jakefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 4512aa23794..4a31c8da179 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -422,7 +422,7 @@ compileFile(buildProtocolJs, [buildProtocolTs], [], /*useBuiltCompiler*/ false, - {noOutFile: true}); + { noOutFile: true, lib: "es6" }); file(buildProtocolDts, [buildProtocolTs, buildProtocolJs, typescriptServicesDts], function() { From fe7719f0a9747214046eb1dc8bbf5047b2fc90d3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Mar 2017 23:03:47 -0800 Subject: [PATCH 049/207] Disable check diagnostics per line --- src/compiler/program.ts | 29 +++++++++++- .../checkJsFiles_skipDiagnostics.symbols | 38 +++++++++++++++ .../checkJsFiles_skipDiagnostics.types | 47 +++++++++++++++++++ .../compiler/checkJsFiles_skipDiagnostics.ts | 33 +++++++++++++ 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols create mode 100644 tests/baselines/reference/checkJsFiles_skipDiagnostics.types create mode 100644 tests/cases/compiler/checkJsFiles_skipDiagnostics.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 67e9f62fe2d..bdc8f76cf60 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4,6 +4,7 @@ namespace ts { const emptyArray: any[] = []; + const suppressDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-suppress)?)/; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string { while (true) { @@ -923,10 +924,36 @@ namespace ts { const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + const diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + return isSourceFileJavaScript(sourceFile) + ? filter(diagnostics, shouldReportDiagnostic) + : diagnostics; }); } + /** + * Skip errors if previous line start with '// @ts-suppress' comment, not counting non-empty non-comment lines + */ + function shouldReportDiagnostic(diagnostic: Diagnostic) { + const { file, start } = diagnostic; + const lineStarts = getLineStarts(file); + let { line } = computeLineAndCharacterOfPosition(lineStarts, start); + while (line > 0) { + const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); + const result = suppressDiagnosticCommentRegEx.exec(previousLineText); + if (!result) { + // non-empty line + return true; + } + if (result[3]) { + // @ts-suppress + return false; + } + line--; + } + return true; + } + function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] { return runWithCancellationToken(() => { const diagnostics: Diagnostic[] = []; diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols new file mode 100644 index 00000000000..a0f2200048f --- /dev/null +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/a.js === + +var x = 0; +>x : Symbol(x, Decl(a.js, 1, 3)) + + +/// @ts-suppress +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + +/// @ts-suppress +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + +/// @ts-suppress +x( +>x : Symbol(x, Decl(a.js, 1, 3)) + + 2, + 3); + + + +// @ts-suppress +// come comment +// some other comment + +// @anohter + +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + + + +// @ts-suppress: no call signature +x(); +>x : Symbol(x, Decl(a.js, 1, 3)) + diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types new file mode 100644 index 00000000000..69105a3112a --- /dev/null +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/a.js === + +var x = 0; +>x : number +>0 : 0 + + +/// @ts-suppress +x(); +>x() : any +>x : number + +/// @ts-suppress +x(); +>x() : any +>x : number + +/// @ts-suppress +x( +>x( 2, 3) : any +>x : number + + 2, +>2 : 2 + + 3); +>3 : 3 + + + +// @ts-suppress +// come comment +// some other comment + +// @anohter + +x(); +>x() : any +>x : number + + + +// @ts-suppress: no call signature +x(); +>x() : any +>x : number + diff --git a/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts new file mode 100644 index 00000000000..bcbcc815e7c --- /dev/null +++ b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts @@ -0,0 +1,33 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @fileName: a.js +var x = 0; + + +/// @ts-suppress +x(); + +/// @ts-suppress +x(); + +/// @ts-suppress +x( + 2, + 3); + + + +// @ts-suppress +// come comment +// some other comment + +// @anohter + +x(); + + + +// @ts-suppress: no call signature +x(); \ No newline at end of file From 706acdf13834bfd479b63aced65e157033353c42 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Mar 2017 13:40:15 -0800 Subject: [PATCH 050/207] Add quick fix to disable error checking in a .js file --- src/compiler/diagnosticMessages.json | 10 +++ .../codefixes/disableJsDiagnostics.ts | 67 +++++++++++++++++++ src/services/codefixes/fixes.ts | 1 + .../codefixes/unusedIdentifierFixes.ts | 12 +--- src/services/tsconfig.json | 3 +- src/services/utilities.ts | 7 ++ .../codeFixDisableJsDiagnosticsInFile.ts | 11 +++ .../codeFixDisableJsDiagnosticsInFile2.ts | 15 +++++ .../codeFixDisableJsDiagnosticsInFile3.ts | 14 ++++ .../codeFixDisableJsDiagnosticsInFile4.ts | 18 +++++ .../codeFixDisableJsDiagnosticsInFile5.ts | 17 +++++ .../codeFixDisableJsDiagnosticsInFile6.ts | 17 +++++ .../codeFixDisableJsDiagnosticsInFile7.ts | 17 +++++ .../codeFixDisableJsDiagnosticsInFile8.ts | 19 ++++++ 14 files changed, 218 insertions(+), 10 deletions(-) create mode 100644 src/services/codefixes/disableJsDiagnostics.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile2.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts create mode 100644 tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 83b4cb961a4..6495f6d9ac4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3355,6 +3355,16 @@ "category": "Message", "code": 90017 }, + "Disable checking for this file.": { + "category": "Message", + "code": 90018 + }, + "Suppress this error message.": { + "category": "Message", + "code": 90019 + }, + + "Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": { "category": "Error", "code": 8017 diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts new file mode 100644 index 00000000000..6e4a5f38586 --- /dev/null +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -0,0 +1,67 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: getApplicableDiagnosticCodes(), + getCodeActions: getDisableJsDiagnosticsCodeActions + }); + + function getApplicableDiagnosticCodes(): number[] { + const allDiagnostcs = >Diagnostics; + return Object.keys(allDiagnostcs) + .filter(d => allDiagnostcs[d] && allDiagnostcs[d].category === DiagnosticCategory.Error) + .map(d => allDiagnostcs[d].code); + } + + function shouldCheckJsFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } + + function getSuppressCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) { + let { line } = getLineAndCharacterOfPosition(sourceFile, position); + const lineStartPosition = getStartPositionOfLine(line, sourceFile); + const startPosition = getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); + if (!isInComment(sourceFile, startPosition) && !isInString(sourceFile, startPosition) && !isInTemplateString(sourceFile, startPosition)) { + const token = getTouchingToken(sourceFile, startPosition); + const tokenLeadingCommnets = getLeadingCommentRangesOfNode(token, sourceFile) + if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { + return { + span: { start: startPosition, length: 0 }, + newText: `// @ts-suppress${newLineCharacter}` + }; + } + } + return { + span: { start: position, length: 0 }, + newText: `${position === startPosition ? "" : newLineCharacter}// @ts-suppress${newLineCharacter}` + }; + } + + function getDisableJsDiagnosticsCodeActions(context: CodeFixContext): CodeAction[] | undefined { + const { sourceFile, program, newLineCharacter, span } = context; + + if (!isInJavaScriptFile(sourceFile) || !shouldCheckJsFile(sourceFile, program.getCompilerOptions())) { + return undefined; + } + + return [{ + description: getLocaleSpecificMessage(Diagnostics.Suppress_this_error_message), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [getSuppressCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] + }] + }, + { + description: getLocaleSpecificMessage(Diagnostics.Disable_checking_for_this_file), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { + start: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.pos : 0, + length: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.end - sourceFile.checkJsDirective.pos : 0 + }, + newText: `// @ts-nocheck${newLineCharacter}` + }] + }] + }]; + } +} \ No newline at end of file diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index 76be34c67cd..ae1643dfa3b 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -7,4 +7,5 @@ /// /// /// +/// /// diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 61d48bdc3bc..6c8bd0a9dbe 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -105,9 +105,10 @@ namespace ts.codefix { else { // import |d,| * as ns from './file' const start = importClause.name.getStart(); - let end = findFirstNonSpaceCharPosStarting(importClause.name.end); + const text = sourceFile.text; + let end = getFirstNonSpaceCharacterPosition(text, importClause.name.end); if (sourceFile.text.charCodeAt(end) === CharacterCodes.comma) { - end = findFirstNonSpaceCharPosStarting(end + 1); + end = getFirstNonSpaceCharacterPosition(text, end + 1); } return createCodeFix("", start, end - start); @@ -166,13 +167,6 @@ namespace ts.codefix { return createCodeFix("", start, end - start); } - function findFirstNonSpaceCharPosStarting(start: number) { - while (isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; - } - function createCodeFix(newText: string, start: number, length: number): CodeAction[] { return [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 93f861e80aa..b97b3c509f8 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -90,6 +90,7 @@ "codefixes/fixes.ts", "codefixes/helpers.ts", "codefixes/importFixes.ts", - "codefixes/unusedIdentifierFixes.ts" + "codefixes/unusedIdentifierFixes.ts", + "codefixes/disableJsDiagnostics.ts" ] } \ No newline at end of file diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 7c5bf862fc8..c894df121f8 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1388,4 +1388,11 @@ namespace ts { // First token is the open curly, this is where we want to put the 'super' call. return constructor.body.getFirstToken(sourceFile).getEnd(); } + + export function getFirstNonSpaceCharacterPosition(text: string, position: number) { + while (isWhiteSpace(text.charCodeAt(position))) { + position += 1; + } + return position; + } } diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts new file mode 100644 index 00000000000..070712c2523 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile.ts @@ -0,0 +1,11 @@ +/// + +// @allowjs: true +// @noEmit: true + +// @Filename: a.js +////[|// @ts-check|] +////var x = ""; +////x = 1; + +verify.rangeAfterCodeFix("// @ts-nocheck", /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile2.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile2.ts new file mode 100644 index 00000000000..4a55f2ba44f --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile2.ts @@ -0,0 +1,15 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////[|var x = ""; +////x = 1;|] + +// Disable checking for the whole file +verify.rangeAfterCodeFix(`// @ts-nocheck +var x = ""; +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts new file mode 100644 index 00000000000..f486a7e171b --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts @@ -0,0 +1,14 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////[|var x = ""; +////x = 1;|] + +// Disable checking for next line +verify.rangeAfterCodeFix(`var x = ""; +// @ts-suppress +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts new file mode 100644 index 00000000000..cadbda2c273 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts @@ -0,0 +1,18 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = ""; +//// +////[|"test \ +////"; x = 1;|] + +// Disable checking for next line +verify.rangeAfterCodeFix(`"test \\ +"; +// @ts-suppress +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts new file mode 100644 index 00000000000..56b9fbf20d9 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts @@ -0,0 +1,17 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = ""; +//// +////[|/** comment */ +////x = 1;|] + +// Disable checking for next line +verify.rangeAfterCodeFix(`/** comment */ +// @ts-suppress +x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts new file mode 100644 index 00000000000..a0497b4deb9 --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts @@ -0,0 +1,17 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = 0; +//// +////function f(_a) { +//// [|f(x());|] +////} + +// Disable checking for next line +verify.rangeAfterCodeFix(`// @ts-suppress + f(x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts new file mode 100644 index 00000000000..ad8377e129d --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts @@ -0,0 +1,17 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = 0; +//// +////function f(_a) { +//// [|x();|] +////} + +// Disable checking for next line +verify.rangeAfterCodeFix(`// @ts-suppress + x();`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts new file mode 100644 index 00000000000..8ec350479af --- /dev/null +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts @@ -0,0 +1,19 @@ +/// + +// @allowjs: true +// @noEmit: true +// @checkJs: true + +// @Filename: a.js +////var x = 0; +//// +////function f(_a) { +//// /** comment for f */ +//// [|f(x());|] +////} + +// Disable checking for next line +verify.rangeAfterCodeFix(`f( + // @ts-suppress + x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); + From 13e80b955875248a0a55b5f1926cf1defaaa53e5 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 7 Mar 2017 13:40:15 -0800 Subject: [PATCH 051/207] Fix building webTestServer --- Jakefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 595875dfc32..5779d75022f 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -945,7 +945,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () { // Browser tests var nodeServerOutFile = "tests/webTestServer.js"; var nodeServerInFile = "tests/webTestServer.ts"; -compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true }); +compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true, lib: "es6" }); desc("Runs browserify on run.js to produce a file suitable for running tests in the browser"); task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() { From 936a91d27118c4b836f7549668976bbfe7050be8 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 9 Mar 2017 16:12:58 -0800 Subject: [PATCH 052/207] Add comment --- src/services/codefixes/disableJsDiagnostics.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts index 6e4a5f38586..c18c0153a03 100644 --- a/src/services/codefixes/disableJsDiagnostics.ts +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -20,9 +20,14 @@ namespace ts.codefix { let { line } = getLineAndCharacterOfPosition(sourceFile, position); const lineStartPosition = getStartPositionOfLine(line, sourceFile); const startPosition = getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); + + // First try to see if we can put the '// @ts-suppress' on the previous line. + // We need to make sure that we are not in the middle of a string literal or a comment. + // We also want to check if the previous line holds a comment for a node on the next line + // if so, we do not want to separate the node from its comment if we can. if (!isInComment(sourceFile, startPosition) && !isInString(sourceFile, startPosition) && !isInTemplateString(sourceFile, startPosition)) { const token = getTouchingToken(sourceFile, startPosition); - const tokenLeadingCommnets = getLeadingCommentRangesOfNode(token, sourceFile) + const tokenLeadingCommnets = getLeadingCommentRangesOfNode(token, sourceFile); if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { return { span: { start: startPosition, length: 0 }, @@ -30,6 +35,8 @@ namespace ts.codefix { }; } } + + // If all fails, add an extra new line immediatlly before the error span. return { span: { start: position, length: 0 }, newText: `${position === startPosition ? "" : newLineCharacter}// @ts-suppress${newLineCharacter}` From 09fcf5b0cee4073404ce684b14b24040d98a01b3 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Tue, 24 Jan 2017 19:31:11 +0800 Subject: [PATCH 053/207] test(baseline): update references affected --- tests/baselines/reference/2dArrays.symbols | 4 +- tests/baselines/reference/2dArrays.types | 6 +- .../anyInferenceAnonymousFunctions.symbols | 8 +- .../anyInferenceAnonymousFunctions.types | 12 +- .../reference/argumentsAsPropertyName.symbols | 4 +- .../reference/argumentsAsPropertyName.types | 6 +- .../reference/arrayConcatMap.symbols | 4 +- .../baselines/reference/arrayConcatMap.types | 6 +- tests/baselines/reference/arrayFilter.symbols | 4 +- tests/baselines/reference/arrayFilter.types | 6 +- .../reference/bestChoiceType.symbols | 12 +- .../baselines/reference/bestChoiceType.types | 18 +-- ...kSwitchStatementIfCaseTypeIsString.symbols | 4 +- ...eckSwitchStatementIfCaseTypeIsString.types | 6 +- ...assExpressionWithStaticProperties3.symbols | 4 +- ...classExpressionWithStaticProperties3.types | 6 +- ...ExpressionWithStaticPropertiesES63.symbols | 4 +- ...ssExpressionWithStaticPropertiesES63.types | 6 +- ...mmaOperatorInConditionalExpression.symbols | 4 +- ...commaOperatorInConditionalExpression.types | 6 +- .../reference/commentInMethodCall.symbols | 4 +- .../reference/commentInMethodCall.types | 6 +- .../contextualSignatureInstantiation3.symbols | 12 +- .../contextualSignatureInstantiation3.types | 12 +- .../reference/contextuallyTypedIife.symbols | 16 +- .../reference/contextuallyTypedIife.types | 24 +-- .../contextuallyTypedIifeStrict.symbols | 16 +- .../contextuallyTypedIifeStrict.types | 24 +-- ...controlFlowDestructuringParameters.symbols | 4 +- .../controlFlowDestructuringParameters.types | 6 +- .../reference/declarationEmitPromise.symbols | 8 +- .../reference/declarationEmitPromise.types | 12 +- tests/baselines/reference/enumIndexer.symbols | 4 +- tests/baselines/reference/enumIndexer.types | 6 +- .../baselines/reference/genericArray1.symbols | 4 +- tests/baselines/reference/genericArray1.types | 6 +- .../reference/genericInference1.symbols | 4 +- .../reference/genericInference1.types | 6 +- .../genericMethodOverspecialization.symbols | 12 +- .../genericMethodOverspecialization.types | 18 +-- .../implementArrayInterface.errors.txt | 4 +- .../reference/inferenceLimit.symbols | 4 +- .../baselines/reference/inferenceLimit.types | 4 +- ...inferentialTypingWithFunctionType2.symbols | 4 +- .../inferentialTypingWithFunctionType2.types | 4 +- .../reference/keyofAndIndexedAccess.symbols | 4 +- .../reference/keyofAndIndexedAccess.types | 6 +- .../reference/mapOnTupleTypes01.symbols | 36 ++--- .../reference/mapOnTupleTypes01.types | 54 +++---- .../reference/mapOnTupleTypes02.symbols | 4 +- .../reference/mapOnTupleTypes02.types | 6 +- ...ibrary_NoErrorDuplicateLibOptions1.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions1.types | 4 +- ...ibrary_NoErrorDuplicateLibOptions2.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions2.types | 4 +- ...larizeLibrary_TargetES5UsingES6Lib.symbols | 4 +- ...dularizeLibrary_TargetES5UsingES6Lib.types | 4 +- ...larizeLibrary_TargetES6UsingES6Lib.symbols | 4 +- ...dularizeLibrary_TargetES6UsingES6Lib.types | 4 +- ...eLibrary_UsingES5LibAndES6ArrayLib.symbols | 4 +- ...izeLibrary_UsingES5LibAndES6ArrayLib.types | 4 +- ...ibES6ArrayLibES6WellknownSymbolLib.symbols | 4 +- ...5LibES6ArrayLibES6WellknownSymbolLib.types | 4 +- tests/baselines/reference/nestedSelf.symbols | 4 +- tests/baselines/reference/nestedSelf.types | 6 +- ...nContextuallyTypesFunctionParamter.symbols | 4 +- ...yInContextuallyTypesFunctionParamter.types | 6 +- .../reference/objectRestForOf.symbols | 4 +- .../baselines/reference/objectRestForOf.types | 6 +- ...arameterReferencedInObjectLiteral1.symbols | 8 +- ...nParameterReferencedInObjectLiteral1.types | 10 +- ...alizationsShouldNotAffectEachOther.symbols | 8 +- ...cializationsShouldNotAffectEachOther.types | 10 +- .../reference/targetTypeArgs.symbols | 24 +-- .../baselines/reference/targetTypeArgs.types | 36 ++--- .../targetTypeObjectLiteralToAny.symbols | 4 +- .../targetTypeObjectLiteralToAny.types | 6 +- .../reference/tsxSpreadChildren.symbols | 4 +- .../reference/tsxSpreadChildren.types | 6 +- ...ReferencedTypeAliasToTypeLiteral01.symbols | 4 +- ...lyReferencedTypeAliasToTypeLiteral01.types | 6 +- ...ReferencedTypeAliasToTypeLiteral02.symbols | 4 +- ...lyReferencedTypeAliasToTypeLiteral02.types | 6 +- tests/baselines/reference/typedArrays.symbols | 144 +++++++++--------- tests/baselines/reference/typedArrays.types | 144 +++++++++--------- 85 files changed, 483 insertions(+), 483 deletions(-) diff --git a/tests/baselines/reference/2dArrays.symbols b/tests/baselines/reference/2dArrays.symbols index 8d6b6b167e6..6f02cdcf963 100644 --- a/tests/baselines/reference/2dArrays.symbols +++ b/tests/baselines/reference/2dArrays.symbols @@ -25,11 +25,11 @@ class Board { >allShipsSunk : Symbol(Board.allShipsSunk, Decl(2dArrays.ts, 9, 18)) return this.ships.every(function (val) { return val.isSunk; }); ->this.ships.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>this.ships.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >this.ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13)) >this : Symbol(Board, Decl(2dArrays.ts, 5, 1)) >ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >val : Symbol(val, Decl(2dArrays.ts, 12, 42)) >val.isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12)) >val : Symbol(val, Decl(2dArrays.ts, 12, 42)) diff --git a/tests/baselines/reference/2dArrays.types b/tests/baselines/reference/2dArrays.types index 00805899294..cd5ddc0efa5 100644 --- a/tests/baselines/reference/2dArrays.types +++ b/tests/baselines/reference/2dArrays.types @@ -26,12 +26,12 @@ class Board { return this.ships.every(function (val) { return val.isSunk; }); >this.ships.every(function (val) { return val.isSunk; }) : boolean ->this.ships.every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean +>this.ships.every : { (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean): boolean; (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Ship, index: number, array: Ship[]) => boolean, thisArg: Z): boolean; } >this.ships : Ship[] >this : this >ships : Ship[] ->every : (callbackfn: (value: Ship, index: number, array: Ship[]) => boolean, thisArg?: any) => boolean ->function (val) { return val.isSunk; } : (val: Ship) => boolean +>every : { (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean): boolean; (callbackfn: (this: undefined, value: Ship, index: number, array: Ship[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: Ship, index: number, array: Ship[]) => boolean, thisArg: Z): boolean; } +>function (val) { return val.isSunk; } : (this: undefined, val: Ship) => boolean >val : Ship >val.isSunk : boolean >val : Ship diff --git a/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols b/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols index ff576a36423..750c7ba85af 100644 --- a/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols +++ b/tests/baselines/reference/anyInferenceAnonymousFunctions.symbols @@ -35,16 +35,16 @@ paired.reduce((b3, b4) => b3.concat({}), []); >b3 : Symbol(b3, Decl(anyInferenceAnonymousFunctions.ts, 13, 15)) paired.map((c1) => c1.count); ->paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12)) >c1 : Symbol(c1, Decl(anyInferenceAnonymousFunctions.ts, 15, 12)) paired.map(function (c2) { return c2.count; }); ->paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>paired.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >paired : Symbol(paired, Decl(anyInferenceAnonymousFunctions.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21)) >c2 : Symbol(c2, Decl(anyInferenceAnonymousFunctions.ts, 16, 21)) diff --git a/tests/baselines/reference/anyInferenceAnonymousFunctions.types b/tests/baselines/reference/anyInferenceAnonymousFunctions.types index 1f3bb78f958..ee176215421 100644 --- a/tests/baselines/reference/anyInferenceAnonymousFunctions.types +++ b/tests/baselines/reference/anyInferenceAnonymousFunctions.types @@ -57,10 +57,10 @@ paired.reduce((b3, b4) => b3.concat({}), []); paired.map((c1) => c1.count); >paired.map((c1) => c1.count) : any[] ->paired.map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>paired.map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >paired : any[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->(c1) => c1.count : (c1: any) => any +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>(c1) => c1.count : (this: undefined, c1: any) => any >c1 : any >c1.count : any >c1 : any @@ -68,10 +68,10 @@ paired.map((c1) => c1.count); paired.map(function (c2) { return c2.count; }); >paired.map(function (c2) { return c2.count; }) : any[] ->paired.map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>paired.map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >paired : any[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->function (c2) { return c2.count; } : (c2: any) => any +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>function (c2) { return c2.count; } : (this: undefined, c2: any) => any >c2 : any >c2.count : any >c2 : any diff --git a/tests/baselines/reference/argumentsAsPropertyName.symbols b/tests/baselines/reference/argumentsAsPropertyName.symbols index 1e3e41abb6e..a17c660374c 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.symbols +++ b/tests/baselines/reference/argumentsAsPropertyName.symbols @@ -34,8 +34,8 @@ function myFunction(myType: MyType) { >x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) [1, 2, 3].forEach(function(j) { use(x); }) ->[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>[1, 2, 3].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >j : Symbol(j, Decl(argumentsAsPropertyName.ts, 12, 35)) >use : Symbol(use, Decl(argumentsAsPropertyName.ts, 3, 1)) >x : Symbol(x, Decl(argumentsAsPropertyName.ts, 11, 13)) diff --git a/tests/baselines/reference/argumentsAsPropertyName.types b/tests/baselines/reference/argumentsAsPropertyName.types index d0aaaa1cc72..00773d2a3cf 100644 --- a/tests/baselines/reference/argumentsAsPropertyName.types +++ b/tests/baselines/reference/argumentsAsPropertyName.types @@ -42,13 +42,13 @@ function myFunction(myType: MyType) { [1, 2, 3].forEach(function(j) { use(x); }) >[1, 2, 3].forEach(function(j) { use(x); }) : void ->[1, 2, 3].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1, 2, 3].forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void ->function(j) { use(x); } : (j: number) => void +>forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } +>function(j) { use(x); } : (this: undefined, j: number) => void >j : number >use(x) : any >use : (s: any) => any diff --git a/tests/baselines/reference/arrayConcatMap.symbols b/tests/baselines/reference/arrayConcatMap.symbols index c3df6bed533..1b26708ae94 100644 --- a/tests/baselines/reference/arrayConcatMap.symbols +++ b/tests/baselines/reference/arrayConcatMap.symbols @@ -1,14 +1,14 @@ === tests/cases/compiler/arrayConcatMap.ts === var x = [].concat([{ a: 1 }], [{ a: 2 }]) >x : Symbol(x, Decl(arrayConcatMap.ts, 0, 3)) ->[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].concat([{ a: 1 }], [{ a: 2 }]) .map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >[].concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >concat : Symbol(Array.concat, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 20)) >a : Symbol(a, Decl(arrayConcatMap.ts, 0, 32)) .map(b => b.a); ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15)) >b : Symbol(b, Decl(arrayConcatMap.ts, 1, 15)) diff --git a/tests/baselines/reference/arrayConcatMap.types b/tests/baselines/reference/arrayConcatMap.types index 10e0a74c16d..da4e998f92c 100644 --- a/tests/baselines/reference/arrayConcatMap.types +++ b/tests/baselines/reference/arrayConcatMap.types @@ -2,7 +2,7 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >x : any[] >[].concat([{ a: 1 }], [{ a: 2 }]) .map(b => b.a) : any[] ->[].concat([{ a: 1 }], [{ a: 2 }]) .map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>[].concat([{ a: 1 }], [{ a: 2 }]) .map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >[].concat([{ a: 1 }], [{ a: 2 }]) : any[] >[].concat : { (...items: any[][]): any[]; (...items: any[]): any[]; } >[] : undefined[] @@ -17,8 +17,8 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >2 : 2 .map(b => b.a); ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->b => b.a : (b: any) => any +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>b => b.a : (this: undefined, b: any) => any >b : any >b.a : any >b : any diff --git a/tests/baselines/reference/arrayFilter.symbols b/tests/baselines/reference/arrayFilter.symbols index fcdd39117a7..81d92ba04b6 100644 --- a/tests/baselines/reference/arrayFilter.symbols +++ b/tests/baselines/reference/arrayFilter.symbols @@ -14,9 +14,9 @@ var foo = [ ] foo.filter(x => x.name); //should accepted all possible types not only boolean! ->foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>foo.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >foo : Symbol(foo, Decl(arrayFilter.ts, 0, 3)) ->filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) >x.name : Symbol(name, Decl(arrayFilter.ts, 1, 5)) >x : Symbol(x, Decl(arrayFilter.ts, 6, 11)) diff --git a/tests/baselines/reference/arrayFilter.types b/tests/baselines/reference/arrayFilter.types index 43ef4161a06..de11296f832 100644 --- a/tests/baselines/reference/arrayFilter.types +++ b/tests/baselines/reference/arrayFilter.types @@ -22,10 +22,10 @@ var foo = [ foo.filter(x => x.name); //should accepted all possible types not only boolean! >foo.filter(x => x.name) : { name: string; }[] ->foo.filter : (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any) => { name: string; }[] +>foo.filter : { (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } >foo : { name: string; }[] ->filter : (callbackfn: (value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg?: any) => { name: string; }[] ->x => x.name : (x: { name: string; }) => string +>filter : { (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any): { name: string; }[]; (callbackfn: (this: undefined, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: undefined): { name: string; }[]; (callbackfn: (this: Z, value: { name: string; }, index: number, array: { name: string; }[]) => any, thisArg: Z): { name: string; }[]; } +>x => x.name : (this: undefined, x: { name: string; }) => string >x : { name: string; } >x.name : string >x : { name: string; } diff --git a/tests/baselines/reference/bestChoiceType.symbols b/tests/baselines/reference/bestChoiceType.symbols index 737ba35b520..45f4342992e 100644 --- a/tests/baselines/reference/bestChoiceType.symbols +++ b/tests/baselines/reference/bestChoiceType.symbols @@ -3,10 +3,10 @@ // Repro from #10041 (''.match(/ /) || []).map(s => s.toLowerCase()); ->(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 3, 26)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 3, 26)) @@ -28,9 +28,9 @@ function f1() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 10, 7)) ->y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 9, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 10, 18)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 10, 18)) @@ -52,9 +52,9 @@ function f2() { let z = y.map(s => s.toLowerCase()); >z : Symbol(z, Decl(bestChoiceType.ts, 16, 7)) ->y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>y.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >y : Symbol(y, Decl(bestChoiceType.ts, 15, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 16, 18)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 16, 18)) diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index 07b61fc9f84..3a540e97d59 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -4,7 +4,7 @@ (''.match(/ /) || []).map(s => s.toLowerCase()); >(''.match(/ /) || []).map(s => s.toLowerCase()) : string[] ->(''.match(/ /) || []).map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>(''.match(/ /) || []).map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >(''.match(/ /) || []) : RegExpMatchArray >''.match(/ /) || [] : RegExpMatchArray >''.match(/ /) : RegExpMatchArray | null @@ -13,8 +13,8 @@ >match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } >/ / : RegExp >[] : never[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.toLowerCase() : (s: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.toLowerCase() : (this: undefined, s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string @@ -43,10 +43,10 @@ function f1() { let z = y.map(s => s.toLowerCase()); >z : string[] >y.map(s => s.toLowerCase()) : string[] ->y.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>y.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >y : RegExpMatchArray ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.toLowerCase() : (s: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.toLowerCase() : (this: undefined, s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string @@ -75,10 +75,10 @@ function f2() { let z = y.map(s => s.toLowerCase()); >z : string[] >y.map(s => s.toLowerCase()) : string[] ->y.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>y.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >y : RegExpMatchArray ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.toLowerCase() : (s: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.toLowerCase() : (this: undefined, s: string) => string >s : string >s.toLowerCase() : string >s.toLowerCase : () => string diff --git a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols index 2a6ba238b4b..33f8f88f9e0 100644 --- a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols +++ b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.symbols @@ -12,9 +12,9 @@ class A { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) x.forEach((v) => { ->x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>x.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 3, 9)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(checkSwitchStatementIfCaseTypeIsString.ts, 4, 19)) switch(v) { diff --git a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types index 30f584894fc..7bae17fb922 100644 --- a/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types +++ b/tests/baselines/reference/checkSwitchStatementIfCaseTypeIsString.types @@ -13,10 +13,10 @@ class A { x.forEach((v) => { >x.forEach((v) => { switch(v) { case "test": use(this); } }) : void ->x.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>x.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >x : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->(v) => { switch(v) { case "test": use(this); } } : (v: string) => void +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>(v) => { switch(v) { case "test": use(this); } } : (this: undefined, v: string) => void >v : string switch(v) { diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols index ff9b7b0d311..4c7750c12a7 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols @@ -31,9 +31,9 @@ for (let i = 0; i < 3; i++) { }); } arr.forEach(C => console.log(C.y())); ->arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12)) >console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11)) >C.y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.types b/tests/baselines/reference/classExpressionWithStaticProperties3.types index b7f6102c8b7..dbbb1f378a8 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties3.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.types @@ -42,10 +42,10 @@ for (let i = 0; i < 3; i++) { } arr.forEach(C => console.log(C.y())); >arr.forEach(C => console.log(C.y())) : void ->arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>arr.forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } >arr : { y(): number; }[] ->forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void ->C => console.log(C.y()) : (C: { y(): number; }) => any +>forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } +>C => console.log(C.y()) : (this: undefined, C: { y(): number; }) => any >C : { y(): number; } >console.log(C.y()) : any >console.log : any diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols index f1a7fa807f5..94ea5cfaa8c 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.symbols @@ -31,9 +31,9 @@ for (let i = 0; i < 3; i++) { }); } arr.forEach(C => console.log(C.y())); ->arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>arr.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >arr : Symbol(arr, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 5)) ->forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >C : Symbol(C, Decl(classExpressionWithStaticPropertiesES63.ts, 9, 12)) >console : Symbol(console, Decl(classExpressionWithStaticPropertiesES63.ts, 1, 11)) >C.y : Symbol(y, Decl(classExpressionWithStaticPropertiesES63.ts, 2, 12)) diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types index 3bc780785aa..b725df6fd74 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types @@ -42,10 +42,10 @@ for (let i = 0; i < 3; i++) { } arr.forEach(C => console.log(C.y())); >arr.forEach(C => console.log(C.y())) : void ->arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>arr.forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } >arr : { y(): number; }[] ->forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void ->C => console.log(C.y()) : (C: { y(): number; }) => any +>forEach : { (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void): void; (callbackfn: (this: undefined, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg: Z): void; } +>C => console.log(C.y()) : (this: undefined, C: { y(): number; }) => any >C : { y(): number; } >console.log(C.y()) : any >console.log : any diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.symbols b/tests/baselines/reference/commaOperatorInConditionalExpression.symbols index 18f749c5c5c..cb124f21f15 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.symbols +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.symbols @@ -4,8 +4,8 @@ function f (m: string) { >m : Symbol(m, Decl(commaOperatorInConditionalExpression.ts, 0, 12)) [1, 2, 3].map(i => { ->[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >i : Symbol(i, Decl(commaOperatorInConditionalExpression.ts, 1, 18)) return true? { [m]: i } : { [m]: i + 1 } diff --git a/tests/baselines/reference/commaOperatorInConditionalExpression.types b/tests/baselines/reference/commaOperatorInConditionalExpression.types index f46282f9b6b..de8a95cd6c3 100644 --- a/tests/baselines/reference/commaOperatorInConditionalExpression.types +++ b/tests/baselines/reference/commaOperatorInConditionalExpression.types @@ -5,13 +5,13 @@ function f (m: string) { [1, 2, 3].map(i => { >[1, 2, 3].map(i => { return true? { [m]: i } : { [m]: i + 1 } }) : { [x: string]: number; }[] ->[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->i => { return true? { [m]: i } : { [m]: i + 1 } } : (i: number) => { [x: string]: number; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>i => { return true? { [m]: i } : { [m]: i + 1 } } : (this: undefined, i: number) => { [x: string]: number; } >i : number return true? { [m]: i } : { [m]: i + 1 } diff --git a/tests/baselines/reference/commentInMethodCall.symbols b/tests/baselines/reference/commentInMethodCall.symbols index 1ef762da871..e082d24daf3 100644 --- a/tests/baselines/reference/commentInMethodCall.symbols +++ b/tests/baselines/reference/commentInMethodCall.symbols @@ -4,9 +4,9 @@ var s: string[]; >s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3)) s.map(// do something ->s.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>s.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(commentInMethodCall.ts, 1, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) function () { }); diff --git a/tests/baselines/reference/commentInMethodCall.types b/tests/baselines/reference/commentInMethodCall.types index a97b0319777..eebbc15823e 100644 --- a/tests/baselines/reference/commentInMethodCall.types +++ b/tests/baselines/reference/commentInMethodCall.types @@ -5,10 +5,10 @@ var s: string[]; s.map(// do something >s.map(// do something function () { }) : void[] ->s.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>s.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >s : string[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } function () { }); ->function () { } : () => void +>function () { } : (this: undefined) => void diff --git a/tests/baselines/reference/contextualSignatureInstantiation3.symbols b/tests/baselines/reference/contextualSignatureInstantiation3.symbols index 50dac0b5d67..a9653673ff2 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation3.symbols +++ b/tests/baselines/reference/contextualSignatureInstantiation3.symbols @@ -12,9 +12,9 @@ function map(items: T[], f: (x: T) => U): U[]{ >U : Symbol(U, Decl(contextualSignatureInstantiation3.ts, 0, 15)) return items.map(f); ->items.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>items.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >items : Symbol(items, Decl(contextualSignatureInstantiation3.ts, 0, 19)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >f : Symbol(f, Decl(contextualSignatureInstantiation3.ts, 0, 30)) } @@ -47,9 +47,9 @@ var v1: number[]; var v1 = xs.map(identity); // Error if not number[] >v1 : Symbol(v1, Decl(contextualSignatureInstantiation3.ts, 15, 3), Decl(contextualSignatureInstantiation3.ts, 16, 3), Decl(contextualSignatureInstantiation3.ts, 17, 3)) ->xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >identity : Symbol(identity, Decl(contextualSignatureInstantiation3.ts, 2, 1)) var v1 = map(xs, identity); // Error if not number[] @@ -63,9 +63,9 @@ var v2: number[][]; var v2 = xs.map(singleton); // Error if not number[][] >v2 : Symbol(v2, Decl(contextualSignatureInstantiation3.ts, 19, 3), Decl(contextualSignatureInstantiation3.ts, 20, 3), Decl(contextualSignatureInstantiation3.ts, 21, 3)) ->xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>xs.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >xs : Symbol(xs, Decl(contextualSignatureInstantiation3.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >singleton : Symbol(singleton, Decl(contextualSignatureInstantiation3.ts, 6, 1)) var v2 = map(xs, singleton); // Error if not number[][] diff --git a/tests/baselines/reference/contextualSignatureInstantiation3.types b/tests/baselines/reference/contextualSignatureInstantiation3.types index 409c685215d..dcb7284ceaa 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation3.types +++ b/tests/baselines/reference/contextualSignatureInstantiation3.types @@ -13,9 +13,9 @@ function map(items: T[], f: (x: T) => U): U[]{ return items.map(f); >items.map(f) : U[] ->items.map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } +>items.map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } >items : T[] ->map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } +>map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } >f : (x: T) => U } @@ -54,9 +54,9 @@ var v1: number[]; var v1 = xs.map(identity); // Error if not number[] >v1 : number[] >xs.map(identity) : number[] ->xs.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>xs.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >xs : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >identity : (x: T) => T var v1 = map(xs, identity); // Error if not number[] @@ -72,9 +72,9 @@ var v2: number[][]; var v2 = xs.map(singleton); // Error if not number[][] >v2 : number[][] >xs.map(singleton) : number[][] ->xs.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>xs.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >xs : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >singleton : (x: T) => T[] var v2 = map(xs, singleton); // Error if not number[][] diff --git a/tests/baselines/reference/contextuallyTypedIife.symbols b/tests/baselines/reference/contextuallyTypedIife.symbols index 7a73beaad16..96e57c1f62f 100644 --- a/tests/baselines/reference/contextuallyTypedIife.symbols +++ b/tests/baselines/reference/contextuallyTypedIife.symbols @@ -47,25 +47,25 @@ // rest parameters ((...numbers) => numbers.every(n => n > 0))(5,6,7); >numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) ->numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numbers : Symbol(numbers, Decl(contextuallyTypedIife.ts, 17, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 17, 31)) ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); >mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) ->mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >mixed : Symbol(mixed, Decl(contextuallyTypedIife.ts, 18, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 18, 27)) ((...noNumbers) => noNumbers.some(n => n > 0))(); >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) ->noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIife.ts, 19, 2)) ->some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 19, 34)) @@ -73,9 +73,9 @@ >first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) >rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) >first : Symbol(first, Decl(contextuallyTypedIife.ts, 20, 2)) ->rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >rest : Symbol(rest, Decl(contextuallyTypedIife.ts, 20, 8)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) >n : Symbol(n, Decl(contextuallyTypedIife.ts, 20, 43)) diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index 676755fb341..b8c59a618b8 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -105,10 +105,10 @@ >(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean >numbers : number[] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >numbers : number[] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: number) => boolean +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number @@ -123,10 +123,10 @@ >(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean >mixed : (string | number)[] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } >mixed : (string | number)[] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean ->n => !!n : (n: string | number) => boolean +>every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } +>n => !!n : (this: undefined, n: string | number) => boolean >n : string | number >!!n : boolean >!n : boolean @@ -141,10 +141,10 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean >noNumbers : any[] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } >noNumbers : any[] ->some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: any) => boolean +>some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: any) => boolean >n : any >n > 0 : boolean >n : any @@ -160,10 +160,10 @@ >first : number >[] : undefined[] >rest.map(n => n > 0) : boolean[] ->rest.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>rest.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >rest : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n > 0 : (n: number) => boolean +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.symbols b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols index f76c9caa104..62b585122dd 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.symbols +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.symbols @@ -47,25 +47,25 @@ // rest parameters ((...numbers) => numbers.every(n => n > 0))(5,6,7); >numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) ->numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>numbers.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numbers : Symbol(numbers, Decl(contextuallyTypedIifeStrict.ts, 17, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 17, 31)) ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); >mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) ->mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>mixed.every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >mixed : Symbol(mixed, Decl(contextuallyTypedIifeStrict.ts, 18, 2)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 18, 27)) ((...noNumbers) => noNumbers.some(n => n > 0))(); >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) ->noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>noNumbers.some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >noNumbers : Symbol(noNumbers, Decl(contextuallyTypedIifeStrict.ts, 19, 2)) ->some : Symbol(Array.some, Decl(lib.d.ts, --, --)) +>some : Symbol(Array.some, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 19, 34)) @@ -73,9 +73,9 @@ >first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) >rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) >first : Symbol(first, Decl(contextuallyTypedIifeStrict.ts, 20, 2)) ->rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>rest.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >rest : Symbol(rest, Decl(contextuallyTypedIifeStrict.ts, 20, 8)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) >n : Symbol(n, Decl(contextuallyTypedIifeStrict.ts, 20, 43)) diff --git a/tests/baselines/reference/contextuallyTypedIifeStrict.types b/tests/baselines/reference/contextuallyTypedIifeStrict.types index cbeee53ec2e..0f888f98277 100644 --- a/tests/baselines/reference/contextuallyTypedIifeStrict.types +++ b/tests/baselines/reference/contextuallyTypedIifeStrict.types @@ -105,10 +105,10 @@ >(...numbers) => numbers.every(n => n > 0) : (...numbers: number[]) => boolean >numbers : number[] >numbers.every(n => n > 0) : boolean ->numbers.every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>numbers.every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >numbers : number[] ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: number) => boolean +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number @@ -123,10 +123,10 @@ >(...mixed) => mixed.every(n => !!n) : (...mixed: (string | number)[]) => boolean >mixed : (string | number)[] >mixed.every(n => !!n) : boolean ->mixed.every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean +>mixed.every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } >mixed : (string | number)[] ->every : (callbackfn: (value: string | number, index: number, array: (string | number)[]) => boolean, thisArg?: any) => boolean ->n => !!n : (n: string | number) => boolean +>every : { (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean): boolean; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => boolean, thisArg: Z): boolean; } +>n => !!n : (this: undefined, n: string | number) => boolean >n : string | number >!!n : boolean >!n : boolean @@ -141,10 +141,10 @@ >(...noNumbers) => noNumbers.some(n => n > 0) : (...noNumbers: any[]) => boolean >noNumbers : any[] >noNumbers.some(n => n > 0) : boolean ->noNumbers.some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean +>noNumbers.some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } >noNumbers : any[] ->some : (callbackfn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean ->n => n > 0 : (n: any) => boolean +>some : { (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean): boolean; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: any, index: number, array: any[]) => boolean, thisArg: Z): boolean; } +>n => n > 0 : (this: undefined, n: any) => boolean >n : any >n > 0 : boolean >n : any @@ -160,10 +160,10 @@ >first : number >[] : never[] >rest.map(n => n > 0) : boolean[] ->rest.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>rest.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >rest : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n > 0 : (n: number) => boolean +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n > 0 : (this: undefined, n: number) => boolean >n : number >n > 0 : boolean >n : number diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.symbols b/tests/baselines/reference/controlFlowDestructuringParameters.symbols index 58d2edfc12c..1874c16c3d3 100644 --- a/tests/baselines/reference/controlFlowDestructuringParameters.symbols +++ b/tests/baselines/reference/controlFlowDestructuringParameters.symbols @@ -3,9 +3,9 @@ [{ x: 1 }].map( ->[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[{ x: 1 }].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 3, 2)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ({ x }) => x >x : Symbol(x, Decl(controlFlowDestructuringParameters.ts, 4, 4)) diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.types b/tests/baselines/reference/controlFlowDestructuringParameters.types index c38a8fb1aa4..d1adadfee17 100644 --- a/tests/baselines/reference/controlFlowDestructuringParameters.types +++ b/tests/baselines/reference/controlFlowDestructuringParameters.types @@ -4,15 +4,15 @@ [{ x: 1 }].map( >[{ x: 1 }].map( ({ x }) => x) : number[] ->[{ x: 1 }].map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; } +>[{ x: 1 }].map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): U[]; } >[{ x: 1 }] : { x: number; }[] >{ x: 1 } : { x: number; } >x : number >1 : 1 ->map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any): U[]; } +>map : { (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; }, { x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; }, { x: number; }], callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg: Z): U[]; } ({ x }) => x ->({ x }) => x : ({x}: { x: number; }) => number +>({ x }) => x : (this: undefined, {x}: { x: number; }) => number >x : number >x : number diff --git a/tests/baselines/reference/declarationEmitPromise.symbols b/tests/baselines/reference/declarationEmitPromise.symbols index 2c37e1dfa78..23d00ec6386 100644 --- a/tests/baselines/reference/declarationEmitPromise.symbols +++ b/tests/baselines/reference/declarationEmitPromise.symbols @@ -40,13 +40,13 @@ export async function runSampleWorks( >bluebird.all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) >bluebird : Symbol(bluebird, Decl(declarationEmitPromise.ts, 0, 0)) >all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) ->[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(declarationEmitPromise.ts, 5, 52)) >b : Symbol(b, Decl(declarationEmitPromise.ts, 6, 19)) >c : Symbol(c, Decl(declarationEmitPromise.ts, 6, 36)) >d : Symbol(d, Decl(declarationEmitPromise.ts, 6, 53)) >e : Symbol(e, Decl(declarationEmitPromise.ts, 6, 70)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 7, 68)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 7, 68)) @@ -112,13 +112,13 @@ export async function runSampleBreaks( >bluebird.all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) >bluebird : Symbol(bluebird, Decl(declarationEmitPromise.ts, 0, 0)) >all : Symbol(bluebird.all, Decl(declarationEmitPromise.ts, 1, 26)) ->[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>[a, b, c, d, e].filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(declarationEmitPromise.ts, 14, 53)) >b : Symbol(b, Decl(declarationEmitPromise.ts, 15, 19)) >c : Symbol(c, Decl(declarationEmitPromise.ts, 15, 36)) >d : Symbol(d, Decl(declarationEmitPromise.ts, 15, 53)) >e : Symbol(e, Decl(declarationEmitPromise.ts, 15, 70)) ->filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 16, 68)) >el : Symbol(el, Decl(declarationEmitPromise.ts, 16, 68)) diff --git a/tests/baselines/reference/declarationEmitPromise.types b/tests/baselines/reference/declarationEmitPromise.types index 4edaa444326..3cdf63ef478 100644 --- a/tests/baselines/reference/declarationEmitPromise.types +++ b/tests/baselines/reference/declarationEmitPromise.types @@ -45,15 +45,15 @@ export async function runSampleWorks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] +>[a, b, c, d, e].filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] ->el => !!el : (el: bluebird) => boolean +>filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>el => !!el : (this: undefined, el: bluebird) => boolean >el : bluebird >!!el : boolean >!el : boolean @@ -130,15 +130,15 @@ export async function runSampleBreaks( >bluebird : typeof bluebird >all : bluebird[] >[a, b, c, d, e].filter(el => !!el) : bluebird[] ->[a, b, c, d, e].filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] +>[a, b, c, d, e].filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } >[a, b, c, d, e] : bluebird[] >a : bluebird >b : bluebird >c : bluebird >d : bluebird >e : bluebird ->filter : (callbackfn: (value: bluebird, index: number, array: bluebird[]) => any, thisArg?: any) => bluebird[] ->el => !!el : (el: bluebird) => boolean +>filter : { (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any): bluebird[]; (callbackfn: (this: undefined, value: bluebird, index: number, array: bluebird[]) => any, thisArg: undefined): bluebird[]; (callbackfn: (this: Z, value: bluebird, index: number, array: bluebird[]) => any, thisArg: Z): bluebird[]; } +>el => !!el : (this: undefined, el: bluebird) => boolean >el : bluebird >!!el : boolean >!el : boolean diff --git a/tests/baselines/reference/enumIndexer.symbols b/tests/baselines/reference/enumIndexer.symbols index 79baee66498..cf87cb106d1 100644 --- a/tests/baselines/reference/enumIndexer.symbols +++ b/tests/baselines/reference/enumIndexer.symbols @@ -19,9 +19,9 @@ var enumValue = MyEnumType.foo; var x = _arr.map(o => MyEnumType[o.key] === enumValue); // these are not same type >x : Symbol(x, Decl(enumIndexer.ts, 5, 3)) ->_arr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>_arr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >_arr : Symbol(_arr, Decl(enumIndexer.ts, 3, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >o : Symbol(o, Decl(enumIndexer.ts, 5, 17)) >MyEnumType : Symbol(MyEnumType, Decl(enumIndexer.ts, 0, 0)) >o.key : Symbol(key, Decl(enumIndexer.ts, 3, 13)) diff --git a/tests/baselines/reference/enumIndexer.types b/tests/baselines/reference/enumIndexer.types index 3abd7eaaa4c..981ad5c8c81 100644 --- a/tests/baselines/reference/enumIndexer.types +++ b/tests/baselines/reference/enumIndexer.types @@ -25,10 +25,10 @@ var enumValue = MyEnumType.foo; var x = _arr.map(o => MyEnumType[o.key] === enumValue); // these are not same type >x : boolean[] >_arr.map(o => MyEnumType[o.key] === enumValue) : boolean[] ->_arr.map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): U[]; } +>_arr.map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): U[]; } >_arr : { key: string; }[] ->map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg?: any): U[]; } ->o => MyEnumType[o.key] === enumValue : (o: { key: string; }) => boolean +>map : { (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ key: string; }, { key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ key: string; }, { key: string; }], callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { key: string; }, index: number, array: { key: string; }[]) => U, thisArg: Z): U[]; } +>o => MyEnumType[o.key] === enumValue : (this: undefined, o: { key: string; }) => boolean >o : { key: string; } >MyEnumType[o.key] === enumValue : boolean >MyEnumType[o.key] : any diff --git a/tests/baselines/reference/genericArray1.symbols b/tests/baselines/reference/genericArray1.symbols index a96b487f1d7..f548f34e553 100644 --- a/tests/baselines/reference/genericArray1.symbols +++ b/tests/baselines/reference/genericArray1.symbols @@ -13,8 +13,8 @@ interface String{ var lengths = ["a", "b", "c"].map(x => x.length); >lengths : Symbol(lengths, Decl(genericArray1.ts, 12, 3)) ->["a", "b", "c"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>["a", "b", "c"].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericArray1.ts, 12, 34)) >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericArray1.ts, 12, 34)) diff --git a/tests/baselines/reference/genericArray1.types b/tests/baselines/reference/genericArray1.types index 68d691a96e3..b893d9778fc 100644 --- a/tests/baselines/reference/genericArray1.types +++ b/tests/baselines/reference/genericArray1.types @@ -14,13 +14,13 @@ interface String{ var lengths = ["a", "b", "c"].map(x => x.length); >lengths : number[] >["a", "b", "c"].map(x => x.length) : number[] ->["a", "b", "c"].map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>["a", "b", "c"].map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >["a", "b", "c"] : string[] >"a" : "a" >"b" : "b" >"c" : "c" ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->x => x.length : (x: string) => number +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>x => x.length : (this: undefined, x: string) => number >x : string >x.length : number >x : string diff --git a/tests/baselines/reference/genericInference1.symbols b/tests/baselines/reference/genericInference1.symbols index 7fc39ac556f..ecc9c811d76 100644 --- a/tests/baselines/reference/genericInference1.symbols +++ b/tests/baselines/reference/genericInference1.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/genericInference1.ts === ['a', 'b', 'c'].map(x => x.length); ->['a', 'b', 'c'].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>['a', 'b', 'c'].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericInference1.ts, 0, 20)) >x.length : Symbol(String.length, Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(genericInference1.ts, 0, 20)) diff --git a/tests/baselines/reference/genericInference1.types b/tests/baselines/reference/genericInference1.types index ddf8d762000..64ff2c399cd 100644 --- a/tests/baselines/reference/genericInference1.types +++ b/tests/baselines/reference/genericInference1.types @@ -1,13 +1,13 @@ === tests/cases/compiler/genericInference1.ts === ['a', 'b', 'c'].map(x => x.length); >['a', 'b', 'c'].map(x => x.length) : number[] ->['a', 'b', 'c'].map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>['a', 'b', 'c'].map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >['a', 'b', 'c'] : string[] >'a' : "a" >'b' : "b" >'c' : "c" ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->x => x.length : (x: string) => number +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>x => x.length : (this: undefined, x: string) => number >x : string >x.length : number >x : string diff --git a/tests/baselines/reference/genericMethodOverspecialization.symbols b/tests/baselines/reference/genericMethodOverspecialization.symbols index 5fd2a0479e6..55ff9cb5afb 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.symbols +++ b/tests/baselines/reference/genericMethodOverspecialization.symbols @@ -27,9 +27,9 @@ interface Document { var elements = names.map(function (name) { >elements : Symbol(elements, Decl(genericMethodOverspecialization.ts, 12, 3)) ->names.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>names.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >names : Symbol(names, Decl(genericMethodOverspecialization.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >name : Symbol(name, Decl(genericMethodOverspecialization.ts, 12, 35)) return document.getElementById(name); @@ -43,9 +43,9 @@ var elements = names.map(function (name) { var xxx = elements.filter(function (e) { >xxx : Symbol(xxx, Decl(genericMethodOverspecialization.ts, 17, 3)) ->elements.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>elements.filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >elements : Symbol(elements, Decl(genericMethodOverspecialization.ts, 12, 3)) ->filter : Symbol(Array.filter, Decl(lib.d.ts, --, --)) +>filter : Symbol(Array.filter, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >e : Symbol(e, Decl(genericMethodOverspecialization.ts, 17, 36)) return !e.isDisabled; @@ -57,9 +57,9 @@ var xxx = elements.filter(function (e) { var widths:number[] = elements.map(function (e) { // should not error >widths : Symbol(widths, Decl(genericMethodOverspecialization.ts, 21, 3)) ->elements.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>elements.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >elements : Symbol(elements, Decl(genericMethodOverspecialization.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >e : Symbol(e, Decl(genericMethodOverspecialization.ts, 21, 45)) return e.clientWidth; diff --git a/tests/baselines/reference/genericMethodOverspecialization.types b/tests/baselines/reference/genericMethodOverspecialization.types index 0f90bd34e2e..36b710b742c 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.types +++ b/tests/baselines/reference/genericMethodOverspecialization.types @@ -34,10 +34,10 @@ interface Document { var elements = names.map(function (name) { >elements : HTMLElement[] >names.map(function (name) { return document.getElementById(name);}) : HTMLElement[] ->names.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>names.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >names : string[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->function (name) { return document.getElementById(name);} : (name: string) => HTMLElement +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (name) { return document.getElementById(name);} : (this: undefined, name: string) => HTMLElement >name : string return document.getElementById(name); @@ -53,10 +53,10 @@ var elements = names.map(function (name) { var xxx = elements.filter(function (e) { >xxx : HTMLElement[] >elements.filter(function (e) { return !e.isDisabled;}) : HTMLElement[] ->elements.filter : (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any) => HTMLElement[] +>elements.filter : { (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } >elements : HTMLElement[] ->filter : (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg?: any) => HTMLElement[] ->function (e) { return !e.isDisabled;} : (e: HTMLElement) => boolean +>filter : { (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any): HTMLElement[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: undefined): HTMLElement[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => any, thisArg: Z): HTMLElement[]; } +>function (e) { return !e.isDisabled;} : (this: undefined, e: HTMLElement) => boolean >e : HTMLElement return !e.isDisabled; @@ -70,10 +70,10 @@ var xxx = elements.filter(function (e) { var widths:number[] = elements.map(function (e) { // should not error >widths : number[] >elements.map(function (e) { // should not error return e.clientWidth;}) : number[] ->elements.map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): U[]; } +>elements.map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): U[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): U[]; } >elements : HTMLElement[] ->map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg?: any): U[]; } ->function (e) { // should not error return e.clientWidth;} : (e: HTMLElement) => number +>map : { (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U, U]; (this: [HTMLElement, HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): [U, U]; (this: [HTMLElement, HTMLElement], callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U): U[]; (callbackfn: (this: undefined, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: HTMLElement, index: number, array: HTMLElement[]) => U, thisArg: Z): U[]; } +>function (e) { // should not error return e.clientWidth;} : (this: undefined, e: HTMLElement) => number >e : HTMLElement return e.clientWidth; diff --git a/tests/baselines/reference/implementArrayInterface.errors.txt b/tests/baselines/reference/implementArrayInterface.errors.txt index 08c438ebaf3..139bb42105d 100644 --- a/tests/baselines/reference/implementArrayInterface.errors.txt +++ b/tests/baselines/reference/implementArrayInterface.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/implementArrayInterface.ts(1,15): error TS2420: Class 'MyArray' incorrectly implements interface 'T[]'. Types of property 'map' are incompatible. - Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }'. + Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; }'. Type 'any[]' is not assignable to type '[any, any, any, any, any]'. Property '0' is missing in type 'any[]'. @@ -10,7 +10,7 @@ tests/cases/compiler/implementArrayInterface.ts(1,15): error TS2420: Class 'MyAr ~~~~~~~ !!! error TS2420: Class 'MyArray' incorrectly implements interface 'T[]'. !!! error TS2420: Types of property 'map' are incompatible. -!!! error TS2420: Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; }'. +!!! error TS2420: Type '(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any) => U[]' is not assignable to type '{ (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; }'. !!! error TS2420: Type 'any[]' is not assignable to type '[any, any, any, any, any]'. !!! error TS2420: Property '0' is missing in type 'any[]'. toString(): string; diff --git a/tests/baselines/reference/inferenceLimit.symbols b/tests/baselines/reference/inferenceLimit.symbols index 488838548ad..e471856e448 100644 --- a/tests/baselines/reference/inferenceLimit.symbols +++ b/tests/baselines/reference/inferenceLimit.symbols @@ -64,9 +64,9 @@ export class BrokenClass { >Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->result.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>result.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >result : Symbol(result, Decl(file1.ts, 10, 7)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7)) .then((orders: Array) => { diff --git a/tests/baselines/reference/inferenceLimit.types b/tests/baselines/reference/inferenceLimit.types index bf917e18e93..9f2f11d988f 100644 --- a/tests/baselines/reference/inferenceLimit.types +++ b/tests/baselines/reference/inferenceLimit.types @@ -84,9 +84,9 @@ export class BrokenClass { >Promise : PromiseConstructor >all : { (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; (values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; (values: (T | PromiseLike)[]): Promise; (values: Iterable>): Promise; } >result.map(populateItems) : Promise<{}>[] ->result.map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): U[]; } +>result.map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): U[]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): U[]; } >result : MyModule.MyModel[] ->map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg?: any): U[]; } +>map : { (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): [U, U]; (this: [MyModule.MyModel, MyModule.MyModel], callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U): U[]; (callbackfn: (this: undefined, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: MyModule.MyModel, index: number, array: MyModule.MyModel[]) => U, thisArg: Z): U[]; } >populateItems : (order: any) => Promise<{}> .then((orders: Array) => { diff --git a/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols b/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols index 56d2c2dc87f..fe60a8c1581 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols +++ b/tests/baselines/reference/inferentialTypingWithFunctionType2.symbols @@ -11,7 +11,7 @@ function identity(a: A): A { } var x = [1, 2, 3].map(identity)[0]; >x : Symbol(x, Decl(inferentialTypingWithFunctionType2.ts, 3, 3)) ->[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >identity : Symbol(identity, Decl(inferentialTypingWithFunctionType2.ts, 0, 0)) diff --git a/tests/baselines/reference/inferentialTypingWithFunctionType2.types b/tests/baselines/reference/inferentialTypingWithFunctionType2.types index b9208409fe0..55caace2c2c 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionType2.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionType2.types @@ -13,12 +13,12 @@ var x = [1, 2, 3].map(identity)[0]; >x : number >[1, 2, 3].map(identity)[0] : number >[1, 2, 3].map(identity) : number[] ->[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1, 2, 3].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1, 2, 3] : number[] >1 : 1 >2 : 2 >3 : 3 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >identity : (a: A) => A >0 : 0 diff --git a/tests/baselines/reference/keyofAndIndexedAccess.symbols b/tests/baselines/reference/keyofAndIndexedAccess.symbols index f6425b5ed0e..d5c4660d474 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess.symbols @@ -454,9 +454,9 @@ function pluck(array: T[], key: K) { >K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 132, 17)) return array.map(x => x[key]); ->array.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>array.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >array : Symbol(array, Decl(keyofAndIndexedAccess.ts, 132, 37)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 133, 21)) >x : Symbol(x, Decl(keyofAndIndexedAccess.ts, 133, 21)) >key : Symbol(key, Decl(keyofAndIndexedAccess.ts, 132, 48)) diff --git a/tests/baselines/reference/keyofAndIndexedAccess.types b/tests/baselines/reference/keyofAndIndexedAccess.types index 86469efc284..66605b41b75 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess.types +++ b/tests/baselines/reference/keyofAndIndexedAccess.types @@ -523,10 +523,10 @@ function pluck(array: T[], key: K) { return array.map(x => x[key]); >array.map(x => x[key]) : T[K][] ->array.map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } +>array.map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } >array : T[] ->map : { (this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; (this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; (this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; } ->x => x[key] : (x: T) => T[K] +>map : { (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; (this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U, U]; (this: [T, T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; (this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): [U, U]; (this: [T, T], callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; (this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U): U[]; (callbackfn: (this: undefined, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): U[]; } +>x => x[key] : (this: undefined, x: T) => T[K] >x : T >x[key] : T[K] >x : T diff --git a/tests/baselines/reference/mapOnTupleTypes01.symbols b/tests/baselines/reference/mapOnTupleTypes01.symbols index 1dbfca4a4c3..0733b1d5b02 100644 --- a/tests/baselines/reference/mapOnTupleTypes01.symbols +++ b/tests/baselines/reference/mapOnTupleTypes01.symbols @@ -2,8 +2,8 @@ export let mapOnLooseArrayLiteral = [1, 2, 3, 4].map(n => n * n); >mapOnLooseArrayLiteral : Symbol(mapOnLooseArrayLiteral, Decl(mapOnTupleTypes01.ts, 1, 10)) ->[1, 2, 3, 4].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1, 2, 3, 4].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 1, 53)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 1, 53)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 1, 53)) @@ -15,9 +15,9 @@ let numTuple: [number] = [1]; export let a = numTuple.map(x => x * x); >a : Symbol(a, Decl(mapOnTupleTypes01.ts, 6, 10)) ->numTuple.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numTuple.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numTuple : Symbol(numTuple, Decl(mapOnTupleTypes01.ts, 5, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 6, 28)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 6, 28)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 6, 28)) @@ -35,18 +35,18 @@ let numStr: [number, string] = [ 100, "hello"]; export let b = numNum.map(n => n * n); >b : Symbol(b, Decl(mapOnTupleTypes01.ts, 14, 10)) ->numNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNum : Symbol(numNum, Decl(mapOnTupleTypes01.ts, 10, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 14, 26)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 14, 26)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 14, 26)) export let c = strStr.map(s => s.charCodeAt(0)); >c : Symbol(c, Decl(mapOnTupleTypes01.ts, 15, 10)) ->strStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>strStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >strStr : Symbol(strStr, Decl(mapOnTupleTypes01.ts, 11, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(mapOnTupleTypes01.ts, 15, 26)) >s.charCodeAt : Symbol(String.charCodeAt, Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(mapOnTupleTypes01.ts, 15, 26)) @@ -54,9 +54,9 @@ export let c = strStr.map(s => s.charCodeAt(0)); export let d = numStr.map(x => x); >d : Symbol(d, Decl(mapOnTupleTypes01.ts, 16, 10)) ->numStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numStr.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numStr : Symbol(numStr, Decl(mapOnTupleTypes01.ts, 12, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 16, 26)) >x : Symbol(x, Decl(mapOnTupleTypes01.ts, 16, 26)) @@ -67,9 +67,9 @@ let numNumNum: [number, number, number] = [1, 2, 3]; export let e = numNumNum.map(n => n * n); >e : Symbol(e, Decl(mapOnTupleTypes01.ts, 22, 10)) ->numNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNum : Symbol(numNumNum, Decl(mapOnTupleTypes01.ts, 20, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 22, 29)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 22, 29)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 22, 29)) @@ -81,9 +81,9 @@ let numNumNumNum: [number, number, number, number] = [1, 2, 3, 4]; export let f = numNumNumNum.map(n => n * n); >f : Symbol(f, Decl(mapOnTupleTypes01.ts, 28, 10)) ->numNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNumNum : Symbol(numNumNumNum, Decl(mapOnTupleTypes01.ts, 26, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 28, 32)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 28, 32)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 28, 32)) @@ -95,9 +95,9 @@ let numNumNumNumNum: [number, number, number, number, number] = [1, 2, 3, 4, 5]; export let g = numNumNumNumNum.map(n => n * n); >g : Symbol(g, Decl(mapOnTupleTypes01.ts, 34, 10)) ->numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNumNumNum : Symbol(numNumNumNumNum, Decl(mapOnTupleTypes01.ts, 32, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 34, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 34, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 34, 35)) @@ -110,9 +110,9 @@ let numNumNumNumNumNum: [number, number, number, number, number, number] = [1, 2 export let h = numNumNumNumNum.map(n => n * n); >h : Symbol(h, Decl(mapOnTupleTypes01.ts, 41, 10)) ->numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>numNumNumNumNum.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >numNumNumNumNum : Symbol(numNumNumNumNum, Decl(mapOnTupleTypes01.ts, 32, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 41, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 41, 35)) >n : Symbol(n, Decl(mapOnTupleTypes01.ts, 41, 35)) diff --git a/tests/baselines/reference/mapOnTupleTypes01.types b/tests/baselines/reference/mapOnTupleTypes01.types index 0a01ecfa380..b8230d3fdf5 100644 --- a/tests/baselines/reference/mapOnTupleTypes01.types +++ b/tests/baselines/reference/mapOnTupleTypes01.types @@ -3,14 +3,14 @@ export let mapOnLooseArrayLiteral = [1, 2, 3, 4].map(n => n * n); >mapOnLooseArrayLiteral : number[] >[1, 2, 3, 4].map(n => n * n) : number[] ->[1, 2, 3, 4].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1, 2, 3, 4].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1, 2, 3, 4] : number[] >1 : 1 >2 : 2 >3 : 3 >4 : 4 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -26,10 +26,10 @@ let numTuple: [number] = [1]; export let a = numTuple.map(x => x * x); >a : number[] >numTuple.map(x => x * x) : number[] ->numTuple.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numTuple.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numTuple : [number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->x => x * x : (x: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>x => x * x : (this: undefined, x: number) => number >x : number >x * x : number >x : number @@ -58,10 +58,10 @@ let numStr: [number, string] = [ 100, "hello"]; export let b = numNum.map(n => n * n); >b : [number, number] >numNum.map(n => n * n) : [number, number] ->numNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNum : [number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -70,10 +70,10 @@ export let b = numNum.map(n => n * n); export let c = strStr.map(s => s.charCodeAt(0)); >c : [number, number] >strStr.map(s => s.charCodeAt(0)) : [number, number] ->strStr.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>strStr.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >strStr : [string, string] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->s => s.charCodeAt(0) : (s: string) => number +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>s => s.charCodeAt(0) : (this: undefined, s: string) => number >s : string >s.charCodeAt(0) : number >s.charCodeAt : (index: number) => number @@ -84,10 +84,10 @@ export let c = strStr.map(s => s.charCodeAt(0)); export let d = numStr.map(x => x); >d : [string | number, string | number] >numStr.map(x => x) : [string | number, string | number] ->numStr.map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U]; (this: [string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): U[]; } +>numStr.map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U]; (this: [string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): U[]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): U[]; } >numStr : [number, string] ->map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U, U]; (this: [string | number, string | number], callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string | number, index: number, array: (string | number)[]) => U, thisArg?: any): U[]; } ->x => x : (x: string | number) => string | number +>map : { (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string | number, string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U, U]; (this: [string | number, string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): [U, U]; (this: [string | number, string | number], callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): [U, U]; (this: [string | number, string | number], callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U): U[]; (callbackfn: (this: undefined, value: string | number, index: number, array: (string | number)[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string | number, index: number, array: (string | number)[]) => U, thisArg: Z): U[]; } +>x => x : (this: undefined, x: string | number) => string | number >x : string | number >x : string | number @@ -103,10 +103,10 @@ let numNumNum: [number, number, number] = [1, 2, 3]; export let e = numNumNum.map(n => n * n); >e : [number, number, number] >numNumNum.map(n => n * n) : [number, number, number] ->numNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNum : [number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -125,10 +125,10 @@ let numNumNumNum: [number, number, number, number] = [1, 2, 3, 4]; export let f = numNumNumNum.map(n => n * n); >f : [number, number, number, number] >numNumNumNum.map(n => n * n) : [number, number, number, number] ->numNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNumNum : [number, number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -148,10 +148,10 @@ let numNumNumNumNum: [number, number, number, number, number] = [1, 2, 3, 4, 5]; export let g = numNumNumNumNum.map(n => n * n); >g : [number, number, number, number, number] >numNumNumNumNum.map(n => n * n) : [number, number, number, number, number] ->numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNumNumNum : [number, number, number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number @@ -173,10 +173,10 @@ let numNumNumNumNumNum: [number, number, number, number, number, number] = [1, 2 export let h = numNumNumNumNum.map(n => n * n); >h : [number, number, number, number, number] >numNumNumNumNum.map(n => n * n) : [number, number, number, number, number] ->numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>numNumNumNumNum.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >numNumNumNumNum : [number, number, number, number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->n => n * n : (n: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>n => n * n : (this: undefined, n: number) => number >n : number >n * n : number >n : number diff --git a/tests/baselines/reference/mapOnTupleTypes02.symbols b/tests/baselines/reference/mapOnTupleTypes02.symbols index da27a13d4f6..6453caace91 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.symbols +++ b/tests/baselines/reference/mapOnTupleTypes02.symbols @@ -9,9 +9,9 @@ export function increment(point: Point) { >Point : Symbol(Point, Decl(mapOnTupleTypes02.ts, 0, 0)) return point.map(d => d + 1); ->point.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>point.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >point : Symbol(point, Decl(mapOnTupleTypes02.ts, 3, 26)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >d : Symbol(d, Decl(mapOnTupleTypes02.ts, 4, 19)) >d : Symbol(d, Decl(mapOnTupleTypes02.ts, 4, 19)) } diff --git a/tests/baselines/reference/mapOnTupleTypes02.types b/tests/baselines/reference/mapOnTupleTypes02.types index 3803e3c319e..5ec555ebf17 100644 --- a/tests/baselines/reference/mapOnTupleTypes02.types +++ b/tests/baselines/reference/mapOnTupleTypes02.types @@ -10,10 +10,10 @@ export function increment(point: Point) { return point.map(d => d + 1); >point.map(d => d + 1) : [number, number] ->point.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>point.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >point : [number, number] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->d => d + 1 : (d: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>d => d + 1 : (this: undefined, d: number) => number >d : number >d + 1 : number >d : number diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols index 62473581abe..ccee4a59a70 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types index b259e30172d..532ef5511fa 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols index ccb78b1c367..97c6852b503 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types index 4fa4c085bca..304b9411bff 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols index 0bbffee6c86..5aae1a6cb2f 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types index 25cd47601e0..28ceac3ac91 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols index d3d3e3d1ed6..568c87d928f 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_TargetES6UsingES6Lib.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types index 5b96ce987bc..c1005cadca6 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U): U[]; (iterable: Iterable, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (iterable: Iterable): T[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols index ce03d4cfc59..90a88d4fbaa 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.symbols @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_UsingES5LibAndES6ArrayLib.ts, 2, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types index a097b116186..b7ab82ffb7d 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types @@ -9,9 +9,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols index 0ed5ec38513..83ae1ac5f08 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.symbols @@ -7,9 +7,9 @@ function f(x: number, y: number, z: number) { >z : Symbol(z, Decl(modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.ts, 1, 32)) return Array.from(arguments); ->Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Array : Symbol(Array, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >arguments : Symbol(arguments) } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types index 6accc7e7905..3515b6dc55d 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types @@ -8,9 +8,9 @@ function f(x: number, y: number, z: number) { return Array.from(arguments); >Array.from(arguments) : any[] ->Array.from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >Array : ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U): U[]; (arrayLike: ArrayLike, mapfn: (this: undefined, v: T, k: number) => U, thisArg: undefined): U[]; (arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): U[]; (arrayLike: ArrayLike): T[]; } >arguments : IArguments } diff --git a/tests/baselines/reference/nestedSelf.symbols b/tests/baselines/reference/nestedSelf.symbols index b9a9e91d36d..6fa6bb1b59f 100644 --- a/tests/baselines/reference/nestedSelf.symbols +++ b/tests/baselines/reference/nestedSelf.symbols @@ -10,8 +10,8 @@ module M { public foo() { [1,2,3].map((x) => { return this.n * x; })} >foo : Symbol(C.foo, Decl(nestedSelf.ts, 2, 17)) ->[1,2,3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[1,2,3].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >x : Symbol(x, Decl(nestedSelf.ts, 3, 31)) >this.n : Symbol(C.n, Decl(nestedSelf.ts, 1, 17)) >this : Symbol(C, Decl(nestedSelf.ts, 0, 10)) diff --git a/tests/baselines/reference/nestedSelf.types b/tests/baselines/reference/nestedSelf.types index 1ec95a8d24a..176e0dc28d3 100644 --- a/tests/baselines/reference/nestedSelf.types +++ b/tests/baselines/reference/nestedSelf.types @@ -12,13 +12,13 @@ module M { public foo() { [1,2,3].map((x) => { return this.n * x; })} >foo : () => void >[1,2,3].map((x) => { return this.n * x; }) : number[] ->[1,2,3].map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>[1,2,3].map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >[1,2,3] : number[] >1 : 1 >2 : 2 >3 : 3 ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } ->(x) => { return this.n * x; } : (x: number) => number +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } +>(x) => { return this.n * x; } : (this: undefined, x: number) => number >x : number >this.n * x : number >this.n : number diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols index 6cee1604cf0..e2e776cf72e 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols @@ -4,9 +4,9 @@ var regexMatchList = ['', '']; >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) regexMatchList.forEach(match => ''.replace(match, '')); ->regexMatchList.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>regexMatchList.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) >''.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types index 928185a0953..d7cb482a51c 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types @@ -8,10 +8,10 @@ var regexMatchList = ['', '']; regexMatchList.forEach(match => ''.replace(match, '')); >regexMatchList.forEach(match => ''.replace(match, '')) : void ->regexMatchList.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>regexMatchList.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >regexMatchList : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->match => ''.replace(match, '') : (match: string) => string +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>match => ''.replace(match, '') : (this: undefined, match: string) => string >match : string >''.replace(match, '') : string >''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } diff --git a/tests/baselines/reference/objectRestForOf.symbols b/tests/baselines/reference/objectRestForOf.symbols index f3786fed55f..d10b0de4d0e 100644 --- a/tests/baselines/reference/objectRestForOf.symbols +++ b/tests/baselines/reference/objectRestForOf.symbols @@ -32,9 +32,9 @@ for ({ x: xx, ...rrestOff } of array ) { } for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { >norest : Symbol(norest, Decl(objectRestForOf.ts, 9, 10)) ->array.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>array.map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >array : Symbol(array, Decl(objectRestForOf.ts, 0, 3)) ->map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >a : Symbol(a, Decl(objectRestForOf.ts, 9, 31)) >a : Symbol(a, Decl(objectRestForOf.ts, 9, 31)) >x : Symbol(x, Decl(objectRestForOf.ts, 9, 44)) diff --git a/tests/baselines/reference/objectRestForOf.types b/tests/baselines/reference/objectRestForOf.types index 2fde7566c74..b7d1d1ac7be 100644 --- a/tests/baselines/reference/objectRestForOf.types +++ b/tests/baselines/reference/objectRestForOf.types @@ -36,10 +36,10 @@ for ({ x: xx, ...rrestOff } of array ) { for (const norest of array.map(a => ({ ...a, x: 'a string' }))) { >norest : { x: string; y: string; } >array.map(a => ({ ...a, x: 'a string' })) : { x: string; y: string; }[] ->array.map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): U[]; } +>array.map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): U[]; } >array : { x: number; y: string; }[] ->map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg?: any): U[]; } ->a => ({ ...a, x: 'a string' }) : (a: { x: number; y: string; }) => { x: string; y: string; } +>map : { (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): [U, U]; (this: [{ x: number; y: string; }, { x: number; y: string; }], callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U): U[]; (callbackfn: (this: undefined, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: { x: number; y: string; }, index: number, array: { x: number; y: string; }[]) => U, thisArg: Z): U[]; } +>a => ({ ...a, x: 'a string' }) : (this: undefined, a: { x: number; y: string; }) => { x: string; y: string; } >a : { x: number; y: string; } >({ ...a, x: 'a string' }) : { x: string; y: string; } >{ ...a, x: 'a string' } : { x: string; y: string; } diff --git a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols index 23a1df25653..edb2c362fc2 100644 --- a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols +++ b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.symbols @@ -1,9 +1,9 @@ === tests/cases/compiler/simpleArrowFunctionParameterReferencedInObjectLiteral1.ts === [].map(() => [].map(p => ({ X: p }))); ->[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>[].map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >p : Symbol(p, Decl(simpleArrowFunctionParameterReferencedInObjectLiteral1.ts, 0, 20)) >X : Symbol(X, Decl(simpleArrowFunctionParameterReferencedInObjectLiteral1.ts, 0, 27)) >p : Symbol(p, Decl(simpleArrowFunctionParameterReferencedInObjectLiteral1.ts, 0, 20)) diff --git a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types index ff1640909d9..ad683ef2e15 100644 --- a/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types +++ b/tests/baselines/reference/simpleArrowFunctionParameterReferencedInObjectLiteral1.types @@ -1,15 +1,15 @@ === tests/cases/compiler/simpleArrowFunctionParameterReferencedInObjectLiteral1.ts === [].map(() => [].map(p => ({ X: p }))); >[].map(() => [].map(p => ({ X: p }))) : { X: any; }[][] ->[].map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>[].map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >[] : undefined[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >() => [].map(p => ({ X: p })) : () => { X: any; }[] >[].map(p => ({ X: p })) : { X: any; }[] ->[].map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } +>[].map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } >[] : undefined[] ->map : { (this: [any, any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U, U]; (this: [any, any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U, U]; (this: [any, any], callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[]; } ->p => ({ X: p }) : (p: any) => { X: any; } +>map : { (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [any, any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U, U]; (this: [any, any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U, U]; (this: [any, any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U, U]; (this: [any, any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): [U, U]; (this: [any, any], callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): [U, U]; (this: [any, any], callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U): U[]; (callbackfn: (this: undefined, value: any, index: number, array: any[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: any, index: number, array: any[]) => U, thisArg: Z): U[]; } +>p => ({ X: p }) : (this: undefined, p: any) => { X: any; } >p : any >({ X: p }) : { X: any; } >{ X: p } : { X: any; } diff --git a/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols b/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols index 7d5a6d979b3..8c8b372bbc8 100644 --- a/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols +++ b/tests/baselines/reference/specializationsShouldNotAffectEachOther.symbols @@ -23,9 +23,9 @@ function foo() { >series2 : Symbol(series2, Decl(specializationsShouldNotAffectEachOther.ts, 12, 7)) series2.map(seriesExtent); ->series2.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>series2.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >series2 : Symbol(series2, Decl(specializationsShouldNotAffectEachOther.ts, 12, 7)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >seriesExtent : Symbol(seriesExtent, Decl(specializationsShouldNotAffectEachOther.ts, 10, 7)) return null; @@ -34,11 +34,11 @@ function foo() { var keyExtent2: any[] = series.data.map(function (d: string) { return d; }); >keyExtent2 : Symbol(keyExtent2, Decl(specializationsShouldNotAffectEachOther.ts, 19, 3)) ->series.data.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>series.data.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >series.data : Symbol(Series.data, Decl(specializationsShouldNotAffectEachOther.ts, 1, 19)) >series : Symbol(series, Decl(specializationsShouldNotAffectEachOther.ts, 5, 3)) >data : Symbol(Series.data, Decl(specializationsShouldNotAffectEachOther.ts, 1, 19)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >d : Symbol(d, Decl(specializationsShouldNotAffectEachOther.ts, 19, 50)) >d : Symbol(d, Decl(specializationsShouldNotAffectEachOther.ts, 19, 50)) diff --git a/tests/baselines/reference/specializationsShouldNotAffectEachOther.types b/tests/baselines/reference/specializationsShouldNotAffectEachOther.types index aa14eca0508..d9c9b7baa20 100644 --- a/tests/baselines/reference/specializationsShouldNotAffectEachOther.types +++ b/tests/baselines/reference/specializationsShouldNotAffectEachOther.types @@ -26,9 +26,9 @@ function foo() { series2.map(seriesExtent); >series2.map(seriesExtent) : any[] ->series2.map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>series2.map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >series2 : number[] ->map : { (this: [number, number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U, U]; (this: [number, number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U, U]; (this: [number, number], callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any): U[]; } +>map : { (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [number, number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U, U]; (this: [number, number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U, U]; (this: [number, number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U, U]; (this: [number, number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): [U, U]; (this: [number, number], callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): [U, U]; (this: [number, number], callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U): U[]; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: number, index: number, array: number[]) => U, thisArg: Z): U[]; } >seriesExtent : (series: any) => any return null; @@ -39,12 +39,12 @@ function foo() { var keyExtent2: any[] = series.data.map(function (d: string) { return d; }); >keyExtent2 : any[] >series.data.map(function (d: string) { return d; }) : string[] ->series.data.map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } +>series.data.map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } >series.data : string[] >series : Series >data : string[] ->map : { (this: [string, string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U, U]; (this: [string, string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U, U]; (this: [string, string], callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any): U[]; } ->function (d: string) { return d; } : (d: string) => string +>map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } +>function (d: string) { return d; } : (this: undefined, d: string) => string >d : string >d : string diff --git a/tests/baselines/reference/targetTypeArgs.symbols b/tests/baselines/reference/targetTypeArgs.symbols index b0d825ddd50..d7c40a6a609 100644 --- a/tests/baselines/reference/targetTypeArgs.symbols +++ b/tests/baselines/reference/targetTypeArgs.symbols @@ -14,44 +14,44 @@ foo(function(x) { x }); >x : Symbol(x, Decl(targetTypeArgs.ts, 4, 13)) [1].forEach(function(v,i,a) { v }); ->[1].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>[1].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 6, 21)) >i : Symbol(i, Decl(targetTypeArgs.ts, 6, 23)) >a : Symbol(a, Decl(targetTypeArgs.ts, 6, 25)) >v : Symbol(v, Decl(targetTypeArgs.ts, 6, 21)) ["hello"].every(function(v,i,a) {return true;}); ->["hello"].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>["hello"].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 7, 25)) >i : Symbol(i, Decl(targetTypeArgs.ts, 7, 27)) >a : Symbol(a, Decl(targetTypeArgs.ts, 7, 29)) [1].every(function(v,i,a) {return true;}); ->[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 8, 19)) >i : Symbol(i, Decl(targetTypeArgs.ts, 8, 21)) >a : Symbol(a, Decl(targetTypeArgs.ts, 8, 23)) [1].every(function(v,i,a) {return true;}); ->[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>[1].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 9, 19)) >i : Symbol(i, Decl(targetTypeArgs.ts, 9, 21)) >a : Symbol(a, Decl(targetTypeArgs.ts, 9, 23)) ["s"].every(function(v,i,a) {return true;}); ->["s"].every : Symbol(Array.every, Decl(lib.d.ts, --, --)) ->every : Symbol(Array.every, Decl(lib.d.ts, --, --)) +>["s"].every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>every : Symbol(Array.every, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 10, 21)) >i : Symbol(i, Decl(targetTypeArgs.ts, 10, 23)) >a : Symbol(a, Decl(targetTypeArgs.ts, 10, 25)) ["s"].forEach(function(v,i,a) { v }); ->["s"].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>["s"].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >v : Symbol(v, Decl(targetTypeArgs.ts, 11, 23)) >i : Symbol(i, Decl(targetTypeArgs.ts, 11, 25)) >a : Symbol(a, Decl(targetTypeArgs.ts, 11, 27)) diff --git a/tests/baselines/reference/targetTypeArgs.types b/tests/baselines/reference/targetTypeArgs.types index 84985316aa2..e1bcb00ba15 100644 --- a/tests/baselines/reference/targetTypeArgs.types +++ b/tests/baselines/reference/targetTypeArgs.types @@ -19,11 +19,11 @@ foo(function(x) { x }); [1].forEach(function(v,i,a) { v }); >[1].forEach(function(v,i,a) { v }) : void ->[1].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1].forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } >[1] : number[] >1 : 1 ->forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void ->function(v,i,a) { v } : (v: number, i: number, a: number[]) => void +>forEach : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void): void; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: number, index: number, array: number[]) => void, thisArg: Z): void; } +>function(v,i,a) { v } : (this: undefined, v: number, i: number, a: number[]) => void >v : number >i : number >a : number[] @@ -31,11 +31,11 @@ foo(function(x) { x }); ["hello"].every(function(v,i,a) {return true;}); >["hello"].every(function(v,i,a) {return true;}) : boolean ->["hello"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>["hello"].every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } >["hello"] : string[] >"hello" : "hello" ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: string, i: number, a: string[]) => true >v : string >i : number >a : string[] @@ -43,11 +43,11 @@ foo(function(x) { x }); [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean ->[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>[1].every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >[1] : number[] >1 : 1 ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: number, i: number, a: number[]) => true >v : number >i : number >a : number[] @@ -55,11 +55,11 @@ foo(function(x) { x }); [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean ->[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean +>[1].every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } >[1] : number[] >1 : 1 ->every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true +>every : { (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean): boolean; (callbackfn: (this: undefined, value: number, index: number, array: number[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: number, index: number, array: number[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: number, i: number, a: number[]) => true >v : number >i : number >a : number[] @@ -67,11 +67,11 @@ foo(function(x) { x }); ["s"].every(function(v,i,a) {return true;}); >["s"].every(function(v,i,a) {return true;}) : boolean ->["s"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean +>["s"].every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } >["s"] : string[] >"s" : "s" ->every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true +>every : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean): boolean; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => boolean, thisArg: undefined): boolean; (callbackfn: (this: Z, value: string, index: number, array: string[]) => boolean, thisArg: Z): boolean; } +>function(v,i,a) {return true;} : (this: undefined, v: string, i: number, a: string[]) => true >v : string >i : number >a : string[] @@ -79,11 +79,11 @@ foo(function(x) { x }); ["s"].forEach(function(v,i,a) { v }); >["s"].forEach(function(v,i,a) { v }) : void ->["s"].forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>["s"].forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >["s"] : string[] >"s" : "s" ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function(v,i,a) { v } : (v: string, i: number, a: string[]) => void +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function(v,i,a) { v } : (this: undefined, v: string, i: number, a: string[]) => void >v : string >i : number >a : string[] diff --git a/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols b/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols index 6df8d8ac2ad..d7903e3328a 100644 --- a/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols +++ b/tests/baselines/reference/targetTypeObjectLiteralToAny.symbols @@ -9,9 +9,9 @@ function suggest(){ >result : Symbol(result, Decl(targetTypeObjectLiteralToAny.ts, 2, 4)) TypeScriptKeywords.forEach(function(keyword) { ->TypeScriptKeywords.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>TypeScriptKeywords.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >TypeScriptKeywords : Symbol(TypeScriptKeywords, Decl(targetTypeObjectLiteralToAny.ts, 1, 4)) ->forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >keyword : Symbol(keyword, Decl(targetTypeObjectLiteralToAny.ts, 4, 37)) result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any diff --git a/tests/baselines/reference/targetTypeObjectLiteralToAny.types b/tests/baselines/reference/targetTypeObjectLiteralToAny.types index 1dd81b33603..1364a5b2a23 100644 --- a/tests/baselines/reference/targetTypeObjectLiteralToAny.types +++ b/tests/baselines/reference/targetTypeObjectLiteralToAny.types @@ -10,10 +10,10 @@ function suggest(){ TypeScriptKeywords.forEach(function(keyword) { >TypeScriptKeywords.forEach(function(keyword) { result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any }) : void ->TypeScriptKeywords.forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void +>TypeScriptKeywords.forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } >TypeScriptKeywords : string[] ->forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void ->function(keyword) { result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any } : (keyword: string) => void +>forEach : { (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void): void; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => void, thisArg: undefined): void; (callbackfn: (this: Z, value: string, index: number, array: string[]) => void, thisArg: Z): void; } +>function(keyword) { result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any } : (this: undefined, keyword: string) => void >keyword : string result.push({text:keyword, type:"keyword"}); // this should not cause a crash - push should be typed to any diff --git a/tests/baselines/reference/tsxSpreadChildren.symbols b/tests/baselines/reference/tsxSpreadChildren.symbols index b2631c70fd9..2556b7c61b6 100644 --- a/tests/baselines/reference/tsxSpreadChildren.symbols +++ b/tests/baselines/reference/tsxSpreadChildren.symbols @@ -59,9 +59,9 @@ function TodoList({ todos }: TodoListProps) { >div : Symbol(JSX.IntrinsicElements, Decl(tsxSpreadChildren.tsx, 2, 22)) {...todos.map(todo => )} ->todos.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>todos.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >todos : Symbol(todos, Decl(tsxSpreadChildren.tsx, 19, 19)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >todo : Symbol(todo, Decl(tsxSpreadChildren.tsx, 21, 22)) >Todo : Symbol(Todo, Decl(tsxSpreadChildren.tsx, 15, 1)) >key : Symbol(key, Decl(tsxSpreadChildren.tsx, 21, 35)) diff --git a/tests/baselines/reference/tsxSpreadChildren.types b/tests/baselines/reference/tsxSpreadChildren.types index 1317499ff45..9ab9d7093d4 100644 --- a/tests/baselines/reference/tsxSpreadChildren.types +++ b/tests/baselines/reference/tsxSpreadChildren.types @@ -64,10 +64,10 @@ function TodoList({ todos }: TodoListProps) { {...todos.map(todo => )} >todos.map(todo => ) : JSX.Element[] ->todos.map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): U[]; } +>todos.map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): U[]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): U[]; } >todos : TodoProp[] ->map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TodoProp, index: number, array: TodoProp[]) => U, thisArg?: any): U[]; } ->todo => : (todo: TodoProp) => JSX.Element +>map : { (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U, U]; (this: [TodoProp, TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): [U, U]; (this: [TodoProp, TodoProp], callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U): U[]; (callbackfn: (this: undefined, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TodoProp, index: number, array: TodoProp[]) => U, thisArg: Z): U[]; } +>todo => : (this: undefined, todo: TodoProp) => JSX.Element >todo : TodoProp > : JSX.Element >Todo : (prop: { key: number; todo: string; }) => JSX.Element diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols index 766c75e2c13..d294a9c28cf 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.symbols @@ -15,9 +15,9 @@ var nodes: TreeNode[]; >TreeNode : Symbol(TreeNode, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 0)) nodes.map(n => n.name); ->nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 5, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) >n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 0, 17)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.ts, 6, 10)) diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types index 045b5e65da3..21332704326 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral01.types @@ -16,10 +16,10 @@ var nodes: TreeNode[]; nodes.map(n => n.name); >nodes.map(n => n.name) : string[] ->nodes.map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): U[]; } +>nodes.map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): U[]; } >nodes : TreeNode[] ->map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNode, index: number, array: TreeNode[]) => U, thisArg?: any): U[]; } ->n => n.name : (n: TreeNode) => string +>map : { (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNode, TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): [U, U]; (this: [TreeNode, TreeNode], callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNode, index: number, array: TreeNode[]) => U, thisArg: Z): U[]; } +>n => n.name : (this: undefined, n: TreeNode) => string >n : TreeNode >n.name : string >n : TreeNode diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols index 62e2b398827..3761994619c 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.symbols @@ -26,9 +26,9 @@ var nodes: TreeNodeMiddleman[]; >TreeNodeMiddleman : Symbol(TreeNodeMiddleman, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 3, 1)) nodes.map(n => n.name); ->nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>nodes.map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >nodes : Symbol(nodes, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 10, 3)) ->map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) >n.name : Symbol(name, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 5, 26)) >n : Symbol(n, Decl(typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.ts, 11, 10)) diff --git a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types index a75a997eb78..6cb4b81e0ce 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types +++ b/tests/baselines/reference/typeArgumentInferenceWithRecursivelyReferencedTypeAliasToTypeLiteral02.types @@ -27,10 +27,10 @@ var nodes: TreeNodeMiddleman[]; nodes.map(n => n.name); >nodes.map(n => n.name) : string[] ->nodes.map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): U[]; } +>nodes.map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): U[]; } >nodes : TreeNodeMiddleman[] ->map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): [U, U]; (callbackfn: (value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg?: any): U[]; } ->n => n.name : (n: TreeNodeMiddleman) => string +>map : { (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): [U, U]; (this: [TreeNodeMiddleman, TreeNodeMiddleman], callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U): U[]; (callbackfn: (this: undefined, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: TreeNodeMiddleman, index: number, array: TreeNodeMiddleman[]) => U, thisArg: Z): U[]; } +>n => n.name : (this: undefined, n: TreeNodeMiddleman) => string >n : TreeNodeMiddleman >n.name : string >n : TreeNodeMiddleman diff --git a/tests/baselines/reference/typedArrays.symbols b/tests/baselines/reference/typedArrays.symbols index 2d45fb7e5c1..ca7812bbcc8 100644 --- a/tests/baselines/reference/typedArrays.symbols +++ b/tests/baselines/reference/typedArrays.symbols @@ -167,65 +167,65 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 47, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 46, 44)) return typedArrays; @@ -242,65 +242,65 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { typedArrays[0] = Int8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[1] = Uint8Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[2] = Int16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[3] = Uint16Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[4] = Int32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[5] = Uint32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[6] = Float32Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[7] = Float64Array.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) typedArrays[8] = Uint8ClampedArray.from(obj); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 62, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 61, 47)) return typedArrays; @@ -458,73 +458,73 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n typedArrays[0] = Int8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[1] = Uint8Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[2] = Int16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[3] = Uint16Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[4] = Int32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[5] = Uint32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[6] = Float32Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[7] = Float64Array.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 107, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 106, 36)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 106, 58)) @@ -546,81 +546,81 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v typedArrays[0] = Int8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int8Array.from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int8Array : Symbol(Int8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8Array.from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8Array : Symbol(Uint8Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[2] = Int16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int16Array.from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int16Array : Symbol(Int16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint16Array.from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint16Array : Symbol(Uint16Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint16ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[4] = Int32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Int32Array.from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Int32Array : Symbol(Int32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Int32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint32Array.from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint32Array : Symbol(Uint32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[6] = Float32Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float32Array.from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float32Array : Symbol(Float32Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float32ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[7] = Float64Array.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Float64Array.from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Float64Array : Symbol(Float64Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Float64ArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg); >typedArrays : Symbol(typedArrays, Decl(typedArrays.ts, 122, 7)) ->Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>Uint8ClampedArray.from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Uint8ClampedArray : Symbol(Uint8ClampedArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) ->from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>from : Symbol(Uint8ClampedArrayConstructor.from, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >obj : Symbol(obj, Decl(typedArrays.ts, 121, 38)) >mapFn : Symbol(mapFn, Decl(typedArrays.ts, 121, 60)) >thisArg : Symbol(thisArg, Decl(typedArrays.ts, 121, 98)) diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index 444d6a74e43..24924a5810e 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -274,9 +274,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : number[] typedArrays[1] = Uint8Array.from(obj); @@ -285,9 +285,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : number[] typedArrays[2] = Int16Array.from(obj); @@ -296,9 +296,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : number[] typedArrays[3] = Uint16Array.from(obj); @@ -307,9 +307,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : number[] typedArrays[4] = Int32Array.from(obj); @@ -318,9 +318,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : number[] typedArrays[5] = Uint32Array.from(obj); @@ -329,9 +329,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : number[] typedArrays[6] = Float32Array.from(obj); @@ -340,9 +340,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : number[] typedArrays[7] = Float64Array.from(obj); @@ -351,9 +351,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : number[] typedArrays[8] = Uint8ClampedArray.from(obj); @@ -362,9 +362,9 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : number[] return typedArrays; @@ -386,9 +386,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >0 : 0 >Int8Array.from(obj) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike typedArrays[1] = Uint8Array.from(obj); @@ -397,9 +397,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >1 : 1 >Uint8Array.from(obj) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike typedArrays[2] = Int16Array.from(obj); @@ -408,9 +408,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >2 : 2 >Int16Array.from(obj) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike typedArrays[3] = Uint16Array.from(obj); @@ -419,9 +419,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >3 : 3 >Uint16Array.from(obj) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike typedArrays[4] = Int32Array.from(obj); @@ -430,9 +430,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >4 : 4 >Int32Array.from(obj) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike typedArrays[5] = Uint32Array.from(obj); @@ -441,9 +441,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >5 : 5 >Uint32Array.from(obj) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike typedArrays[6] = Float32Array.from(obj); @@ -452,9 +452,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >6 : 6 >Float32Array.from(obj) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike typedArrays[7] = Float64Array.from(obj); @@ -463,9 +463,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >7 : 7 >Float64Array.from(obj) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike typedArrays[8] = Uint8ClampedArray.from(obj); @@ -474,9 +474,9 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike return typedArrays; @@ -758,9 +758,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -770,9 +770,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -782,9 +782,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -794,9 +794,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -806,9 +806,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -818,9 +818,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -830,9 +830,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -842,9 +842,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -854,9 +854,9 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number @@ -883,9 +883,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >0 : 0 >Int8Array.from(obj, mapFn, thisArg) : Int8Array ->Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>Int8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >Int8Array : Int8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: ArrayLike): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; (arrayLike: Iterable): Int8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -896,9 +896,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >1 : 1 >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array ->Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>Uint8Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >Uint8Array : Uint8ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: ArrayLike): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; (arrayLike: Iterable): Uint8Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -909,9 +909,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >2 : 2 >Int16Array.from(obj, mapFn, thisArg) : Int16Array ->Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>Int16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >Int16Array : Int16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: ArrayLike): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; (arrayLike: Iterable): Int16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -922,9 +922,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >3 : 3 >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array ->Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>Uint16Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >Uint16Array : Uint16ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: ArrayLike): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint16Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint16Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; (arrayLike: Iterable): Uint16Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -935,9 +935,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >4 : 4 >Int32Array.from(obj, mapFn, thisArg) : Int32Array ->Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>Int32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >Int32Array : Int32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: ArrayLike): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Int32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Int32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; (arrayLike: Iterable): Int32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -948,9 +948,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >5 : 5 >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array ->Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>Uint32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >Uint32Array : Uint32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: ArrayLike): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; (arrayLike: Iterable): Uint32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -961,9 +961,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >6 : 6 >Float32Array.from(obj, mapFn, thisArg) : Float32Array ->Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>Float32Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >Float32Array : Float32ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: ArrayLike): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float32Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float32Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; (arrayLike: Iterable): Float32Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -974,9 +974,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >7 : 7 >Float64Array.from(obj, mapFn, thisArg) : Float64Array ->Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>Float64Array.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >Float64Array : Float64ArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: ArrayLike): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Float64Array; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Float64Array; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; (arrayLike: Iterable): Float64Array; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} @@ -987,9 +987,9 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays : any[] >8 : 8 >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray ->Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor ->from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } +>from : { (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: ArrayLike): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: undefined, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; (arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; (arrayLike: Iterable): Uint8ClampedArray; } >obj : ArrayLike >mapFn : (n: number, v: number) => number >thisArg : {} From 3f980bead0bac4865fd64d14e37c158e118dc0af Mon Sep 17 00:00:00 2001 From: DLehenbauer Date: Fri, 10 Mar 2017 07:10:58 -0800 Subject: [PATCH 054/207] Remove vestiges of WScript support (Issue #14414) --- Jakefile.js | 8 +- src/compiler/diagnosticMessages.json | 4 - src/compiler/program.ts | 7 +- src/compiler/sys.ts | 156 --------------------------- src/harness/harness.ts | 100 ++--------------- src/tsconfig-base.json | 4 +- 6 files changed, 13 insertions(+), 266 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 595875dfc32..9f075f7c056 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -333,7 +333,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --lib " + opts.lib } else { - options += " --lib es5,scripthost" + options += " --lib es5" } options += " --noUnusedLocals --noUnusedParameters"; @@ -587,13 +587,13 @@ var cancellationTokenFile = path.join(builtLocalDirectory, "cancellationToken.js compileFile(cancellationTokenFile, cancellationTokenSources, [builtLocalDirectory].concat(cancellationTokenSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: true, lib: "es6" }); var typingsInstallerFile = path.join(builtLocalDirectory, "typingsInstaller.js"); -compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6,scripthost" }); +compileFile(typingsInstallerFile, typingsInstallerSources, [builtLocalDirectory].concat(typingsInstallerSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" }); var watchGuardFile = path.join(builtLocalDirectory, "watchGuard.js"); compileFile(watchGuardFile, watchGuardSources, [builtLocalDirectory].concat(watchGuardSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], outDir: builtLocalDirectory, noOutFile: false, lib: "es6" }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6,scripthost" }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright, cancellationTokenFile, typingsInstallerFile, watchGuardFile].concat(serverSources).concat(servicesSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"], preserveConstEnums: true, lib: "es6" }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( @@ -717,7 +717,7 @@ compileFile( /*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), /*prefixes*/[], /*useBuiltCompiler:*/ true, - /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6,scripthost" }); + /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"], lib: "es6" }); var internalTests = "internal/"; diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 318f06ceeaa..919158645a4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2413,10 +2413,6 @@ "category": "Error", "code": 5012 }, - "Unsupported file encoding.": { - "category": "Error", - "code": 5013 - }, "Failed to parse file '{0}': {1}.": { "category": "Error", "code": 5014 diff --git a/src/compiler/program.ts b/src/compiler/program.ts index abb8b0b2f09..e117761a3a3 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -87,9 +87,6 @@ namespace ts { return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - // returned by CScript sys environment - const unsupportedFileEncodingErrorCode = -2147024809; - function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { let text: string; try { @@ -100,9 +97,7 @@ namespace ts { } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? createCompilerDiagnostic(Diagnostics.Unsupported_file_encoding).messageText - : e.message); + onError(e.message); } text = ""; } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 2a15df80102..3f585900654 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -74,13 +74,6 @@ namespace ts { return parseInt(version.substring(1, dot)); } - declare class Enumerator { - public atEnd(): boolean; - public moveNext(): boolean; - public item(): any; - constructor(o: any); - } - declare var ChakraHost: { args: string[]; currentDirectory: string; @@ -104,152 +97,6 @@ namespace ts { }; export let sys: System = (function() { - - function getWScriptSystem(): System { - - const fso = new ActiveXObject("Scripting.FileSystemObject"); - const shell = new ActiveXObject("WScript.Shell"); - - const fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2 /*text*/; - - const binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1 /*binary*/; - - const args: string[] = []; - for (let i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - - function readFile(fileName: string, encoding?: string): string { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - // Load file and read the first two bytes into a string with no interpretation - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - const bom = fileStream.ReadText(2) || ""; - // Position must be at 0 before encoding can be changed - fileStream.Position = 0; - // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - // ReadText method always strips byte order mark from resulting string - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - - function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { - fileStream.Open(); - binaryStream.Open(); - try { - // Write characters in UTF-8 encoding - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). - // If not, start from position 0, as the BOM will be added automatically when charset==utf8. - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2 /*overwrite*/); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - - function getNames(collection: any): string[] { - const result: string[] = []; - for (const e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - - function getDirectories(path: string): string[] { - const folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - - function getAccessibleFileSystemEntries(path: string): FileSystemEntries { - try { - const folder = fso.GetFolder(path || "."); - const files = getNames(folder.files); - const directories = getNames(folder.subfolders); - return { files, directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - - function readDirectory(path: string, extensions?: string[], excludes?: string[], includes?: string[]): string[] { - return matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - - const wscriptSystem: System = { - args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write(s: string): void { - WScript.StdOut.Write(s); - }, - readFile, - writeFile, - resolvePath(path: string): string { - return fso.GetAbsolutePathName(path); - }, - fileExists(path: string): boolean { - return fso.FileExists(path); - }, - directoryExists(path: string) { - return fso.FolderExists(path); - }, - createDirectory(directoryName: string) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath() { - return WScript.ScriptFullName; - }, - getCurrentDirectory() { - return shell.CurrentDirectory; - }, - getDirectories, - getEnvironmentVariable(name: string) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings(`%${name}%`); - }, - readDirectory, - exit(exitCode?: number): void { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; - } - function getNodeSystem(): System { const _fs = require("fs"); const _path = require("path"); @@ -646,9 +493,6 @@ namespace ts { if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { // process and process.nextTick checks if current environment is node-like // process.browser check excludes webpack and browserify diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 23e8106864a..57041a1f2e3 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -34,12 +34,6 @@ var _chai: typeof chai = require("chai"); var assert: typeof _chai.assert = _chai.assert; declare var __dirname: string; // Node-specific var global: NodeJS.Global = Function("return this").call(undefined); -declare namespace NodeJS { - export interface Global { - WScript: typeof WScript; - ActiveXObject: typeof ActiveXObject; - } -} declare var window: {}; declare var XMLHttpRequest: { @@ -60,14 +54,10 @@ namespace Utils { export const enum ExecutionEnvironment { Node, Browser, - CScript } export function getExecutionEnvironment() { - if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - return ExecutionEnvironment.CScript; - } - else if (typeof window !== "undefined") { + if (typeof window !== "undefined") { return ExecutionEnvironment.Browser; } else { @@ -93,7 +83,6 @@ namespace Utils { export function evalFile(fileContents: string, fileName: string, nodeContext?: any) { const environment = getExecutionEnvironment(); switch (environment) { - case ExecutionEnvironment.CScript: case ExecutionEnvironment.Browser: eval(fileContents); break; @@ -516,83 +505,6 @@ namespace Harness { export const virtualFileSystemRoot = "/"; namespace IOImpl { - declare class Enumerator { - public atEnd(): boolean; - public moveNext(): boolean; - public item(): any; - constructor(o: any); - } - - export namespace CScript { - let fso: any; - if (global.ActiveXObject) { - fso = new global.ActiveXObject("Scripting.FileSystemObject"); - } - else { - fso = {}; - } - - export const args = () => ts.sys.args; - export const getExecutingFilePath = () => ts.sys.getExecutingFilePath(); - export const exit = (exitCode: number) => ts.sys.exit(exitCode); - export const resolvePath = (path: string) => ts.sys.resolvePath(path); - export const getCurrentDirectory = () => ts.sys.getCurrentDirectory(); - export const newLine = () => harnessNewLine; - export const useCaseSensitiveFileNames = () => ts.sys.useCaseSensitiveFileNames; - - export const readFile: typeof IO.readFile = path => ts.sys.readFile(path); - export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content); - export const directoryName: typeof IO.directoryName = fso.GetParentFolderName; - export const getDirectories: typeof IO.getDirectories = dir => ts.sys.getDirectories(dir); - export const directoryExists: typeof IO.directoryExists = fso.FolderExists; - export const fileExists: typeof IO.fileExists = fso.FileExists; - export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; - export const getEnvironmentVariable: typeof IO.getEnvironmentVariable = name => ts.sys.getEnvironmentVariable(name); - export const readDirectory: typeof IO.readDirectory = (path, extension, exclude, include) => ts.sys.readDirectory(path, extension, exclude, include); - - export function createDirectory(path: string) { - if (directoryExists(path)) { - fso.CreateFolder(path); - } - } - - export function deleteFile(path: string) { - if (fileExists(path)) { - fso.DeleteFile(path, true); // true: delete read-only files - } - } - - export let listFiles: typeof IO.listFiles = (path, spec?, options?) => { - options = options || <{ recursive?: boolean; }>{}; - function filesInFolder(folder: any, root: string): string[] { - let paths: string[] = []; - let fc: any; - - if (options.recursive) { - fc = new Enumerator(folder.subfolders); - - for (; !fc.atEnd(); fc.moveNext()) { - paths = paths.concat(filesInFolder(fc.item(), root + "\\" + fc.item().Name)); - } - } - - fc = new Enumerator(folder.files); - - for (; !fc.atEnd(); fc.moveNext()) { - if (!spec || fc.item().Name.match(spec)) { - paths.push(root + "\\" + fc.item().Name); - } - } - - return paths; - } - - const folder: any = fso.GetFolder(path); - - return filesInFolder(folder, path); - }; - } - export namespace Node { declare const require: any; let fs: any, pathModule: any; @@ -840,16 +752,16 @@ namespace Harness { } } - switch (Utils.getExecutionEnvironment()) { - case Utils.ExecutionEnvironment.CScript: - IO = IOImpl.CScript; - break; + const environment = Utils.getExecutionEnvironment(); + switch (environment) { case Utils.ExecutionEnvironment.Node: IO = IOImpl.Node; break; case Utils.ExecutionEnvironment.Browser: IO = IOImpl.Network; break; + default: + throw new Error(`Unknown value '${environment}' for ExecutionEnvironment'.`); } } @@ -873,7 +785,7 @@ namespace Harness { /** Aggregate various writes into a single array of lines. Useful for passing to the * TypeScript compiler to fill with source code or errors. */ - export class WriterAggregator implements ITextWriter { + export class WriterAggregator { public lines: string[] = []; public currentLine = undefined; diff --git a/src/tsconfig-base.json b/src/tsconfig-base.json index 078fdcc91e7..caf8e880fad 100644 --- a/src/tsconfig-base.json +++ b/src/tsconfig-base.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "lib": ["es5", "scripthost"], + "lib": ["es5"], "noEmitOnError": true, "noImplicitAny": true, "noImplicitThis": true, @@ -13,4 +13,4 @@ "target": "es5", "types": [] } -} \ No newline at end of file +} From 17cb68cbbf3754342c950990c4705d74bba8b15e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Fri, 10 Mar 2017 10:34:01 -0800 Subject: [PATCH 055/207] send error if obtaining of types-registry package failed (#14573) --- src/server/protocol.ts | 11 +++++++++++ src/server/server.ts | 14 +++++++++++++- src/server/shared.ts | 1 + src/server/types.ts | 8 +++++++- .../typingsInstaller/nodeTypingsInstaller.ts | 14 +++++++++++++- 5 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index d054867cd1c..d12aa2e0a48 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2127,6 +2127,17 @@ namespace ts.server.protocol { payload: any; } + export type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + + export interface TypesInstallerInitializationFailedEvent extends Event { + event: TypesInstallerInitializationFailedEventName; + body: TypesInstallerInitializationFailedEventBody; + } + + export interface TypesInstallerInitializationFailedEventBody { + message: string; + } + export type TypingsInstalledTelemetryEventName = "typingsInstalled"; export interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { diff --git a/src/server/server.ts b/src/server/server.ts index 475e5cdf920..bfd4e422047 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -304,11 +304,23 @@ namespace ts.server { }); } - private handleMessage(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes) { + private handleMessage(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | InitializationFailedResponse) { if (this.logger.hasLevel(LogLevel.verbose)) { this.logger.info(`Received response: ${JSON.stringify(response)}`); } + if (response.kind === EventInitializationFailed) { + if (!this.eventSender) { + return; + } + const body: protocol.TypesInstallerInitializationFailedEventBody = { + message: response.message + } + const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + this.eventSender.event(body, eventName); + return; + } + if (response.kind === EventBeginInstallTypes) { if (!this.eventSender) { return; diff --git a/src/server/shared.ts b/src/server/shared.ts index 77f66fc5a2d..5d65f8c90e9 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -5,6 +5,7 @@ namespace ts.server { export const ActionInvalidate: ActionInvalidate = "action::invalidate"; export const EventBeginInstallTypes: EventBeginInstallTypes = "event::beginInstallTypes"; export const EventEndInstallTypes: EventEndInstallTypes = "event::endInstallTypes"; + export const EventInitializationFailed: EventInitializationFailed = "event::initializationFailed"; export namespace Arguments { export const GlobalCacheLocation = "--globalTypingsCacheLocation"; diff --git a/src/server/types.ts b/src/server/types.ts index 6edf424cbe6..81e1f09639f 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -47,9 +47,15 @@ declare namespace ts.server { export type ActionInvalidate = "action::invalidate"; export type EventBeginInstallTypes = "event::beginInstallTypes"; export type EventEndInstallTypes = "event::endInstallTypes"; + export type EventInitializationFailed = "event::initializationFailed"; export interface TypingInstallerResponse { - readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; + readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed; + } + + export interface InitializationFailedResponse extends TypingInstallerResponse { + readonly kind: EventInitializationFailed; + readonly message: string; } export interface ProjectResponse extends TypingInstallerResponse { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index b9d08937467..74497504ba3 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -74,6 +74,8 @@ namespace ts.server.typingsInstaller { private readonly npmPath: string; readonly typesRegistry: Map; + private delayedInitializationError: InitializationFailedResponse; + constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) { super( sys, @@ -99,6 +101,11 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Error updating ${TypesRegistryPackageName} package: ${(e).message}`); } + // store error info to report it later when it is known that server is already listening to events from typings installer + this.delayedInitializationError = { + kind: "event::initializationFailed", + message: (e).message + }; } this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), this.installTypingHost, this.log); @@ -106,6 +113,11 @@ namespace ts.server.typingsInstaller { listen() { process.on("message", (req: DiscoverTypings | CloseProject) => { + if (this.delayedInitializationError) { + // report initializationFailed error + this.sendResponse(this.delayedInitializationError); + this.delayedInitializationError = undefined; + } switch (req.kind) { case "discover": this.install(req); @@ -116,7 +128,7 @@ namespace ts.server.typingsInstaller { }); } - protected sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes) { + protected sendResponse(response: SetTypings | InvalidateCachedTypings | BeginInstallTypes | EndInstallTypes | InitializationFailedResponse) { if (this.log.isEnabled()) { this.log.writeLine(`Sending response: ${JSON.stringify(response)}`); } From 746b7e4798595b518f2c2778a78607045ea9d472 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 10 Mar 2017 10:42:26 -0800 Subject: [PATCH 056/207] Expose `forEachChild` as a method of Node --- src/services/services.ts | 8 ++++++++ src/services/types.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/services/services.ts b/src/services/services.ts index df5330ebaed..0a4733cf98a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -209,6 +209,10 @@ namespace ts { return child.kind < SyntaxKind.FirstNode ? child : child.getLastToken(sourceFile); } + + public forEachChild(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T { + return forEachChild(this, cbNode, cbNodeArray); + } } class TokenOrIdentifierObject implements Node { @@ -282,6 +286,10 @@ namespace ts { public getLastToken(): Node { return undefined; } + + public forEachChild(): T { + return undefined; + } } class SymbolObject implements Symbol { diff --git a/src/services/types.ts b/src/services/types.ts index c7852db6d6e..f67cc6b918f 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -14,6 +14,8 @@ namespace ts { getText(sourceFile?: SourceFile): string; getFirstToken(sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; + // See ts.forEachChild for documentation. + forEachChild(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; } export interface Symbol { From 2980231b5ee3c89b70a4d1ff8a465bfbecc5efc3 Mon Sep 17 00:00:00 2001 From: Christophe Vidal Date: Sat, 11 Mar 2017 01:55:50 +0700 Subject: [PATCH 057/207] Updated quick start & handbook links in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f631439eb0..d21e558360c 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ with any additional questions or comments. ## Documentation -* [Quick tutorial](http://www.typescriptlang.org/Tutorial) -* [Programming handbook](http://www.typescriptlang.org/Handbook) +* [Quick tutorial](http://www.typescriptlang.org/docs/tutorial.html) +* [Programming handbook](http://www.typescriptlang.org/docs/handbook/basic-types.html) * [Language specification](https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md) * [Homepage](http://www.typescriptlang.org/) @@ -95,4 +95,4 @@ node built/local/tsc.js hello.ts ## Roadmap -For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap). \ No newline at end of file +For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap). From 7532ab2d830ff24c186160ec7aa2a80ef9fc79a0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 10 Mar 2017 17:25:31 -0800 Subject: [PATCH 058/207] Remove stray apostrophe. --- src/harness/harness.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 57041a1f2e3..29eec356148 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -761,7 +761,7 @@ namespace Harness { IO = IOImpl.Network; break; default: - throw new Error(`Unknown value '${environment}' for ExecutionEnvironment'.`); + throw new Error(`Unknown value '${environment}' for ExecutionEnvironment.`); } } From fd65966a5028d3403dda934f97fe285cee427198 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 10 Mar 2017 21:18:18 -0800 Subject: [PATCH 059/207] temp --- src/compiler/checker.ts | 191 ++++++++++++++++++++++++++++++++++++++++ src/compiler/factory.ts | 37 +++++++- src/compiler/types.ts | 21 +++-- 3 files changed, 240 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa7908f52c1..109e6f33ea3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2388,11 +2388,198 @@ namespace ts { } } + function createTypeNode(type: Type) { + let encounteredError = false; + let checkAlias = true; + + return createTypeNodeWorker(type); + + function createTypeNodeWorker(type: Type): TypeNode { + if(!type) { + return undefined; + } + + if (checkAlias && type.aliasSymbol) { + const name = getNameOfSymbol(type.aliasSymbol); + const typeArguments = mapToTypeNodeArray(type.aliasTypeArguments); + return createTypeReferenceNode(createIdentifier(name), typeArguments); + } + checkAlias = false; + + + if(type.flags & TypeFlags.Any) { + // TODO: add other case where type ends up being `any`. + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if(type.flags & TypeFlags.String) { + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if(type.flags & TypeFlags.Number) { + return createKeywordTypeNode(SyntaxKind.NumberKeyword); + } + if(type.flags & (TypeFlags.Boolean | TypeFlags.StringOrNumberLiteral)) { + // TODO: check if this actually works with boolean. + return createLiteralTypeNode((type).text); + } + if(type.flags & TypeFlags.Void) { + return createKeywordTypeNode(SyntaxKind.VoidKeyword); + } + if(type.flags & TypeFlags.Undefined) { + return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); + } + if(type.flags & TypeFlags.Null) { + return createKeywordTypeNode(SyntaxKind.NullKeyword); + } + if(type.flags & TypeFlags.Never) { + return createKeywordTypeNode(SyntaxKind.NeverKeyword); + } + if(type.flags & TypeFlags.Enum) { + throw new Error("not implemented"); + } + if(type.flags & TypeFlags.ESSymbol) { + throw new Error("not implemented"); + } + if(type.flags & TypeFlags.TypeParameter) { + const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)); + const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)); + if(!type.symbol) { + encounteredError = true; + throw new Error("No symbol for type parameter so can't get name"); + } + const name = getNameOfSymbol(type.symbol); + return createTypeParameterNode(name, constraint, defaultParameter); + } + if(type.flags & TypeFlags.Union) { + throw new Error("not implemented"); + } + if(type.flags & TypeFlags.Intersection) { + throw new Error("not implemented"); + } + if(type.flags & TypeFlags.Index) { + throw new Error("not implemented"); + } + if(type.flags & TypeFlags.IndexedAccess) { + throw new Error("not implemented"); + } + + // if(type.flags & TypeFlags.Object) { + // throw new Error("not implemented"); + // } + + // TODO: should these be within the if above (check with asserts) + const objectFlags = getObjectFlags(type); + + if (objectFlags & ObjectFlags.ClassOrInterface) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, + // type must be an anonymous class or interface. + return false; + } + + if (objectFlags & ObjectFlags.Reference) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // and vice versa. + // this case includes tuple types + const typeArguments = (type as TypeReference).typeArguments || emptyArray; + return allTypesVisible(typeArguments); + } + + // keyword types + // this type node + // function type node + // constructor type node + // type reference node + // type predicate node - is Foo (for return types) + // type query node -- typeof number + // type literal node (like object literal) + // array type + // tuple type + // union type + // might need parens + // intersection type + // Type operator node (eg (ie?): keyof T) + // IndexedAccess Type Node + // mapped type node + // literal type node + + // if (inTypeAlias && type.aliasSymbol) { + // return isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/false).accessibility === SymbolAccessibility.Accessible + // && (!type.aliasTypeArguments || allTypesVisible(type.aliasTypeArguments)); + // } + // const typeSymbolAccessibility = type.symbol && isSymbolAccessible(type.symbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility; + // if (type.flags & TypeFlags.TypeParameter) { + // if (inObjectLiteral && (type as TypeParameter).isThisType) { + // return false; + // } + // const constraint = getConstraintFromTypeParameter((type)); + // return typeSymbolAccessibility === SymbolAccessibility.Accessible + // && (!constraint || isTypeAccessibleWorker(constraint, inObjectLiteral, /*inTypeAlias*/false)); + // } + // if (typeSymbolAccessibility === SymbolAccessibility.Accessible) { + // return true; + // } + // if (type.flags & (TypeFlags.Intrinsic | TypeFlags.Literal)) { + // return true; + // } + // const objectFlags = getObjectFlags(type); + // if (objectFlags & ObjectFlags.ClassOrInterface) { + // // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, + // // type must be an anonymous class or interface. + // return false; + // } + // if (objectFlags & ObjectFlags.Reference) { + // // and vice versa. + // // this case includes tuple types + // const typeArguments = (type as TypeReference).typeArguments || emptyArray; + // return allTypesVisible(typeArguments); + // } + // if (type.flags & TypeFlags.UnionOrIntersection) { + // return allTypesVisible((type as UnionOrIntersectionType).types); + // } + + if (objectFlags & ObjectFlags.Mapped) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const typeParameter = getTypeParameterFromMappedType(type); + const constraintType = getConstraintTypeFromMappedType(type); + const templateType = getTemplateTypeFromMappedType(type); + } + + if (objectFlags & ObjectFlags.Anonymous) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // The type is an object literal type. + if (!type.symbol) { + // Anonymous types without symbols are literals. + return true; + } + // what case is this? + const members = type.symbol.members; + let allVisible = true; + members && members.forEach((member) => { + const memberType = getTypeOfSymbolAtLocation(member, enclosingDeclaration); + allVisible = allVisible && isTypeAccessibleWorker(memberType, /*inObjectLiteral*/ true, /*inTypeAlias*/false); + }); + return allVisible; + } + + Debug.fail("Should be unreachable here"); + + /** Note that mapToTypeNodeArray(undefined) === undefined. */ + function mapToTypeNodeArray(types: Type[]): NodeArray { + return asNodeArray(types && types.map(createTypeNodeWorker)); + } + // function allTypesVisible(types: Type[]): boolean { + // return types.every(type => isTypeAccessibleWorker(type, inObjectLiteral, /*inTypeAlias*/false)); + // } + } + } + function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { const globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; let inObjectTypeLiteral = false; return writeType(type, globalFlags); + const typeNode = createTypeNode(type, enclosingDeclaration); + function writeType(type: Type, flags: TypeFormatFlags) { const nextFlags = flags & ~TypeFormatFlags.InTypeAlias; // Write undefined/null type as any @@ -6939,6 +7126,10 @@ namespace ts { } } + // export function synthesizeTypeNode(type: Type, enclosingDeclaration: Node): TypeNode { + // throw new Error("Not implemented" + enclosingDeclaration); + // } + function instantiateList(items: T[], mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): T[] { if (items && items.length) { const result: T[] = []; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 669c66c4337..1e5395fe7b2 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -213,8 +213,43 @@ namespace ts { : node; } + // Types + + export function createLiteralTypeNode(value: string | number | boolean) { + const literal = createLiteral(value); + const literalTypeNode = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; + literalTypeNode.literal = literal; + return literalTypeNode; + } + + export function createTypeReferenceNode(typeName: string | EntityName, typeArguments?: NodeArray) { + const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; + typeReference.typeName = asName(typeName); + typeReference.typeName.parent + typeReference.typeArguments = typeArguments; + return typeReference; + } + + export function createTypeParameterNode(name: string | Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { + const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; + typeParameter.name = asName(name); + typeParameter.constraint = constraint; + typeParameter.default = defaultParameter; + + return typeParameter; + } + // Signature elements + export function createSignature(kind: SyntaxKind, parameters: NodeArray, name?: PropertyName, typeParameters?: NodeArray, returnType?: TypeNode): SignatureDeclaration { + const signature = createSynthesizedNode(kind) as SignatureDeclaration; + signature.parameters = parameters; + signature.name = name; + signature.typeParameters = typeParameters; + signature.type = returnType; + return signature; + } + export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { const node = createSynthesizedNode(SyntaxKind.Parameter); node.decorators = asNodeArray(decorators); @@ -1801,7 +1836,7 @@ namespace ts { return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - function asNodeArray(array: T[] | undefined): NodeArray | undefined { + export function asNodeArray(array: T[] | undefined): NodeArray | undefined { return array ? createNodeArray(array) : undefined; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1492a106d2b..52207920b48 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -849,14 +849,19 @@ namespace ts { _typeNodeBrand: any; } + export type KeywordKind = SyntaxKind.AnyKeyword + | SyntaxKind.NumberKeyword + | SyntaxKind.ObjectKeyword + | SyntaxKind.BooleanKeyword + | SyntaxKind.StringKeyword + | SyntaxKind.SymbolKeyword + | SyntaxKind.VoidKeyword + | SyntaxKind.UndefinedKeyword + | SyntaxKind.NullKeyword + | SyntaxKind.NeverKeyword; + export interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword - | SyntaxKind.NumberKeyword - | SyntaxKind.ObjectKeyword - | SyntaxKind.BooleanKeyword - | SyntaxKind.StringKeyword - | SyntaxKind.SymbolKeyword - | SyntaxKind.VoidKeyword; + kind: KeywordKind; } export interface ThisTypeNode extends TypeNode { @@ -892,7 +897,7 @@ namespace ts { exprName: EntityName; } - // A TypeLiteral is the declaration node for an anonymous symbol. + /** A TypeLiteral is the declaration node for an anonymous symbol. */ export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; From 205f63891edf75844a4eda8fce81916b9bd72819 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 10 Mar 2017 22:13:58 -0800 Subject: [PATCH 060/207] Fix Per Request Cancellation Tokens While working on https://github.com/Microsoft/vscode/pull/22437, I believe there is a bug in the per request cancellation in the `setRequest` function on the line `currentRequestId = currentRequestId ;` This causes `currentRequestId` to always be undefined Fix is to assign the `currentRequestId` to `requestId` --- src/server/cancellationToken/cancellationToken.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/cancellationToken/cancellationToken.ts b/src/server/cancellationToken/cancellationToken.ts index 0e7969c1e45..6f2f4a8897c 100644 --- a/src/server/cancellationToken/cancellationToken.ts +++ b/src/server/cancellationToken/cancellationToken.ts @@ -48,7 +48,7 @@ function createCancellationToken(args: string[]): ServerCancellationToken { return { isCancellationRequested: () => perRequestPipeName !== undefined && pipeExists(perRequestPipeName), setRequest(requestId: number) { - currentRequestId = currentRequestId; + currentRequestId = requestId; perRequestPipeName = namePrefix + requestId; }, resetRequest(requestId: number) { @@ -67,4 +67,4 @@ function createCancellationToken(args: string[]): ServerCancellationToken { }; } } -export = createCancellationToken; \ No newline at end of file +export = createCancellationToken; From c6693983f42d570fd4b30f73c2c4506d11a6b326 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sat, 11 Mar 2017 09:10:26 -0800 Subject: [PATCH 061/207] Revert "temp" This reverts commit fd65966a5028d3403dda934f97fe285cee427198. Accidentally pushed to the wrong branch. --- src/compiler/checker.ts | 191 ---------------------------------------- src/compiler/factory.ts | 37 +------- src/compiler/types.ts | 21 ++--- 3 files changed, 9 insertions(+), 240 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 109e6f33ea3..aa7908f52c1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2388,198 +2388,11 @@ namespace ts { } } - function createTypeNode(type: Type) { - let encounteredError = false; - let checkAlias = true; - - return createTypeNodeWorker(type); - - function createTypeNodeWorker(type: Type): TypeNode { - if(!type) { - return undefined; - } - - if (checkAlias && type.aliasSymbol) { - const name = getNameOfSymbol(type.aliasSymbol); - const typeArguments = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(createIdentifier(name), typeArguments); - } - checkAlias = false; - - - if(type.flags & TypeFlags.Any) { - // TODO: add other case where type ends up being `any`. - return createKeywordTypeNode(SyntaxKind.StringKeyword); - } - if(type.flags & TypeFlags.String) { - return createKeywordTypeNode(SyntaxKind.StringKeyword); - } - if(type.flags & TypeFlags.Number) { - return createKeywordTypeNode(SyntaxKind.NumberKeyword); - } - if(type.flags & (TypeFlags.Boolean | TypeFlags.StringOrNumberLiteral)) { - // TODO: check if this actually works with boolean. - return createLiteralTypeNode((type).text); - } - if(type.flags & TypeFlags.Void) { - return createKeywordTypeNode(SyntaxKind.VoidKeyword); - } - if(type.flags & TypeFlags.Undefined) { - return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); - } - if(type.flags & TypeFlags.Null) { - return createKeywordTypeNode(SyntaxKind.NullKeyword); - } - if(type.flags & TypeFlags.Never) { - return createKeywordTypeNode(SyntaxKind.NeverKeyword); - } - if(type.flags & TypeFlags.Enum) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.ESSymbol) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.TypeParameter) { - const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)); - const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)); - if(!type.symbol) { - encounteredError = true; - throw new Error("No symbol for type parameter so can't get name"); - } - const name = getNameOfSymbol(type.symbol); - return createTypeParameterNode(name, constraint, defaultParameter); - } - if(type.flags & TypeFlags.Union) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.Intersection) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.Index) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.IndexedAccess) { - throw new Error("not implemented"); - } - - // if(type.flags & TypeFlags.Object) { - // throw new Error("not implemented"); - // } - - // TODO: should these be within the if above (check with asserts) - const objectFlags = getObjectFlags(type); - - if (objectFlags & ObjectFlags.ClassOrInterface) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, - // type must be an anonymous class or interface. - return false; - } - - if (objectFlags & ObjectFlags.Reference) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // and vice versa. - // this case includes tuple types - const typeArguments = (type as TypeReference).typeArguments || emptyArray; - return allTypesVisible(typeArguments); - } - - // keyword types - // this type node - // function type node - // constructor type node - // type reference node - // type predicate node - is Foo (for return types) - // type query node -- typeof number - // type literal node (like object literal) - // array type - // tuple type - // union type - // might need parens - // intersection type - // Type operator node (eg (ie?): keyof T) - // IndexedAccess Type Node - // mapped type node - // literal type node - - // if (inTypeAlias && type.aliasSymbol) { - // return isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/false).accessibility === SymbolAccessibility.Accessible - // && (!type.aliasTypeArguments || allTypesVisible(type.aliasTypeArguments)); - // } - // const typeSymbolAccessibility = type.symbol && isSymbolAccessible(type.symbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility; - // if (type.flags & TypeFlags.TypeParameter) { - // if (inObjectLiteral && (type as TypeParameter).isThisType) { - // return false; - // } - // const constraint = getConstraintFromTypeParameter((type)); - // return typeSymbolAccessibility === SymbolAccessibility.Accessible - // && (!constraint || isTypeAccessibleWorker(constraint, inObjectLiteral, /*inTypeAlias*/false)); - // } - // if (typeSymbolAccessibility === SymbolAccessibility.Accessible) { - // return true; - // } - // if (type.flags & (TypeFlags.Intrinsic | TypeFlags.Literal)) { - // return true; - // } - // const objectFlags = getObjectFlags(type); - // if (objectFlags & ObjectFlags.ClassOrInterface) { - // // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, - // // type must be an anonymous class or interface. - // return false; - // } - // if (objectFlags & ObjectFlags.Reference) { - // // and vice versa. - // // this case includes tuple types - // const typeArguments = (type as TypeReference).typeArguments || emptyArray; - // return allTypesVisible(typeArguments); - // } - // if (type.flags & TypeFlags.UnionOrIntersection) { - // return allTypesVisible((type as UnionOrIntersectionType).types); - // } - - if (objectFlags & ObjectFlags.Mapped) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const typeParameter = getTypeParameterFromMappedType(type); - const constraintType = getConstraintTypeFromMappedType(type); - const templateType = getTemplateTypeFromMappedType(type); - } - - if (objectFlags & ObjectFlags.Anonymous) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // The type is an object literal type. - if (!type.symbol) { - // Anonymous types without symbols are literals. - return true; - } - // what case is this? - const members = type.symbol.members; - let allVisible = true; - members && members.forEach((member) => { - const memberType = getTypeOfSymbolAtLocation(member, enclosingDeclaration); - allVisible = allVisible && isTypeAccessibleWorker(memberType, /*inObjectLiteral*/ true, /*inTypeAlias*/false); - }); - return allVisible; - } - - Debug.fail("Should be unreachable here"); - - /** Note that mapToTypeNodeArray(undefined) === undefined. */ - function mapToTypeNodeArray(types: Type[]): NodeArray { - return asNodeArray(types && types.map(createTypeNodeWorker)); - } - // function allTypesVisible(types: Type[]): boolean { - // return types.every(type => isTypeAccessibleWorker(type, inObjectLiteral, /*inTypeAlias*/false)); - // } - } - } - function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { const globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; let inObjectTypeLiteral = false; return writeType(type, globalFlags); - const typeNode = createTypeNode(type, enclosingDeclaration); - function writeType(type: Type, flags: TypeFormatFlags) { const nextFlags = flags & ~TypeFormatFlags.InTypeAlias; // Write undefined/null type as any @@ -7126,10 +6939,6 @@ namespace ts { } } - // export function synthesizeTypeNode(type: Type, enclosingDeclaration: Node): TypeNode { - // throw new Error("Not implemented" + enclosingDeclaration); - // } - function instantiateList(items: T[], mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): T[] { if (items && items.length) { const result: T[] = []; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 1e5395fe7b2..669c66c4337 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -213,43 +213,8 @@ namespace ts { : node; } - // Types - - export function createLiteralTypeNode(value: string | number | boolean) { - const literal = createLiteral(value); - const literalTypeNode = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; - literalTypeNode.literal = literal; - return literalTypeNode; - } - - export function createTypeReferenceNode(typeName: string | EntityName, typeArguments?: NodeArray) { - const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; - typeReference.typeName = asName(typeName); - typeReference.typeName.parent - typeReference.typeArguments = typeArguments; - return typeReference; - } - - export function createTypeParameterNode(name: string | Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { - const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; - typeParameter.name = asName(name); - typeParameter.constraint = constraint; - typeParameter.default = defaultParameter; - - return typeParameter; - } - // Signature elements - export function createSignature(kind: SyntaxKind, parameters: NodeArray, name?: PropertyName, typeParameters?: NodeArray, returnType?: TypeNode): SignatureDeclaration { - const signature = createSynthesizedNode(kind) as SignatureDeclaration; - signature.parameters = parameters; - signature.name = name; - signature.typeParameters = typeParameters; - signature.type = returnType; - return signature; - } - export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { const node = createSynthesizedNode(SyntaxKind.Parameter); node.decorators = asNodeArray(decorators); @@ -1836,7 +1801,7 @@ namespace ts { return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - export function asNodeArray(array: T[] | undefined): NodeArray | undefined { + function asNodeArray(array: T[] | undefined): NodeArray | undefined { return array ? createNodeArray(array) : undefined; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 52207920b48..1492a106d2b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -849,19 +849,14 @@ namespace ts { _typeNodeBrand: any; } - export type KeywordKind = SyntaxKind.AnyKeyword - | SyntaxKind.NumberKeyword - | SyntaxKind.ObjectKeyword - | SyntaxKind.BooleanKeyword - | SyntaxKind.StringKeyword - | SyntaxKind.SymbolKeyword - | SyntaxKind.VoidKeyword - | SyntaxKind.UndefinedKeyword - | SyntaxKind.NullKeyword - | SyntaxKind.NeverKeyword; - export interface KeywordTypeNode extends TypeNode { - kind: KeywordKind; + kind: SyntaxKind.AnyKeyword + | SyntaxKind.NumberKeyword + | SyntaxKind.ObjectKeyword + | SyntaxKind.BooleanKeyword + | SyntaxKind.StringKeyword + | SyntaxKind.SymbolKeyword + | SyntaxKind.VoidKeyword; } export interface ThisTypeNode extends TypeNode { @@ -897,7 +892,7 @@ namespace ts { exprName: EntityName; } - /** A TypeLiteral is the declaration node for an anonymous symbol. */ + // A TypeLiteral is the declaration node for an anonymous symbol. export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; From fff531ca25e251942bd7c9af3716d986f9774d67 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sat, 11 Mar 2017 15:16:28 -0800 Subject: [PATCH 062/207] more temp --- src/compiler/checker.ts | 389 +++++++++--------- src/compiler/factory.ts | 66 ++- src/compiler/types.ts | 4 +- src/services/codefixes/fixAddMissingMember.ts | 49 ++- .../fixClassSuperMustPrecedeThisAccess.ts | 2 +- src/services/utilities.ts | 4 + 6 files changed, 302 insertions(+), 212 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 109e6f33ea3..3ed15f8b035 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -106,6 +106,7 @@ namespace ts { getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, + createTypeNode, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2188,6 +2189,207 @@ namespace ts { return result; } + function createTypeNode(type: Type) { + let encounteredError = false; + let checkAlias = true; + + return createTypeNodeWorker(type); + + // function createTypeDeclaration(type: Type): Declaration { + // if (!type) { + // return undefined; + // } + // throw new Error("not implemented."); + // } + + function createTypeNodeWorker(type: Type): TypeNode { + if (!type) { + return undefined; + } + + if (checkAlias && type.aliasSymbol) { + const name = getNameOfSymbol(type.aliasSymbol); + const typeArguments = mapToTypeNodeArray(type.aliasTypeArguments); + return createTypeReferenceNode(createIdentifier(name), typeArguments); + } + checkAlias = false; + + if (type.flags & TypeFlags.Any) { + // TODO: add other case where type ends up being `any`. + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if (type.flags & TypeFlags.String) { + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if (type.flags & TypeFlags.Number) { + return createKeywordTypeNode(SyntaxKind.NumberKeyword); + } + if (type.flags & (TypeFlags.Boolean | TypeFlags.StringOrNumberLiteral)) { + // TODO: check if this actually works with boolean. + return createLiteralTypeNode((type).text); + } + if (type.flags & TypeFlags.Void) { + return createKeywordTypeNode(SyntaxKind.VoidKeyword); + } + if (type.flags & TypeFlags.Undefined) { + return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); + } + if (type.flags & TypeFlags.Null) { + return createKeywordTypeNode(SyntaxKind.NullKeyword); + } + if (type.flags & TypeFlags.Never) { + return createKeywordTypeNode(SyntaxKind.NeverKeyword); + } + if (type.flags & TypeFlags.Enum) { + throw new Error("not implemented"); + } + if (type.flags & TypeFlags.ESSymbol) { + throw new Error("not implemented"); + } + if (type.flags & TypeFlags.TypeParameter) { + throw new Error("Type Parameter declarations only handled in other worker."); + // const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)) as TypeNode; + // const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)) as TypeNode; + // if (!type.symbol) { + // encounteredError = true; + // throw new Error("No symbol for type parameter so can't get name"); + // } + // const name = getNameOfSymbol(type.symbol); + // return createTypeParameterNode(name, constraint, defaultParameter); + } + if (type.flags & TypeFlags.Union) { + throw new Error("not implemented"); + } + if (type.flags & TypeFlags.Intersection) { + throw new Error("not implemented"); + } + if (type.flags & TypeFlags.Index) { + throw new Error("not implemented"); + } + if (type.flags & TypeFlags.IndexedAccess) { + throw new Error("not implemented"); + } + + // if(type.flags & TypeFlags.Object) { + // throw new Error("not implemented"); + // } + + // TODO: should these be within the if above (check with asserts) + const objectFlags = getObjectFlags(type); + + if (objectFlags & ObjectFlags.ClassOrInterface) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, + // type must be an anonymous class or interface. + + encounteredError = true; + return undefined; + } + + if (objectFlags & ObjectFlags.Reference) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // and vice versa. + // this case includes tuple types + // TODO: test empty tuples, see if they are coherent. + const typeArguments = (type as TypeReference).typeArguments || emptyArray; + return createTupleTypeNode(mapToTypeNodeArray(typeArguments)) + } + + // keyword types + // this type node + // function type node + // constructor type node + // type reference node + // type predicate node - is Foo (for return types) + // type query node -- typeof number + // type literal node (like object literal) + // array type + // tuple type + // union type + // might need parens + // intersection type + // Type operator node (eg (ie?): keyof T) + // IndexedAccess Type Node + // mapped type node + // literal type node + + // if (inTypeAlias && type.aliasSymbol) { + // return isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/false).accessibility === SymbolAccessibility.Accessible + // && (!type.aliasTypeArguments || allTypesVisible(type.aliasTypeArguments)); + // } + // const typeSymbolAccessibility = type.symbol && isSymbolAccessible(type.symbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility; + // if (type.flags & TypeFlags.TypeParameter) { + // if (inObjectLiteral && (type as TypeParameter).isThisType) { + // return false; + // } + // const constraint = getConstraintFromTypeParameter((type)); + // return typeSymbolAccessibility === SymbolAccessibility.Accessible + // && (!constraint || isTypeAccessibleWorker(constraint, inObjectLiteral, /*inTypeAlias*/false)); + // } + // if (typeSymbolAccessibility === SymbolAccessibility.Accessible) { + // return true; + // } + // if (type.flags & (TypeFlags.Intrinsic | TypeFlags.Literal)) { + // return true; + // } + // const objectFlags = getObjectFlags(type); + // if (objectFlags & ObjectFlags.ClassOrInterface) { + // // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, + // // type must be an anonymous class or interface. + // return false; + // } + // if (objectFlags & ObjectFlags.Reference) { + // // and vice versa. + // // this case includes tuple types + // const typeArguments = (type as TypeReference).typeArguments || emptyArray; + // return allTypesVisible(typeArguments); + // } + // if (type.flags & TypeFlags.UnionOrIntersection) { + // return allTypesVisible((type as UnionOrIntersectionType).types); + // } + + if (objectFlags & ObjectFlags.Mapped) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // const typeParameter = getTypeParameterFromMappedType(type); + // const constraintType = getConstraintTypeFromMappedType(type); + // const templateType = getTemplateTypeFromMappedType(type); + throw new Error("Mapped types not implemented"); + } + + if (objectFlags & ObjectFlags.Anonymous) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // The type is an object literal type. + if (!type.symbol) { + // Anonymous types without symbols are literals. + + + // mapToTypeDeclarationsArray(type) + throw new Error("object literal types not implemented."); + } + // what case is this? + throw new Error("unknown case.") + // const members = type.symbol.members; + // let allVisible = true; + // members && members.forEach((member) => { + // const memberType = getTypeOfSymbolAtLocation(member, enclosingDeclaration); + // allVisible = allVisible && isTypeAccessibleWorker(memberType, /*inObjectLiteral*/ true, /*inTypeAlias*/false); + // }); + // return allVisible; + } + + Debug.fail("Should be unreachable."); + + /** Note that mapToTypeNodeArray(undefined) === undefined. */ + function mapToTypeNodeArray(types: Type[]): NodeArray { + return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); + } + + // function mapToTypeDeclarationsArray(types: Type[]): NodeArray { + // return asNodeArray(types && types.map(createTypeDeclaration)); + // } + } + } + function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string { const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); @@ -2388,198 +2590,11 @@ namespace ts { } } - function createTypeNode(type: Type) { - let encounteredError = false; - let checkAlias = true; - - return createTypeNodeWorker(type); - - function createTypeNodeWorker(type: Type): TypeNode { - if(!type) { - return undefined; - } - - if (checkAlias && type.aliasSymbol) { - const name = getNameOfSymbol(type.aliasSymbol); - const typeArguments = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(createIdentifier(name), typeArguments); - } - checkAlias = false; - - - if(type.flags & TypeFlags.Any) { - // TODO: add other case where type ends up being `any`. - return createKeywordTypeNode(SyntaxKind.StringKeyword); - } - if(type.flags & TypeFlags.String) { - return createKeywordTypeNode(SyntaxKind.StringKeyword); - } - if(type.flags & TypeFlags.Number) { - return createKeywordTypeNode(SyntaxKind.NumberKeyword); - } - if(type.flags & (TypeFlags.Boolean | TypeFlags.StringOrNumberLiteral)) { - // TODO: check if this actually works with boolean. - return createLiteralTypeNode((type).text); - } - if(type.flags & TypeFlags.Void) { - return createKeywordTypeNode(SyntaxKind.VoidKeyword); - } - if(type.flags & TypeFlags.Undefined) { - return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); - } - if(type.flags & TypeFlags.Null) { - return createKeywordTypeNode(SyntaxKind.NullKeyword); - } - if(type.flags & TypeFlags.Never) { - return createKeywordTypeNode(SyntaxKind.NeverKeyword); - } - if(type.flags & TypeFlags.Enum) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.ESSymbol) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.TypeParameter) { - const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)); - const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)); - if(!type.symbol) { - encounteredError = true; - throw new Error("No symbol for type parameter so can't get name"); - } - const name = getNameOfSymbol(type.symbol); - return createTypeParameterNode(name, constraint, defaultParameter); - } - if(type.flags & TypeFlags.Union) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.Intersection) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.Index) { - throw new Error("not implemented"); - } - if(type.flags & TypeFlags.IndexedAccess) { - throw new Error("not implemented"); - } - - // if(type.flags & TypeFlags.Object) { - // throw new Error("not implemented"); - // } - - // TODO: should these be within the if above (check with asserts) - const objectFlags = getObjectFlags(type); - - if (objectFlags & ObjectFlags.ClassOrInterface) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, - // type must be an anonymous class or interface. - return false; - } - - if (objectFlags & ObjectFlags.Reference) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // and vice versa. - // this case includes tuple types - const typeArguments = (type as TypeReference).typeArguments || emptyArray; - return allTypesVisible(typeArguments); - } - - // keyword types - // this type node - // function type node - // constructor type node - // type reference node - // type predicate node - is Foo (for return types) - // type query node -- typeof number - // type literal node (like object literal) - // array type - // tuple type - // union type - // might need parens - // intersection type - // Type operator node (eg (ie?): keyof T) - // IndexedAccess Type Node - // mapped type node - // literal type node - - // if (inTypeAlias && type.aliasSymbol) { - // return isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/false).accessibility === SymbolAccessibility.Accessible - // && (!type.aliasTypeArguments || allTypesVisible(type.aliasTypeArguments)); - // } - // const typeSymbolAccessibility = type.symbol && isSymbolAccessible(type.symbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility; - // if (type.flags & TypeFlags.TypeParameter) { - // if (inObjectLiteral && (type as TypeParameter).isThisType) { - // return false; - // } - // const constraint = getConstraintFromTypeParameter((type)); - // return typeSymbolAccessibility === SymbolAccessibility.Accessible - // && (!constraint || isTypeAccessibleWorker(constraint, inObjectLiteral, /*inTypeAlias*/false)); - // } - // if (typeSymbolAccessibility === SymbolAccessibility.Accessible) { - // return true; - // } - // if (type.flags & (TypeFlags.Intrinsic | TypeFlags.Literal)) { - // return true; - // } - // const objectFlags = getObjectFlags(type); - // if (objectFlags & ObjectFlags.ClassOrInterface) { - // // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, - // // type must be an anonymous class or interface. - // return false; - // } - // if (objectFlags & ObjectFlags.Reference) { - // // and vice versa. - // // this case includes tuple types - // const typeArguments = (type as TypeReference).typeArguments || emptyArray; - // return allTypesVisible(typeArguments); - // } - // if (type.flags & TypeFlags.UnionOrIntersection) { - // return allTypesVisible((type as UnionOrIntersectionType).types); - // } - - if (objectFlags & ObjectFlags.Mapped) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const typeParameter = getTypeParameterFromMappedType(type); - const constraintType = getConstraintTypeFromMappedType(type); - const templateType = getTemplateTypeFromMappedType(type); - } - - if (objectFlags & ObjectFlags.Anonymous) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // The type is an object literal type. - if (!type.symbol) { - // Anonymous types without symbols are literals. - return true; - } - // what case is this? - const members = type.symbol.members; - let allVisible = true; - members && members.forEach((member) => { - const memberType = getTypeOfSymbolAtLocation(member, enclosingDeclaration); - allVisible = allVisible && isTypeAccessibleWorker(memberType, /*inObjectLiteral*/ true, /*inTypeAlias*/false); - }); - return allVisible; - } - - Debug.fail("Should be unreachable here"); - - /** Note that mapToTypeNodeArray(undefined) === undefined. */ - function mapToTypeNodeArray(types: Type[]): NodeArray { - return asNodeArray(types && types.map(createTypeNodeWorker)); - } - // function allTypesVisible(types: Type[]): boolean { - // return types.every(type => isTypeAccessibleWorker(type, inObjectLiteral, /*inTypeAlias*/false)); - // } - } - } - function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { const globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; let inObjectTypeLiteral = false; return writeType(type, globalFlags); - const typeNode = createTypeNode(type, enclosingDeclaration); - function writeType(type: Type, flags: TypeFormatFlags) { const nextFlags = flags & ~TypeFormatFlags.InTypeAlias; // Write undefined/null type as any diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 1e5395fe7b2..3633cc657ac 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -213,8 +213,28 @@ namespace ts { : node; } + // Type Elements + + export function createPropertySignature(name: PropertyName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): PropertySignature { + const propertySignature = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; + propertySignature.name = name; + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + + export function createConstructSignature() { + throw new Error("not implemented."); + } + // Types + export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode { + return createSynthesizedNode(kind); + } + + export function createLiteralTypeNode(value: string | number | boolean) { const literal = createLiteral(value); const literalTypeNode = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; @@ -222,7 +242,8 @@ namespace ts { return literalTypeNode; } - export function createTypeReferenceNode(typeName: string | EntityName, typeArguments?: NodeArray) { + // TODO: handle qualified names, ie EntityName's. + export function createTypeReferenceNode(typeName: string | Identifier, typeArguments?: NodeArray) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; typeReference.typeName = asName(typeName); typeReference.typeName.parent @@ -239,8 +260,34 @@ namespace ts { return typeParameter; } + export function createUnionTypeNode(types: NodeArray) { + const unionTypeNode = createSynthesizedNode(SyntaxKind.UnionType) as UnionTypeNode; + unionTypeNode.types = asNodeArray(types); + return unionTypeNode; + } + + export function createIntersectionTypeNode(types: NodeArray) { + const intersectionTypeNode = createSynthesizedNode(SyntaxKind.IntersectionType) as IntersectionTypeNode; + intersectionTypeNode.types = asNodeArray(types); + return intersectionTypeNode; + } + + export function createTypeLiteralNode(typeElements: TypeElement[]) { + const typeLiteralNode = createSynthesizedNode(SyntaxKind.LiteralType) as TypeLiteralNode; + typeLiteralNode.members = asNodeArray(typeElements); + return typeLiteralNode; + } + + export function createTupleTypeNode(types: NodeArray) { + const tupleTypeNode = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode; + tupleTypeNode.elementTypes = asNodeArray(types); + return tupleTypeNode; + } + + // Signature elements + /** Note, can also be used to construct index signatures. */ export function createSignature(kind: SyntaxKind, parameters: NodeArray, name?: PropertyName, typeParameters?: NodeArray, returnType?: TypeNode): SignatureDeclaration { const signature = createSynthesizedNode(kind) as SignatureDeclaration; signature.parameters = parameters; @@ -250,6 +297,19 @@ namespace ts { return signature; } + // TODO: check usage of name... + export function createIndexSignature(parameter: ParameterDeclaration, type: TypeNode, decorators?: Decorator[], modifiers?: Modifier[]): IndexSignatureDeclaration { + const indexSignature = createSignature( + SyntaxKind.IndexSignature + , asNodeArray([parameter]) + , /*name*/ undefined + , /*typeParameters*/undefined + , type) as IndexSignatureDeclaration; + indexSignature.decorators = asNodeArray(decorators); + indexSignature.modifiers = asNodeArray(modifiers); + return indexSignature; + } + export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { const node = createSynthesizedNode(SyntaxKind.Parameter); node.decorators = asNodeArray(decorators); @@ -1134,10 +1194,6 @@ namespace ts { : node; } - export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode { - return createSynthesizedNode(kind); - } - export function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.FunctionDeclaration); node.decorators = asNodeArray(decorators); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 52207920b48..4fd4dd1780c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -673,7 +673,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface BindingElement extends Declaration { + export interface BindingElement extends Declaration { kind: SyntaxKind.BindingElement; parent?: BindingPattern; propertyName?: PropertyName; // Binding property name (in object binding pattern) @@ -2468,6 +2468,8 @@ namespace ts { */ /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNonNullableType(type: Type): Type; + /** Note that the resulting type node cannot be checked. */ + createTypeNode(type: Type): TypeNode; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 6ae2ba3f51c..05ff29f0692 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -31,37 +31,50 @@ namespace ts.codefix { return undefined; } - let typeString = "any"; + let typeNode: TypeNode = createKeywordTypeNode(SyntaxKind.AnyKeyword); if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { const binaryExpression = token.parent.parent as BinaryExpression; const checker = context.program.getTypeChecker(); const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); - typeString = checker.typeToString(widenedType); + typeNode = checker.createTypeNode(widenedType) || typeNode; } - const startPos = classDeclaration.members.pos; + const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); - return [{ + const property = createProperty( + /*decorators*/undefined + , /*modifiers*/ undefined + , token.getText(sourceFile) + , /*questionToken*/ undefined + , typeNode + , /*initializer*/ undefined); + // TODO: make index signature. + const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { insertTrailingNewLine: true }); + + const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword); + const indexingParameter = createParameter( + /*decorators*/ undefined + , /*modifiers*/ undefined + , /*dotDotDotToken*/ undefined + , "name" + , /*questionToken*/ undefined + , stringTypeNode); + const indexSignature = createIndexSignature(indexingParameter, typeNode); + + // const startPos = classDeclaration.members.pos; + const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { insertTrailingNewLine: true }); + + return [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `${token.getFullText(sourceFile)}: ${typeString};` - }] - }] + changes: propertyChangeTracker.getChanges() }, { description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `[name: string]: ${typeString};` - }] - }] + changes: indexSignatureChangeTracker.getChanges() }]; } } \ No newline at end of file diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 207d039df8e..63fc846f8cf 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -16,7 +16,7 @@ namespace ts.codefix { return undefined; } - // figure out if the this access is actuall inside the supercall + // figure out if the `this` access is actually inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix if (superCall.expression && superCall.expression.kind == SyntaxKind.CallExpression) { const arguments = (superCall.expression).arguments; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 1b32b3bbad7..0fed656af5a 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1384,4 +1384,8 @@ namespace ts { // First token is the open curly, this is where we want to put the 'super' call. return constructor.body.getFirstToken(sourceFile); } + + export function getOpenBraceOfClassLike(declaration: ClassLikeDeclaration, sourceFile: SourceFile) { + return getTokenAtPosition(sourceFile, declaration.members.pos); + } } From bf2acf1d2cdf51fb462561f054d6dd0f01bd8aef Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sat, 11 Mar 2017 18:58:46 -0800 Subject: [PATCH 063/207] basic end-to-end building type nodes --- src/compiler/checker.ts | 23 +++-- src/compiler/factory.ts | 99 +++++++++++++------ src/compiler/types.ts | 24 +++-- src/compiler/visitor.ts | 68 +++++++++++-- src/services/codefixes/fixAddMissingMember.ts | 5 +- src/services/utilities.ts | 2 +- 6 files changed, 159 insertions(+), 62 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3ed15f8b035..f29204f7ca1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2190,7 +2190,7 @@ namespace ts { } function createTypeNode(type: Type) { - let encounteredError = false; + // let encounteredError = false; let checkAlias = true; return createTypeNodeWorker(type); @@ -2224,9 +2224,17 @@ namespace ts { if (type.flags & TypeFlags.Number) { return createKeywordTypeNode(SyntaxKind.NumberKeyword); } - if (type.flags & (TypeFlags.Boolean | TypeFlags.StringOrNumberLiteral)) { + if(type.flags & TypeFlags.Boolean) { + // TODO: this is probably x: boolean. How do we deal with x: true ? + return createKeywordTypeNode(SyntaxKind.BooleanKeyword); + } + if (type.flags & (TypeFlags.StringLiteral)) { // TODO: check if this actually works with boolean. - return createLiteralTypeNode((type).text); + return createLiteralTypeNode((createLiteral((type).text))); + } + if (type.flags & (TypeFlags.NumberLiteral)) { + // TODO: check if this actually works with boolean. + return createLiteralTypeNode((createNumericLiteral((type).text))); } if (type.flags & TypeFlags.Void) { return createKeywordTypeNode(SyntaxKind.VoidKeyword); @@ -2279,11 +2287,10 @@ namespace ts { if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); - // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, - // type must be an anonymous class or interface. - - encounteredError = true; - return undefined; + const name = getNameOfSymbol(type.symbol); + // TODO: handle type arguments. + // TODO: handle anonymous classes. + return createTypeReferenceNode(name); } if (objectFlags & ObjectFlags.Reference) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 3633cc657ac..19e8ef25da0 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -234,23 +234,75 @@ namespace ts { return createSynthesizedNode(kind); } - - export function createLiteralTypeNode(value: string | number | boolean) { - const literal = createLiteral(value); + export function createLiteralTypeNode(literal: Expression) { const literalTypeNode = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; literalTypeNode.literal = literal; return literalTypeNode; } + export function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + // TODO: handle qualified names, ie EntityName's. export function createTypeReferenceNode(typeName: string | Identifier, typeArguments?: NodeArray) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; typeReference.typeName = asName(typeName); - typeReference.typeName.parent typeReference.typeArguments = typeArguments; return typeReference; } + export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: Identifier, typeArguments?: NodeArray) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode; + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode; + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode; + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode { + const unionTypeNode = createSynthesizedNode(kind) as UnionTypeNode | IntersectionTypeNode; + unionTypeNode.types = asNodeArray(types); + return unionTypeNode; + } + + export function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: NodeArray) { + return node.types !== types + || node.kind !== kind + ? updateNode(createUnionOrIntersectionTypeNode(kind, types), node) + : node; + } + + export function createTypeLiteralNode(members: TypeElement[]) { + const typeLiteralNode = createSynthesizedNode(SyntaxKind.LiteralType) as TypeLiteralNode; + typeLiteralNode.members = asNodeArray(members); + return typeLiteralNode; + } + + export function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + + export function createTupleTypeNode(elementTypes: TypeNode[]) { + const tupleTypeNode = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode; + tupleTypeNode.elementTypes = asNodeArray(elementTypes); + return tupleTypeNode; + } + + export function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + + // Type Declarations + export function createTypeParameterNode(name: string | Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; typeParameter.name = asName(name); @@ -260,31 +312,6 @@ namespace ts { return typeParameter; } - export function createUnionTypeNode(types: NodeArray) { - const unionTypeNode = createSynthesizedNode(SyntaxKind.UnionType) as UnionTypeNode; - unionTypeNode.types = asNodeArray(types); - return unionTypeNode; - } - - export function createIntersectionTypeNode(types: NodeArray) { - const intersectionTypeNode = createSynthesizedNode(SyntaxKind.IntersectionType) as IntersectionTypeNode; - intersectionTypeNode.types = asNodeArray(types); - return intersectionTypeNode; - } - - export function createTypeLiteralNode(typeElements: TypeElement[]) { - const typeLiteralNode = createSynthesizedNode(SyntaxKind.LiteralType) as TypeLiteralNode; - typeLiteralNode.members = asNodeArray(typeElements); - return typeLiteralNode; - } - - export function createTupleTypeNode(types: NodeArray) { - const tupleTypeNode = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode; - tupleTypeNode.elementTypes = asNodeArray(types); - return tupleTypeNode; - } - - // Signature elements /** Note, can also be used to construct index signatures. */ @@ -298,10 +325,11 @@ namespace ts { } // TODO: check usage of name... - export function createIndexSignature(parameter: ParameterDeclaration, type: TypeNode, decorators?: Decorator[], modifiers?: Modifier[]): IndexSignatureDeclaration { + // TODO: create entry in visitor.ts + export function createIndexSignatureDeclaration(parameters: ParameterDeclaration[], type: TypeNode, decorators?: Decorator[], modifiers?: Modifier[]): IndexSignatureDeclaration { const indexSignature = createSignature( SyntaxKind.IndexSignature - , asNodeArray([parameter]) + , asNodeArray(parameters) , /*name*/ undefined , /*typeParameters*/undefined , type) as IndexSignatureDeclaration; @@ -310,6 +338,15 @@ namespace ts { return indexSignature; } + export function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, parameters: ParameterDeclaration[], type: TypeNode, decorators?: Decorator[], modifiers?: Modifier[]) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignatureDeclaration(parameters, type, decorators, modifiers), node) + : node; + } + export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { const node = createSynthesizedNode(SyntaxKind.Parameter); node.decorators = asNodeArray(decorators); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4fd4dd1780c..463638484c6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -673,7 +673,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface BindingElement extends Declaration { + export interface BindingElement extends Declaration { kind: SyntaxKind.BindingElement; parent?: BindingPattern; propertyName?: PropertyName; // Binding property name (in object binding pattern) @@ -849,19 +849,17 @@ namespace ts { _typeNodeBrand: any; } - export type KeywordKind = SyntaxKind.AnyKeyword - | SyntaxKind.NumberKeyword - | SyntaxKind.ObjectKeyword - | SyntaxKind.BooleanKeyword - | SyntaxKind.StringKeyword - | SyntaxKind.SymbolKeyword - | SyntaxKind.VoidKeyword - | SyntaxKind.UndefinedKeyword - | SyntaxKind.NullKeyword - | SyntaxKind.NeverKeyword; - export interface KeywordTypeNode extends TypeNode { - kind: KeywordKind; + kind: SyntaxKind.AnyKeyword + | SyntaxKind.NumberKeyword + | SyntaxKind.ObjectKeyword + | SyntaxKind.BooleanKeyword + | SyntaxKind.StringKeyword + | SyntaxKind.SymbolKeyword + | SyntaxKind.VoidKeyword + | SyntaxKind.UndefinedKeyword + | SyntaxKind.NullKeyword + | SyntaxKind.NeverKeyword; } export interface ThisTypeNode extends TypeNode { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 133c62e1926..35119dc7fc0 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -212,16 +212,12 @@ namespace ts { } const kind = node.kind; + // No need to visit nodes with no children. if ((kind > SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken)) { return node; } - // We do not yet support types. - if ((kind >= SyntaxKind.TypePredicate && kind <= SyntaxKind.LiteralType)) { - return node; - } - switch (node.kind) { case SyntaxKind.SemicolonClassElement: case SyntaxKind.EmptyStatement: @@ -241,6 +237,13 @@ namespace ts { visitNode((node).expression, visitor, isExpression)); // Signature elements + case SyntaxKind.IndexSignature: + return updateIndexSignatureDeclaration(node + , nodesVisitor((node).parameters, visitor) + , visitNode((node).type, visitor) + , nodesVisitor((node).decorators, visitor, isDecorator) + , nodesVisitor((node).modifiers, visitor, isModifier)); + case SyntaxKind.Parameter: return updateParameter(node, nodesVisitor((node).decorators, visitor, isDecorator), @@ -254,7 +257,60 @@ namespace ts { return updateDecorator(node, visitNode((node).expression, visitor, isExpression)); - // Type member + // Keyword Types + + case SyntaxKind.AnyKeyword: + case SyntaxKind.NumberKeyword: + case SyntaxKind.ObjectKeyword: + case SyntaxKind.BooleanKeyword: + case SyntaxKind.StringKeyword: + case SyntaxKind.SymbolKeyword: + case SyntaxKind.VoidKeyword: + case SyntaxKind.UndefinedKeyword: + case SyntaxKind.NullKeyword: + case SyntaxKind.NeverKeyword: + case SyntaxKind.NeverKeyword: + return node; + + // Types + + case SyntaxKind.TypePredicate: + throw new Error("reached unsupported type."); + case SyntaxKind.TypeReference: + return updateTypeReferenceNode(node + , visitNode((node).typeName as Identifier, visitor) + , nodesVisitor((node).typeArguments, visitor) + ); + case SyntaxKind.FunctionType: + throw new Error("reached unsupported type."); + case SyntaxKind.ConstructorType: + throw new Error("reached unsupported type."); + case SyntaxKind.TypeQuery: + throw new Error("reached unsupported type."); + case SyntaxKind.TypeLiteral: + throw new Error("reached unsupported type."); + case SyntaxKind.ArrayType: + throw new Error("reached unsupported type."); + case SyntaxKind.TupleType: + throw new Error("reached unsupported type."); + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + throw new Error("reached unsupported type."); + case SyntaxKind.ParenthesizedType: + throw new Error("reached unsupported type."); + case SyntaxKind.ThisType: + throw new Error("reached unsupported type."); + case SyntaxKind.TypeOperator: + throw new Error("reached unsupported type."); + case SyntaxKind.IndexedAccessType: + throw new Error("reached unsupported type."); + case SyntaxKind.MappedType: + throw new Error("reached unsupported type."); + case SyntaxKind.LiteralType: + throw new Error("reached unsupported type."); + + // Type members + case SyntaxKind.PropertyDeclaration: return updateProperty(node, nodesVisitor((node).decorators, visitor, isDecorator), diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 05ff29f0692..79b95e4799d 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -62,13 +62,12 @@ namespace ts.codefix { , "name" , /*questionToken*/ undefined , stringTypeNode); - const indexSignature = createIndexSignature(indexingParameter, typeNode); + const indexSignature = createIndexSignatureDeclaration([indexingParameter], typeNode); - // const startPos = classDeclaration.members.pos; const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { insertTrailingNewLine: true }); - return [{ + return [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), changes: propertyChangeTracker.getChanges() }, diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0fed656af5a..92b63656573 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1386,6 +1386,6 @@ namespace ts { } export function getOpenBraceOfClassLike(declaration: ClassLikeDeclaration, sourceFile: SourceFile) { - return getTokenAtPosition(sourceFile, declaration.members.pos); + return getTokenAtPosition(sourceFile, declaration.members.pos - 1); } } From d6863bea256cc8a51caf0d978a09fa73ea427cb2 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 12:49:29 -0700 Subject: [PATCH 064/207] missing member fixes use createTypeNode --- ...sDoesntImplementInheritedAbstractMember.ts | 19 +--- .../fixClassIncorrectlyImplementsInterface.ts | 57 +++++----- src/services/codefixes/helpers.ts | 105 +++++++++++++----- 3 files changed, 112 insertions(+), 69 deletions(-) diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 16edce0a516..513853e4614 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -19,10 +19,9 @@ namespace ts.codefix { const checker = context.program.getTypeChecker(); if (isClassLike(token.parent)) { - const classDecl = token.parent as ClassLikeDeclaration; - const startPos = classDecl.members.pos; + const classDeclaration = token.parent as ClassLikeDeclaration; - const extendsNode = getClassExtendsHeritageClauseElement(classDecl); + const extendsNode = getClassExtendsHeritageClauseElement(classDeclaration); const instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, @@ -30,18 +29,12 @@ namespace ts.codefix { const extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); const abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); - const insertion = getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); - - if (insertion.length) { + const newNodes = createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker); + const changes = newNodesToChanges(newNodes, getOpenBraceOfClassLike(classDeclaration, sourceFile), context); + if(changes && changes.length > 0) { return [{ description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes }]; } } diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 67b2242c8d9..a5bde70c011 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -16,7 +16,7 @@ namespace ts.codefix { return undefined; } - const startPos: number = classDecl.members.pos; + const openBrace = getOpenBraceOfClassLike(classDecl, sourceFile); const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl); @@ -31,43 +31,46 @@ namespace ts.codefix { const implementedTypeSymbols = checker.getPropertiesOfType(implementedType); const nonPrivateMembers = implementedTypeSymbols.filter(symbol => !(getModifierFlags(symbol.valueDeclaration) & ModifierFlags.Private)); - let insertion = getMissingIndexSignatureInsertion(implementedType, IndexKind.Number, classDecl, hasNumericIndexSignature); - insertion += getMissingIndexSignatureInsertion(implementedType, IndexKind.String, classDecl, hasStringIndexSignature); - insertion += getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); - + let newNodes: Node[] = []; + createAndAddMissingIndexSignatureDeclaration(implementedType, IndexKind.Number, hasNumericIndexSignature, newNodes); + createAndAddMissingIndexSignatureDeclaration(implementedType, IndexKind.String, hasStringIndexSignature, newNodes); + newNodes = newNodes.concat(createMissingMemberNodes(classDecl, nonPrivateMembers, checker)); const message = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); - if (insertion) { - pushAction(result, insertion, message); + if (newNodes.length > 0) { + pushAction(result, newNodes, message); } } return result; - function getMissingIndexSignatureInsertion(type: InterfaceType, kind: IndexKind, enclosingDeclaration: ClassLikeDeclaration, hasIndexSigOfKind: boolean) { - if (!hasIndexSigOfKind) { - const IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); - if (IndexInfoOfKind) { - const writer = getSingleLineStringWriter(); - checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - const result = writer.string(); - releaseStringWriter(writer); - - return result; - } + function createAndAddMissingIndexSignatureDeclaration(type: InterfaceType, kind: IndexKind, hasIndexSigOfKind: boolean, newNodes: Node[]): void { + if (hasIndexSigOfKind) { + return undefined; } - return ""; + + const indexInfoOfKind = checker.getIndexInfoOfType(type, kind); + + if (!indexInfoOfKind) { + return undefined; + } + const typeNode = checker.createTypeNode(indexInfoOfKind.type); + let name: string; + const newIndexSignatureDeclaration = createIndexSignatureDeclaration( + [createParameter( + /*decorators*/undefined + , /*modifiers*/ undefined + , /*dotDotDotToken*/ undefined + , name + , /*questionToken*/ undefined + , kind === IndexKind.String ? createKeywordTypeNode(SyntaxKind.StringKeyword) : createKeywordTypeNode(SyntaxKind.NumberKeyword))] + , typeNode); + newNodes.push(newIndexSignatureDeclaration); } - function pushAction(result: CodeAction[], insertion: string, description: string): void { + function pushAction(result: CodeAction[], newNodes: Node[], description: string): void { const newAction: CodeAction = { description: description, - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: newNodesToChanges(newNodes, openBrace, context) }; result.push(newAction); } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index d20fc0129cd..0af13bf41e4 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -1,31 +1,53 @@ /* @internal */ namespace ts.codefix { + export function newNodesToChanges(newNodes: Node[], insertAfter: Node, context: CodeFixContext) { + const sourceFile = context.sourceFile; + if (!(newNodes)) { + // TODO: make the appropriate value flow through gracefully. + throw new Error("newNodesToChanges expects an array"); + } + + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + + for (let i = newNodes.length - 1; i >= 0; i--) { + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNodes[i], { insertTrailingNewLine: true }); + } + return changeTracker.getChanges(); + } + /** * Finds members of the resolved type that are missing in the class pointed to by class decl * and generates source code for the missing members. * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. * @returns Empty string iff there are no member insertions. */ - export function getMissingMembersInsertion(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker, newlineChar: string): string { + export function createMissingMemberNodes(classDeclaration: ClassLikeDeclaration, possiblyMissingSymbols: Symbol[], checker: TypeChecker): Node[] { const classMembers = classDeclaration.symbol.members; const missingMembers = possiblyMissingSymbols.filter(symbol => !classMembers.has(symbol.getName())); - let insertion = ""; - + let newNodes: Node[] = []; for (const symbol of missingMembers) { - insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + const newNode = getNewNodeForMemberSymbol(symbol, classDeclaration, checker); + if (newNode) { + if (Array.isArray(newNode)) { + newNodes = newNodes.concat(newNode); + } + else { + newNodes.push(newNode); + } + } } - return insertion; + return newNodes; } /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function getInsertionForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker, newlineChar: string): string { + function getNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker): Node[] | Node | undefined { const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { - return ""; + return undefined; } const declaration = declarations[0] as Declaration; @@ -39,9 +61,16 @@ namespace ts.codefix { case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - const typeString = checker.typeToString(type, enclosingDeclaration, TypeFormatFlags.None); - return `${visibility}${name}: ${typeString};${newlineChar}`; - + const typeNode = checker.createTypeNode(type); + // TODO: add modifiers. + const property = createProperty( + /*decorators*/undefined + , /*modifiers*/ undefined + , name + , /*questionToken*/ undefined + , typeNode + , /*initializer*/ undefined); + return property; case SyntaxKind.MethodSignature: case SyntaxKind.MethodDeclaration: // The signature for the implementation appears as an entry in `signatures` iff @@ -53,18 +82,22 @@ namespace ts.codefix { // correspondence of declarations and signatures. const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); if (!(signatures && signatures.length > 0)) { - return ""; + return undefined; } if (declarations.length === 1) { Debug.assert(signatures.length === 1); - const sigString = checker.signatureToString(signatures[0], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - return getStubbedMethod(visibility, name, sigString, newlineChar); + // TODO: extract signature declaration from a signature. + // const sigString = checker.signatureToString(signatures[0], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); + // TODO: get parameters working. + // TODO: add support for type parameters. + return createStubbedMethod([visibility], name, /*typeParameters*/undefined, []); } - let result = ""; + let signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { - const sigString = checker.signatureToString(signatures[i], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - result += `${visibility}${name}${sigString};${newlineChar}`; + // const sigString = checker.signatureToString(signatures[i], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); + // TODO: make signatures instead of methods + signatureDeclarations.push(createStubbedMethod([visibility], name, /*typeParameters*/undefined, [])); } // If there is a declaration with a body, it is the last declaration, @@ -77,12 +110,12 @@ namespace ts.codefix { Debug.assert(declarations.length === signatures.length); bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); } - const sigString = checker.signatureToString(bodySig, enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - result += getStubbedMethod(visibility, name, sigString, newlineChar); - - return result; + // const sigString = checker.signatureToString(bodySig, enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); + signatureDeclarations.push(createStubbedMethod([visibility], name, /*typeParameters*/undefined, [])); + + return signatureDeclarations; default: - return ""; + return undefined; } } @@ -138,22 +171,36 @@ namespace ts.codefix { } } - export function getStubbedMethod(visibility: string, name: string, sigString = "()", newlineChar: string): string { - return `${visibility}${name}${sigString}${getMethodBodyStub(newlineChar)}`; + export function createStubbedMethod(modifiers: Modifier[], name: string, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType?: TypeNode) { + return createMethod( + /*decorators*/undefined + , /*modifiers*/modifiers + , /*asteriskToken*/undefined + , name + , typeParameters + , parameters + , returnType + , createStubbedMethodBody()); } - function getMethodBodyStub(newlineChar: string) { - return ` {${newlineChar}throw new Error('Method not implemented.');${newlineChar}}${newlineChar}`; + function createStubbedMethodBody() { + return createBlock( + [createThrow( + createNew( + createIdentifier('Error') + , /*typeArguments*/undefined + , [createLiteral('Method not implemented.')]))] + , /*multiline*/true); } - function getVisibilityPrefixWithSpace(flags: ModifierFlags): string { + function getVisibilityPrefixWithSpace(flags: ModifierFlags) { if (flags & ModifierFlags.Public) { - return "public "; + return createToken(SyntaxKind.PublicKeyword); } else if (flags & ModifierFlags.Protected) { - return "protected "; + return createToken(SyntaxKind.ProtectedKeyword); } - return ""; + return undefined; } const SymbolConstructor = objectAllocator.getSymbolConstructor(); From 3ac54e8a47fad55c6ad88acbb682b2aed3d1b15b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sun, 12 Mar 2017 15:00:24 -0700 Subject: [PATCH 065/207] Infer class property declarations from assignments in nested arrow functions --- src/compiler/binder.ts | 2 + .../inferringClassMembersFromAssignments.js | 78 +++++++ ...ferringClassMembersFromAssignments.symbols | 210 +++++++++++++----- ...inferringClassMembersFromAssignments.types | 130 +++++++++++ .../inferringClassMembersFromAssignments.ts | 38 ++++ 5 files changed, 406 insertions(+), 52 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 418905e604c..650797c6dba 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2332,6 +2332,7 @@ namespace ts { function bindThisPropertyAssignment(node: BinaryExpression) { Debug.assert(isInJavaScriptFile(node)); + const container = getThisContainer(node, /*includeArrowFunctions*/false); switch (container.kind) { case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: @@ -2342,6 +2343,7 @@ namespace ts { break; case SyntaxKind.Constructor: + case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.js b/tests/baselines/reference/inferringClassMembersFromAssignments.js index a7b9e4ff8f0..74c47dab565 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.js +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.js @@ -20,6 +20,15 @@ class C { this.inMethod = "string" } this.inMultiple = "string"; + + var action = () => { + if (Math.random()) { + this.inNestedArrowFunction = 0; + } + else { + this.inNestedArrowFunction = "string" + } + }; } get() { if (Math.random()) { @@ -38,6 +47,14 @@ class C { this.inSetter = "string" } } + prop = () => { + if (Math.random()) { + this.inPropertyDeclaration = 0; + } + else { + this.inPropertyDeclaration = "string" + } + } static method() { if (Math.random()) { this.inStaticMethod = 0; @@ -45,6 +62,15 @@ class C { else { this.inStaticMethod = "string" } + + var action = () => { + if (Math.random()) { + this.inStaticNestedArrowFunction = 0; + } + else { + this.inStaticNestedArrowFunction = "string" + } + }; } static get() { if (Math.random()) { @@ -62,6 +88,14 @@ class C { this.inStaticSetter = "string" } } + static prop = () => { + if (Math.random()) { + this.inStaticPropertyDeclaration = 0; + } + else { + this.inStaticPropertyDeclaration = "string" + } + } } //// [b.ts] @@ -75,6 +109,8 @@ var stringOrNumberOrUndefined: string | number | undefined; var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +var stringOrNumberOrUndefined = c.inNestedArrowFunction var stringOrNumberOrBoolean: string | number | boolean; @@ -84,11 +120,23 @@ var stringOrNumberOrBoolean = c.inMultiple; var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; //// [output.js] +var _this = this; var C = (function () { function C() { + var _this = this; + this.prop = function () { + if (Math.random()) { + _this.inPropertyDeclaration = 0; + } + else { + _this.inPropertyDeclaration = "string"; + } + }; if (Math.random()) { this.inConstructor = 0; } @@ -98,6 +146,7 @@ var C = (function () { this.inMultiple = 0; } C.prototype.method = function () { + var _this = this; if (Math.random()) { this.inMethod = 0; } @@ -105,6 +154,14 @@ var C = (function () { this.inMethod = "string"; } this.inMultiple = "string"; + var action = function () { + if (Math.random()) { + _this.inNestedArrowFunction = 0; + } + else { + _this.inNestedArrowFunction = "string"; + } + }; }; C.prototype.get = function () { if (Math.random()) { @@ -124,12 +181,21 @@ var C = (function () { } }; C.method = function () { + var _this = this; if (Math.random()) { this.inStaticMethod = 0; } else { this.inStaticMethod = "string"; } + var action = function () { + if (Math.random()) { + _this.inStaticNestedArrowFunction = 0; + } + else { + _this.inStaticNestedArrowFunction = "string"; + } + }; }; C.get = function () { if (Math.random()) { @@ -149,6 +215,14 @@ var C = (function () { }; return C; }()); +C.prop = function () { + if (Math.random()) { + _this.inStaticPropertyDeclaration = 0; + } + else { + _this.inStaticPropertyDeclaration = "string"; + } +}; var c = new C(); var stringOrNumber; var stringOrNumber = c.inConstructor; @@ -156,8 +230,12 @@ var stringOrNumberOrUndefined; var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +var stringOrNumberOrUndefined = c.inNestedArrowFunction; var stringOrNumberOrBoolean; var stringOrNumberOrBoolean = c.inMultiple; var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols index 9951339f8a8..086c4246697 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.symbols +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.symbols @@ -21,9 +21,9 @@ class C { >inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) } this.inMultiple = 0; ->this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) } method() { >method : Symbol(C.method, Decl(a.js, 10, 5)) @@ -45,12 +45,33 @@ class C { >inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) } this.inMultiple = "string"; ->this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) + + var action = () => { +>action : Symbol(action, Decl(a.js, 20, 11)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inNestedArrowFunction = 0; +>this.inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) + } + else { + this.inNestedArrowFunction = "string" +>this.inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) + } + }; } get() { ->get : Symbol(C.get, Decl(a.js, 19, 5)) +>get : Symbol(C.get, Decl(a.js, 28, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -58,23 +79,23 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inGetter = 0; ->this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) } else { this.inGetter = "string" ->this.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>this.inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) } this.inMultiple = false; ->this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>this.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) } set() { ->set : Symbol(C.set, Decl(a.js, 28, 5)) +>set : Symbol(C.set, Decl(a.js, 37, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -82,19 +103,39 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inSetter = 0; ->this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) } else { this.inSetter = "string" ->this.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>this.inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) + } + } + prop = () => { +>prop : Symbol(C.prop, Decl(a.js, 45, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inPropertyDeclaration = 0; +>this.inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) + } + else { + this.inPropertyDeclaration = "string" +>this.inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) } } static method() { ->method : Symbol(C.method, Decl(a.js, 36, 5)) +>method : Symbol(C.method, Decl(a.js, 53, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -102,19 +143,40 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticMethod = 0; ->this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) } else { this.inStaticMethod = "string" ->this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>this.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) } + + var action = () => { +>action : Symbol(action, Decl(a.js, 62, 11)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticNestedArrowFunction = 0; +>this.inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) + } + else { + this.inStaticNestedArrowFunction = "string" +>this.inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) + } + }; } static get() { ->get : Symbol(C.get, Decl(a.js, 44, 5)) +>get : Symbol(C.get, Decl(a.js, 70, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -122,19 +184,19 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticGetter = 0; ->this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) } else { this.inStaticGetter = "string" ->this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>this.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) } } static set() { ->set : Symbol(C.set, Decl(a.js, 52, 5)) +>set : Symbol(C.set, Decl(a.js, 78, 5)) if (Math.random()) { >Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) @@ -142,15 +204,35 @@ class C { >random : Symbol(Math.random, Decl(lib.d.ts, --, --)) this.inStaticSetter = 0; ->this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) } else { this.inStaticSetter = "string" ->this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>this.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) >this : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) + } + } + static prop = () => { +>prop : Symbol(C.prop, Decl(a.js, 86, 5)) + + if (Math.random()) { +>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>random : Symbol(Math.random, Decl(lib.d.ts, --, --)) + + this.inStaticPropertyDeclaration = 0; +>this.inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) + } + else { + this.inStaticPropertyDeclaration = "string" +>this.inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) } } } @@ -170,51 +252,75 @@ var stringOrNumber = c.inConstructor; >inConstructor : Symbol(C.inConstructor, Decl(a.js, 3, 28), Decl(a.js, 6, 14)) var stringOrNumberOrUndefined: string | number | undefined; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) var stringOrNumberOrUndefined = c.inMethod; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) >c.inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) >inMethod : Symbol(C.inMethod, Decl(a.js, 12, 28), Decl(a.js, 15, 14)) var stringOrNumberOrUndefined = c.inGetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->c.inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inGetter : Symbol(C.inGetter, Decl(a.js, 21, 28), Decl(a.js, 24, 14)) +>inGetter : Symbol(C.inGetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) var stringOrNumberOrUndefined = c.inSetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->c.inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inSetter : Symbol(C.inSetter, Decl(a.js, 30, 28), Decl(a.js, 33, 14)) +>inSetter : Symbol(C.inSetter, Decl(a.js, 39, 28), Decl(a.js, 42, 14)) + +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inPropertyDeclaration : Symbol(C.inPropertyDeclaration, Decl(a.js, 47, 28), Decl(a.js, 50, 14)) + +var stringOrNumberOrUndefined = c.inNestedArrowFunction +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>c.inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) +>c : Symbol(c, Decl(b.ts, 0, 3)) +>inNestedArrowFunction : Symbol(C.inNestedArrowFunction, Decl(a.js, 21, 32), Decl(a.js, 24, 18)) var stringOrNumberOrBoolean: string | number | boolean; ->stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 13, 3), Decl(b.ts, 15, 3)) var stringOrNumberOrBoolean = c.inMultiple; ->stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 11, 3), Decl(b.ts, 13, 3)) ->c.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>stringOrNumberOrBoolean : Symbol(stringOrNumberOrBoolean, Decl(b.ts, 13, 3), Decl(b.ts, 15, 3)) +>c.inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) >c : Symbol(c, Decl(b.ts, 0, 3)) ->inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 26, 9)) +>inMultiple : Symbol(C.inMultiple, Decl(a.js, 8, 9), Decl(a.js, 17, 9), Decl(a.js, 35, 9)) var stringOrNumberOrUndefined = C.inStaticMethod; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 38, 28), Decl(a.js, 41, 14)) +>inStaticMethod : Symbol(C.inStaticMethod, Decl(a.js, 55, 28), Decl(a.js, 58, 14)) var stringOrNumberOrUndefined = C.inStaticGetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 46, 28), Decl(a.js, 49, 14)) +>inStaticGetter : Symbol(C.inStaticGetter, Decl(a.js, 72, 28), Decl(a.js, 75, 14)) var stringOrNumberOrUndefined = C.inStaticSetter; ->stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 16, 3), Decl(b.ts, 17, 3), Decl(b.ts, 18, 3)) ->C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) >C : Symbol(C, Decl(a.js, 0, 0)) ->inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 54, 28), Decl(a.js, 57, 14)) +>inStaticSetter : Symbol(C.inStaticSetter, Decl(a.js, 80, 28), Decl(a.js, 83, 14)) + +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticPropertyDeclaration : Symbol(C.inStaticPropertyDeclaration, Decl(a.js, 88, 28), Decl(a.js, 91, 14)) + +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; +>stringOrNumberOrUndefined : Symbol(stringOrNumberOrUndefined, Decl(b.ts, 5, 3), Decl(b.ts, 7, 3), Decl(b.ts, 8, 3), Decl(b.ts, 9, 3), Decl(b.ts, 10, 3), Decl(b.ts, 11, 3), Decl(b.ts, 18, 3), Decl(b.ts, 19, 3), Decl(b.ts, 20, 3), Decl(b.ts, 21, 3), Decl(b.ts, 22, 3)) +>C.inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) +>C : Symbol(C, Decl(a.js, 0, 0)) +>inStaticNestedArrowFunction : Symbol(C.inStaticNestedArrowFunction, Decl(a.js, 63, 32), Decl(a.js, 66, 18)) diff --git a/tests/baselines/reference/inferringClassMembersFromAssignments.types b/tests/baselines/reference/inferringClassMembersFromAssignments.types index 547cc62ba32..d759009983c 100644 --- a/tests/baselines/reference/inferringClassMembersFromAssignments.types +++ b/tests/baselines/reference/inferringClassMembersFromAssignments.types @@ -62,6 +62,33 @@ class C { >this : this >inMultiple : string | number | boolean >"string" : "string" + + var action = () => { +>action : () => void +>() => { if (Math.random()) { this.inNestedArrowFunction = 0; } else { this.inNestedArrowFunction = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inNestedArrowFunction = 0; +>this.inNestedArrowFunction = 0 : 0 +>this.inNestedArrowFunction : string | number | undefined +>this : this +>inNestedArrowFunction : string | number | undefined +>0 : 0 + } + else { + this.inNestedArrowFunction = "string" +>this.inNestedArrowFunction = "string" : "string" +>this.inNestedArrowFunction : string | number | undefined +>this : this +>inNestedArrowFunction : string | number | undefined +>"string" : "string" + } + }; } get() { >get : () => void @@ -116,6 +143,32 @@ class C { >this.inSetter : string | number | undefined >this : this >inSetter : string | number | undefined +>"string" : "string" + } + } + prop = () => { +>prop : () => void +>() => { if (Math.random()) { this.inPropertyDeclaration = 0; } else { this.inPropertyDeclaration = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inPropertyDeclaration = 0; +>this.inPropertyDeclaration = 0 : 0 +>this.inPropertyDeclaration : string | number | undefined +>this : this +>inPropertyDeclaration : string | number | undefined +>0 : 0 + } + else { + this.inPropertyDeclaration = "string" +>this.inPropertyDeclaration = "string" : "string" +>this.inPropertyDeclaration : string | number | undefined +>this : this +>inPropertyDeclaration : string | number | undefined >"string" : "string" } } @@ -143,6 +196,33 @@ class C { >inStaticMethod : string | number | undefined >"string" : "string" } + + var action = () => { +>action : () => void +>() => { if (Math.random()) { this.inStaticNestedArrowFunction = 0; } else { this.inStaticNestedArrowFunction = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticNestedArrowFunction = 0; +>this.inStaticNestedArrowFunction = 0 : 0 +>this.inStaticNestedArrowFunction : string | number | undefined +>this : typeof C +>inStaticNestedArrowFunction : string | number | undefined +>0 : 0 + } + else { + this.inStaticNestedArrowFunction = "string" +>this.inStaticNestedArrowFunction = "string" : "string" +>this.inStaticNestedArrowFunction : string | number | undefined +>this : typeof C +>inStaticNestedArrowFunction : string | number | undefined +>"string" : "string" + } + }; } static get() { >get : () => void @@ -191,6 +271,32 @@ class C { >this.inStaticSetter : string | number | undefined >this : typeof C >inStaticSetter : string | number | undefined +>"string" : "string" + } + } + static prop = () => { +>prop : () => void +>() => { if (Math.random()) { this.inStaticPropertyDeclaration = 0; } else { this.inStaticPropertyDeclaration = "string" } } : () => void + + if (Math.random()) { +>Math.random() : number +>Math.random : () => number +>Math : Math +>random : () => number + + this.inStaticPropertyDeclaration = 0; +>this.inStaticPropertyDeclaration = 0 : 0 +>this.inStaticPropertyDeclaration : string | number | undefined +>this : typeof C +>inStaticPropertyDeclaration : string | number | undefined +>0 : 0 + } + else { + this.inStaticPropertyDeclaration = "string" +>this.inStaticPropertyDeclaration = "string" : "string" +>this.inStaticPropertyDeclaration : string | number | undefined +>this : typeof C +>inStaticPropertyDeclaration : string | number | undefined >"string" : "string" } } @@ -232,6 +338,18 @@ var stringOrNumberOrUndefined = c.inSetter; >c : C >inSetter : string | number | undefined +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +>stringOrNumberOrUndefined : string | number | undefined +>c.inPropertyDeclaration : string | number | undefined +>c : C +>inPropertyDeclaration : string | number | undefined + +var stringOrNumberOrUndefined = c.inNestedArrowFunction +>stringOrNumberOrUndefined : string | number | undefined +>c.inNestedArrowFunction : string | number | undefined +>c : C +>inNestedArrowFunction : string | number | undefined + var stringOrNumberOrBoolean: string | number | boolean; >stringOrNumberOrBoolean : string | number | boolean @@ -260,3 +378,15 @@ var stringOrNumberOrUndefined = C.inStaticSetter; >C : typeof C >inStaticSetter : string | number | undefined +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticPropertyDeclaration : string | number | undefined +>C : typeof C +>inStaticPropertyDeclaration : string | number | undefined + +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; +>stringOrNumberOrUndefined : string | number | undefined +>C.inStaticNestedArrowFunction : string | number | undefined +>C : typeof C +>inStaticNestedArrowFunction : string | number | undefined + diff --git a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts index d843e86b725..9cf02a9c7dd 100644 --- a/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts +++ b/tests/cases/conformance/salsa/inferringClassMembersFromAssignments.ts @@ -21,6 +21,15 @@ class C { this.inMethod = "string" } this.inMultiple = "string"; + + var action = () => { + if (Math.random()) { + this.inNestedArrowFunction = 0; + } + else { + this.inNestedArrowFunction = "string" + } + }; } get() { if (Math.random()) { @@ -39,6 +48,14 @@ class C { this.inSetter = "string" } } + prop = () => { + if (Math.random()) { + this.inPropertyDeclaration = 0; + } + else { + this.inPropertyDeclaration = "string" + } + } static method() { if (Math.random()) { this.inStaticMethod = 0; @@ -46,6 +63,15 @@ class C { else { this.inStaticMethod = "string" } + + var action = () => { + if (Math.random()) { + this.inStaticNestedArrowFunction = 0; + } + else { + this.inStaticNestedArrowFunction = "string" + } + }; } static get() { if (Math.random()) { @@ -63,6 +89,14 @@ class C { this.inStaticSetter = "string" } } + static prop = () => { + if (Math.random()) { + this.inStaticPropertyDeclaration = 0; + } + else { + this.inStaticPropertyDeclaration = "string" + } + } } // @filename: b.ts @@ -76,6 +110,8 @@ var stringOrNumberOrUndefined: string | number | undefined; var stringOrNumberOrUndefined = c.inMethod; var stringOrNumberOrUndefined = c.inGetter; var stringOrNumberOrUndefined = c.inSetter; +var stringOrNumberOrUndefined = c.inPropertyDeclaration; +var stringOrNumberOrUndefined = c.inNestedArrowFunction var stringOrNumberOrBoolean: string | number | boolean; @@ -85,3 +121,5 @@ var stringOrNumberOrBoolean = c.inMultiple; var stringOrNumberOrUndefined = C.inStaticMethod; var stringOrNumberOrUndefined = C.inStaticGetter; var stringOrNumberOrUndefined = C.inStaticSetter; +var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration; +var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction; From 03511c0b092a33e3e1fad2f61406760f2142c769 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 16:36:03 -0700 Subject: [PATCH 066/207] snythesize methods in missing member fix --- src/compiler/factory.ts | 5 +- src/services/codefixes/helpers.ts | 123 ++++++++++++++++++------------ 2 files changed, 80 insertions(+), 48 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 19e8ef25da0..f59eea8461b 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -45,7 +45,10 @@ namespace ts { * Creates a shallow, memberwise clone of a node with no source map location. */ /* @internal */ - export function getSynthesizedClone(node: T): T { + export function getSynthesizedClone(node: T | undefined): T { + if(node === undefined) { + return undefined; + } // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 0af13bf41e4..27195ac0be0 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -28,7 +28,7 @@ namespace ts.codefix { let newNodes: Node[] = []; for (const symbol of missingMembers) { - const newNode = getNewNodeForMemberSymbol(symbol, classDeclaration, checker); + const newNode = createNewNodeForMemberSymbol(symbol, classDeclaration, checker); if (newNode) { if (Array.isArray(newNode)) { newNodes = newNodes.concat(newNode); @@ -44,7 +44,7 @@ namespace ts.codefix { /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function getNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker): Node[] | Node | undefined { + function createNewNodeForMemberSymbol(symbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker): Node[] | Node | undefined { const declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; @@ -52,8 +52,7 @@ namespace ts.codefix { const declaration = declarations[0] as Declaration; const name = declaration.name ? declaration.name.getText() : undefined; - const visibility = getVisibilityPrefixWithSpace(getModifierFlags(declaration)); - + const modifiers = [createVisibilityModifier(getModifierFlags(declaration))]; const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); switch (declaration.kind) { @@ -86,43 +85,55 @@ namespace ts.codefix { } if (declarations.length === 1) { Debug.assert(signatures.length === 1); - // TODO: extract signature declaration from a signature. - // const sigString = checker.signatureToString(signatures[0], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); + // TODO: suppress any return type // TODO: get parameters working. // TODO: add support for type parameters. - return createStubbedMethod([visibility], name, /*typeParameters*/undefined, []); + const signature = signatures[0]; + const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); + const returnType = checker.createTypeNode(signature.resolvedReturnType); + return createStubbedMethod(modifiers, name, /*typeParameters*/undefined, newParameterNodes, returnType); } let signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { // const sigString = checker.signatureToString(signatures[i], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); // TODO: make signatures instead of methods - signatureDeclarations.push(createStubbedMethod([visibility], name, /*typeParameters*/undefined, [])); + const signature = signatures[i]; + const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); + const returnType = checker.createTypeNode(signature.resolvedReturnType); + signatureDeclarations.push(createMethod( + /*decorators*/ undefined + , modifiers + , /*asteriskToken*/ undefined + , name + , /*typeParameters*/undefined + , newParameterNodes + , returnType + , /*body*/undefined)); } - // If there is a declaration with a body, it is the last declaration, - // and it isn't caught by `getSignaturesOfType`. - let bodySig: Signature | undefined = undefined; if (declarations.length > signatures.length) { - bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); + let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); + const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); + const returnType = checker.createTypeNode(signature.resolvedReturnType); + signatureDeclarations.push(createStubbedMethod(modifiers, name, /*typeParameters*/undefined, newParameterNodes, returnType)); } else { Debug.assert(declarations.length === signatures.length); - bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); + const methodImplementingSignatures = createMethodImplementingSignatures(signatures, enclosingDeclaration, name, modifiers); + signatureDeclarations.push(methodImplementingSignatures); } - // const sigString = checker.signatureToString(bodySig, enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); - signatureDeclarations.push(createStubbedMethod([visibility], name, /*typeParameters*/undefined, [])); - return signatureDeclarations; default: return undefined; } } - function createBodySignatureWithAnyTypes(signatures: Signature[], enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker): Signature { - const newSignatureDeclaration = createNode(SyntaxKind.CallSignature) as SignatureDeclaration; - newSignatureDeclaration.parent = enclosingDeclaration; - newSignatureDeclaration.name = signatures[0].getDeclaration().name; + // TODO: infer types of arguments? + function createMethodImplementingSignatures(signatures: Signature[], enclosingDeclaration: ClassLikeDeclaration, name: string, modifiers: Modifier[] | undefined): MethodDeclaration { + const newMethodDeclaration = createNode(SyntaxKind.CallSignature) as SignatureDeclaration; + newMethodDeclaration.parent = enclosingDeclaration; + newMethodDeclaration.name = signatures[0].getDeclaration().name; let maxNonRestArgs = -1; let maxArgsIndex = 0; @@ -133,42 +144,47 @@ namespace ts.codefix { minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); hasRestParameter = hasRestParameter || sig.hasRestParameter; const nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); - if (nonRestLength > maxNonRestArgs) { + if (nonRestLength >= maxNonRestArgs) { maxNonRestArgs = nonRestLength; maxArgsIndex = i; } } const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName()); - const optionalToken = createToken(SyntaxKind.QuestionToken); - - newSignatureDeclaration.parameters = createNodeArray(); + const parameters = createNodeArray(); for (let i = 0; i < maxNonRestArgs; i++) { - const newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); - newSignatureDeclaration.parameters.push(newParameter); + const newParameter = createParameter( + /*decorators*/ undefined + , /*modifiers*/ undefined + , /*dotDotDotToken*/ undefined + , maxArgsParameterSymbolNames[i] + , /*questionToken*/ i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined + , /*type*/ undefined + , /*initializer*/ undefined); + parameters.push(newParameter); } if (hasRestParameter) { - const restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); - restParameter.dotDotDotToken = createToken(SyntaxKind.DotDotDotToken); - newSignatureDeclaration.parameters.push(restParameter); + const restParameter = createParameter( + /*decorators*/ undefined + , /*modifiers*/ undefined + , createToken(SyntaxKind.DotDotDotToken) + , maxArgsParameterSymbolNames[maxNonRestArgs] || "rest" + , /*questionToken*/ maxNonRestArgs >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined + , /*type*/ undefined + , /*initializer*/ undefined); + parameters.push(restParameter); } - return checker.getSignatureFromDeclaration(newSignatureDeclaration); - - function createParameterDeclarationWithoutType(index: number, minArgCount: number, enclosingSignatureDeclaration: SignatureDeclaration): ParameterDeclaration { - const newParameter = createNode(SyntaxKind.Parameter) as ParameterDeclaration; - - newParameter.symbol = new SymbolConstructor(SymbolFlags.FunctionScopedVariable, maxArgsParameterSymbolNames[index] || "rest"); - newParameter.symbol.valueDeclaration = newParameter; - newParameter.symbol.declarations = [newParameter]; - newParameter.parent = enclosingSignatureDeclaration; - if (index >= minArgCount) { - newParameter.questionToken = optionalToken; - } - - return newParameter; - } + return createMethod( + /*decorators*/ undefined + , modifiers + , /*asteriskToken*/ undefined + , name + , /*typeParameters*/undefined + , parameters + , /*type*/ undefined + , /*body*/undefined); } export function createStubbedMethod(modifiers: Modifier[], name: string, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType?: TypeNode) { @@ -187,13 +203,13 @@ namespace ts.codefix { return createBlock( [createThrow( createNew( - createIdentifier('Error') + createIdentifier('Error') , /*typeArguments*/undefined , [createLiteral('Method not implemented.')]))] , /*multiline*/true); } - function getVisibilityPrefixWithSpace(flags: ModifierFlags) { + function createVisibilityModifier(flags: ModifierFlags) { if (flags & ModifierFlags.Public) { return createToken(SyntaxKind.PublicKeyword); } @@ -203,5 +219,18 @@ namespace ts.codefix { return undefined; } - const SymbolConstructor = objectAllocator.getSymbolConstructor(); + function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker) { + const parameterDeclaration = parameterSymbol.getDeclarations()[0] as ParameterDeclaration; + const parameterType = checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration); + const parameterTypeNode = checker.createTypeNode(parameterType); + // TODO: deep cloning of decorators/any node. + const parameterNode = createParameter( + parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedClone) + , parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone) + , parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken) + , parameterDeclaration.name + , parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken) + , parameterTypeNode); + return parameterNode; + } } \ No newline at end of file From f5f01a162f46f69d8dbb6a0e99db00f49b250503 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 17:14:20 -0700 Subject: [PATCH 067/207] Simplify Ranges --- ...ixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts | 3 +-- ...codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts | 3 +-- .../fourslash/codeFixClassExtendAbstractPrivateProperty.ts | 3 +-- tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts | 3 +-- .../fourslash/codeFixClassExtendAbstractProtectedProperty.ts | 3 +-- .../fourslash/codeFixClassExtendAbstractPublicProperty.ts | 4 ++-- .../fourslash/codeFixClassImplementClassMethodViaHeritage.ts | 4 ++-- .../cases/fourslash/codeFixClassImplementDeepInheritance.ts | 3 +-- tests/cases/fourslash/codeFixClassImplementInterface36.ts | 4 +--- tests/cases/fourslash/codeFixClassImplementInterface39.ts | 3 +-- .../codeFixClassImplementInterfaceDuplicateMember1.ts | 3 +-- .../codeFixClassImplementInterfaceIndexSignaturesNumber.ts | 3 +-- ...deFixClassImplementInterfaceMethodThisAndSelfReference.ts | 3 +-- .../codeFixClassImplementInterfaceMultipleImplements1.ts | 5 ++--- .../codeFixClassImplementInterfaceMultipleImplements2.ts | 3 +-- ...ClassImplementInterfaceMultipleImplementsIntersection1.ts | 3 +-- ...ixClassImplementInterfaceMultipleMembersAndPunctuation.ts | 3 +-- .../codeFixClassImplementInterfaceNamespaceConflict.ts | 3 +-- ...mplementInterfacePropertyFromParentConstructorFunction.ts | 2 +- .../codeFixClassImplementInterfaceSomePropertiesPresent.ts | 2 +- ...deFixClassImplementInterfaceTypeParamInstantiateDeeply.ts | 2 +- ...deFixClassImplementInterfaceTypeParamInstantiateNumber.ts | 2 +- .../codeFixClassImplementInterfaceTypeParamInstantiateT.ts | 2 +- .../codeFixClassImplementInterfaceTypeParamInstantiateU.ts | 2 +- 24 files changed, 27 insertions(+), 44 deletions(-) diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts index bdf198b89e3..a69852f5e9a 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts @@ -4,8 +4,7 @@ //// abstract f(x: T): T; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(`f(x: number): number{ throw new Error('Method not implemented.'); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts index 647a533c1c5..98d118214d2 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts @@ -4,8 +4,7 @@ //// abstract f(x: T): T; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(`f(x: U): U{ throw new Error('Method not implemented.'); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts index d395272b36f..b8f6b3d81eb 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPrivateProperty.ts @@ -4,8 +4,7 @@ //// private abstract x: number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} // We don't know how to fix this problem. We can: // 1) Make x protected, and then insert. diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index b7300acf5ae..1973f452f6d 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -7,8 +7,7 @@ //// abstract foo(): number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(` x: number; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts index 6d0571fce6b..d2532ef16de 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProtectedProperty.ts @@ -4,8 +4,7 @@ //// protected abstract x: number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} verify.rangeAfterCodeFix(` protected x: number; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts index 917f75051f1..495d661ec79 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractPublicProperty.ts @@ -4,8 +4,8 @@ //// public abstract x: number; //// } //// -//// class C extends A {[| -//// |]} +//// class C extends A {[| |]} + verify.rangeAfterCodeFix(` public x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts index 4365a160531..b70c2898f15 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts @@ -8,8 +8,8 @@ //// //// } //// -//// class C3 implements C2 {[| -//// |]f2(){} +//// class C3 implements C2 {[| |] +//// f2(){} //// } verify.rangeAfterCodeFix(`f1(): void{ diff --git a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts index e8b199b21af..f11dc29395d 100644 --- a/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts +++ b/tests/cases/fourslash/codeFixClassImplementDeepInheritance.ts @@ -24,8 +24,7 @@ //// } //// //// interface I6 extends C4 {} -//// class C5 implements I6 {[| -//// |]} +//// class C5 implements I6 {[| |]} /** diff --git a/tests/cases/fourslash/codeFixClassImplementInterface36.ts b/tests/cases/fourslash/codeFixClassImplementInterface36.ts index f9fc48991fc..d96ce523902 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface36.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterface36.ts @@ -10,9 +10,7 @@ //// //// interface I1 extends C1, C2 {} //// -//// class C3 implements I1 {[| -//// -//// |]} +//// class C3 implements I1 {[| |]} verify.rangeAfterCodeFix(`f1(){ throw new Error('Method not implemented.'); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface39.ts b/tests/cases/fourslash/codeFixClassImplementInterface39.ts index f81dea49782..1df34c2e1a2 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface39.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterface39.ts @@ -9,8 +9,7 @@ //// f1(); //// } //// -//// class C1 implements N1.I1 {[| -//// |]} +//// class C1 implements N1.I1 {[| |]} verify.rangeAfterCodeFix(`f1(): string{ throw new Error('Method not implemented.'); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts index a2154de567a..bea14ae4040 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceDuplicateMember1.ts @@ -7,7 +7,6 @@ //// x: number; //// } //// -//// class C implements I1,I2 {[| -//// |]} +//// class C implements I1,I2 {[| |]} verify.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts index 0f143442530..41bb7257e41 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts @@ -4,8 +4,7 @@ //// [x: number]: I; //// } //// -//// class C implements I {[| -//// |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` [x: number]: I; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index 95cc3476bf1..48e33e6ef0c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -4,8 +4,7 @@ //// f(x: number, y: this): I //// } //// -//// class C implements I {[| -//// |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` f(x: number,y: this): I { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts index c8d61227c49..5043a4d9c23 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts @@ -7,13 +7,12 @@ //// y: number; //// } //// -//// class C implements I1,I2 {[| +//// class C implements I1,I2 {[| |] //// y: number; -//// |]} +//// } verify.rangeAfterCodeFix(` x: number; -y: number; `); verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts index d29b23998b8..ead23751680 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts @@ -7,13 +7,12 @@ //// y: number; //// } //// -//// class C implements I1,I2 {[| +//// class C implements I1,I2 {[| |] //// x: number; //// |]} verify.rangeAfterCodeFix(` y: number; -x: number; `); verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts index 321d41e4633..cac1038eb18 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplementsIntersection1.ts @@ -7,7 +7,6 @@ //// x: string; //// } //// -//// class C implements I1,I2 {[| -//// |]} +//// class C implements I1,I2 {[| |]} verify.codeFixAvailable(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts index beab89c06a5..afc1dae551c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts @@ -9,8 +9,7 @@ //// h(); //// } //// -//// class C1 implements I1 {[| -//// |]} +//// class C1 implements I1 {[| |]} verify.rangeAfterCodeFix(` x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts index 4fea72aa48f..4ca42640c2c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts @@ -9,8 +9,7 @@ //// f1(); //// } //// -//// class C1 implements N1.I1 {[| -//// |]} +//// class C1 implements N1.I1 {[| |]} verify.rangeAfterCodeFix(` x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts index 2a4ca4df923..acda59513ad 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyFromParentConstructorFunction.ts @@ -4,7 +4,7 @@ //// constructor(public x: number) { } //// } //// -//// class B implements A {[| |]} +//// class B implements A {[| |]} verify.not.codeFixAvailable(); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts index 6e0658019f5..03807ab450c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts @@ -6,7 +6,7 @@ //// z: number & { __iBrand: any }; //// } //// -//// class C implements I {[| |] +//// class C implements I {[| |] //// constructor(public x: number) { } //// y: number; //// } diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts index f76bd5dae99..acccafe0fc3 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateDeeply.ts @@ -4,7 +4,7 @@ //// x: { y: T, z: T[] }; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: { y: number; z: number[]; }; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts index af0e7a162ee..a11101c7f4b 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateNumber.ts @@ -4,7 +4,7 @@ //// x: T; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: number; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts index 45fa3fd40ca..298ee0704f2 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateT.ts @@ -4,7 +4,7 @@ //// x: T; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: T; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts index 16c35f41773..3f1da116f42 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamInstantiateU.ts @@ -4,7 +4,7 @@ //// x: T; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` x: U; From 965d43c6a553aaeb7c849baa9410566974dfd178 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 18:35:48 -0700 Subject: [PATCH 068/207] Print new nodes in correct order --- src/services/codefixes/helpers.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 27195ac0be0..bbbe14ab337 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -10,8 +10,8 @@ namespace ts.codefix { const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); - for (let i = newNodes.length - 1; i >= 0; i--) { - changeTracker.insertNodeAfter(sourceFile, insertAfter, newNodes[i], { insertTrailingNewLine: true }); + for (const newNode of newNodes) { + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { insertTrailingNewLine: true }); } return changeTracker.getChanges(); } @@ -52,7 +52,8 @@ namespace ts.codefix { const declaration = declarations[0] as Declaration; const name = declaration.name ? declaration.name.getText() : undefined; - const modifiers = [createVisibilityModifier(getModifierFlags(declaration))]; + const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); + const modifiers = visibilityModifier ? [visibilityModifier] : undefined; const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); switch (declaration.kind) { @@ -64,7 +65,7 @@ namespace ts.codefix { // TODO: add modifiers. const property = createProperty( /*decorators*/undefined - , /*modifiers*/ undefined + , modifiers , name , /*questionToken*/ undefined , typeNode From 93cd1dc1eab6dc0f18ae9a6d7408015bbe8d5071 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 18:47:17 -0700 Subject: [PATCH 069/207] get name for index info --- src/services/codefixes/fixAddMissingMember.ts | 2 +- .../codefixes/fixClassIncorrectlyImplementsInterface.ts | 3 +-- src/services/codefixes/helpers.ts | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 79b95e4799d..fe12249f176 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -59,7 +59,7 @@ namespace ts.codefix { /*decorators*/ undefined , /*modifiers*/ undefined , /*dotDotDotToken*/ undefined - , "name" + , "x" , /*questionToken*/ undefined , stringTypeNode); const indexSignature = createIndexSignatureDeclaration([indexingParameter], typeNode); diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index a5bde70c011..f653d21e02b 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -54,13 +54,12 @@ namespace ts.codefix { return undefined; } const typeNode = checker.createTypeNode(indexInfoOfKind.type); - let name: string; const newIndexSignatureDeclaration = createIndexSignatureDeclaration( [createParameter( /*decorators*/undefined , /*modifiers*/ undefined , /*dotDotDotToken*/ undefined - , name + , getNameFromIndexInfo(indexInfoOfKind) , /*questionToken*/ undefined , kind === IndexKind.String ? createKeywordTypeNode(SyntaxKind.StringKeyword) : createKeywordTypeNode(SyntaxKind.NumberKeyword))] , typeNode); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index bbbe14ab337..67f53fb8e5a 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -234,4 +234,8 @@ namespace ts.codefix { , parameterTypeNode); return parameterNode; } + + export function getNameFromIndexInfo(info: IndexInfo) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : "x" + } } \ No newline at end of file From 060317759e3b84f3c10ddc26224fba75a121a640 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 18:48:51 -0700 Subject: [PATCH 070/207] Add type parameters --- src/compiler/factory.ts | 21 ++++++++++++++------- src/compiler/types.ts | 2 +- src/compiler/visitor.ts | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index f59eea8461b..901f3a4bd17 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -306,7 +306,7 @@ namespace ts { // Type Declarations - export function createTypeParameterNode(name: string | Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { + export function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; typeParameter.name = asName(name); typeParameter.constraint = constraint; @@ -315,6 +315,14 @@ namespace ts { return typeParameter; } + export function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { + return node.name !== name + || node.constraint !== constraint + || node.default !== defaultParameter + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultParameter), node) + : node; + } + // Signature elements /** Note, can also be used to construct index signatures. */ @@ -330,12 +338,11 @@ namespace ts { // TODO: check usage of name... // TODO: create entry in visitor.ts export function createIndexSignatureDeclaration(parameters: ParameterDeclaration[], type: TypeNode, decorators?: Decorator[], modifiers?: Modifier[]): IndexSignatureDeclaration { - const indexSignature = createSignature( - SyntaxKind.IndexSignature - , asNodeArray(parameters) - , /*name*/ undefined - , /*typeParameters*/undefined - , type) as IndexSignatureDeclaration; + const indexSignature = createSynthesizedNode(SyntaxKind.IndexSignature) as IndexSignatureDeclaration; + // indexSignature.name = asName(name); + // type parameters + indexSignature.parameters = asNodeArray(parameters); + indexSignature.type = type; indexSignature.decorators = asNodeArray(decorators); indexSignature.modifiers = asNodeArray(modifiers); return indexSignature; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 463638484c6..b9f5da0f6e6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -818,7 +818,7 @@ namespace ts { body?: FunctionBody; } - // For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. + /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements.*/ export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 35119dc7fc0..91110accbb0 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -309,8 +309,23 @@ namespace ts { case SyntaxKind.LiteralType: throw new Error("reached unsupported type."); + // Type Declarations + + case SyntaxKind.TypeParameter: + return updateTypeParameterDeclaration(node + , visitNode((node).name, visitor, isIdentifier) + , visitNode((node).constraint, visitor, isTypeNode) + , visitNode((node).default, visitor, isTypeNode)); + // Type members + case SyntaxKind.IndexSignature: + updateIndexSignatureDeclaration(node + , nodesVisitor((node).parameters, visitor, isParameter) + , visitNode((node).type, visitor, isTypeNode) + , nodesVisitor((node).decorators, visitor, isDecorator) + , nodesVisitor((node).modifiers, visitor, isModifier)); + case SyntaxKind.PropertyDeclaration: return updateProperty(node, nodesVisitor((node).decorators, visitor, isDecorator), From 6c72283378a3b3f02dfa380aa41a269fb5078dc6 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 18:52:38 -0700 Subject: [PATCH 071/207] Use consistent quotes --- ...sExprClassImplementClassFunctionVoidInferred.ts | 2 +- .../fourslash/codeFixClassExtendAbstractMethod.ts | 2 +- .../codeFixClassExtendAbstractMethodThis.ts | 2 +- ...endAbstractMethodTypeParamsInstantiateNumber.ts | 2 +- ...ssExtendAbstractMethodTypeParamsInstantiateU.ts | 2 +- .../codeFixClassExtendAbstractProperty.ts | 2 +- ...deFixClassImplementClassFunctionVoidInferred.ts | 2 +- .../codeFixClassImplementClassMethodViaHeritage.ts | 2 +- ...odeFixClassImplementClassMultipleSignatures1.ts | 2 +- ...odeFixClassImplementClassMultipleSignatures2.ts | 2 +- .../fourslash/codeFixClassImplementInterface36.ts | 2 +- .../fourslash/codeFixClassImplementInterface39.ts | 2 +- ...ssImplementInterfaceComputedPropertyLiterals.ts | 4 ++-- ...nterfaceComputedPropertyNameWellKnownSymbols.ts | 14 +++++++------- ...ImplementInterfaceMethodThisAndSelfReference.ts | 2 +- ...lementInterfaceMultipleMembersAndPunctuation.ts | 6 +++--- ...FixClassImplementInterfaceMultipleSignatures.ts | 2 +- ...assImplementInterfaceMultipleSignaturesRest1.ts | 2 +- ...assImplementInterfaceMultipleSignaturesRest2.ts | 2 +- ...odeFixClassImplementInterfaceTypeParamMethod.ts | 2 +- 20 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts index bdf8ea3bd25..2568111fb90 100644 --- a/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts +++ b/tests/cases/fourslash/codeFixClassExprClassImplementClassFunctionVoidInferred.ts @@ -8,6 +8,6 @@ verify.rangeAfterCodeFix(` f(): void{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts index 344a7ee3f2b..b6b408cf5ff 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -15,6 +15,6 @@ verify.rangeAfterCodeFix(` f(a: string, b: number): Function; f(a: string): Function; f(a: any, b?: any) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts index 55b3ad4b77e..a462ac98121 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodThis.ts @@ -8,6 +8,6 @@ verify.rangeAfterCodeFix(` f(): this { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts index a69852f5e9a..c1a55e88034 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateNumber.ts @@ -7,6 +7,6 @@ //// class C extends A {[| |]} verify.rangeAfterCodeFix(`f(x: number): number{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts index 98d118214d2..c2ec5ff8035 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodTypeParamsInstantiateU.ts @@ -7,6 +7,6 @@ //// class C extends A {[| |]} verify.rangeAfterCodeFix(`f(x: U): U{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index 1973f452f6d..83f770b5553 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -14,6 +14,6 @@ verify.rangeAfterCodeFix(` y: this; z: A; foo(): number { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts index d9b9f57d4d2..b8fdace9f7e 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassFunctionVoidInferred.ts @@ -8,6 +8,6 @@ verify.rangeAfterCodeFix(` f(): void{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts index b70c2898f15..ede19ef570a 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts @@ -13,6 +13,6 @@ //// } verify.rangeAfterCodeFix(`f1(): void{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts index 82ecde6c418..2e8dc316b38 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures1.ts @@ -9,6 +9,6 @@ verify.rangeAfterCodeFix(` method(a: number, b: string): boolean; method(a: string | number, b?: string | number): boolean | Function { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts index f187e0ca0f1..463b10c450f 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMultipleSignatures2.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, b: number): Function; method(a: string): Function; method(a: string | number, b?: string | number): boolean | Function { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterface36.ts b/tests/cases/fourslash/codeFixClassImplementInterface36.ts index d96ce523902..5b0459ab663 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface36.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterface36.ts @@ -13,6 +13,6 @@ //// class C3 implements I1 {[| |]} verify.rangeAfterCodeFix(`f1(){ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterface39.ts b/tests/cases/fourslash/codeFixClassImplementInterface39.ts index 1df34c2e1a2..e4e1cf3608a 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterface39.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterface39.ts @@ -12,6 +12,6 @@ //// class C1 implements N1.I1 {[| |]} verify.rangeAfterCodeFix(`f1(): string{ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts index 341b4e59814..4a6bb20f57c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts @@ -11,11 +11,11 @@ verify.rangeAfterCodeFix(` ["foo"](o: any): boolean { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } ["x"]: boolean; [1](): string { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [2]: boolean; `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts index 7c1156acd78..61b4267e7f0 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts @@ -22,30 +22,30 @@ verify.rangeAfterCodeFix(` [Symbol.hasInstance](o: any): boolean { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.isConcatSpreadable]: boolean; [Symbol.iterator]() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.match]: boolean; [Symbol.replace](...args: {}) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.search](str: string): number { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.species](): number { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.split](str: string, limit?: number): {} { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.toPrimitive](hint: "number"): number; [Symbol.toPrimitive](hint: "default"): number; [Symbol.toPrimitive](hint: "string"): string; [Symbol.toPrimitive](hint: any) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } [Symbol.toStringTag]: string; [Symbol.unscopables]: any; diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts index 48e33e6ef0c..b8225f31e04 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodThisAndSelfReference.ts @@ -8,6 +8,6 @@ verify.rangeAfterCodeFix(` f(x: number,y: this): I { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts index afc1dae551c..66cdb1f5454 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleMembersAndPunctuation.ts @@ -16,12 +16,12 @@ x: number; y: number; z: number; f() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } g() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } h() { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts index bda58b3767d..583dda1305c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignatures.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, b: number): Function; method(a: string): Function; method(a: any, b?: any) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts index 6e0a272a42a..132c63ae0fc 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest1.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, ...b: number[]): Function; method(a: string): Function; method(a: any, ...b?: any[]) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts index 7ba7ae2c98c..b4e9a8ff91e 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleSignaturesRest2.ts @@ -13,6 +13,6 @@ verify.rangeAfterCodeFix(` method(a: string, b: number): Function; method(a: string): Function; method(a: any, b?: any, ...rest?: any[]) { - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts index 4d6afaefedc..9bcd4b88456 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceTypeParamMethod.ts @@ -7,6 +7,6 @@ //// class C implements I {[| |]} verify.rangeAfterCodeFix(`f(x: T){ - throw new Error('Method not implemented.'); + throw new Error("Method not implemented."); } `); \ No newline at end of file From 6fe59f34509e9fd99f0ae45964edac8a73e13aa0 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 12 Mar 2017 19:18:51 -0700 Subject: [PATCH 072/207] Unions and intersections --- src/compiler/checker.ts | 49 ++++++++++++++++++----------------------- src/compiler/factory.ts | 5 ++--- src/compiler/visitor.ts | 29 ++++++++++++------------ 3 files changed, 39 insertions(+), 44 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f29204f7ca1..d3e1eeb08e2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2190,20 +2190,34 @@ namespace ts { } function createTypeNode(type: Type) { - // let encounteredError = false; + let undefinedArgumentIsError = true; + let encounteredError = false; let checkAlias = true; return createTypeNodeWorker(type); // function createTypeDeclaration(type: Type): Declaration { // if (!type) { + // if (undefinedArgumentIsError) { encounteredError = true; } // return undefined; // } - // throw new Error("not implemented."); + // if (type.flags & TypeFlags.TypeParameter) { + // const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)) as TypeNode; + // const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)) as TypeNode; + // if (!type.symbol) { + // encounteredError = true; + // throw new Error("No symbol for type parameter so can't get name"); + // } + // const name = getNameOfSymbol(type.symbol); + // return createTypeParameterDeclaration(name, constraint, defaultParameter); + // } + + // throw new Error("type declarations not implemented."); // } function createTypeNodeWorker(type: Type): TypeNode { if (!type) { + if (undefinedArgumentIsError) { encounteredError = true; } return undefined; } @@ -2229,11 +2243,9 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.BooleanKeyword); } if (type.flags & (TypeFlags.StringLiteral)) { - // TODO: check if this actually works with boolean. return createLiteralTypeNode((createLiteral((type).text))); } if (type.flags & (TypeFlags.NumberLiteral)) { - // TODO: check if this actually works with boolean. return createLiteralTypeNode((createNumericLiteral((type).text))); } if (type.flags & TypeFlags.Void) { @@ -2249,40 +2261,27 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.NeverKeyword); } if (type.flags & TypeFlags.Enum) { - throw new Error("not implemented"); + throw new Error("enum not implemented"); } if (type.flags & TypeFlags.ESSymbol) { - throw new Error("not implemented"); + throw new Error("ESSymbol not implemented"); } if (type.flags & TypeFlags.TypeParameter) { throw new Error("Type Parameter declarations only handled in other worker."); - // const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)) as TypeNode; - // const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)) as TypeNode; - // if (!type.symbol) { - // encounteredError = true; - // throw new Error("No symbol for type parameter so can't get name"); - // } - // const name = getNameOfSymbol(type.symbol); - // return createTypeParameterNode(name, constraint, defaultParameter); } if (type.flags & TypeFlags.Union) { - throw new Error("not implemented"); + return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray((type as UnionType).types)); } if (type.flags & TypeFlags.Intersection) { - throw new Error("not implemented"); + return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); } if (type.flags & TypeFlags.Index) { - throw new Error("not implemented"); + throw new Error("index not implemented"); } if (type.flags & TypeFlags.IndexedAccess) { - throw new Error("not implemented"); + throw new Error("indexed access not implemented"); } - // if(type.flags & TypeFlags.Object) { - // throw new Error("not implemented"); - // } - - // TODO: should these be within the if above (check with asserts) const objectFlags = getObjectFlags(type); if (objectFlags & ObjectFlags.ClassOrInterface) { @@ -2390,10 +2389,6 @@ namespace ts { function mapToTypeNodeArray(types: Type[]): NodeArray { return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); } - - // function mapToTypeDeclarationsArray(types: Type[]): NodeArray { - // return asNodeArray(types && types.map(createTypeDeclaration)); - // } } } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 901f3a4bd17..6e10d8bb22b 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -273,10 +273,9 @@ namespace ts { return unionTypeNode; } - export function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: NodeArray) { + export function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray) { return node.types !== types - || node.kind !== kind - ? updateNode(createUnionOrIntersectionTypeNode(kind, types), node) + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) : node; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 91110accbb0..bd2d26b7753 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -275,39 +275,40 @@ namespace ts { // Types case SyntaxKind.TypePredicate: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeReference: return updateTypeReferenceNode(node , visitNode((node).typeName as Identifier, visitor) , nodesVisitor((node).typeArguments, visitor) ); case SyntaxKind.FunctionType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.ConstructorType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeQuery: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeLiteral: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.ArrayType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.TupleType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.UnionType: case SyntaxKind.IntersectionType: - throw new Error("reached unsupported type."); + return updateUnionOrIntersectionTypeNode(node + , nodesVisitor((node).types, visitor, isTypeNode)); case SyntaxKind.ParenthesizedType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.ThisType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeOperator: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.IndexedAccessType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.MappedType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); case SyntaxKind.LiteralType: - throw new Error("reached unsupported type."); + throw new Error("reached unsupported type in visitor."); // Type Declarations From f0b4efe94f7e1817b3075cd2a39d3ccd3544b4c6 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 13 Mar 2017 09:18:40 -0700 Subject: [PATCH 073/207] type literals, properties only --- src/compiler/checker.ts | 100 ++++++++++-------- src/compiler/factory.ts | 12 ++- src/compiler/types.ts | 2 +- src/compiler/visitor.ts | 25 ++++- src/services/codefixes/helpers.ts | 1 + src/services/textChanges.ts | 20 ---- ...lassExtendAbstractSomePropertiesPresent.ts | 4 +- ...FixClassImplementClassMethodViaHeritage.ts | 4 +- ...lementInterfaceComputedPropertyLiterals.ts | 2 +- 9 files changed, 97 insertions(+), 73 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d3e1eeb08e2..65907536f84 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2196,25 +2196,6 @@ namespace ts { return createTypeNodeWorker(type); - // function createTypeDeclaration(type: Type): Declaration { - // if (!type) { - // if (undefinedArgumentIsError) { encounteredError = true; } - // return undefined; - // } - // if (type.flags & TypeFlags.TypeParameter) { - // const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)) as TypeNode; - // const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)) as TypeNode; - // if (!type.symbol) { - // encounteredError = true; - // throw new Error("No symbol for type parameter so can't get name"); - // } - // const name = getNameOfSymbol(type.symbol); - // return createTypeParameterDeclaration(name, constraint, defaultParameter); - // } - - // throw new Error("type declarations not implemented."); - // } - function createTypeNodeWorker(type: Type): TypeNode { if (!type) { if (undefinedArgumentIsError) { encounteredError = true; } @@ -2267,6 +2248,9 @@ namespace ts { throw new Error("ESSymbol not implemented"); } if (type.flags & TypeFlags.TypeParameter) { + if ((type).isThisType) { + return createThis(); + } throw new Error("Type Parameter declarations only handled in other worker."); } if (type.flags & TypeFlags.Union) { @@ -2332,27 +2316,12 @@ namespace ts { // return typeSymbolAccessibility === SymbolAccessibility.Accessible // && (!constraint || isTypeAccessibleWorker(constraint, inObjectLiteral, /*inTypeAlias*/false)); // } - // if (typeSymbolAccessibility === SymbolAccessibility.Accessible) { - // return true; - // } - // if (type.flags & (TypeFlags.Intrinsic | TypeFlags.Literal)) { - // return true; - // } // const objectFlags = getObjectFlags(type); // if (objectFlags & ObjectFlags.ClassOrInterface) { // // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, // // type must be an anonymous class or interface. // return false; // } - // if (objectFlags & ObjectFlags.Reference) { - // // and vice versa. - // // this case includes tuple types - // const typeArguments = (type as TypeReference).typeArguments || emptyArray; - // return allTypesVisible(typeArguments); - // } - // if (type.flags & TypeFlags.UnionOrIntersection) { - // return allTypesVisible((type as UnionOrIntersectionType).types); - // } if (objectFlags & ObjectFlags.Mapped) { Debug.assert(!!(type.flags & TypeFlags.Object)); @@ -2370,25 +2339,68 @@ namespace ts { // mapToTypeDeclarationsArray(type) - throw new Error("object literal types not implemented."); + throw new Error("unknown case."); } - // what case is this? - throw new Error("unknown case.") - // const members = type.symbol.members; - // let allVisible = true; - // members && members.forEach((member) => { - // const memberType = getTypeOfSymbolAtLocation(member, enclosingDeclaration); - // allVisible = allVisible && isTypeAccessibleWorker(memberType, /*inObjectLiteral*/ true, /*inTypeAlias*/false); - // }); - // return allVisible; + + const members = type.symbol.members; + const newMembers: TypeElement[] = []; + memberLoop: for(const key in members){ + const oldMember = members.get(key); + const name = getNameOfSymbol(oldMember); + const oldDeclaration = oldMember.declarations && oldMember.declarations[0] as TypeElement; + if(!oldDeclaration) { + continue memberLoop; + } + + const kind = oldDeclaration.kind; + + switch (kind) { + case SyntaxKind.PropertySignature: + const optional = !!oldDeclaration.questionToken; + newMembers.push(createPropertySignature( + createIdentifier(name) + , optional ? createToken(SyntaxKind.QuestionToken) : undefined + , createTypeNode(getTypeOfSymbol(oldMember)))); + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + default: + throw new Error("type literal constituent not implemented."); + } + } + return createTypeLiteralNode(newMembers); } Debug.fail("Should be unreachable."); + // function createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration { + // if (!type) { + // if (undefinedArgumentIsError) { encounteredError = true; } + // return undefined; + // } + // if (type.flags & TypeFlags.TypeParameter) { + // const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)) as TypeNode; + // const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)) as TypeNode; + // if (!type.symbol) { + // encounteredError = true; + // throw new Error("No symbol for type parameter so can't get name"); + // } + // const name = getNameOfSymbol(type.symbol); + // return createTypeParameterDeclaration(name, constraint, defaultParameter); + // } + // throw new Error("type declarations not implemented."); + // } + /** Note that mapToTypeNodeArray(undefined) === undefined. */ function mapToTypeNodeArray(types: Type[]): NodeArray { return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); } + + // /** Note that mapToTypeNodeArray(undefined) === undefined. */ + // function mapToTypeParameterArray(types: Type[]): NodeArray { + // return asNodeArray(types && types.map(createTypeParameterDeclarationFromType) as TypeNode[]); + // } } } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 6e10d8bb22b..88bf5f458f6 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -67,6 +67,14 @@ namespace ts { return clone; } + /* @internal */ + export function getSynthesizedDeepClone(node: T | undefined): T { + if (node === undefined) { + return undefined; + } + return getSynthesizedClone(visitEachChild(node, getSynthesizedClone, nullTransformationContext)); + } + // Literals export function createLiteral(value: string): StringLiteral; @@ -173,11 +181,11 @@ namespace ts { } export function createThis() { - return createSynthesizedNode(SyntaxKind.ThisKeyword); + return createSynthesizedNode(SyntaxKind.ThisKeyword); } export function createNull() { - return createSynthesizedNode(SyntaxKind.NullKeyword); + return createSynthesizedNode(SyntaxKind.NullKeyword); } export function createTrue() { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b9f5da0f6e6..bf8916026fd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4065,7 +4065,7 @@ namespace ts { export type Transformer = (node: T) => T; /** - * A function that accepts and possible transforms a node. + * A function that accepts and possibly transforms a node. */ export type Visitor = (node: Node) => VisitResult; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index bd2d26b7753..d2991b7cf03 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -3,6 +3,28 @@ /// namespace ts { + + + export const nullTransformationContext: TransformationContext = { + enableEmitNotification: noop, + enableSubstitution: noop, + endLexicalEnvironment: () => undefined, + getCompilerOptions: notImplemented, + getEmitHost: notImplemented, + getEmitResolver: notImplemented, + hoistFunctionDeclaration: noop, + hoistVariableDeclaration: noop, + isEmitNotificationEnabled: notImplemented, + isSubstitutionEnabled: notImplemented, + onEmitNode: noop, + onSubstituteNode: notImplemented, + readEmitHelpers: notImplemented, + requestEmitHelper: noop, + resumeLexicalEnvironment: noop, + startLexicalEnvironment: noop, + suspendLexicalEnvironment: noop + }; + /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * @@ -813,7 +835,8 @@ namespace ts { visitNode((node).expression, visitor, isExpression)); default: - return node; + throw new Error("not handled"); + // return node; } } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 67f53fb8e5a..fb76e83faa7 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -51,6 +51,7 @@ namespace ts.codefix { } const declaration = declarations[0] as Declaration; + // TODO: get name as identifier or computer property name, etc. const name = declaration.name ? declaration.name.getText() : undefined; const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); const modifiers = visibilityModifier ? [visibilityModifier] : undefined; diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 5c345e6e4e4..cb8c614cb22 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -341,26 +341,6 @@ namespace ts.textChanges { return skipTrivia(s, 0) === s.length; } - const nullTransformationContext: TransformationContext = { - enableEmitNotification: noop, - enableSubstitution: noop, - endLexicalEnvironment: () => undefined, - getCompilerOptions: notImplemented, - getEmitHost: notImplemented, - getEmitResolver: notImplemented, - hoistFunctionDeclaration: noop, - hoistVariableDeclaration: noop, - isEmitNotificationEnabled: notImplemented, - isSubstitutionEnabled: notImplemented, - onEmitNode: noop, - onSubstituteNode: notImplemented, - readEmitHelpers: notImplemented, - requestEmitHelper: noop, - resumeLexicalEnvironment: noop, - startLexicalEnvironment: noop, - suspendLexicalEnvironment: noop - }; - function assignPositionsToNode(node: Node): Node { const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray); // create proxy node for non synthesized nodes diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts b/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts index b6dd679bb71..fb66a04cd5c 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractSomePropertiesPresent.ts @@ -6,8 +6,8 @@ //// abstract z: number; //// } //// -//// class C extends A {[| |] -//// constructor(public x: number) { super(); } +//// class C extends A {[| +//// |]constructor(public x: number) { super(); } //// y: number; //// } diff --git a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts index ede19ef570a..57372dd7e8f 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMethodViaHeritage.ts @@ -8,8 +8,8 @@ //// //// } //// -//// class C3 implements C2 {[| |] -//// f2(){} +//// class C3 implements C2 {[| +//// |]f2(){} //// } verify.rangeAfterCodeFix(`f1(): void{ diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts index 4a6bb20f57c..7d77c5b9af3 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyLiterals.ts @@ -7,7 +7,7 @@ //// [2]: boolean; //// } //// -//// class C implements I {[| |]} +//// class C implements I {[| |]} verify.rangeAfterCodeFix(` ["foo"](o: any): boolean { From 53f04ad89c03892638cceb8a883f25a42764befc Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 13 Mar 2017 09:28:05 -0700 Subject: [PATCH 074/207] Update issue template to use TS2.2 --- issue_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/issue_template.md b/issue_template.md index 4d397a0afd6..29190e79763 100644 --- a/issue_template.md +++ b/issue_template.md @@ -2,7 +2,7 @@ -**TypeScript Version:** 2.1.1 / nightly (2.2.0-dev.201xxxxx) +**TypeScript Version:** 2.2.1 / nightly (2.2.0-dev.201xxxxx) **Code** From c46a2e7e1b6f05ce79fb2fa551edaec1b481a39c Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Mon, 13 Mar 2017 12:45:28 -0700 Subject: [PATCH 075/207] always create new node array when assigning positions --- src/services/textChanges.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 5c345e6e4e4..5b9f0f5ef4d 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -380,7 +380,7 @@ namespace ts.textChanges { return visited; } // clone nodearray if necessary - const nodeArray = visited === nodes ? createNodeArray(visited) : visited; + const nodeArray = visited === nodes ? createNodeArray(visited.slice(0)) : visited; nodeArray.pos = getPos(nodes); nodeArray.end = getEnd(nodes); return nodeArray; From 3f3b05e67e35c7e97ca3c6bb76be7006aaef72f5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 13 Mar 2017 13:15:09 -0700 Subject: [PATCH 076/207] Properly track method/property distinction for intersection members --- src/compiler/checker.ts | 38 +++++++++++++++++-------------- src/compiler/types.ts | 16 +++++++------ src/services/findAllReferences.ts | 2 +- src/services/symbolDisplay.ts | 2 +- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 00498191f28..b581ca315b4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5129,7 +5129,8 @@ namespace ts { const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0; // Flags we want to propagate to the result if they exist in all source symbols let commonFlags = isUnion ? SymbolFlags.None : SymbolFlags.Optional; - let checkFlags = CheckFlags.SyntheticProperty; + let syntheticFlag = CheckFlags.SyntheticMethod; + let checkFlags = 0; for (const current of types) { const type = getApparentType(current); if (type !== unknownType) { @@ -5148,6 +5149,9 @@ namespace ts { (modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) | (modifiers & ModifierFlags.Private ? CheckFlags.ContainsPrivate : 0) | (modifiers & ModifierFlags.Static ? CheckFlags.ContainsStatic : 0); + if (!isMethodLike(prop)) { + syntheticFlag = CheckFlags.SyntheticProperty; + } } else if (isUnion) { checkFlags |= CheckFlags.Partial; @@ -5177,7 +5181,7 @@ namespace ts { propTypes.push(type); } const result = createSymbol(SymbolFlags.Property | commonFlags, name); - result.checkFlags = checkFlags; + result.checkFlags = syntheticFlag | checkFlags; result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -8630,7 +8634,7 @@ namespace ts { // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop: Symbol, callback: (p: Symbol) => T): T { - if (getCheckFlags(prop) & CheckFlags.SyntheticProperty) { + if (getCheckFlags(prop) & CheckFlags.Synthetic) { for (const t of (prop).containingType.types) { const p = getPropertyOfType(t, prop.name); const result = p && forEachProperty(p, callback); @@ -13112,7 +13116,7 @@ namespace ts { const flags = getCombinedModifierFlags(s.valueDeclaration); return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier; } - if (getCheckFlags(s) & CheckFlags.SyntheticProperty) { + if (getCheckFlags(s) & CheckFlags.Synthetic) { const checkFlags = (s).checkFlags; const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private : checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public : @@ -13130,6 +13134,10 @@ namespace ts { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0; } + function isMethodLike(symbol: Symbol) { + return !!(symbol.flags & SymbolFlags.Method || getCheckFlags(symbol) & CheckFlags.SyntheticMethod); + } + /** * Check whether the requested property access is valid. * Returns true if node is a valid property access, and false otherwise. @@ -13159,11 +13167,11 @@ namespace ts { // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. if (languageVersion < ScriptTarget.ES2015) { - const propKind = getDeclarationKindFromSymbol(prop); - if (propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature) { - // `prop` refers to a *property* declared in the super class - // rather than a *method*, so it does not satisfy the above criteria. - + const hasNonMethodDeclaration = forEachProperty(prop, p => { + const propKind = getDeclarationKindFromSymbol(p); + return propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature; + }); + if (hasNonMethodDeclaration) { error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -19697,7 +19705,7 @@ namespace ts { else { // derived overrides base. const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if ((baseDeclarationFlags & ModifierFlags.Private) || (derivedDeclarationFlags & ModifierFlags.Private)) { + if (baseDeclarationFlags & ModifierFlags.Private || derivedDeclarationFlags & ModifierFlags.Private) { // either base or derived property is private - not override, skip it continue; } @@ -19707,28 +19715,24 @@ namespace ts { continue; } - if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { + if (isMethodLike(base) && isMethodLike(derived) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } let errorMessage: DiagnosticMessage; - if (base.flags & SymbolFlags.Method) { + if (isMethodLike(base)) { if (derived.flags & SymbolFlags.Accessor) { errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - Debug.assert((derived.flags & SymbolFlags.Property) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & SymbolFlags.Property) { - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } @@ -21387,7 +21391,7 @@ namespace ts { } function getRootSymbols(symbol: Symbol): Symbol[] { - if (getCheckFlags(symbol) & CheckFlags.SyntheticProperty) { + if (getCheckFlags(symbol) & CheckFlags.Synthetic) { const symbols: Symbol[] = []; const name = symbol.name; forEach(getSymbolLinks(symbol).containingType.types, t => { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 97b12aeb712..e36731ff363 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2811,13 +2811,15 @@ namespace ts { export const enum CheckFlags { Instantiated = 1 << 0, // Instantiated symbol SyntheticProperty = 1 << 1, // Property in union or intersection type - Readonly = 1 << 2, // Readonly transient symbol - Partial = 1 << 3, // Synthetic property present in some but not all constituents - HasNonUniformType = 1 << 4, // Synthetic property with non-uniform type in constituents - ContainsPublic = 1 << 5, // Synthetic property with public constituent(s) - ContainsProtected = 1 << 6, // Synthetic property with protected constituent(s) - ContainsPrivate = 1 << 7, // Synthetic property with private constituent(s) - ContainsStatic = 1 << 8, // Synthetic property with static constituent(s) + SyntheticMethod = 1 << 2, // Method in union or intersection type + Readonly = 1 << 3, // Readonly transient symbol + Partial = 1 << 4, // Synthetic property present in some but not all constituents + HasNonUniformType = 1 << 5, // Synthetic property with non-uniform type in constituents + ContainsPublic = 1 << 6, // Synthetic property with public constituent(s) + ContainsProtected = 1 << 7, // Synthetic property with protected constituent(s) + ContainsPrivate = 1 << 8, // Synthetic property with private constituent(s) + ContainsStatic = 1 << 9, // Synthetic property with static constituent(s) + Synthetic = SyntheticProperty | SyntheticMethod } /* @internal */ diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bc1e50391c8..2c999ba9fa0 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -281,7 +281,7 @@ namespace ts.FindAllReferences { // if this symbol is visible from its parent container, e.g. exported, then bail out // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.SyntheticProperty)) { + if (symbol.parent || (symbol.flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.Synthetic)) { return undefined; } diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index b7b739b4244..b457165b67f 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -52,7 +52,7 @@ namespace ts.SymbolDisplay { if (flags & SymbolFlags.Constructor) return ScriptElementKind.constructorImplementationElement; if (flags & SymbolFlags.Property) { - if (flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.SyntheticProperty) { + if (flags & SymbolFlags.Transient && (symbol).checkFlags & CheckFlags.Synthetic) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property const unionPropertyKind = forEach(typeChecker.getRootSymbols(symbol), rootSymbol => { const rootSymbolFlags = rootSymbol.getFlags(); From dd84d7ca483c6a94592b592ab07fb980c21e2732 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 13 Mar 2017 13:24:14 -0700 Subject: [PATCH 077/207] Add repro --- .../overrideBaseIntersectionMethod.js | 83 ++++++++++++++ .../overrideBaseIntersectionMethod.symbols | 88 +++++++++++++++ .../overrideBaseIntersectionMethod.types | 102 ++++++++++++++++++ .../overrideBaseIntersectionMethod.ts | 31 ++++++ 4 files changed, 304 insertions(+) create mode 100644 tests/baselines/reference/overrideBaseIntersectionMethod.js create mode 100644 tests/baselines/reference/overrideBaseIntersectionMethod.symbols create mode 100644 tests/baselines/reference/overrideBaseIntersectionMethod.types create mode 100644 tests/cases/compiler/overrideBaseIntersectionMethod.ts diff --git a/tests/baselines/reference/overrideBaseIntersectionMethod.js b/tests/baselines/reference/overrideBaseIntersectionMethod.js new file mode 100644 index 00000000000..26613f07469 --- /dev/null +++ b/tests/baselines/reference/overrideBaseIntersectionMethod.js @@ -0,0 +1,83 @@ +//// [overrideBaseIntersectionMethod.ts] + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; + +const WithLocation = >(Base: T) => class extends Base { + getLocation(): [number, number] { + const [x,y] = super.getLocation(); + return [this.x | x, this.y | y]; + } +} + +class Point { + constructor(public x: number, public y: number) { } + getLocation(): [number, number] { + return [0,0]; + } +} + +class Foo extends WithLocation(Point) { + calculate() { + return this.x + this.y; + } + getLocation() { + return super.getLocation() + } + whereAmI() { + return this.getLocation(); + } +} + + +//// [overrideBaseIntersectionMethod.js] +// Repro from #14615 +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var WithLocation = function (Base) { return (function (_super) { + __extends(class_1, _super); + function class_1() { + return _super !== null && _super.apply(this, arguments) || this; + } + class_1.prototype.getLocation = function () { + var _a = _super.prototype.getLocation.call(this), x = _a[0], y = _a[1]; + return [this.x | x, this.y | y]; + }; + return class_1; +}(Base)); }; +var Point = (function () { + function Point(x, y) { + this.x = x; + this.y = y; + } + Point.prototype.getLocation = function () { + return [0, 0]; + }; + return Point; +}()); +var Foo = (function (_super) { + __extends(Foo, _super); + function Foo() { + return _super !== null && _super.apply(this, arguments) || this; + } + Foo.prototype.calculate = function () { + return this.x + this.y; + }; + Foo.prototype.getLocation = function () { + return _super.prototype.getLocation.call(this); + }; + Foo.prototype.whereAmI = function () { + return this.getLocation(); + }; + return Foo; +}(WithLocation(Point))); diff --git a/tests/baselines/reference/overrideBaseIntersectionMethod.symbols b/tests/baselines/reference/overrideBaseIntersectionMethod.symbols new file mode 100644 index 00000000000..45a84543408 --- /dev/null +++ b/tests/baselines/reference/overrideBaseIntersectionMethod.symbols @@ -0,0 +1,88 @@ +=== tests/cases/compiler/overrideBaseIntersectionMethod.ts === + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; +>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17)) +>args : Symbol(args, Decl(overrideBaseIntersectionMethod.ts, 3, 27)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 3, 17)) + +const WithLocation = >(Base: T) => class extends Base { +>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22)) +>Constructor : Symbol(Constructor, Decl(overrideBaseIntersectionMethod.ts, 0, 0)) +>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) +>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52)) +>T : Symbol(T, Decl(overrideBaseIntersectionMethod.ts, 5, 22)) +>Base : Symbol(Base, Decl(overrideBaseIntersectionMethod.ts, 5, 52)) + + getLocation(): [number, number] { +>getLocation : Symbol((Anonymous class).getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84)) + + const [x,y] = super.getLocation(); +>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11)) +>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13)) +>super.getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53)) +>super : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) +>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53)) + + return [this.x | x, this.y | y]; +>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63)) +>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>x : Symbol(x, Decl(overrideBaseIntersectionMethod.ts, 7, 11)) +>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) +>this : Symbol((Anonymous class), Decl(overrideBaseIntersectionMethod.ts, 5, 63)) +>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) +>y : Symbol(y, Decl(overrideBaseIntersectionMethod.ts, 7, 13)) + } +} + +class Point { +>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) + + constructor(public x: number, public y: number) { } +>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) + + getLocation(): [number, number] { +>getLocation : Symbol(Point.getLocation, Decl(overrideBaseIntersectionMethod.ts, 13, 53)) + + return [0,0]; + } +} + +class Foo extends WithLocation(Point) { +>Foo : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>WithLocation : Symbol(WithLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 5)) +>Point : Symbol(Point, Decl(overrideBaseIntersectionMethod.ts, 10, 1)) + + calculate() { +>calculate : Symbol(Foo.calculate, Decl(overrideBaseIntersectionMethod.ts, 19, 39)) + + return this.x + this.y; +>this.x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>x : Symbol(Point.x, Decl(overrideBaseIntersectionMethod.ts, 13, 14)) +>this.y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) +>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>y : Symbol(Point.y, Decl(overrideBaseIntersectionMethod.ts, 13, 31)) + } + getLocation() { +>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3)) + + return super.getLocation() +>super.getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53)) +>getLocation : Symbol(getLocation, Decl(overrideBaseIntersectionMethod.ts, 5, 84), Decl(overrideBaseIntersectionMethod.ts, 13, 53)) + } + whereAmI() { +>whereAmI : Symbol(Foo.whereAmI, Decl(overrideBaseIntersectionMethod.ts, 25, 3)) + + return this.getLocation(); +>this.getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3)) +>this : Symbol(Foo, Decl(overrideBaseIntersectionMethod.ts, 17, 1)) +>getLocation : Symbol(Foo.getLocation, Decl(overrideBaseIntersectionMethod.ts, 22, 3)) + } +} + diff --git a/tests/baselines/reference/overrideBaseIntersectionMethod.types b/tests/baselines/reference/overrideBaseIntersectionMethod.types new file mode 100644 index 00000000000..3e31211bdbf --- /dev/null +++ b/tests/baselines/reference/overrideBaseIntersectionMethod.types @@ -0,0 +1,102 @@ +=== tests/cases/compiler/overrideBaseIntersectionMethod.ts === + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; +>Constructor : Constructor +>T : T +>args : any[] +>T : T + +const WithLocation = >(Base: T) => class extends Base { +>WithLocation : >(Base: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>>(Base: T) => class extends Base { getLocation(): [number, number] { const [x,y] = super.getLocation(); return [this.x | x, this.y | y]; }} : >(Base: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>T : T +>Constructor : Constructor +>Point : Point +>Base : T +>T : T +>class extends Base { getLocation(): [number, number] { const [x,y] = super.getLocation(); return [this.x | x, this.y | y]; }} : { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>Base : Point + + getLocation(): [number, number] { +>getLocation : () => [number, number] + + const [x,y] = super.getLocation(); +>x : number +>y : number +>super.getLocation() : [number, number] +>super.getLocation : () => [number, number] +>super : Point +>getLocation : () => [number, number] + + return [this.x | x, this.y | y]; +>[this.x | x, this.y | y] : [number, number] +>this.x | x : number +>this.x : number +>this : this +>x : number +>x : number +>this.y | y : number +>this.y : number +>this : this +>y : number +>y : number + } +} + +class Point { +>Point : Point + + constructor(public x: number, public y: number) { } +>x : number +>y : number + + getLocation(): [number, number] { +>getLocation : () => [number, number] + + return [0,0]; +>[0,0] : [number, number] +>0 : 0 +>0 : 0 + } +} + +class Foo extends WithLocation(Point) { +>Foo : Foo +>WithLocation(Point) : .(Anonymous class) & Point +>WithLocation : >(Base: T) => { new (...args: any[]): (Anonymous class); prototype: .(Anonymous class); } & T +>Point : typeof Point + + calculate() { +>calculate : () => number + + return this.x + this.y; +>this.x + this.y : number +>this.x : number +>this : this +>x : number +>this.y : number +>this : this +>y : number + } + getLocation() { +>getLocation : () => [number, number] + + return super.getLocation() +>super.getLocation() : [number, number] +>super.getLocation : () => [number, number] +>super : .(Anonymous class) & Point +>getLocation : () => [number, number] + } + whereAmI() { +>whereAmI : () => [number, number] + + return this.getLocation(); +>this.getLocation() : [number, number] +>this.getLocation : () => [number, number] +>this : this +>getLocation : () => [number, number] + } +} + diff --git a/tests/cases/compiler/overrideBaseIntersectionMethod.ts b/tests/cases/compiler/overrideBaseIntersectionMethod.ts new file mode 100644 index 00000000000..99cd4664bc5 --- /dev/null +++ b/tests/cases/compiler/overrideBaseIntersectionMethod.ts @@ -0,0 +1,31 @@ +// @strict: true + +// Repro from #14615 + +type Constructor = new (...args: any[]) => T; + +const WithLocation = >(Base: T) => class extends Base { + getLocation(): [number, number] { + const [x,y] = super.getLocation(); + return [this.x | x, this.y | y]; + } +} + +class Point { + constructor(public x: number, public y: number) { } + getLocation(): [number, number] { + return [0,0]; + } +} + +class Foo extends WithLocation(Point) { + calculate() { + return this.x + this.y; + } + getLocation() { + return super.getLocation() + } + whereAmI() { + return this.getLocation(); + } +} From d86976a9efba2d573a808b4644efc28afd67c978 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Tue, 14 Mar 2017 08:06:00 +0900 Subject: [PATCH 078/207] Convert overloads to unions --- src/lib/es5.d.ts | 47 +++---------------- .../reference/bestChoiceType.symbols | 12 ++--- .../baselines/reference/bestChoiceType.types | 12 ++--- .../controlFlowPropertyDeclarations.symbols | 8 ++-- .../controlFlowPropertyDeclarations.types | 8 ++-- ...nContextuallyTypesFunctionParamter.symbols | 4 +- ...yInContextuallyTypesFunctionParamter.types | 4 +- ...overloadResolutionOverNonCTLambdas.symbols | 4 +- .../overloadResolutionOverNonCTLambdas.types | 4 +- .../baselines/reference/parser630933.symbols | 4 +- tests/baselines/reference/parser630933.types | 4 +- .../regExpWithSlashInCharClass.symbols | 12 ++--- .../regExpWithSlashInCharClass.types | 12 ++--- 13 files changed, 51 insertions(+), 84 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 61f8e396471..7d3a2179a38 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -325,53 +325,27 @@ interface String { * Matches a string with a regular expression, and returns an array containing the results of that search. * @param regexp A variable name or string literal containing the regular expression pattern and flags. */ - match(regexp: string): RegExpMatchArray | null; - - /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. - */ - match(regexp: RegExp): RegExpMatchArray | null; + match(regexp: string | RegExp): RegExpMatchArray | null; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ - replace(searchValue: string, replaceValue: string): string; + replace(searchValue: string | RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replacer A function that returns the replacement text. */ - replace(searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. - */ - replace(searchValue: RegExp, replaceValue: string): string; - - /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags - * @param replacer A function that returns the replacement text. - */ - replace(searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; + replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** * Finds the first substring match in a regular expression search. * @param regexp The regular expression pattern and applicable flags. */ - search(regexp: string): number; - - /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ - search(regexp: RegExp): number; + search(regexp: string | RegExp): number; /** * Returns a section of a string. @@ -386,14 +360,7 @@ interface String { * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. * @param limit A value used to limit the number of elements returned in the array. */ - split(separator: string, limit?: number): string[]; - - /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ - split(separator: RegExp, limit?: number): string[]; + split(separator: string | RegExp, limit?: number): string[]; /** * Returns the substring at the specified location within a String object. @@ -861,9 +828,9 @@ interface RegExp { } interface RegExpConstructor { - new (pattern: RegExp): RegExp; + new (pattern: RegExp | string): RegExp; new (pattern: string, flags?: string): RegExp; - (pattern: RegExp): RegExp; + (pattern: RegExp | string): RegExp; (pattern: string, flags?: string): RegExp; readonly prototype: RegExp; diff --git a/tests/baselines/reference/bestChoiceType.symbols b/tests/baselines/reference/bestChoiceType.symbols index 45f4342992e..d6197ad9a6b 100644 --- a/tests/baselines/reference/bestChoiceType.symbols +++ b/tests/baselines/reference/bestChoiceType.symbols @@ -4,8 +4,8 @@ (''.match(/ /) || []).map(s => s.toLowerCase()); >(''.match(/ /) || []).map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.match : Symbol(String.match, Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) >map : Symbol(Array.map, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >s : Symbol(s, Decl(bestChoiceType.ts, 3, 26)) >s.toLowerCase : Symbol(String.toLowerCase, Decl(lib.d.ts, --, --)) @@ -19,8 +19,8 @@ function f1() { let x = ''.match(/ /); >x : Symbol(x, Decl(bestChoiceType.ts, 8, 7)) ->''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.match : Symbol(String.match, Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) let y = x || []; >y : Symbol(y, Decl(bestChoiceType.ts, 9, 7)) @@ -42,8 +42,8 @@ function f2() { let x = ''.match(/ /); >x : Symbol(x, Decl(bestChoiceType.ts, 14, 7)) ->''.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.match : Symbol(String.match, Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) let y = x ? x : []; >y : Symbol(y, Decl(bestChoiceType.ts, 15, 7)) diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index 3a540e97d59..1aa35c8da9e 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -8,9 +8,9 @@ >(''.match(/ /) || []) : RegExpMatchArray >''.match(/ /) || [] : RegExpMatchArray >''.match(/ /) : RegExpMatchArray | null ->''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>''.match : (regexp: string | RegExp) => RegExpMatchArray | null >'' : "" ->match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp >[] : never[] >map : { (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U, U]; (this: [string, string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U, U]; (this: [string, string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U, U]; (this: [string, string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U, U]; (this: [string, string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): [U, U]; (this: [string, string], callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): [U, U]; (this: [string, string], callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): [U, U]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U): U[]; (callbackfn: (this: undefined, value: string, index: number, array: string[]) => U, thisArg: undefined): U[]; (callbackfn: (this: Z, value: string, index: number, array: string[]) => U, thisArg: Z): U[]; } @@ -29,9 +29,9 @@ function f1() { let x = ''.match(/ /); >x : RegExpMatchArray | null >''.match(/ /) : RegExpMatchArray | null ->''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>''.match : (regexp: string | RegExp) => RegExpMatchArray | null >'' : "" ->match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp let y = x || []; @@ -60,9 +60,9 @@ function f2() { let x = ''.match(/ /); >x : RegExpMatchArray | null >''.match(/ /) : RegExpMatchArray | null ->''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>''.match : (regexp: string | RegExp) => RegExpMatchArray | null >'' : "" ->match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } +>match : (regexp: string | RegExp) => RegExpMatchArray | null >/ / : RegExp let y = x ? x : []; diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.symbols b/tests/baselines/reference/controlFlowPropertyDeclarations.symbols index 8e87d71ae33..fdaa61c2e2d 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.symbols +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.symbols @@ -220,15 +220,15 @@ export class HTMLtoJSX { // wrapping newlines and sequences of two or more spaces in variables. text = text >text : Symbol(text, Decl(controlFlowPropertyDeclarations.ts, 113, 7)) ->text .replace(/\r/g, '') .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->text .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>text .replace(/\r/g, '') .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>text .replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >text : Symbol(text, Decl(controlFlowPropertyDeclarations.ts, 113, 7)) .replace(/\r/g, '') ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >whitespace : Symbol(whitespace, Decl(controlFlowPropertyDeclarations.ts, 121, 50)) return '{' + JSON.stringify(whitespace) + '}'; diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.types b/tests/baselines/reference/controlFlowPropertyDeclarations.types index fae5ed27da2..286124ca346 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.types +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.types @@ -295,18 +295,18 @@ export class HTMLtoJSX { >text = text .replace(/\r/g, '') .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { return '{' + JSON.stringify(whitespace) + '}'; }) : string >text : string >text .replace(/\r/g, '') .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { return '{' + JSON.stringify(whitespace) + '}'; }) : string ->text .replace(/\r/g, '') .replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>text .replace(/\r/g, '') .replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >text .replace(/\r/g, '') : string ->text .replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>text .replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >text : string .replace(/\r/g, '') ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/\r/g : RegExp >'' : "" .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/( {2,}|\n|\t|\{|\})/g : RegExp >function(whitespace) { return '{' + JSON.stringify(whitespace) + '}'; } : (whitespace: string) => string >whitespace : string diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols index e2e776cf72e..45b62e29b8a 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.symbols @@ -8,7 +8,7 @@ regexMatchList.forEach(match => ''.replace(match, '')); >regexMatchList : Symbol(regexMatchList, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 1, 3)) >forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) ->''.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>''.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(noImplicitAnyInContextuallyTypesFunctionParamter.ts, 2, 23)) diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types index d7cb482a51c..100d64482ce 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types @@ -14,9 +14,9 @@ regexMatchList.forEach(match => ''.replace(match, '')); >match => ''.replace(match, '') : (this: undefined, match: string) => string >match : string >''.replace(match, '') : string ->''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>''.replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >'' : "" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >match : string >'' : "" diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols index 02390079e38..0070954bb1e 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.symbols @@ -14,9 +14,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : Symbol(result, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 7)) ->message.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>message.replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >message : Symbol(message, Decl(overloadResolutionOverNonCTLambdas.ts, 5, 16)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) >match : Symbol(match, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 55)) >rest : Symbol(rest, Decl(overloadResolutionOverNonCTLambdas.ts, 6, 61)) diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types index a4de1666d0b..ce2171f1e9a 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types @@ -15,9 +15,9 @@ module Bugs { var result= message.replace(/\{(\d+)\}/g, function(match, ...rest) { >result : string >message.replace(/\{(\d+)\}/g, function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; }) : string ->message.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>message.replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >message : string ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/\{(\d+)\}/g : RegExp >function(match, ...rest) { var index= rest[0]; return typeof args[index] !== 'undefined' ? args[index] : match; } : (match: string, ...rest: any[]) => any >match : string diff --git a/tests/baselines/reference/parser630933.symbols b/tests/baselines/reference/parser630933.symbols index 0f2ac0679e0..8aff3b01ffd 100644 --- a/tests/baselines/reference/parser630933.symbols +++ b/tests/baselines/reference/parser630933.symbols @@ -4,7 +4,7 @@ var a = "Hello"; var b = a.match(/\/ver=([^/]+)/); >b : Symbol(b, Decl(parser630933.ts, 1, 3)) ->a.match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a.match : Symbol(String.match, Decl(lib.d.ts, --, --)) >a : Symbol(a, Decl(parser630933.ts, 0, 3)) ->match : Symbol(String.match, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>match : Symbol(String.match, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/parser630933.types b/tests/baselines/reference/parser630933.types index 9a0ba9e7205..7b38c188f2d 100644 --- a/tests/baselines/reference/parser630933.types +++ b/tests/baselines/reference/parser630933.types @@ -6,8 +6,8 @@ var a = "Hello"; var b = a.match(/\/ver=([^/]+)/); >b : RegExpMatchArray >a.match(/\/ver=([^/]+)/) : RegExpMatchArray ->a.match : { (regexp: string): RegExpMatchArray; (regexp: RegExp): RegExpMatchArray; } +>a.match : (regexp: string | RegExp) => RegExpMatchArray >a : string ->match : { (regexp: string): RegExpMatchArray; (regexp: RegExp): RegExpMatchArray; } +>match : (regexp: string | RegExp) => RegExpMatchArray >/\/ver=([^/]+)/ : RegExp diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.symbols b/tests/baselines/reference/regExpWithSlashInCharClass.symbols index 105724b12f1..6ee33e12b45 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.symbols +++ b/tests/baselines/reference/regExpWithSlashInCharClass.symbols @@ -1,16 +1,16 @@ === tests/cases/compiler/regExpWithSlashInCharClass.ts === var foo1 = "a/".replace(/.[/]/, ""); >foo1 : Symbol(foo1, Decl(regExpWithSlashInCharClass.ts, 0, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : Symbol(foo2, Decl(regExpWithSlashInCharClass.ts, 1, 3)) ->"a//".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>"a//".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : Symbol(foo3, Decl(regExpWithSlashInCharClass.ts, 2, 3)) ->"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>"a/".replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replace : Symbol(String.replace, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.types b/tests/baselines/reference/regExpWithSlashInCharClass.types index e866f2bc229..1c980ca8d8b 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.types +++ b/tests/baselines/reference/regExpWithSlashInCharClass.types @@ -2,27 +2,27 @@ var foo1 = "a/".replace(/.[/]/, ""); >foo1 : string >"a/".replace(/.[/]/, "") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : "a/" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/]/ : RegExp >"" : "" var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : string >"a//".replace(/.[//]/g, "") : string ->"a//".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>"a//".replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a//" : "a//" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[//]/g : RegExp >"" : "" var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : string >"a/".replace(/.[/no sleep /till/]/, "bugfix") : string ->"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>"a/".replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >"a/" : "a/" ->replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } +>replace : { (searchValue: string | RegExp, replaceValue: string): string; (searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/no sleep /till/]/ : RegExp >"bugfix" : "bugfix" From 8aa7e224aa58fcd33934877481dff446bf69a22d Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 00:08:18 +0100 Subject: [PATCH 079/207] added entries foreach values and keys --- lib/lib.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 126e5d82ac4..f48dd389616 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -18053,6 +18053,10 @@ declare var URLSearchParams: { interface NodeListOf extends NodeList { length: number; item(index: number): TNode; + keys(): ArrayLike; + values(): ArrayLike<[number, TNode]>; + entries(): ArrayLike; + forEach():void; [index: number]: TNode; } From 1b14ed4d0ecf4b5c05a6d4f3cbb1d6f9f094dcbb Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 13 Mar 2017 16:51:43 -0700 Subject: [PATCH 080/207] update visitor/factory --- src/compiler/factory.ts | 52 ++++++++++++++++++++++++++++------------- src/compiler/visitor.ts | 19 ++++++++++----- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 88bf5f458f6..14af23e95b5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -189,11 +189,11 @@ namespace ts { } export function createTrue() { - return createSynthesizedNode(SyntaxKind.TrueKeyword); + return createSynthesizedNode(SyntaxKind.TrueKeyword); } export function createFalse() { - return createSynthesizedNode(SyntaxKind.FalseKeyword); + return createSynthesizedNode(SyntaxKind.FalseKeyword); } // Names @@ -226,15 +226,6 @@ namespace ts { // Type Elements - export function createPropertySignature(name: PropertyName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): PropertySignature { - const propertySignature = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; - propertySignature.name = name; - propertySignature.questionToken = questionToken; - propertySignature.type = type; - propertySignature.initializer = initializer; - return propertySignature; - } - export function createConstructSignature() { throw new Error("not implemented."); } @@ -258,14 +249,26 @@ namespace ts { } // TODO: handle qualified names, ie EntityName's. - export function createTypeReferenceNode(typeName: string | Identifier, typeArguments?: NodeArray) { + export function createTypeReferenceNode(typeName: string | EntityName, typeArguments?: NodeArray) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; - typeReference.typeName = asName(typeName); + + typeReference.typeName = isQualifiedName(typeName) ? typeName : asName(typeName); typeReference.typeArguments = typeArguments; return typeReference; } - export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: Identifier, typeArguments?: NodeArray) { + export function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode { + const arrayTypeNode = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode; + arrayTypeNode.elementType = elementType; + return arrayTypeNode; + } + + export function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments?: NodeArray) { return node.typeName !== typeName || node.typeArguments !== typeArguments ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) @@ -288,7 +291,7 @@ namespace ts { } export function createTypeLiteralNode(members: TypeElement[]) { - const typeLiteralNode = createSynthesizedNode(SyntaxKind.LiteralType) as TypeLiteralNode; + const typeLiteralNode = createSynthesizedNode(SyntaxKind.TypeLiteral) as TypeLiteralNode; typeLiteralNode.members = asNodeArray(members); return typeLiteralNode; } @@ -332,7 +335,24 @@ namespace ts { // Signature elements - /** Note, can also be used to construct index signatures. */ + export function createPropertySignature(name: PropertyName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): PropertySignature { + const propertySignature = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; + propertySignature.name = name; + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + + export function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { + return node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) + : node; + } + export function createSignature(kind: SyntaxKind, parameters: NodeArray, name?: PropertyName, typeParameters?: NodeArray, returnType?: TypeNode): SignatureDeclaration { const signature = createSynthesizedNode(kind) as SignatureDeclaration; signature.parameters = parameters; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index d2991b7cf03..547178e3b7f 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -279,7 +279,7 @@ namespace ts { return updateDecorator(node, visitNode((node).expression, visitor, isExpression)); - // Keyword Types + // Keyword Types and This case SyntaxKind.AnyKeyword: case SyntaxKind.NumberKeyword: @@ -292,6 +292,7 @@ namespace ts { case SyntaxKind.NullKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.NeverKeyword: + case SyntaxKind.ThisKeyword: return node; // Types @@ -300,8 +301,8 @@ namespace ts { throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeReference: return updateTypeReferenceNode(node - , visitNode((node).typeName as Identifier, visitor) - , nodesVisitor((node).typeArguments, visitor) + , visitNode((node).typeName, visitor, isEntityName) + , nodesVisitor((node).typeArguments, visitor, isTypeNode) ); case SyntaxKind.FunctionType: throw new Error("reached unsupported type in visitor."); @@ -310,9 +311,9 @@ namespace ts { case SyntaxKind.TypeQuery: throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeLiteral: - throw new Error("reached unsupported type in visitor."); + return updateTypeLiteralNode((node), nodesVisitor((node).members, visitor)); case SyntaxKind.ArrayType: - throw new Error("reached unsupported type in visitor."); + return updateArrayTypeNode(node, visitNode((node).elementType, visitor, isTypeNode)); case SyntaxKind.TupleType: throw new Error("reached unsupported type in visitor."); case SyntaxKind.UnionType: @@ -342,8 +343,14 @@ namespace ts { // Type members + case SyntaxKind.PropertySignature: + return updatePropertySignature((node) + , visitNode((node).name, visitor, isPropertyName) + , visitNode((node).questionToken, visitor, isToken) + , visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.IndexSignature: - updateIndexSignatureDeclaration(node + return updateIndexSignatureDeclaration(node , nodesVisitor((node).parameters, visitor, isParameter) , visitNode((node).type, visitor, isTypeNode) , nodesVisitor((node).decorators, visitor, isDecorator) From 5f37d32dbf049b36f5a56a648e87865be122aa53 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 00:52:47 +0100 Subject: [PATCH 081/207] added `keys`, `entries`, `values`, `forEach` on NodeListOf --- lib/lib.d.ts | 4 ---- src/lib/dom.iterable.d.ts | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/lib.d.ts b/lib/lib.d.ts index f48dd389616..126e5d82ac4 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -18053,10 +18053,6 @@ declare var URLSearchParams: { interface NodeListOf extends NodeList { length: number; item(index: number): TNode; - keys(): ArrayLike; - values(): ArrayLike<[number, TNode]>; - entries(): ArrayLike; - forEach():void; [index: number]: TNode; } diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 7f653dc8e0c..4e9112a9a44 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,9 +5,14 @@ interface DOMTokenList { } interface NodeList { + [Symbol.iterator](): IterableIterator } interface NodeListOf { + keys(): IterableIterator; + values(): IterableIterator<[number, TNode]>; + entries(): IterableIterator; + forEach(): void; [Symbol.iterator](): IterableIterator } From 20f512cfd218ff45ea817cc7971780c94b92c119 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 13 Mar 2017 16:54:29 -0700 Subject: [PATCH 082/207] type parameters and basic object literals --- src/compiler/checker.ts | 242 +++++++++++++----- src/compiler/types.ts | 3 + src/services/codefixes/helpers.ts | 12 +- ...ImplementInterfaceSomePropertiesPresent.ts | 4 +- 4 files changed, 190 insertions(+), 71 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 509efe941d5..ee999b3fe10 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -107,6 +107,7 @@ namespace ts { getReturnTypeOfSignature, getNonNullableType, createTypeNode, + createTypeParameterDeclarationFromType, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2189,9 +2190,25 @@ namespace ts { return result; } - function createTypeNode(type: Type) { + function createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration { + if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { + return undefined; + } + + const constraint = createTypeNode(getConstraintFromTypeParameter(type)) as TypeNode; + const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type)) as TypeNode; + if (!type.symbol) { + return undefined; + } + + const name = symbolToString(type.symbol); + return createTypeParameterDeclaration(name, constraint, defaultParameter); + } + + function createTypeNode(type: Type): TypeNode { let undefinedArgumentIsError = true; let encounteredError = false; + let inObjectTypeLiteral = false; let checkAlias = true; return createTypeNodeWorker(type); @@ -2202,6 +2219,8 @@ namespace ts { return undefined; } + const typeString = typeToString(type); typeString; // TODO: remove. + if (checkAlias && type.aliasSymbol) { const name = getNameOfSymbol(type.aliasSymbol); const typeArguments = mapToTypeNodeArray(type.aliasTypeArguments); @@ -2211,7 +2230,7 @@ namespace ts { if (type.flags & TypeFlags.Any) { // TODO: add other case where type ends up being `any`. - return createKeywordTypeNode(SyntaxKind.StringKeyword); + return createKeywordTypeNode(SyntaxKind.AnyKeyword); } if (type.flags & TypeFlags.String) { return createKeywordTypeNode(SyntaxKind.StringKeyword); @@ -2220,15 +2239,23 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.NumberKeyword); } if(type.flags & TypeFlags.Boolean) { - // TODO: this is probably x: boolean. How do we deal with x: true ? return createKeywordTypeNode(SyntaxKind.BooleanKeyword); } + if (type.flags & TypeFlags.Enum) { + throw new Error("enum not implemented"); + } if (type.flags & (TypeFlags.StringLiteral)) { return createLiteralTypeNode((createLiteral((type).text))); } if (type.flags & (TypeFlags.NumberLiteral)) { return createLiteralTypeNode((createNumericLiteral((type).text))); } + if(type.flags & TypeFlags.BooleanLiteral) { + return (type).intrinsicName === "true" ? createTrue() : createFalse(); + } + if (type.flags & TypeFlags.EnumLiteral) { + throw new Error("enum literal not implemented"); + } if (type.flags & TypeFlags.Void) { return createKeywordTypeNode(SyntaxKind.VoidKeyword); } @@ -2241,18 +2268,29 @@ namespace ts { if (type.flags & TypeFlags.Never) { return createKeywordTypeNode(SyntaxKind.NeverKeyword); } - if (type.flags & TypeFlags.Enum) { - throw new Error("enum not implemented"); - } if (type.flags & TypeFlags.ESSymbol) { throw new Error("ESSymbol not implemented"); } if (type.flags & TypeFlags.TypeParameter) { if ((type).isThisType) { + if (inObjectTypeLiteral) { + encounteredError = true; + } return createThis(); } throw new Error("Type Parameter declarations only handled in other worker."); } + + const objectFlags = getObjectFlags(type); + + if (objectFlags & ObjectFlags.Reference) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // and vice versa. + // this case includes tuple types + // TODO: test empty tuples, see if they are coherent. + return createTypeReferenceNodeFromType(type); + } + if (type.flags & TypeFlags.Union) { return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray((type as UnionType).types)); } @@ -2266,8 +2304,6 @@ namespace ts { throw new Error("indexed access not implemented"); } - const objectFlags = getObjectFlags(type); - if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); const name = getNameOfSymbol(type.symbol); @@ -2276,15 +2312,6 @@ namespace ts { return createTypeReferenceNode(name); } - if (objectFlags & ObjectFlags.Reference) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // and vice versa. - // this case includes tuple types - // TODO: test empty tuples, see if they are coherent. - const typeArguments = (type as TypeReference).typeArguments || emptyArray; - return createTupleTypeNode(mapToTypeNodeArray(typeArguments)) - } - // keyword types // this type node // function type node @@ -2336,67 +2363,152 @@ namespace ts { // The type is an object literal type. if (!type.symbol) { // Anonymous types without symbols are literals. - - // mapToTypeDeclarationsArray(type) throw new Error("unknown case."); } - const members = type.symbol.members; - const newMembers: TypeElement[] = []; - memberLoop: for(const key in members){ - const oldMember = members.get(key); - const name = getNameOfSymbol(oldMember); - const oldDeclaration = oldMember.declarations && oldMember.declarations[0] as TypeElement; - if(!oldDeclaration) { - continue memberLoop; - } - - const kind = oldDeclaration.kind; - - switch (kind) { - case SyntaxKind.PropertySignature: - const optional = !!oldDeclaration.questionToken; - newMembers.push(createPropertySignature( - createIdentifier(name) - , optional ? createToken(SyntaxKind.QuestionToken) : undefined - , createTypeNode(getTypeOfSymbol(oldMember)))); - case SyntaxKind.MethodSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - default: - throw new Error("type literal constituent not implemented."); - } - } - return createTypeLiteralNode(newMembers); + return createTypeLiteralNodeFromType(type); } Debug.fail("Should be unreachable."); - // function createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration { - // if (!type) { - // if (undefinedArgumentIsError) { encounteredError = true; } - // return undefined; - // } - // if (type.flags & TypeFlags.TypeParameter) { - // const constraint = createTypeNodeWorker(getConstraintFromTypeParameter(type)) as TypeNode; - // const defaultParameter = createTypeNodeWorker(getDefaultFromTypeParameter(type)) as TypeNode; - // if (!type.symbol) { - // encounteredError = true; - // throw new Error("No symbol for type parameter so can't get name"); - // } - // const name = getNameOfSymbol(type.symbol); - // return createTypeParameterDeclaration(name, constraint, defaultParameter); - // } - // throw new Error("type declarations not implemented."); - // } - /** Note that mapToTypeNodeArray(undefined) === undefined. */ function mapToTypeNodeArray(types: Type[]): NodeArray { return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); } + function createTypeReferenceNodeFromType(type: TypeReference) { + const typeArguments: Type[] = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + const elementType = createTypeNodeWorker(typeArguments[0]); + return createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & ObjectFlags.Tuple) { + return createTupleTypeNode(mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type)))); + } + else { + // TODO: handle type parameters in qualified names... + const outerTypeParameters = type.target.outerTypeParameters; + let i = 0; + let qualifiedName: QualifiedName | undefined = undefined; + if (outerTypeParameters) { + const length = outerTypeParameters.length; + while (i < length) { + // Find group of type arguments for type parameters with the same declaring container. + const start = i; + const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + // When type parameters are their own type arguments for the whole group (i.e. we have + // the default outer type arguments), we don't show the group. + // TODO: figure out how to handle type arguments + if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { + const name = symbolToString(parent); + const qualifiedNamePart = createIdentifier(name); // createTypeReferenceNode(name, mapToTypeNodeArray(typeArguments.slice(start, i - start))); + if (!qualifiedName) { + qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/undefined); + } + else { + Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = createQualifiedName(qualifiedName, /*right*/undefined); + } + } + } + } + let entityName: EntityName = undefined; + const nameIdentifier = createIdentifier(symbolToString(type.symbol)); + if (qualifiedName) { + // TODO: handle checking of type arguments for qualified names? + Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + const typeParameterCount = (type.target.typeParameters || emptyArray).length; + const typeArgumentNodes = mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)); + return createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + + function createTypeLiteralNodeFromType(type: ObjectType) { + // TODO: do we need to do something for mapped types here??? + const resolvedType = resolveStructuredTypeMembers(type); + const newMembers = createTypeNodesFromResolvedType(resolvedType); + return createTypeLiteralNode(newMembers); + } + + function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { + const typeElements: TypeElement[] = []; + for(const signature of resolvedType.callSignatures) { + signature; + throw new Error("call signatures not implemented"); + } + for (const signature of resolvedType.constructSignatures) { + signature; + throw new Error("Construct signatures not implemented"); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.stringIndexInfo, IndexKind.String)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.stringIndexInfo, IndexKind.Number)); + } + + const members = resolvedType.members; + + members.forEach(memberSymbol => { + const oldDeclaration = memberSymbol.declarations && memberSymbol.declarations[0] as TypeElement; + if (!oldDeclaration) { + return; + } + + const kind = oldDeclaration.kind; + const memberName = symbolToString(memberSymbol); + + switch (kind) { + case SyntaxKind.PropertySignature: + const optional = !!oldDeclaration.questionToken; + const typeOfOldMember = getTypeOfSymbol(memberSymbol); + typeElements.push(createPropertySignature( + createIdentifier(memberName) + , optional ? createToken(SyntaxKind.QuestionToken) : undefined + , createTypeNode(typeOfOldMember))); + break; + case SyntaxKind.MethodSignature: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.IndexSignature: + throw new Error("type literal constituent not implemented."); + default: + throw new Error("Unknown case."); + } + }); + return typeElements.length ? typeElements : undefined; + } + + function createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind) { + const stringTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); + + const name = (indexInfo.declaration && indexInfo.declaration.name && getTextOfPropertyName(indexInfo.declaration.name)) || "x"; + const indexingParameter = createParameter( + /*decorators*/ undefined + , /*modifiers*/ undefined + , /*dotDotDotToken*/ undefined + , name + , /*questionToken*/ undefined + , stringTypeNode); + const typeNode = createTypeNode(indexInfo.type); + return createIndexSignatureDeclaration( + [indexingParameter] + , typeNode + , /*decoarators*/ undefined + , indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); + } + // /** Note that mapToTypeNodeArray(undefined) === undefined. */ // function mapToTypeParameterArray(types: Type[]): NodeArray { // return asNodeArray(types && types.map(createTypeParameterDeclarationFromType) as TypeNode[]); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fd85ad9cabc..e3c5525e06f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2466,8 +2466,11 @@ namespace ts { */ /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNonNullableType(type: Type): Type; + /** Note that the resulting type node cannot be checked. */ createTypeNode(type: Type): TypeNode; + /** Note that the resulting type node cannot be checked. */ + createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index fb76e83faa7..8c4eb40a3ea 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -91,9 +91,11 @@ namespace ts.codefix { // TODO: get parameters working. // TODO: add support for type parameters. const signature = signatures[0]; + const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = checker.createTypeNode(signature.resolvedReturnType); - return createStubbedMethod(modifiers, name, /*typeParameters*/undefined, newParameterNodes, returnType); + + const returnType = checker.createTypeNode(checker.getReturnTypeOfSignature(signature)); + return createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType); } let signatureDeclarations = []; @@ -101,6 +103,7 @@ namespace ts.codefix { // const sigString = checker.signatureToString(signatures[i], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); // TODO: make signatures instead of methods const signature = signatures[i]; + const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); const returnType = checker.createTypeNode(signature.resolvedReturnType); signatureDeclarations.push(createMethod( @@ -108,7 +111,7 @@ namespace ts.codefix { , modifiers , /*asteriskToken*/ undefined , name - , /*typeParameters*/undefined + , newTypeParameters , newParameterNodes , returnType , /*body*/undefined)); @@ -116,9 +119,10 @@ namespace ts.codefix { if (declarations.length > signatures.length) { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); + const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); const returnType = checker.createTypeNode(signature.resolvedReturnType); - signatureDeclarations.push(createStubbedMethod(modifiers, name, /*typeParameters*/undefined, newParameterNodes, returnType)); + signatureDeclarations.push(createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType)); } else { Debug.assert(declarations.length === signatures.length); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts index 03807ab450c..e667783b995 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceSomePropertiesPresent.ts @@ -6,8 +6,8 @@ //// z: number & { __iBrand: any }; //// } //// -//// class C implements I {[| |] -//// constructor(public x: number) { } +//// class C implements I {[| +//// |]constructor(public x: number) { } //// y: number; //// } From 875328c123557879a887ea0e558b32ca912372ac Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 00:55:41 +0100 Subject: [PATCH 083/207] removed white space --- src/lib/dom.iterable.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 4e9112a9a44..34c91aa148b 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,7 +5,6 @@ interface DOMTokenList { } interface NodeList { - [Symbol.iterator](): IterableIterator } From d298f960ab6dff2acb408e856c1e79ae9302986a Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 13 Mar 2017 18:09:53 -0700 Subject: [PATCH 084/207] Refactor --- src/compiler/checker.ts | 112 +++++++----------- src/compiler/factory.ts | 45 +++---- src/compiler/visitor.ts | 7 +- src/services/codefixes/fixAddMissingMember.ts | 6 +- .../fixClassIncorrectlyImplementsInterface.ts | 4 +- .../codeFixClassExtendAbstractMethod.ts | 4 + .../codeFixClassExtendAbstractProperty.ts | 4 - 7 files changed, 78 insertions(+), 104 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ee999b3fe10..ea7c01b9735 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2211,7 +2211,10 @@ namespace ts { let inObjectTypeLiteral = false; let checkAlias = true; - return createTypeNodeWorker(type); + let result = createTypeNodeWorker(type); + (result).__type_source = type; + (result).__type_source_str = typeToString(type); + return result; function createTypeNodeWorker(type: Type): TypeNode { if (!type) { @@ -2221,12 +2224,6 @@ namespace ts { const typeString = typeToString(type); typeString; // TODO: remove. - if (checkAlias && type.aliasSymbol) { - const name = getNameOfSymbol(type.aliasSymbol); - const typeArguments = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(createIdentifier(name), typeArguments); - } - checkAlias = false; if (type.flags & TypeFlags.Any) { // TODO: add other case where type ends up being `any`. @@ -2271,14 +2268,14 @@ namespace ts { if (type.flags & TypeFlags.ESSymbol) { throw new Error("ESSymbol not implemented"); } - if (type.flags & TypeFlags.TypeParameter) { - if ((type).isThisType) { - if (inObjectTypeLiteral) { - encounteredError = true; - } - return createThis(); + if (type.flags & TypeFlags.NonPrimitive) { + throw new Error("Non primitive not implemented"); + } + if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { + if (inObjectTypeLiteral) { + encounteredError = true; } - throw new Error("Type Parameter declarations only handled in other worker."); + return createThis(); } const objectFlags = getObjectFlags(type); @@ -2291,64 +2288,35 @@ namespace ts { return createTypeReferenceNodeFromType(type); } + if (type.flags & TypeFlags.EnumLiteral) { + throw new Error("Enum literal not implemented"); + } + if (objectFlags & ObjectFlags.ClassOrInterface) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const name = getNameOfSymbol(type.symbol); + // TODO: handle type arguments. + // TODO: handle anonymous classes. + return createTypeReferenceNode(name, /*typeParameters*/undefined); + } + if (type.flags & TypeFlags.TypeParameter) { + throw new Error("Type Parameter declarations only handled in other worker."); + } + + // accessible type aliasSymbol + // TODO: move back up later on? + if (checkAlias && type.aliasSymbol) { + const name = getNameOfSymbol(type.aliasSymbol); + const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); + return createTypeReferenceNode(createIdentifier(name), typeArgumentNodes); + } + checkAlias = false; + if (type.flags & TypeFlags.Union) { return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray((type as UnionType).types)); } if (type.flags & TypeFlags.Intersection) { return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); } - if (type.flags & TypeFlags.Index) { - throw new Error("index not implemented"); - } - if (type.flags & TypeFlags.IndexedAccess) { - throw new Error("indexed access not implemented"); - } - - if (objectFlags & ObjectFlags.ClassOrInterface) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const name = getNameOfSymbol(type.symbol); - // TODO: handle type arguments. - // TODO: handle anonymous classes. - return createTypeReferenceNode(name); - } - - // keyword types - // this type node - // function type node - // constructor type node - // type reference node - // type predicate node - is Foo (for return types) - // type query node -- typeof number - // type literal node (like object literal) - // array type - // tuple type - // union type - // might need parens - // intersection type - // Type operator node (eg (ie?): keyof T) - // IndexedAccess Type Node - // mapped type node - // literal type node - - // if (inTypeAlias && type.aliasSymbol) { - // return isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/false).accessibility === SymbolAccessibility.Accessible - // && (!type.aliasTypeArguments || allTypesVisible(type.aliasTypeArguments)); - // } - // const typeSymbolAccessibility = type.symbol && isSymbolAccessible(type.symbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility; - // if (type.flags & TypeFlags.TypeParameter) { - // if (inObjectLiteral && (type as TypeParameter).isThisType) { - // return false; - // } - // const constraint = getConstraintFromTypeParameter((type)); - // return typeSymbolAccessibility === SymbolAccessibility.Accessible - // && (!constraint || isTypeAccessibleWorker(constraint, inObjectLiteral, /*inTypeAlias*/false)); - // } - // const objectFlags = getObjectFlags(type); - // if (objectFlags & ObjectFlags.ClassOrInterface) { - // // If type is a class or interface type that wasn't hit by the isSymbolAccessible check above, - // // type must be an anonymous class or interface. - // return false; - // } if (objectFlags & ObjectFlags.Mapped) { Debug.assert(!!(type.flags & TypeFlags.Object)); @@ -2370,6 +2338,15 @@ namespace ts { return createTypeLiteralNodeFromType(type); } + // TODO: string or number literal here or above? + + if (type.flags & TypeFlags.Index) { + throw new Error("index not implemented"); + } + if (type.flags & TypeFlags.IndexedAccess) { + throw new Error("indexed access not implemented"); + } + Debug.fail("Should be unreachable."); /** Note that mapToTypeNodeArray(undefined) === undefined. */ @@ -2476,7 +2453,8 @@ namespace ts { typeElements.push(createPropertySignature( createIdentifier(memberName) , optional ? createToken(SyntaxKind.QuestionToken) : undefined - , createTypeNode(typeOfOldMember))); + , createTypeNode(typeOfOldMember) + , /*initializer*/undefined)); break; case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 14af23e95b5..7eb44f93bc5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -248,30 +248,30 @@ namespace ts { : node; } - // TODO: handle qualified names, ie EntityName's. - export function createTypeReferenceNode(typeName: string | EntityName, typeArguments?: NodeArray) { + export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: NodeArray | undefined) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; - + typeReference.typeName = isQualifiedName(typeName) ? typeName : asName(typeName); typeReference.typeArguments = typeArguments; return typeReference; } + export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + export function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode { const arrayTypeNode = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode; arrayTypeNode.elementType = elementType; return arrayTypeNode; } - + export function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode { return node.elementType !== elementType - ? updateNode(createArrayTypeNode(elementType), node) - : node; - } - export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments?: NodeArray) { - return node.typeName !== typeName - || node.typeArguments !== typeArguments - ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + ? updateNode(createArrayTypeNode(elementType), node) : node; } @@ -316,7 +316,7 @@ namespace ts { // Type Declarations - export function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { + export function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultParameter: TypeNode | undefined) { const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; typeParameter.name = asName(name); typeParameter.constraint = constraint; @@ -325,7 +325,7 @@ namespace ts { return typeParameter; } - export function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint?: TypeNode, defaultParameter?: TypeNode) { + export function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultParameter: TypeNode | undefined) { return node.name !== name || node.constraint !== constraint || node.default !== defaultParameter @@ -335,7 +335,7 @@ namespace ts { // Signature elements - export function createPropertySignature(name: PropertyName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): PropertySignature { + export function createPropertySignature(name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature { const propertySignature = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; propertySignature.name = name; propertySignature.questionToken = questionToken; @@ -344,7 +344,7 @@ namespace ts { return propertySignature; } - export function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { + export function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) { return node.name !== name || node.questionToken !== questionToken || node.type !== type @@ -353,18 +353,7 @@ namespace ts { : node; } - export function createSignature(kind: SyntaxKind, parameters: NodeArray, name?: PropertyName, typeParameters?: NodeArray, returnType?: TypeNode): SignatureDeclaration { - const signature = createSynthesizedNode(kind) as SignatureDeclaration; - signature.parameters = parameters; - signature.name = name; - signature.typeParameters = typeParameters; - signature.type = returnType; - return signature; - } - - // TODO: check usage of name... - // TODO: create entry in visitor.ts - export function createIndexSignatureDeclaration(parameters: ParameterDeclaration[], type: TypeNode, decorators?: Decorator[], modifiers?: Modifier[]): IndexSignatureDeclaration { + export function createIndexSignatureDeclaration(parameters: ParameterDeclaration[], type: TypeNode, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined): IndexSignatureDeclaration { const indexSignature = createSynthesizedNode(SyntaxKind.IndexSignature) as IndexSignatureDeclaration; // indexSignature.name = asName(name); // type parameters @@ -375,7 +364,7 @@ namespace ts { return indexSignature; } - export function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, parameters: ParameterDeclaration[], type: TypeNode, decorators?: Decorator[], modifiers?: Modifier[]) { + export function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, parameters: ParameterDeclaration[], type: TypeNode, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined) { return node.parameters !== parameters || node.type !== type || node.decorators !== decorators diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 547178e3b7f..3b75e072a57 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -302,8 +302,8 @@ namespace ts { case SyntaxKind.TypeReference: return updateTypeReferenceNode(node , visitNode((node).typeName, visitor, isEntityName) - , nodesVisitor((node).typeArguments, visitor, isTypeNode) - ); + , nodesVisitor((node).typeArguments, visitor, isTypeNode)); + case SyntaxKind.FunctionType: throw new Error("reached unsupported type in visitor."); case SyntaxKind.ConstructorType: @@ -347,7 +347,8 @@ namespace ts { return updatePropertySignature((node) , visitNode((node).name, visitor, isPropertyName) , visitNode((node).questionToken, visitor, isToken) - , visitNode((node).type, visitor, isTypeNode)); + , visitNode((node).type, visitor, isTypeNode) + , visitNode((node).initializer, visitor, isExpression)); case SyntaxKind.IndexSignature: return updateIndexSignatureDeclaration(node diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index fe12249f176..2403c0adbe0 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -62,7 +62,11 @@ namespace ts.codefix { , "x" , /*questionToken*/ undefined , stringTypeNode); - const indexSignature = createIndexSignatureDeclaration([indexingParameter], typeNode); + const indexSignature = createIndexSignatureDeclaration( + [indexingParameter] + , typeNode + , /*decorators*/undefined + , /*modifiers*/ undefined); const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { insertTrailingNewLine: true }); diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index f653d21e02b..220cea55d6f 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -62,7 +62,9 @@ namespace ts.codefix { , getNameFromIndexInfo(indexInfoOfKind) , /*questionToken*/ undefined , kind === IndexKind.String ? createKeywordTypeNode(SyntaxKind.StringKeyword) : createKeywordTypeNode(SyntaxKind.NumberKeyword))] - , typeNode); + , typeNode + , /*decorators*/undefined + , /*modifiers*/ undefined); newNodes.push(newIndexSignatureDeclaration); } diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts index b6b408cf5ff..7e51e2216dc 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethod.ts @@ -5,6 +5,7 @@ //// abstract f(a: number, b: string): this; //// abstract f(a: string, b: number): Function; //// abstract f(a: string): Function; +//// abstract foo(): number; //// } //// //// class C extends A {[| |]} @@ -17,4 +18,7 @@ verify.rangeAfterCodeFix(` f(a: any, b?: any) { throw new Error("Method not implemented."); } + foo(): number { + throw new Error("Method not implemented."); + } `); diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index 83f770b5553..701903d6770 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -4,7 +4,6 @@ //// abstract x: number; //// abstract y: this; //// abstract z: A; -//// abstract foo(): number; //// } //// //// class C extends A {[| |]} @@ -13,7 +12,4 @@ verify.rangeAfterCodeFix(` x: number; y: this; z: A; - foo(): number { - throw new Error("Method not implemented."); - } `); From 8cac5285b90b7c8a19741c0f74958353a5c79d2d Mon Sep 17 00:00:00 2001 From: cedvdb Date: Tue, 14 Mar 2017 04:15:32 +0100 Subject: [PATCH 085/207] added `keys`, `values`, ``forEach, `entries` to nodelist --- src/lib/dom.iterable.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 34c91aa148b..fb862376a24 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,6 +5,10 @@ interface DOMTokenList { } interface NodeList { + keys(): IterableIterator; + values(): IterableIterator<[number, Node]>; + entries(): IterableIterator; + forEach(): void; [Symbol.iterator](): IterableIterator } From 27fe2df203eb552976c853b704f6682eb8e81ae2 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 13 Mar 2017 20:20:26 -0700 Subject: [PATCH 086/207] some missed token bugs --- src/compiler/checker.ts | 11 ++---- src/compiler/factory.ts | 9 +++-- src/compiler/transformers/esnext.ts | 1 + src/compiler/types.ts | 2 +- src/compiler/visitor.ts | 1 + src/services/codefixes/fixAddMissingMember.ts | 3 +- src/services/codefixes/helpers.ts | 39 +++++++++---------- src/services/textChanges.ts | 2 +- .../codeFixClassExtendAbstractGetterSetter.ts | 2 +- 9 files changed, 34 insertions(+), 36 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ea7c01b9735..ca105c41139 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2361,7 +2361,7 @@ namespace ts { return createArrayTypeNode(elementType); } else if (type.target.objectFlags & ObjectFlags.Tuple) { - return createTupleTypeNode(mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type)))); + return createTupleTypeNode(typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))) : undefined); } else { // TODO: handle type parameters in qualified names... @@ -2406,7 +2406,7 @@ namespace ts { entityName = nameIdentifier; } const typeParameterCount = (type.target.typeParameters || emptyArray).length; - const typeArgumentNodes = mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)); + const typeArgumentNodes = mapToTypeNodeArray(typeArguments.length > 0 ? typeArguments.slice(i, typeParameterCount - i) : undefined); return createTypeReferenceNode(entityName, typeArgumentNodes); } } @@ -2478,7 +2478,8 @@ namespace ts { , /*dotDotDotToken*/ undefined , name , /*questionToken*/ undefined - , stringTypeNode); + , stringTypeNode + , /*initializer*/ undefined); const typeNode = createTypeNode(indexInfo.type); return createIndexSignatureDeclaration( [indexingParameter] @@ -7261,10 +7262,6 @@ namespace ts { } } - // export function synthesizeTypeNode(type: Type, enclosingDeclaration: Node): TypeNode { - // throw new Error("Not implemented" + enclosingDeclaration); - // } - function instantiateList(items: T[], mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): T[] { if (items && items.length) { const result: T[] = []; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 7eb44f93bc5..077bc349867 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -355,8 +355,6 @@ namespace ts { export function createIndexSignatureDeclaration(parameters: ParameterDeclaration[], type: TypeNode, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined): IndexSignatureDeclaration { const indexSignature = createSynthesizedNode(SyntaxKind.IndexSignature) as IndexSignatureDeclaration; - // indexSignature.name = asName(name); - // type parameters indexSignature.parameters = asNodeArray(parameters); indexSignature.type = type; indexSignature.decorators = asNodeArray(decorators); @@ -373,6 +371,8 @@ namespace ts { : node; } + // Signature elements + export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { const node = createSynthesizedNode(SyntaxKind.Parameter); node.decorators = asNodeArray(decorators); @@ -385,11 +385,12 @@ namespace ts { return node; } - export function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined) { + export function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) { return node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name + || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) @@ -438,7 +439,7 @@ namespace ts { node.asteriskToken = asteriskToken; node.name = asName(name); node.typeParameters = asNodeArray(typeParameters); - node.parameters = createNodeArray(parameters); + node.parameters = asNodeArray(parameters); node.type = type; node.body = body; return node; diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 971dddd20ea..f66bf14da53 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -475,6 +475,7 @@ namespace ts { /*modifiers*/ undefined, node.dotDotDotToken, getGeneratedNameForNode(node), + node.questionToken, /*type*/ undefined, visitNode(node.initializer, visitor, isExpression) ); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e3c5525e06f..bccf0f1c4f9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -895,7 +895,7 @@ namespace ts { exprName: EntityName; } - /** A TypeLiteral is the declaration node for an anonymous symbol. */ + // A TypeLiteral is the declaration node for an anonymous symbol. export interface TypeLiteralNode extends TypeNode, Declaration { kind: SyntaxKind.TypeLiteral; members: NodeArray; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 3b75e072a57..e64e59eba3a 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -272,6 +272,7 @@ namespace ts { nodesVisitor((node).modifiers, visitor, isModifier), (node).dotDotDotToken, visitNode((node).name, visitor, isBindingName), + visitNode((node).questionToken, visitor, isToken), visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 2403c0adbe0..61c823908d9 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -61,7 +61,8 @@ namespace ts.codefix { , /*dotDotDotToken*/ undefined , "x" , /*questionToken*/ undefined - , stringTypeNode); + , stringTypeNode + , /*initializer*/ undefined); const indexSignature = createIndexSignatureDeclaration( [indexingParameter] , typeNode diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 8c4eb40a3ea..2db14f81df1 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -126,7 +126,7 @@ namespace ts.codefix { } else { Debug.assert(declarations.length === signatures.length); - const methodImplementingSignatures = createMethodImplementingSignatures(signatures, enclosingDeclaration, name, modifiers); + const methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, modifiers); signatureDeclarations.push(methodImplementingSignatures); } return signatureDeclarations; @@ -135,11 +135,8 @@ namespace ts.codefix { } } - // TODO: infer types of arguments? - function createMethodImplementingSignatures(signatures: Signature[], enclosingDeclaration: ClassLikeDeclaration, name: string, modifiers: Modifier[] | undefined): MethodDeclaration { - const newMethodDeclaration = createNode(SyntaxKind.CallSignature) as SignatureDeclaration; - newMethodDeclaration.parent = enclosingDeclaration; - newMethodDeclaration.name = signatures[0].getDeclaration().name; + function createMethodImplementingSignatures(signatures: Signature[], name: string, modifiers: Modifier[] | undefined): MethodDeclaration { + Debug.assert(signatures && signatures.length > 0); let maxNonRestArgs = -1; let maxArgsIndex = 0; @@ -157,46 +154,45 @@ namespace ts.codefix { } const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName()); - const parameters = createNodeArray(); + const parameters: ParameterDeclaration[] = []; for (let i = 0; i < maxNonRestArgs; i++) { + const anyType = createKeywordTypeNode(SyntaxKind.AnyKeyword); const newParameter = createParameter( /*decorators*/ undefined , /*modifiers*/ undefined , /*dotDotDotToken*/ undefined , maxArgsParameterSymbolNames[i] , /*questionToken*/ i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined - , /*type*/ undefined + , anyType , /*initializer*/ undefined); parameters.push(newParameter); } if (hasRestParameter) { + const anyType = createKeywordTypeNode(SyntaxKind.AnyKeyword); const restParameter = createParameter( /*decorators*/ undefined , /*modifiers*/ undefined , createToken(SyntaxKind.DotDotDotToken) , maxArgsParameterSymbolNames[maxNonRestArgs] || "rest" , /*questionToken*/ maxNonRestArgs >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined - , /*type*/ undefined + , anyType , /*initializer*/ undefined); parameters.push(restParameter); } - return createMethod( - /*decorators*/ undefined - , modifiers - , /*asteriskToken*/ undefined + return createStubbedMethod( + modifiers , name , /*typeParameters*/undefined , parameters - , /*type*/ undefined - , /*body*/undefined); + , /*returnType*/ undefined); } - export function createStubbedMethod(modifiers: Modifier[], name: string, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType?: TypeNode) { + export function createStubbedMethod(modifiers: Modifier[], name: string, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { return createMethod( /*decorators*/undefined - , /*modifiers*/modifiers + , modifiers , /*asteriskToken*/undefined , name , typeParameters @@ -231,12 +227,13 @@ namespace ts.codefix { const parameterTypeNode = checker.createTypeNode(parameterType); // TODO: deep cloning of decorators/any node. const parameterNode = createParameter( - parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedClone) - , parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone) + parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedDeepClone) + , parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedDeepClone) , parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken) - , parameterDeclaration.name + , getSynthesizedDeepClone(parameterDeclaration.name) , parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken) - , parameterTypeNode); + , parameterTypeNode + , /*initializer*/ undefined); return parameterNode; } diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index cb8c614cb22..71536dc75f5 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -360,7 +360,7 @@ namespace ts.textChanges { return visited; } // clone nodearray if necessary - const nodeArray = visited === nodes ? createNodeArray(visited) : visited; + const nodeArray = visited === nodes ? createNodeArray(visited.slice(0)) : visited; nodeArray.pos = getPos(nodes); nodeArray.end = getEnd(nodes); return nodeArray; diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts index 4bddfb799f2..bc437c93bcd 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractGetterSetter.ts @@ -28,4 +28,4 @@ verify.rangeAfterCodeFix(` e: this; f: A; g: string; -`); \ No newline at end of file +`); From 6e86596a732c868cc709dcc5c1db21566030a373 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 13 Mar 2017 22:43:37 -0700 Subject: [PATCH 087/207] Add debugging utilities --- src/harness/fourslash.ts | 11 ++++++++++- tests/cases/fourslash/fourslash.ts | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 0df9f4f4dd2..11103bf6e2d 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1,4 +1,4 @@ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -2550,6 +2550,11 @@ namespace FourSlash { } } + public printAvailableCodeFixes() { + const codeFixes = this.getCodeFixActions(this.activeFile.fileName); + Harness.IO.log(stringify(codeFixes)); + } + // Get the text of the entire line the caret is currently at private getCurrentLineContent() { const text = this.getFileContent(this.activeFile.fileName); @@ -3738,6 +3743,10 @@ namespace FourSlashInterface { this.state.printCompletionListMembers(); } + public printAvailableCodeFixes() { + this.state.printAvailableCodeFixes(); + } + public printBreakpointLocation(pos: number) { this.state.printBreakpointLocation(pos); } diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index ab83752d93b..418066fb6f9 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -296,6 +296,7 @@ declare namespace FourSlashInterface { printCurrentQuickInfo(): void; printCurrentSignatureHelp(): void; printCompletionListMembers(): void; + printAvailableCodeFixes(): void; printBreakpointLocation(pos: number): void; printBreakpointAtCurrentLocation(): void; printNameOrDottedNameSpans(pos: number): void; From fd9fb8f9bce4828fc657cfb36a3a47c3283a583c Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 13 Mar 2017 22:49:54 -0700 Subject: [PATCH 088/207] Support static properties --- src/services/codefixes/fixAddMissingMember.ts | 99 ++++++++++++------- .../fourslash/codeFixAddMissingMember.ts | 14 +++ .../fourslash/codeFixAddMissingMember2.ts | 14 +++ .../fourslash/codeFixAddMissingMember3.ts | 14 +++ .../fourslash/codeFixAddMissingMember4.ts | 22 +++++ .../fourslash/codeFixAddMissingMember5.ts | 19 ++++ .../fourslash/codeFixAddMissingMember6.ts | 18 ++++ .../fourslash/codeFixAddMissingMember7.ts | 15 +++ ...xUndeclaredIndexSignatureNumericLiteral.ts | 2 +- 9 files changed, 181 insertions(+), 36 deletions(-) create mode 100644 tests/cases/fourslash/codeFixAddMissingMember.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingMember2.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingMember3.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingMember4.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingMember5.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingMember6.ts create mode 100644 tests/cases/fourslash/codeFixAddMissingMember7.ts diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index fe4176a766a..bc2ee6fe0f8 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { registerCodeFix({ errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code], @@ -13,22 +13,27 @@ namespace ts.codefix { // this.missing = 1; // ^^^^^^^ const token = getTokenAtPosition(sourceFile, start); - if (token.kind != SyntaxKind.Identifier) { return undefined; } - const classDeclaration = getContainingClass(token); - if (!classDeclaration) { - return undefined; - } - if (!isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== SyntaxKind.ThisKeyword) { return undefined; } - return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); + const classMemberDeclaration = getThisContainer(token, /*includeArrowFunctions*/ false); + if (!isClassElement(classMemberDeclaration)) { + return undefined; + } + const classDeclaration = classMemberDeclaration.parent; + if (!classDeclaration || !isClassLike(classDeclaration)) { + return undefined; + } + + const isStatic = hasModifier(getThisContainer(token, /*includeArrowFunctions*/ false), ModifierFlags.Static); + + return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); function getActionsForAddMissingMemberInTypeScriptFile(): CodeAction[] | undefined { let typeString = "any"; @@ -43,47 +48,71 @@ namespace ts.codefix { const startPos = classDeclaration.members.pos; - return [{ + const actions = [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), changes: [{ fileName: sourceFile.fileName, textChanges: [{ span: { start: startPos, length: 0 }, - newText: `${token.getFullText(sourceFile)}: ${typeString};` - }] - }] - }, - { - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `[name: string]: ${typeString};` + newText: `${isStatic ? "static " : ""}${token.getFullText(sourceFile)}: ${typeString};` }] }] }]; + + if (!isStatic) { + actions.push({ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: startPos, length: 0 }, + newText: `[x: string]: ${typeString};` + }] + }] + }); + } + + return actions; } function getActionsForAddMissingMemberInJavaScriptFile(): CodeAction[] | undefined { - const classConstructor = getFirstConstructorWithBody(classDeclaration); - if (!classConstructor) { - return undefined; - } - const memberName = token.getText(); - const startPos = classConstructor.body.getEnd() - 1; - return [{ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: `this.${memberName} = undefined;` + if (isStatic) { + if (classDeclaration.kind === SyntaxKind.ClassExpression) { + return undefined; + } + + const className = classDeclaration.name.getText(); + + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classDeclaration.getEnd(), length: 0 }, + newText: `${context.newLineCharacter}${className}.${memberName} = undefined;${context.newLineCharacter}` + }] }] - }] - }]; + }]; + } + else { + const classConstructor = getFirstConstructorWithBody(classDeclaration); + if (!classConstructor) { + return undefined; + } + + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classConstructor.body.getEnd() - 1, length: 0 }, + newText: `this.${memberName} = undefined;${context.newLineCharacter}` + }] + }] + }]; + } } } } \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember.ts b/tests/cases/fourslash/codeFixAddMissingMember.ts new file mode 100644 index 00000000000..43c0bc3b765 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember.ts @@ -0,0 +1,14 @@ +/// + +////[|class C { +//// method() { +//// this.foo = 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + foo: number; + method() { + this.foo = 10; + } +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember2.ts b/tests/cases/fourslash/codeFixAddMissingMember2.ts new file mode 100644 index 00000000000..7b64fde8c01 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember2.ts @@ -0,0 +1,14 @@ +/// + +////[|class C { +//// method() { +//// this.foo = 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + [x:string]: number; + method() { + this.foo = 10; + } +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 1); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember3.ts b/tests/cases/fourslash/codeFixAddMissingMember3.ts new file mode 100644 index 00000000000..5864c9c1029 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember3.ts @@ -0,0 +1,14 @@ +/// + +////[|class C { +//// static method() { +//// this.foo = 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + static foo: number; + static method() { + this.foo = 10; + } +}`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember4.ts b/tests/cases/fourslash/codeFixAddMissingMember4.ts new file mode 100644 index 00000000000..08df9ccabc2 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember4.ts @@ -0,0 +1,22 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// constructor() { +//// } +//// method() { +//// this.foo === 10; +//// } +////}|] + +verify.rangeAfterCodeFix(`class C { + constructor() { + this.foo = undefined; +} + method() { + this.foo === 10; + } +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember5.ts b/tests/cases/fourslash/codeFixAddMissingMember5.ts new file mode 100644 index 00000000000..cbabc0ba6c5 --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember5.ts @@ -0,0 +1,19 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// static method() { +//// ()=>{ this.foo === 10 }; +//// } +////} +////|] + +verify.rangeAfterCodeFix(`class C { + static method() { + ()=>{ this.foo === 10 }; + } +} +C.foo = undefined;`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember6.ts b/tests/cases/fourslash/codeFixAddMissingMember6.ts new file mode 100644 index 00000000000..2f3911d779e --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember6.ts @@ -0,0 +1,18 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// constructor() { +//// } +//// prop = ()=>{ this.foo === 10 }; +////}|] + +verify.rangeAfterCodeFix(`class C { + constructor() { + this.foo = undefined; + } + prop = ()=>{ this.foo === 10 }; +}`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddMissingMember7.ts b/tests/cases/fourslash/codeFixAddMissingMember7.ts new file mode 100644 index 00000000000..0e937a3ab6e --- /dev/null +++ b/tests/cases/fourslash/codeFixAddMissingMember7.ts @@ -0,0 +1,15 @@ +/// + +// @checkJs: true +// @allowJs: true + +// @Filename: a.js +////[|class C { +//// static p = ()=>{ this.foo === 10 }; +////} +////|] + +verify.rangeAfterCodeFix(`class C { + static p = ()=>{ this.foo === 10 }; +} +C.foo = undefined;`, /*includeWhiteSpace*/false, /*errorCode*/ undefined, /*index*/ 2); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts b/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts index 2e49a8184eb..0a2b0ee799d 100644 --- a/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts +++ b/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts @@ -8,7 +8,7 @@ verify.rangeAfterCodeFix(` class A { - [name: string]: number; + [x: string]: number; constructor() { this.x = 10; From 509b2dc18e32ec0ac399b131a2381e12ef77e6de Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 13 Mar 2017 23:03:06 -0700 Subject: [PATCH 089/207] Add disableJsDiagnostics codefixes to harnes --- src/harness/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 21622325368..9f0e30baa1c 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -1,4 +1,4 @@ -{ +{ "extends": "../tsconfig-base", "compilerOptions": { "removeComments": false, @@ -81,6 +81,7 @@ "../services/codefixes/helpers.ts", "../services/codefixes/importFixes.ts", "../services/codefixes/unusedIdentifierFixes.ts", + "../services/codefixes/disableJsDiagnostics.ts", "harness.ts", "sourceMapRecorder.ts", From 2fd3229568dad45411c9af7e3ca1234197b29bad Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 14 Mar 2017 14:35:23 -0700 Subject: [PATCH 090/207] Various fixes * create type reference node from type parameters * expose index signature synthesis * widen types in helpers * format unions * use deep cloning --- src/compiler/checker.ts | 74 ++++++++++--------- src/compiler/types.ts | 2 + src/compiler/utilities.ts | 4 + .../fixClassIncorrectlyImplementsInterface.ts | 13 +--- src/services/codefixes/helpers.ts | 18 ++--- .../codeFixClassImplementInterface36.ts | 18 ----- ...eFixClassImplementInterfaceInNamespace.ts} | 0 ...mplementInterfaceInheritsAbstractMethod.ts | 18 +++++ ...ssImplementInterfaceMultipleImplements1.ts | 4 +- ...ssImplementInterfaceMultipleImplements2.ts | 6 +- 10 files changed, 76 insertions(+), 81 deletions(-) delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterface36.ts rename tests/cases/fourslash/{codeFixClassImplementInterface39.ts => codeFixClassImplementInterfaceInNamespace.ts} (100%) create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca105c41139..e9cea047eaf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -108,6 +108,7 @@ namespace ts { getNonNullableType, createTypeNode, createTypeParameterDeclarationFromType, + createIndexSignatureFromIndexInfo, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2190,16 +2191,13 @@ namespace ts { return result; } - function createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration { + function createTypeParameterDeclarationFromType(type: TypeParameter): TypeParameterDeclaration { if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { return undefined; } - const constraint = createTypeNode(getConstraintFromTypeParameter(type)) as TypeNode; - const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type)) as TypeNode; - if (!type.symbol) { - return undefined; - } + const constraint = createTypeNode(getConstraintFromTypeParameter(type)) as TypeNode; + const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type)) as TypeNode; const name = symbolToString(type.symbol); return createTypeParameterDeclaration(name, constraint, defaultParameter); @@ -2212,8 +2210,10 @@ namespace ts { let checkAlias = true; let result = createTypeNodeWorker(type); - (result).__type_source = type; - (result).__type_source_str = typeToString(type); + if (result) { + (result).__type_source = type; + (result).__type_source_str = typeToString(type); + } return result; function createTypeNodeWorker(type: Type): TypeNode { @@ -2299,7 +2299,16 @@ namespace ts { return createTypeReferenceNode(name, /*typeParameters*/undefined); } if (type.flags & TypeFlags.TypeParameter) { - throw new Error("Type Parameter declarations only handled in other worker."); + const constraint = createTypeNode(getConstraintFromTypeParameter(type)) as TypeNode; + const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type)) as TypeNode; + if(constraint || defaultParameter) { + // Type parameters in type position can't have constraints or defaults. + encounteredError = true; + return undefined; + } + // TODO: get qualified name when necessary instead of string. + const name = symbolToString(type.symbol); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); } // accessible type aliasSymbol @@ -2312,7 +2321,7 @@ namespace ts { checkAlias = false; if (type.flags & TypeFlags.Union) { - return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray((type as UnionType).types)); + return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray(formatUnionTypes((type).types))); } if (type.flags & TypeFlags.Intersection) { return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); @@ -2467,34 +2476,29 @@ namespace ts { }); return typeElements.length ? typeElements : undefined; } - - function createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind) { - const stringTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); - - const name = (indexInfo.declaration && indexInfo.declaration.name && getTextOfPropertyName(indexInfo.declaration.name)) || "x"; - const indexingParameter = createParameter( - /*decorators*/ undefined - , /*modifiers*/ undefined - , /*dotDotDotToken*/ undefined - , name - , /*questionToken*/ undefined - , stringTypeNode - , /*initializer*/ undefined); - const typeNode = createTypeNode(indexInfo.type); - return createIndexSignatureDeclaration( - [indexingParameter] - , typeNode - , /*decoarators*/ undefined - , indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); - } - - // /** Note that mapToTypeNodeArray(undefined) === undefined. */ - // function mapToTypeParameterArray(types: Type[]): NodeArray { - // return asNodeArray(types && types.map(createTypeParameterDeclarationFromType) as TypeNode[]); - // } } } + function createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration { + const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); + + const name = getNameFromIndexInfo(indexInfo); + const indexingParameter = createParameter( + /*decorators*/ undefined + , /*modifiers*/ undefined + , /*dotDotDotToken*/ undefined + , name + , /*questionToken*/ undefined + , indexerTypeNode + , /*initializer*/ undefined); + const typeNode = createTypeNode(indexInfo.type); + return createIndexSignatureDeclaration( + [indexingParameter] + , typeNode + , /*decorators*/ undefined + , indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); + } + function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string { const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index bccf0f1c4f9..28c293ae533 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2471,6 +2471,8 @@ namespace ts { createTypeNode(type: Type): TypeNode; /** Note that the resulting type node cannot be checked. */ createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration; + /** Note that the resulting type node cannot be checked. */ + createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 030b66813a5..b4d65958f3c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -524,6 +524,10 @@ namespace ts { export function declarationNameToString(name: DeclarationName) { return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } + + export function getNameFromIndexInfo(info: IndexInfo) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; + } export function getTextOfPropertyName(name: PropertyName): string { switch (name.kind) { diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 220cea55d6f..33b4a10dffc 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -53,18 +53,7 @@ namespace ts.codefix { if (!indexInfoOfKind) { return undefined; } - const typeNode = checker.createTypeNode(indexInfoOfKind.type); - const newIndexSignatureDeclaration = createIndexSignatureDeclaration( - [createParameter( - /*decorators*/undefined - , /*modifiers*/ undefined - , /*dotDotDotToken*/ undefined - , getNameFromIndexInfo(indexInfoOfKind) - , /*questionToken*/ undefined - , kind === IndexKind.String ? createKeywordTypeNode(SyntaxKind.StringKeyword) : createKeywordTypeNode(SyntaxKind.NumberKeyword))] - , typeNode - , /*decorators*/undefined - , /*modifiers*/ undefined); + const newIndexSignatureDeclaration = checker.createIndexSignatureFromIndexInfo(indexInfoOfKind, kind); newNodes.push(newIndexSignatureDeclaration); } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 2db14f81df1..c51687962b3 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -52,10 +52,10 @@ namespace ts.codefix { const declaration = declarations[0] as Declaration; // TODO: get name as identifier or computer property name, etc. - const name = declaration.name ? declaration.name.getText() : undefined; + const name = declaration.name ? getSynthesizedDeepClone(declaration.name) as PropertyName : undefined; const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); const modifiers = visibilityModifier ? [visibilityModifier] : undefined; - const type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); switch (declaration.kind) { case SyntaxKind.GetAccessor: @@ -94,7 +94,7 @@ namespace ts.codefix { const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = checker.createTypeNode(checker.getReturnTypeOfSignature(signature)); + const returnType = checker.createTypeNode(checker.getWidenedType(checker.getReturnTypeOfSignature(signature))); return createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType); } @@ -121,7 +121,7 @@ namespace ts.codefix { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = checker.createTypeNode(signature.resolvedReturnType); + const returnType = checker.createTypeNode(checker.getWidenedType(checker.getReturnTypeOfSignature(signature))); signatureDeclarations.push(createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType)); } else { @@ -135,7 +135,7 @@ namespace ts.codefix { } } - function createMethodImplementingSignatures(signatures: Signature[], name: string, modifiers: Modifier[] | undefined): MethodDeclaration { + function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, modifiers: Modifier[] | undefined): MethodDeclaration { Debug.assert(signatures && signatures.length > 0); let maxNonRestArgs = -1; @@ -189,7 +189,7 @@ namespace ts.codefix { , /*returnType*/ undefined); } - export function createStubbedMethod(modifiers: Modifier[], name: string, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { + export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { return createMethod( /*decorators*/undefined , modifiers @@ -223,7 +223,7 @@ namespace ts.codefix { function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker) { const parameterDeclaration = parameterSymbol.getDeclarations()[0] as ParameterDeclaration; - const parameterType = checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration); + const parameterType = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration)); const parameterTypeNode = checker.createTypeNode(parameterType); // TODO: deep cloning of decorators/any node. const parameterNode = createParameter( @@ -236,8 +236,4 @@ namespace ts.codefix { , /*initializer*/ undefined); return parameterNode; } - - export function getNameFromIndexInfo(info: IndexInfo) { - return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : "x" - } } \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterface36.ts b/tests/cases/fourslash/codeFixClassImplementInterface36.ts deleted file mode 100644 index 5b0459ab663..00000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterface36.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -//// abstract class C1 { -//// -//// } -//// -//// abstract class C2 { -//// abstract f1(); -//// } -//// -//// interface I1 extends C1, C2 {} -//// -//// class C3 implements I1 {[| |]} - -verify.rangeAfterCodeFix(`f1(){ - throw new Error("Method not implemented."); -} -`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterface39.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts similarity index 100% rename from tests/cases/fourslash/codeFixClassImplementInterface39.ts rename to tests/cases/fourslash/codeFixClassImplementInterfaceInNamespace.ts diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts new file mode 100644 index 00000000000..b49d42dab54 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts @@ -0,0 +1,18 @@ +/// + +// abstract class C1 { +// +// } +// +// abstract class C2 { +// abstract f1(); +// } +// +// interface I1 extends C1, C2 {} +// +// class C3 implements I1 {[| |]} + +verify.rangeAfterCodeFix(`f1(){ + throw new Error("Method not implemented."); +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts index 5043a4d9c23..13d58d0ad6e 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements1.ts @@ -7,8 +7,8 @@ //// y: number; //// } //// -//// class C implements I1,I2 {[| |] -//// y: number; +//// class C implements I1,I2 {[| +//// |]y: number; //// } verify.rangeAfterCodeFix(` diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts index ead23751680..e5100b88f6c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMultipleImplements2.ts @@ -7,9 +7,9 @@ //// y: number; //// } //// -//// class C implements I1,I2 {[| |] -//// x: number; -//// |]} +//// class C implements I1,I2 {[| +//// |]x: number; +//// } verify.rangeAfterCodeFix(` y: number; From 92b3e17bc0db3daac25f29a7219de527f8c2b591 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 14 Mar 2017 15:26:30 -0700 Subject: [PATCH 091/207] Fix deep clone --- src/compiler/factory.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 077bc349867..bd46e208784 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -68,11 +68,18 @@ namespace ts { } /* @internal */ + /** + * Note this implementation is inefficient in that all nodes except leaves are cloned twice, + * First by the explicit call below and then again as part of updateNode. + * We need to clone before visiting the children because otherwise updateNode + * will overwrite the synthesized span with the original node's span. + */ export function getSynthesizedDeepClone(node: T | undefined): T { if (node === undefined) { return undefined; } - return getSynthesizedClone(visitEachChild(node, getSynthesizedClone, nullTransformationContext)); + const clone = getSynthesizedClone(node); + return visitEachChild(clone, getSynthesizedDeepClone, nullTransformationContext); } // Literals From d4bb267ee3618f03fb64c515cfa2a7a02261baac Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 14 Mar 2017 16:13:33 -0700 Subject: [PATCH 092/207] add insertNodeInListAfter functionality --- src/harness/unittests/textChanges.ts | 172 +++++++++++-- .../fixClassSuperMustPrecedeThisAccess.ts | 2 +- .../fixConstructorForDerivedNeedSuperCall.ts | 2 +- src/services/codefixes/importFixes.ts | 103 +++----- .../codefixes/unusedIdentifierFixes.ts | 2 +- src/services/formatting/formattingScanner.ts | 4 +- src/services/textChanges.ts | 242 +++++++++++++++--- .../textChanges/insertNodeInListAfter1.js | 6 + .../textChanges/insertNodeInListAfter10.js | 10 + .../textChanges/insertNodeInListAfter11.js | 11 + .../textChanges/insertNodeInListAfter12.js | 10 + .../textChanges/insertNodeInListAfter13.js | 11 + .../textChanges/insertNodeInListAfter14.js | 13 + .../textChanges/insertNodeInListAfter15.js | 13 + .../textChanges/insertNodeInListAfter16.js | 13 + .../textChanges/insertNodeInListAfter17.js | 13 + .../textChanges/insertNodeInListAfter18.js | 10 + .../textChanges/insertNodeInListAfter2.js | 6 + .../textChanges/insertNodeInListAfter3.js | 6 + .../textChanges/insertNodeInListAfter4.js | 6 + .../textChanges/insertNodeInListAfter5.js | 6 + .../textChanges/insertNodeInListAfter6.js | 9 + .../textChanges/insertNodeInListAfter7.js | 9 + .../textChanges/insertNodeInListAfter8.js | 9 + .../textChanges/insertNodeInListAfter9.js | 9 + .../importNameCodeFixExistingImport10.ts | 2 +- .../importNameCodeFixExistingImport11.ts | 3 +- .../importNameCodeFixExistingImport9.ts | 3 +- 28 files changed, 580 insertions(+), 125 deletions(-) create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter10.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter11.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter12.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter13.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter14.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter15.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter16.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter17.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter18.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter3.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter4.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter5.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter6.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter7.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter8.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter9.js diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts index b8c9a8e873d..61f6d738e57 100644 --- a/src/harness/unittests/textChanges.ts +++ b/src/harness/unittests/textChanges.ts @@ -130,7 +130,7 @@ namespace M /*body */ createBlock(statements) ); - changeTracker.insertNodeBefore(sourceFile, /*before*/findChild("M2", sourceFile), newFunction, { insertTrailingNewLine: true }); + changeTracker.insertNodeBefore(sourceFile, /*before*/findChild("M2", sourceFile), newFunction, { suffix: newLineCharacter }); // replace statements with return statement const newStatement = createReturn( @@ -139,7 +139,7 @@ namespace M /*typeArguments*/ undefined, /*argumentsArray*/ emptyArray )); - changeTracker.replaceNodeRange(sourceFile, statements[0], lastOrUndefined(statements), newStatement, { insertTrailingNewLine: true }); + changeTracker.replaceNodeRange(sourceFile, statements[0], lastOrUndefined(statements), newStatement, { suffix: newLineCharacter }); }); } { @@ -255,10 +255,10 @@ var z = 3; // comment 5 // comment 6 var a = 4; // comment 7`; runSingleFileTest("replaceRange", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { insertTrailingNewLine: true }); + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { suffix: newLineCharacter }); }); runSingleFileTest("replaceRangeWithForcedIndentation", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { insertTrailingNewLine: true, indentation: 8, delta: 0 }); + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { suffix: newLineCharacter, indentation: 8, delta: 0 }); }); runSingleFileTest("replaceRangeNoLineBreakBefore", setNewLineForOpenBraceInFunctions, `const x = 1, y = "2";`, /*validateNodes*/ false, (sourceFile, changeTracker) => { @@ -287,13 +287,13 @@ var z = 3; // comment 5 // comment 6 var a = 4; // comment 7`; runSingleFileTest("replaceNode1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); }); runSingleFileTest("replaceNode2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, insertTrailingNewLine: true, insertLeadingNewLine: true }); + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, suffix: newLineCharacter, prefix: newLineCharacter }); }); runSingleFileTest("replaceNode3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, insertTrailingNewLine: true }); + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, suffix: newLineCharacter }); }); runSingleFileTest("replaceNode4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); @@ -312,13 +312,13 @@ var z = 3; // comment 5 // comment 6 var a = 4; // comment 7`; runSingleFileTest("replaceNodeRange1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { suffix: newLineCharacter }); }); runSingleFileTest("replaceNodeRange2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, insertTrailingNewLine: true, insertLeadingNewLine: true }); + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, suffix: newLineCharacter, prefix: newLineCharacter }); }); runSingleFileTest("replaceNodeRange3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, insertTrailingNewLine: true }); + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, suffix: newLineCharacter }); }); runSingleFileTest("replaceNodeRange4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); @@ -334,7 +334,7 @@ var z = 3; // comment 5 // comment 6 var a = 4; // comment 7`; runSingleFileTest("insertNodeAt1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.insertNodeAt(sourceFile, text.indexOf("var y"), createTestClass(), { insertTrailingNewLine: true }); + changeTracker.insertNodeAt(sourceFile, text.indexOf("var y"), createTestClass(), { suffix: newLineCharacter }); }); runSingleFileTest("insertNodeAt2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeAt(sourceFile, text.indexOf("; // comment 4"), createTestVariableDeclaration("z1")); @@ -352,16 +352,16 @@ namespace M { var a = 4; // comment 7 }`; runSingleFileTest("insertNodeBefore1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.insertNodeBefore(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + changeTracker.insertNodeBefore(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); }); runSingleFileTest("insertNodeBefore2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.insertNodeBefore(sourceFile, findChild("M", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + changeTracker.insertNodeBefore(sourceFile, findChild("M", sourceFile), createTestClass(), { suffix: newLineCharacter }); }); runSingleFileTest("insertNodeAfter1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { insertTrailingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); }); runSingleFileTest("insertNodeAfter2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { - changeTracker.insertNodeAfter(sourceFile, findChild("M", sourceFile), createTestClass(), { insertLeadingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, findChild("M", sourceFile), createTestClass(), { prefix: newLineCharacter }); }); } { @@ -385,7 +385,7 @@ class A { } `; runSingleFileTest("insertNodeAfter3", noop, text1, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { insertTrailingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); }); const text2 = ` class A { @@ -395,7 +395,7 @@ class A { } `; runSingleFileTest("insertNodeAfter4", noop, text2, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), createTestSuperCall(), { insertTrailingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); }); const text3 = ` class A { @@ -405,7 +405,7 @@ class A { } `; runSingleFileTest("insertNodeAfter3-block with newline", noop, text3, /*validateNodes*/ false, (sourceFile, changeTracker) => { - changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { insertTrailingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); }); } { @@ -498,7 +498,7 @@ function foo(a: number,b: string,c = true) { changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); }); } -{ + { const text = ` function foo( a: number, @@ -516,5 +516,139 @@ function foo( changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); }); } + { + const text = ` +const x = 1, y = 2;`; + runSingleFileTest("insertNodeInListAfter1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const /*x*/ x = 1, /*y*/ y = 2;`; + runSingleFileTest("insertNodeInListAfter3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const x = 1;`; + runSingleFileTest("insertNodeInListAfter5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const x = 1, + y = 2;`; + runSingleFileTest("insertNodeInListAfter6", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter7", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const /*x*/ x = 1, + /*y*/ y = 2;`; + runSingleFileTest("insertNodeInListAfter8", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter9", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +import { + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter16", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter17", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter18", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } }); } \ No newline at end of file diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 207d039df8e..6d7efb64c6f 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -27,7 +27,7 @@ namespace ts.codefix { } } const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); - changeTracker.insertNodeAfter(sourceFile, getOpenBrace(constructor, sourceFile), superCall, { insertTrailingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); changeTracker.deleteNode(sourceFile, superCall); return [{ diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 27b655f19ce..822c34842fd 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -12,7 +12,7 @@ namespace ts.codefix { const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); const superCall = createStatement(createCall(createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ emptyArray)); - changeTracker.insertNodeAfter(sourceFile, getOpenBrace(token.parent, sourceFile), superCall, { insertTrailingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 3e07efbc3de..743c13ccf38 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -130,7 +130,7 @@ namespace ts.codefix { // this is a module id -> module import declaration map const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; - let cachedNewImportInsertPosition: number; + let lastImportDeclaration: Node; const currentTokenMeaning = getMeaningFromLocation(token); if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { @@ -138,14 +138,14 @@ namespace ts.codefix { return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); } - const allPotentialModules = checker.getAmbientModules(); + const candidateModules = checker.getAmbientModules(); for (const otherSourceFile of allSourceFiles) { if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); + candidateModules.push(otherSourceFile.symbol); } } - for (const moduleSymbol of allPotentialModules) { + for (const moduleSymbol of candidateModules) { context.cancellationToken.throwIfCancellationRequested(); // check the default export @@ -277,14 +277,12 @@ namespace ts.codefix { * If the existing import declaration already has a named import list, just * insert the identifier into that list. */ - const textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + const fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); actions.push(createCodeAction( Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], - textChange.newText, - textChange.span, - sourceFile.fileName, + fileTextChanges, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes )); @@ -302,49 +300,31 @@ namespace ts.codefix { return declaration.moduleReference.getText(); } - function getTextChangeForImportClause(importClause: ImportClause): TextChange { - const newImportText = isDefault ? `default as ${name}` : name; + function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] { + //const newImportText = isDefault ? `default as ${name}` : name; const importList = importClause.namedBindings; + const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)); // case 1: // original text: import default from "module" // change to: import default, { name } from "module" - if (!importList && importClause.name) { - const start = importClause.name.getEnd(); - return { - newText: `, { ${newImportText} }`, - span: { start, length: 0 } - }; - } - // case 2: // original text: import {} from "module" // change to: import { name } from "module" - if (importList.elements.length === 0) { - const start = importList.getStart(); - return { - newText: `{ ${newImportText} }`, - span: { start, length: importList.getEnd() - start } - }; + if (!importList || importList.elements.length === 0) { + const newImportClause = createImportClause(importClause.name, createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - // case 3: - // original text: import { foo, bar } from "module" - // change to: import { foo, bar, name } from "module" - const insertPoint = importList.elements[importList.elements.length - 1].getEnd(); /** * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element * import { * foo * } from "./module"; */ - const startLine = getLineOfLocalPosition(sourceFile, importList.getStart()); - const endLine = getLineOfLocalPosition(sourceFile, importList.getEnd()); - const oneImportPerLine = endLine - startLine > importList.elements.length; - - return { - newText: `,${oneImportPerLine ? context.newLineCharacter : " "}${newImportText}`, - span: { start: insertPoint, length: 0 } - }; + return createChangeTracker().insertNodeInListAfter( + sourceFile, + importList.elements[importList.elements.length - 1], + newImportSpecifier).getChanges(); } function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction { @@ -370,48 +350,47 @@ namespace ts.codefix { return createCodeAction( Diagnostics.Change_0_to_1, [name, `${namespacePrefix}.${name}`], - `${namespacePrefix}.`, - { start: token.getStart(), length: 0 }, - sourceFile.fileName, + createChangeTracker().replaceNode(sourceFile, token, createPropertyAccess(createIdentifier(namespacePrefix), name)).getChanges(), "CodeChange" ); } } function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction { - if (!cachedNewImportInsertPosition) { + if (!lastImportDeclaration) { // insert after any existing imports - let lastModuleSpecifierEnd = -1; - for (const moduleSpecifier of sourceFile.imports) { - const end = moduleSpecifier.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; + for (let i = sourceFile.statements.length - 1; i >= 0; i--) { + const statement = sourceFile.statements[i]; + if (statement.kind === SyntaxKind.ImportEqualsDeclaration || statement.kind === SyntaxKind.ImportDeclaration) { + lastImportDeclaration = statement; + break; } } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); } const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - const importStatementText = isDefault - ? `import ${name} from "${moduleSpecifierWithoutQuotes}"` + const changeTracker = createChangeTracker(); + const importClause = isDefault + ? createImportClause(createIdentifier(name), /*namedBindings*/ undefined) : isNamespaceImport - ? `import * as ${name} from "${moduleSpecifierWithoutQuotes}"` - : `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`; + ? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name))) + : createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))])); + const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. - const newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? `${importStatementText};${context.newLineCharacter}${context.newLineCharacter}` - : `${context.newLineCharacter}${importStatementText};`; - return createCodeAction( Diagnostics.Import_0_from_1, [name, `"${moduleSpecifierWithoutQuotes}"`], - newText, - { start: cachedNewImportInsertPosition, length: 0 }, - sourceFile.fileName, + changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes ); @@ -576,17 +555,19 @@ namespace ts.codefix { } + function createChangeTracker() { + return textChanges.ChangeTracker.fromCodeFixContext(context);; + } + function createCodeAction( description: DiagnosticMessage, diagnosticArgs: string[], - newText: string, - span: TextSpan, - fileName: string, + changes: FileTextChanges[], kind: ImportCodeActionKind, moduleSpecifier?: string): ImportCodeAction { return { description: formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName, textChanges: [{ newText, span }] }], + changes, kind, moduleSpecifier }; diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 1773427fcea..f77f9723d0f 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -132,7 +132,7 @@ namespace ts.codefix { else { const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1); if (previousToken && previousToken.kind === SyntaxKind.CommaToken) { - const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, /*forDeleteOperation*/ true); + const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart); return deleteRange({ pos: startPosition, end: namespaceImport.end }); } return deleteRange(namespaceImport); diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 981ae09b2b2..20d190de2f3 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -276,8 +276,8 @@ namespace ts.formatting { function isOnToken(): boolean { Debug.assert(scanner !== undefined); - const current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - const startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + const current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + const startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current); } diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 5b9f0f5ef4d..174f2969a00 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -28,6 +28,28 @@ namespace ts.textChanges { useNonAdjustedEndPosition?: boolean; } + export enum Position { + FullStart, + Start + } + + function skipWhitespacesAndLineBreaks(text: string, start: number) { + return skipTrivia(text, start, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + } + + function hasCommentsBeforeLineBreak(text: string, start: number) { + let i = start; + while (i < text.length) { + const ch = text.charCodeAt(i); + if (isWhiteSpaceSingleLine(ch)) { + i++; + continue; + } + return ch === CharacterCodes.slash; + } + return false; + } + /** * Usually node.pos points to a position immediately after the previous token. * If this position is used as a beginning of the span to remove - it might lead to removing the trailing trivia of the previous node, i.e: @@ -44,13 +66,13 @@ namespace ts.textChanges { export interface InsertNodeOptions { /** - * Set this value to true to make sure that node text of newly inserted node ends with new line + * Text to be inserted before the new node */ - insertTrailingNewLine?: boolean; + prefix?: string; /** - * Set this value to true to make sure that node text of newly inserted node starts with new line + * Text to be inserted after the new node */ - insertLeadingNewLine?: boolean; + suffix?: string; /** * Text of inserted node will be formatted with this indentation, otherwise indentation will be inferred from the old node */ @@ -66,12 +88,16 @@ namespace ts.textChanges { interface Change { readonly sourceFile: SourceFile; readonly range: TextRange; - readonly oldNode?: Node; + readonly useIndentationFromFile?: boolean; readonly node?: Node; readonly options?: ChangeNodeOptions; } - export function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, forDeleteOperation: boolean) { + export function getSeparatorCharacter(separator: Token) { + return tokenToString(separator.kind); + } + + export function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, position: Position) { if (options.useNonAdjustedStartPosition) { return node.getFullStart(); } @@ -90,12 +116,12 @@ namespace ts.textChanges { // fullstart // when b is replaced - we usually want to keep the leading trvia // when b is deleted - we delete it - return forDeleteOperation ? fullStart : start; + return position === Position.Start ? start : fullStart; } // get start position of the line following the line that contains fullstart position let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); // skip whitespaces/newlines - adjustedStartPosition = skipTrivia(sourceFile.text, adjustedStartPosition, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } @@ -112,8 +138,19 @@ namespace ts.textChanges { : end; } - function isSeparator(node: Node, separator: Node): boolean { - return node.parent && (separator.kind === SyntaxKind.CommaToken || (separator.kind === SyntaxKind.SemicolonToken && node.parent.kind === SyntaxKind.ObjectLiteralExpression)); + /** + * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element + */ + function isSeparator(node: Node, candidate: Node): candidate is Token { + return candidate && node.parent && (candidate.kind === SyntaxKind.CommaToken || (candidate.kind === SyntaxKind.SemicolonToken && node.parent.kind === SyntaxKind.ObjectLiteralExpression)); + } + + function spaces(count: number) { + let s = ""; + for (let i = 0; i < count; i++) { + s += " "; + } + return s; } export class ChangeTracker { @@ -132,7 +169,7 @@ namespace ts.textChanges { } public deleteNode(sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, node, options, /*forDeleteOperation*/ true); + const startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); const endPosition = getAdjustedEndPosition(sourceFile, node, options); this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); return this; @@ -144,7 +181,7 @@ namespace ts.textChanges { } public deleteNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options: ConfigurableStartEnd = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, /*forDeleteOperation*/ true); + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); return this; @@ -153,7 +190,7 @@ namespace ts.textChanges { public deleteNodeInList(sourceFile: SourceFile, node: Node) { const containingList = formatting.SmartIndenter.getContainingList(node, sourceFile); if (!containingList) { - return; + return this; } const index = containingList.indexOf(node); if (index < 0) { @@ -167,10 +204,10 @@ namespace ts.textChanges { const nextToken = getTokenAtPosition(sourceFile, node.end); if (nextToken && isSeparator(node, nextToken)) { // find first non-whitespace position in the leading trivia of the node - const startPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, /*forDeleteOperation*/ true), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + const startPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); const nextElement = containingList[index + 1]; /// find first non-whitespace position in the leading trivia of the next node - const endPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, /*forDeleteOperation*/ true), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + const endPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); } @@ -190,16 +227,16 @@ namespace ts.textChanges { } public replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, /*forDeleteOperation*/ false); + const startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); const endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); - this.changes.push({ sourceFile, options, oldNode, node: newNode, range: { pos: startPosition, end: endPosition } }); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); return this; } public replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, /*forDeleteOperation*/ false); + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); - this.changes.push({ sourceFile, options, oldNode: startNode, node: newNode, range: { pos: startPosition, end: endPosition } }); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); return this; } @@ -209,14 +246,149 @@ namespace ts.textChanges { } public insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, options: InsertNodeOptions & ConfigurableStart = {}) { - const startPosition = getAdjustedStartPosition(sourceFile, before, options, /*forDeleteOperation*/ false); - this.changes.push({ sourceFile, options, oldNode: before, node: newNode, range: { pos: startPosition, end: startPosition } }); + const startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); return this; } public insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node, options: InsertNodeOptions & ConfigurableEnd = {}) { const endPosition = getAdjustedEndPosition(sourceFile, after, options); - this.changes.push({ sourceFile, options, oldNode: after, node: newNode, range: { pos: endPosition, end: endPosition } }); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + } + + public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { + const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); + if (!containingList) { + return this; + } + const index = containingList.indexOf(after); + if (index < 0) { + return this; + } + const end = after.getEnd(); + if (index !== containingList.length - 1) { + // any element except the last one + // use next sibling as an anchor + const nextToken = getTokenAtPosition(sourceFile, after.end); + if (nextToken && isSeparator(after, nextToken)) { + // for list + // a, b, c + // create change for adding 'e' after 'a' as + // - find start of next element after a (it is b) + // - use this start as start and end position in final change + // - build text of change by formatting the text of node + separator + whitespace trivia of b + + // in multiline case it will work as + // a, + // b, + // c, + // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') + // a,* + //***insertedtext# + //###b, + // c, + // find line and character of the next element + const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); + // find line and character of the token that precedes next element (usually it is separator) + const lineAndCharOfNextToken = getLineAndCharacterOfPosition(sourceFile, nextToken.end); + let prefix: string; + let startPos: number; + if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { + // next element is located on the same line with separator: + // a,$$$$b + // ^ ^ + // | |-next element + // |-separator + // where $$$ is some leading trivia + // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces + // a, x,$$$$b + // ^ ^ ^ + // | | |-next element + // | |-new inserted node padded with spaces + // |-separator + startPos = nextToken.end; + prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); + } + else { + // next element is located on different line that separator + // let insert position be the beginning of the line that contains next element + startPos = getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); + } + + this.changes.push({ + sourceFile, + range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, + node: newNode, + useIndentationFromFile: true, + options: { + prefix, + // write separator and leading trivia of the next element as suffix + suffix: `${tokenToString(nextToken.kind)}${sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile))}` + } + }); + } + } + else { + const afterStart = after.getStart(sourceFile); + const afterStartLinePosition = getLineStartPositionForPosition(afterStart, sourceFile); + + let separator: SyntaxKind.CommaToken | SyntaxKind.SemicolonToken; + let multilineList = false; + + // insert element after the last element in the list that has more than one item + // pick the element preceding the after element to: + // - pick the separator + // - determine if list is a multiline + if (containingList.length === 1) { + // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise + // i.e. var x = 1 // this is x + // | new element will be inserted at this position + separator = SyntaxKind.CommaToken; + } + else { + // element has more than one element, pick separator from the list + const tokenBeforeInsertPosition = findPrecedingToken(after.pos, sourceFile); + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : SyntaxKind.CommaToken; + // determine if list is multiline by checking lines of after element and element that precedes it. + const afterMinusOneStartLinePosition = getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); + multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; + } + if (hasCommentsBeforeLineBreak(sourceFile.text, after.end)) { + // in this case we'll always treat containing list as multiline + multilineList = true; + } + if (multilineList) { + // insert separator immediately following the 'after' node to preserve comments in trailing trivia + this.changes.push({ + sourceFile, + range: { pos: end, end }, + node: createToken(separator), + options: {} + }); + // use the same indentation as 'after' item + const indentation = formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.rulesProvider.getFormatOptions()); + // insert element before the line break on the line that contains 'after' element + let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false); + if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { + insertPos-- + } + this.changes.push({ + sourceFile, + range: { pos: insertPos, end: insertPos }, + node: newNode, + options: { indentation, prefix: this.newLineCharacter } + }); + } + else { + this.changes.push({ + sourceFile, + range: { pos: end, end }, + node: newNode, + options: { prefix: `${tokenToString(separator)} ` } + }); + } + } return this; } @@ -267,13 +439,13 @@ namespace ts.textChanges { const formatOptions = this.rulesProvider.getFormatOptions(); const pos = change.range.pos; - const posStartsLine = getLineStartPositionForPosition(pos, sourceFile) === pos; + const posStartsLine = getLineStartPositionForPosition(pos, sourceFile) === pos; const initialIndentation = change.options.indentation !== undefined ? change.options.indentation - : change.oldNode - ? formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || change.options.insertLeadingNewLine) + : change.useIndentationFromFile + ? formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix == this.newLineCharacter)) : 0; const delta = change.options.delta !== undefined @@ -284,15 +456,9 @@ namespace ts.textChanges { let text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line - text = posStartsLine ? text : text.replace(/^\s+/, ""); - - if (options.insertLeadingNewLine) { - text = this.newLineCharacter + text; - } - if (options.insertTrailingNewLine) { - text = text + this.newLineCharacter; - } - return text; + // however keep indentation if it is was forced + text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + return (options.prefix || "") + text + (options.suffix || ""); } private static normalize(changes: Change[]) { @@ -397,9 +563,13 @@ namespace ts.textChanges { constructor(newLine: string) { this.writer = createTextWriter(newLine); this.onEmitNode = (hint, node, printCallback) => { - setPos(node, this.lastNonTriviaPosition); + if (node) { + setPos(node, this.lastNonTriviaPosition); + } printCallback(hint, node); - setEnd(node, this.lastNonTriviaPosition); + if (node) { + setEnd(node, this.lastNonTriviaPosition); + } }; this.onBeforeEmitNodeArray = nodes => { if (nodes) { diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter1.js b/tests/baselines/reference/textChanges/insertNodeInListAfter1.js new file mode 100644 index 00000000000..9b0ed7b819d --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter1.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1, y = 2; +===MODIFIED=== + +const x = 1, z = 1, y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter10.js b/tests/baselines/reference/textChanges/insertNodeInListAfter10.js new file mode 100644 index 00000000000..300230bf51c --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter10.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x +} from "bar" +===MODIFIED=== + +import { + x, b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter11.js b/tests/baselines/reference/textChanges/insertNodeInListAfter11.js new file mode 100644 index 00000000000..f0ba43a0f3a --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter11.js @@ -0,0 +1,11 @@ +===ORIGINAL=== + +import { + x // this is x +} from "bar" +===MODIFIED=== + +import { + x, // this is x + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter12.js b/tests/baselines/reference/textChanges/insertNodeInListAfter12.js new file mode 100644 index 00000000000..79e7bb2c8b6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter12.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x +} from "bar" +===MODIFIED=== + +import { + x, a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter13.js b/tests/baselines/reference/textChanges/insertNodeInListAfter13.js new file mode 100644 index 00000000000..a7ac7179ab6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter13.js @@ -0,0 +1,11 @@ +===ORIGINAL=== + +import { + x // this is x +} from "bar" +===MODIFIED=== + +import { + x, // this is x + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter14.js b/tests/baselines/reference/textChanges/insertNodeInListAfter14.js new file mode 100644 index 00000000000..e44a21723be --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter14.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x +} from "bar" +===MODIFIED=== + +import { + x0, + x, + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter15.js b/tests/baselines/reference/textChanges/insertNodeInListAfter15.js new file mode 100644 index 00000000000..a80bdc2db5e --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter15.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x // this is x +} from "bar" +===MODIFIED=== + +import { + x0, + x, // this is x + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter16.js b/tests/baselines/reference/textChanges/insertNodeInListAfter16.js new file mode 100644 index 00000000000..07f8db919f8 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter16.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x +} from "bar" +===MODIFIED=== + +import { + x0, + x, + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter17.js b/tests/baselines/reference/textChanges/insertNodeInListAfter17.js new file mode 100644 index 00000000000..990139408ee --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter17.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x // this is x +} from "bar" +===MODIFIED=== + +import { + x0, + x, // this is x + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter18.js b/tests/baselines/reference/textChanges/insertNodeInListAfter18.js new file mode 100644 index 00000000000..b25a3f46346 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter18.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x0, x +} from "bar" +===MODIFIED=== + +import { + x0, x, a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter2.js b/tests/baselines/reference/textChanges/insertNodeInListAfter2.js new file mode 100644 index 00000000000..32e8e63c0f6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter2.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1, y = 2; +===MODIFIED=== + +const x = 1, y = 2, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter3.js b/tests/baselines/reference/textChanges/insertNodeInListAfter3.js new file mode 100644 index 00000000000..70a0b0bddcb --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter3.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const /*x*/ x = 1, /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, z = 1, /*y*/ y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter4.js b/tests/baselines/reference/textChanges/insertNodeInListAfter4.js new file mode 100644 index 00000000000..4a30acd7071 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter4.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const /*x*/ x = 1, /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, /*y*/ y = 2, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter5.js b/tests/baselines/reference/textChanges/insertNodeInListAfter5.js new file mode 100644 index 00000000000..42d5fe2ca40 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter5.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1; +===MODIFIED=== + +const x = 1, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter6.js b/tests/baselines/reference/textChanges/insertNodeInListAfter6.js new file mode 100644 index 00000000000..06eae7372a9 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter6.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const x = 1, + y = 2; +===MODIFIED=== + +const x = 1, + z = 1, + y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter7.js b/tests/baselines/reference/textChanges/insertNodeInListAfter7.js new file mode 100644 index 00000000000..bef01503683 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter7.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const x = 1, + y = 2; +===MODIFIED=== + +const x = 1, + y = 2, + z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter8.js b/tests/baselines/reference/textChanges/insertNodeInListAfter8.js new file mode 100644 index 00000000000..e3c44b14274 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter8.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const /*x*/ x = 1, + /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, + z = 1, + /*y*/ y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter9.js b/tests/baselines/reference/textChanges/insertNodeInListAfter9.js new file mode 100644 index 00000000000..510984b7574 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter9.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const /*x*/ x = 1, + /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, + /*y*/ y = 2, + z = 1; \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts b/tests/cases/fourslash/importNameCodeFixExistingImport10.ts index 25246e70123..8a178e72730 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport10.ts @@ -16,6 +16,6 @@ verify.importFixAtPosition([ `{ v1, v2, -f1 + f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts b/tests/cases/fourslash/importNameCodeFixExistingImport11.ts index 304ffb896df..8822356c13a 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport11.ts @@ -15,6 +15,7 @@ verify.importFixAtPosition([ `{ v1, v2, - v3, f1 + v3, + f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts b/tests/cases/fourslash/importNameCodeFixExistingImport9.ts index 05d17927454..51496abff12 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport9.ts @@ -11,7 +11,6 @@ verify.importFixAtPosition([ `{ - v1, -f1 + v1, f1 }` ]); \ No newline at end of file From 79a4557f4c1737ee4dd4151e94f7f2c24b792e8b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 14 Mar 2017 16:24:59 -0700 Subject: [PATCH 093/207] visit type literal and dotDotDottoken --- src/compiler/visitor.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index e64e59eba3a..ba348a558bd 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -270,7 +270,7 @@ namespace ts { return updateParameter(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - (node).dotDotDotToken, + visitNode((node).dotDotDotToken, visitor), visitNode((node).name, visitor, isBindingName), visitNode((node).questionToken, visitor, isToken), visitNode((node).type, visitor, isTypeNode), @@ -294,7 +294,7 @@ namespace ts { case SyntaxKind.NeverKeyword: case SyntaxKind.NeverKeyword: case SyntaxKind.ThisKeyword: - return node; + throw new Error("should be caught above"); // Types @@ -332,7 +332,8 @@ namespace ts { case SyntaxKind.MappedType: throw new Error("reached unsupported type in visitor."); case SyntaxKind.LiteralType: - throw new Error("reached unsupported type in visitor."); + return updateLiteralTypeNode(node + , visitNode((node).literal, visitor, isExpression)); // Type Declarations From e381ffaac7f0b59caa2a41f9813acf4a487664b5 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 14 Mar 2017 16:25:51 -0700 Subject: [PATCH 094/207] don't add any typenode for signature return type --- src/services/codefixes/helpers.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index c51687962b3..e6f4524c718 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -94,18 +94,17 @@ namespace ts.codefix { const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = checker.createTypeNode(checker.getWidenedType(checker.getReturnTypeOfSignature(signature))); + const returnType = createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker); return createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType); } let signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { - // const sigString = checker.signatureToString(signatures[i], enclosingDeclaration, TypeFormatFlags.SuppressAnyReturnType, SignatureKind.Call); // TODO: make signatures instead of methods const signature = signatures[i]; const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = checker.createTypeNode(signature.resolvedReturnType); + const returnType = createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker); signatureDeclarations.push(createMethod( /*decorators*/ undefined , modifiers @@ -121,7 +120,7 @@ namespace ts.codefix { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = checker.createTypeNode(checker.getWidenedType(checker.getReturnTypeOfSignature(signature))); + const returnType = createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker); signatureDeclarations.push(createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType)); } else { @@ -236,4 +235,9 @@ namespace ts.codefix { , /*initializer*/ undefined); return parameterNode; } + + function createTypeNodeExceptAny(type: Type, checker: TypeChecker) { + const typeNode = checker.createTypeNode(type); + return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; + } } \ No newline at end of file From b8756597b8208844dcbf724fc69eb84589608fd2 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 14 Mar 2017 16:45:47 -0700 Subject: [PATCH 095/207] test cleanup --- ...ssImplementInterfaceIndexSignaturesNumber.ts | 1 - ...sImplementInterfaceInheritsAbstractMethod.ts | 17 ++++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts index 41bb7257e41..82cc53570fe 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexSignaturesNumber.ts @@ -3,7 +3,6 @@ //// interface I { //// [x: number]: I; //// } -//// //// class C implements I {[| |]} verify.rangeAfterCodeFix(` diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts index b49d42dab54..c141592823a 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceInheritsAbstractMethod.ts @@ -1,16 +1,11 @@ /// -// abstract class C1 { -// -// } -// -// abstract class C2 { -// abstract f1(); -// } -// -// interface I1 extends C1, C2 {} -// -// class C3 implements I1 {[| |]} +//// abstract class C1 { } +//// abstract class C2 { +//// abstract f1(); +//// } +//// interface I1 extends C1, C2 { } +//// class C3 implements I1 {[| |]} verify.rangeAfterCodeFix(`f1(){ throw new Error("Method not implemented."); From 5775d27e32034d2712902011f05c713f95698aba Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 14 Mar 2017 17:08:35 -0700 Subject: [PATCH 096/207] respect initial order of changes --- src/harness/unittests/textChanges.ts | 17 +++++++++++++++ src/services/textChanges.ts | 14 +++++++------ .../insertNodeAfterMultipleNodes.js | 21 +++++++++++++++++++ 3 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts index 61f6d738e57..8724f7aa392 100644 --- a/src/harness/unittests/textChanges.ts +++ b/src/harness/unittests/textChanges.ts @@ -650,5 +650,22 @@ import { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); }) } + { + const text = ` +class A { + x; +}`; + runSingleFileTest("insertNodeAfterMultipleNodes", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + let newNodes = []; + for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) { + newNodes.push( + createProperty(undefined, undefined, i + "", undefined, undefined, undefined)); + } + const insertAfter = findChild("x", sourceFile); + for (const newNode of newNodes) { + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: newLineCharacter }); + } + }); + } }); } \ No newline at end of file diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 174f2969a00..bb310657b60 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -407,10 +407,8 @@ namespace ts.textChanges { changesPerFile.forEachValue(path => { const changesInFile = changesPerFile.get(path); const sourceFile = changesInFile[0].sourceFile; - ChangeTracker.normalize(changesInFile); - const fileTextChanges: FileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; - for (const c of changesInFile) { + for (const c of ChangeTracker.normalize(changesInFile)) { fileTextChanges.textChanges.push({ span: this.computeSpan(c, sourceFile), newText: this.computeNewText(c, sourceFile) @@ -463,11 +461,15 @@ namespace ts.textChanges { private static normalize(changes: Change[]) { // order changes by start position - changes.sort((a, b) => a.range.pos - b.range.pos); + const normalized = changes + .map((c, i) => ({ c, i })) + .sort(({ c: a, i: i1 }, { c: b, i: i2 }) => (a.range.pos - b.range.pos) || i1 - i2) + .map(({ c }) => c); // verify that end position of the change is less than start position of the next change - for (let i = 0; i < changes.length - 2; i++) { - Debug.assert(changes[i].range.end <= changes[i + 1].range.pos); + for (let i = 0; i < normalized.length - 2; i++) { + Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); } + return normalized; } } diff --git a/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js b/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js new file mode 100644 index 00000000000..1c3bbe4d3e2 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js @@ -0,0 +1,21 @@ +===ORIGINAL=== + +class A { + x; +} +===MODIFIED=== + +class A { + x; + 0; + 1; + 2; + 3; + 4; + 5; + 6; + 7; + 8; + 9; + 10; +} \ No newline at end of file From 45ae0b453cc75d53c42fd0450512bfbb24e47c6c Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 01:15:15 +0100 Subject: [PATCH 097/207] change to forEach method --- src/lib/dom.iterable.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index fb862376a24..35afb0ddd5c 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -8,7 +8,7 @@ interface NodeList { keys(): IterableIterator; values(): IterableIterator<[number, Node]>; entries(): IterableIterator; - forEach(): void; + forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; [Symbol.iterator](): IterableIterator } @@ -16,6 +16,6 @@ interface NodeListOf { keys(): IterableIterator; values(): IterableIterator<[number, TNode]>; entries(): IterableIterator; - forEach(): void; + forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; [Symbol.iterator](): IterableIterator } From 323aa3a56c14d76c0ecd2d450572cd120269b41d Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 14 Mar 2017 17:17:16 -0700 Subject: [PATCH 098/207] add asserts for cases when containing list cannot be determined --- src/services/textChanges.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index bb310657b60..4dcb0867d9a 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -190,6 +190,7 @@ namespace ts.textChanges { public deleteNodeInList(sourceFile: SourceFile, node: Node) { const containingList = formatting.SmartIndenter.getContainingList(node, sourceFile); if (!containingList) { + Debug.fail("node is not a list element"); return this; } const index = containingList.indexOf(node); @@ -260,6 +261,7 @@ namespace ts.textChanges { public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); if (!containingList) { + Debug.fail("node is not a list element"); return this; } const index = containingList.indexOf(after); From e185ebb8d52bac8e0a344629d7cfda8e7e39c2b3 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 14 Mar 2017 18:24:00 -0700 Subject: [PATCH 099/207] simplify rest param handling --- src/compiler/checker.ts | 6 ++--- src/services/codefixes/fixAddMissingMember.ts | 4 +-- src/services/codefixes/helpers.ts | 25 +++++++++++-------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e9cea047eaf..df4bfbb8458 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2340,8 +2340,8 @@ namespace ts { // The type is an object literal type. if (!type.symbol) { // Anonymous types without symbols are literals. - // mapToTypeDeclarationsArray(type) - throw new Error("unknown case."); + // TODO: handle this case correctly. + noop(); } return createTypeLiteralNodeFromType(type); @@ -2471,7 +2471,7 @@ namespace ts { case SyntaxKind.IndexSignature: throw new Error("type literal constituent not implemented."); default: - throw new Error("Unknown case."); + throw new Error("Unknown resolved member kind."); } }); return typeElements.length ? typeElements : undefined; diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 61c823908d9..ace11cda807 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -52,7 +52,7 @@ namespace ts.codefix { , /*initializer*/ undefined); // TODO: make index signature. const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); - propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { insertTrailingNewLine: true }); + propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword); const indexingParameter = createParameter( @@ -70,7 +70,7 @@ namespace ts.codefix { , /*modifiers*/ undefined); const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); - indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { insertTrailingNewLine: true }); + indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); return [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index e6f4524c718..da579cccb1a 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -11,7 +11,7 @@ namespace ts.codefix { const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); for (const newNode of newNodes) { - changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { insertTrailingNewLine: true }); + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); } return changeTracker.getChanges(); } @@ -137,20 +137,23 @@ namespace ts.codefix { function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, modifiers: Modifier[] | undefined): MethodDeclaration { Debug.assert(signatures && signatures.length > 0); - let maxNonRestArgs = -1; let maxArgsIndex = 0; + /** This is *a* signature with the maximal number of arguments, + * such that if there is a "maximal" signature without rest arguments, + * this is one of them. + */ + let maxArgsSignature = signatures[0]; let minArgumentCount = signatures[0].minArgumentCount; - let hasRestParameter = false; + let someSigHasRestParameter = false; for (let i = 0; i < signatures.length; i++) { const sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - hasRestParameter = hasRestParameter || sig.hasRestParameter; - const nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); - if (nonRestLength >= maxNonRestArgs) { - maxNonRestArgs = nonRestLength; - maxArgsIndex = i; + someSigHasRestParameter = someSigHasRestParameter || sig.hasRestParameter; + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + maxArgsSignature = sig; } } + const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName()); const parameters: ParameterDeclaration[] = []; @@ -167,15 +170,15 @@ namespace ts.codefix { parameters.push(newParameter); } - if (hasRestParameter) { - const anyType = createKeywordTypeNode(SyntaxKind.AnyKeyword); + if (someSigHasRestParameter) { + const anyArrayType = createArrayTypeNode(createKeywordTypeNode(SyntaxKind.AnyKeyword)); const restParameter = createParameter( /*decorators*/ undefined , /*modifiers*/ undefined , createToken(SyntaxKind.DotDotDotToken) , maxArgsParameterSymbolNames[maxNonRestArgs] || "rest" , /*questionToken*/ maxNonRestArgs >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined - , anyType + , anyArrayType , /*initializer*/ undefined); parameters.push(restParameter); } From 64070632dc9f578e98843b85bc0dfdc3e2681624 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:06:25 +0100 Subject: [PATCH 100/207] added comments --- src/lib/dom.iterable.d.ts | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 35afb0ddd5c..543f49e3751 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,17 +5,40 @@ interface DOMTokenList { } interface NodeList { - keys(): IterableIterator; - values(): IterableIterator<[number, Node]>; + + /** + * Returns an list of values in the list + */ entries(): IterableIterator; + forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns an array of key, value pairs for every entry in the list + */ + values(): IterableIterator<[number, Node]>; + + [Symbol.iterator](): IterableIterator } interface NodeListOf { + /** + * Returns an list of values in the list + */ + entries(): IterableIterator; + + forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ keys(): IterableIterator; - values(): IterableIterator<[number, TNode]>; - entries(): IterableIterator; - forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; + /** + * Returns an array of key, value pairs for every entry in the list + */ + values(): IterableIterator<[number, Node]>; [Symbol.iterator](): IterableIterator } From d9cab8331433744ee7b975ba610d2292a5f9fe72 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:08:16 +0100 Subject: [PATCH 101/207] Change Node to TNode in NodeListOf --- src/lib/dom.iterable.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 543f49e3751..bb6d75aa657 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -29,9 +29,9 @@ interface NodeListOf { /** * Returns an list of values in the list */ - entries(): IterableIterator; + entries(): IterableIterator; - forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + forEach(callbackfn: (value: TNode, index: number, listObj: NodeList) => void, thisArg?: any): void; /** * Returns an list of keys in the list */ @@ -39,6 +39,6 @@ interface NodeListOf { /** * Returns an array of key, value pairs for every entry in the list */ - values(): IterableIterator<[number, Node]>; + values(): IterableIterator<[number, TNode]>; [Symbol.iterator](): IterableIterator } From f20c59a7d287584a0c9b0cdfe8c6eca5b8049caf Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:10:40 +0100 Subject: [PATCH 102/207] change NodeList to NodeListOf in NodeListOf.forEach --- src/lib/dom.iterable.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index bb6d75aa657..a3f3f238fb2 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -31,7 +31,7 @@ interface NodeListOf { */ entries(): IterableIterator; - forEach(callbackfn: (value: TNode, index: number, listObj: NodeList) => void, thisArg?: any): void; + forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; /** * Returns an list of keys in the list */ From 8d0e0f3f795193c22b3f7ddfabc0759e20e6ae64 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:12:08 +0100 Subject: [PATCH 103/207] Added comment for forEach --- src/lib/dom.iterable.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index a3f3f238fb2..ebdb01603e7 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -10,7 +10,9 @@ interface NodeList { * Returns an list of values in the list */ entries(): IterableIterator; - + /** + * Executes a provided function once per NodeList element. + */ forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; /** * Returns an list of keys in the list @@ -30,7 +32,10 @@ interface NodeListOf { * Returns an list of values in the list */ entries(): IterableIterator; - + + /** + * Executes a provided function once per NodeList element. + */ forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; /** * Returns an list of keys in the list From db878adea31c025328276cdba365f578ba9acd7b Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 03:15:58 +0100 Subject: [PATCH 104/207] changed forEach comment --- src/lib/dom.iterable.d.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index ebdb01603e7..3badfc39a3e 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -10,9 +10,11 @@ interface NodeList { * Returns an list of values in the list */ entries(): IterableIterator; - /** - * Executes a provided function once per NodeList element. - */ + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; /** * Returns an list of keys in the list @@ -33,9 +35,11 @@ interface NodeListOf { */ entries(): IterableIterator; - /** - * Executes a provided function once per NodeList element. - */ + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; /** * Returns an list of keys in the list From c687add579382a0910e985a36f88434312097dcc Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Tue, 14 Mar 2017 22:36:38 -0700 Subject: [PATCH 105/207] add tests to add and remove members in class --- src/harness/unittests/textChanges.ts | 42 +++++++++++++++++++ .../textChanges/deleteNodeAfterInClass1.js | 12 ++++++ .../textChanges/deleteNodeAfterInClass2.js | 12 ++++++ .../textChanges/insertNodeAfterInClass1.js | 12 ++++++ .../textChanges/insertNodeAfterInClass2.js | 12 ++++++ 5 files changed, 90 insertions(+) create mode 100644 tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterInClass1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterInClass2.js diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts index 8724f7aa392..b2fc1ae5774 100644 --- a/src/harness/unittests/textChanges.ts +++ b/src/harness/unittests/textChanges.ts @@ -667,5 +667,47 @@ class A { } }); } + { + const text = ` +class A { + x +} +`; + runSingleFileTest("insertNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x; +} +`; + runSingleFileTest("insertNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x; + y = 1; +} +`; + runSingleFileTest("deleteNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + }); + } + { + const text = ` +class A { + x + y = 1; +} +`; + runSingleFileTest("deleteNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + }); + } }); } \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js b/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js new file mode 100644 index 00000000000..d8d54153eaa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x; + y = 1; +} + +===MODIFIED=== + +class A { + y = 1; +} diff --git a/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js b/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js new file mode 100644 index 00000000000..8d18d820214 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x + y = 1; +} + +===MODIFIED=== + +class A { + y = 1; +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js b/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js new file mode 100644 index 00000000000..87206e588f2 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x +} + +===MODIFIED=== + +class A { + x + a: boolean; +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js b/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js new file mode 100644 index 00000000000..1d583d8ac90 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x; +} + +===MODIFIED=== + +class A { + x; + a: boolean; +} From e8b6e8b0f1328484156f763b71bc9050410568d5 Mon Sep 17 00:00:00 2001 From: cedvdb Date: Wed, 15 Mar 2017 12:48:55 +0100 Subject: [PATCH 106/207] swap entries and values --- src/lib/dom.iterable.d.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 3badfc39a3e..e4da7a62763 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -6,10 +6,11 @@ interface DOMTokenList { interface NodeList { + /** - * Returns an list of values in the list - */ - entries(): IterableIterator; + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, Node]>; /** * Performs the specified action for each node in an list. * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. @@ -20,20 +21,22 @@ interface NodeList { * Returns an list of keys in the list */ keys(): IterableIterator; + /** - * Returns an array of key, value pairs for every entry in the list + * Returns an list of values in the list */ - values(): IterableIterator<[number, Node]>; + values(): IterableIterator; [Symbol.iterator](): IterableIterator } interface NodeListOf { + /** - * Returns an list of values in the list - */ - entries(): IterableIterator; + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, TNode]>; /** * Performs the specified action for each node in an list. @@ -46,8 +49,9 @@ interface NodeListOf { */ keys(): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the list + * Returns an list of values in the list */ - values(): IterableIterator<[number, TNode]>; + values(): IterableIterator; + [Symbol.iterator](): IterableIterator } From 758e1ff8b7ee7b87f0d0e55b2e2a446d70eec6d8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 15 Mar 2017 09:06:59 -0700 Subject: [PATCH 107/207] temp --- src/compiler/checker.ts | 11 ++--------- src/services/codefixes/helpers.ts | 2 +- .../codeFixUndeclaredIndexSignatureNumericLiteral.ts | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index df4bfbb8458..bc718e4c1d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2293,25 +2293,18 @@ namespace ts { } if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); + // TODO: Detect whether class is named and fail if not. const name = getNameOfSymbol(type.symbol); // TODO: handle type arguments. - // TODO: handle anonymous classes. return createTypeReferenceNode(name, /*typeParameters*/undefined); } if (type.flags & TypeFlags.TypeParameter) { - const constraint = createTypeNode(getConstraintFromTypeParameter(type)) as TypeNode; - const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type)) as TypeNode; - if(constraint || defaultParameter) { - // Type parameters in type position can't have constraints or defaults. - encounteredError = true; - return undefined; - } // TODO: get qualified name when necessary instead of string. const name = symbolToString(type.symbol); + // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } - // accessible type aliasSymbol // TODO: move back up later on? if (checkAlias && type.aliasSymbol) { const name = getNameOfSymbol(type.aliasSymbol); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index da579cccb1a..37ea8bab1a9 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -225,7 +225,7 @@ namespace ts.codefix { function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker) { const parameterDeclaration = parameterSymbol.getDeclarations()[0] as ParameterDeclaration; - const parameterType = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration)); + const parameterType = checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration); const parameterTypeNode = checker.createTypeNode(parameterType); // TODO: deep cloning of decorators/any node. const parameterNode = createParameter( diff --git a/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts b/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts index 2e49a8184eb..0a2b0ee799d 100644 --- a/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts +++ b/tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts @@ -8,7 +8,7 @@ verify.rangeAfterCodeFix(` class A { - [name: string]: number; + [x: string]: number; constructor() { this.x = 10; From 2b10611fbfb63c4fe24d865dc275fec016af003e Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Wed, 15 Mar 2017 11:44:36 -0700 Subject: [PATCH 108/207] initial revision of infrastructure to produce text changes that uses existing node factory, formatter and printer (#14441) initial revision of infrastructure to produce text changes that uses existing node factory, formatter and printer --- Jakefile.js | 5 +- src/compiler/emitter.ts | 33 +- src/compiler/factory.ts | 4 + src/compiler/scanner.ts | 2 +- src/compiler/types.ts | 12 + src/compiler/utilities.ts | 14 +- src/compiler/visitor.ts | 150 ++-- src/harness/fourslash.ts | 11 +- src/harness/tsconfig.json | 3 +- src/harness/unittests/textChanges.ts | 791 ++++++++++++++++++ src/server/session.ts | 3 +- src/services/codeFixProvider.ts | 1 + .../fixClassSuperMustPrecedeThisAccess.ts | 17 +- .../fixConstructorForDerivedNeedSuperCall.ts | 7 +- .../fixExtendsInterfaceBecomesImplements.ts | 14 +- .../fixForgottenThisPropertyAccess.ts | 8 +- src/services/codefixes/importFixes.ts | 103 +-- .../codefixes/unusedIdentifierFixes.ts | 133 ++- src/services/formatting/formatting.ts | 50 +- src/services/formatting/formattingContext.ts | 2 +- src/services/formatting/formattingScanner.ts | 10 +- src/services/formatting/rulesProvider.ts | 4 + src/services/formatting/smartIndenter.ts | 87 +- src/services/services.ts | 14 +- src/services/textChanges.ts | 666 +++++++++++++++ src/services/tsconfig.json | 1 + src/services/types.ts | 10 +- src/services/utilities.ts | 14 +- .../reference/textChanges/deleteNode1.js | 13 + .../reference/textChanges/deleteNode2.js | 12 + .../reference/textChanges/deleteNode3.js | 14 + .../reference/textChanges/deleteNode4.js | 13 + .../reference/textChanges/deleteNode5.js | 16 + .../textChanges/deleteNodeAfterInClass1.js | 12 + .../textChanges/deleteNodeAfterInClass2.js | 12 + .../textChanges/deleteNodeInList1.js | 4 + .../textChanges/deleteNodeInList10.js | 10 + .../textChanges/deleteNodeInList11.js | 10 + .../textChanges/deleteNodeInList12.js | 10 + .../textChanges/deleteNodeInList13.js | 15 + .../textChanges/deleteNodeInList14.js | 15 + .../textChanges/deleteNodeInList15.js | 15 + .../textChanges/deleteNodeInList1_1.js | 4 + .../textChanges/deleteNodeInList2.js | 4 + .../textChanges/deleteNodeInList2_1.js | 4 + .../textChanges/deleteNodeInList3.js | 4 + .../textChanges/deleteNodeInList3_1.js | 4 + .../textChanges/deleteNodeInList4.js | 13 + .../textChanges/deleteNodeInList4_1.js | 17 + .../textChanges/deleteNodeInList5.js | 13 + .../textChanges/deleteNodeInList5_1.js | 16 + .../textChanges/deleteNodeInList6.js | 13 + .../textChanges/deleteNodeInList6_1.js | 16 + .../textChanges/deleteNodeInList7.js | 10 + .../textChanges/deleteNodeInList8.js | 10 + .../textChanges/deleteNodeInList9.js | 10 + .../reference/textChanges/deleteNodeRange1.js | 16 + .../reference/textChanges/deleteNodeRange2.js | 15 + .../reference/textChanges/deleteNodeRange3.js | 17 + .../reference/textChanges/deleteNodeRange4.js | 16 + .../reference/textChanges/deleteRange1.js | 15 + .../textChanges/extractMethodLike.js | 49 ++ .../reference/textChanges/insertNodeAfter1.js | 26 + .../reference/textChanges/insertNodeAfter2.js | 26 + .../insertNodeAfter3-block with newline.js | 16 + .../reference/textChanges/insertNodeAfter3.js | 14 + .../reference/textChanges/insertNodeAfter4.js | 16 + .../textChanges/insertNodeAfterInClass1.js | 12 + .../textChanges/insertNodeAfterInClass2.js | 12 + .../insertNodeAfterMultipleNodes.js | 21 + .../reference/textChanges/insertNodeAt1.js | 22 + .../reference/textChanges/insertNodeAt2.js | 20 + .../textChanges/insertNodeBefore1.js | 26 + .../textChanges/insertNodeBefore2.js | 26 + ...rtNodeInClassAfterNodeWithoutSeparator1.js | 12 + ...rtNodeInClassAfterNodeWithoutSeparator2.js | 14 + ...deInInterfaceAfterNodeWithoutSeparator1.js | 12 + ...deInInterfaceAfterNodeWithoutSeparator2.js | 12 + .../textChanges/insertNodeInListAfter1.js | 6 + .../textChanges/insertNodeInListAfter10.js | 10 + .../textChanges/insertNodeInListAfter11.js | 11 + .../textChanges/insertNodeInListAfter12.js | 10 + .../textChanges/insertNodeInListAfter13.js | 11 + .../textChanges/insertNodeInListAfter14.js | 13 + .../textChanges/insertNodeInListAfter15.js | 13 + .../textChanges/insertNodeInListAfter16.js | 13 + .../textChanges/insertNodeInListAfter17.js | 13 + .../textChanges/insertNodeInListAfter18.js | 10 + .../textChanges/insertNodeInListAfter2.js | 6 + .../textChanges/insertNodeInListAfter3.js | 6 + .../textChanges/insertNodeInListAfter4.js | 6 + .../textChanges/insertNodeInListAfter5.js | 6 + .../textChanges/insertNodeInListAfter6.js | 9 + .../textChanges/insertNodeInListAfter7.js | 9 + .../textChanges/insertNodeInListAfter8.js | 9 + .../textChanges/insertNodeInListAfter9.js | 9 + ...StatementListAfterNodeWithoutSeparator1.js | 8 + .../reference/textChanges/replaceNode1.js | 20 + .../replaceNode1NoLineBreakBefore.js | 13 + .../reference/textChanges/replaceNode2.js | 20 + .../reference/textChanges/replaceNode3.js | 21 + .../reference/textChanges/replaceNode4.js | 19 + .../reference/textChanges/replaceNode5.js | 19 + .../textChanges/replaceNodeRange1.js | 19 + .../textChanges/replaceNodeRange2.js | 19 + .../textChanges/replaceNodeRange3.js | 20 + .../textChanges/replaceNodeRange4.js | 18 + .../reference/textChanges/replaceRange.js | 19 + .../replaceRangeNoLineBreakBefore.js | 6 + .../replaceRangeWithForcedIndentation.js | 19 + .../fourslash/codeFixAddForgottenThis01.ts | 10 +- .../cases/fourslash/codeFixSuperAfterThis.ts | 10 +- tests/cases/fourslash/codeFixSuperCall.ts | 11 +- .../importNameCodeFixExistingImport10.ts | 2 +- .../importNameCodeFixExistingImport11.ts | 3 +- .../importNameCodeFixExistingImport9.ts | 3 +- .../fourslash/unusedFunctionInNamespace1.ts | 1 - .../fourslash/unusedVariableInForLoop7FS.ts | 18 +- 118 files changed, 3015 insertions(+), 346 deletions(-) create mode 100644 src/harness/unittests/textChanges.ts create mode 100644 src/services/textChanges.ts create mode 100644 tests/baselines/reference/textChanges/deleteNode1.js create mode 100644 tests/baselines/reference/textChanges/deleteNode2.js create mode 100644 tests/baselines/reference/textChanges/deleteNode3.js create mode 100644 tests/baselines/reference/textChanges/deleteNode4.js create mode 100644 tests/baselines/reference/textChanges/deleteNode5.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList10.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList11.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList12.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList13.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList14.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList15.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList1_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList2_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList3.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList3_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList4.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList4_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList5.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList5_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList6.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList6_1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList7.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList8.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeInList9.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange1.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange2.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange3.js create mode 100644 tests/baselines/reference/textChanges/deleteNodeRange4.js create mode 100644 tests/baselines/reference/textChanges/deleteRange1.js create mode 100644 tests/baselines/reference/textChanges/extractMethodLike.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter3.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfter4.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterInClass1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterInClass2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAt1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeAt2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeBefore1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeBefore2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter1.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter10.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter11.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter12.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter13.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter14.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter15.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter16.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter17.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter18.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter2.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter3.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter4.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter5.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter6.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter7.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter8.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInListAfter9.js create mode 100644 tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js create mode 100644 tests/baselines/reference/textChanges/replaceNode1.js create mode 100644 tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js create mode 100644 tests/baselines/reference/textChanges/replaceNode2.js create mode 100644 tests/baselines/reference/textChanges/replaceNode3.js create mode 100644 tests/baselines/reference/textChanges/replaceNode4.js create mode 100644 tests/baselines/reference/textChanges/replaceNode5.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange1.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange2.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange3.js create mode 100644 tests/baselines/reference/textChanges/replaceNodeRange4.js create mode 100644 tests/baselines/reference/textChanges/replaceRange.js create mode 100644 tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js create mode 100644 tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js diff --git a/Jakefile.js b/Jakefile.js index 595875dfc32..2df29911125 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -11,11 +11,7 @@ var ts = require("./lib/typescript"); // Variables var compilerDirectory = "src/compiler/"; -var servicesDirectory = "src/services/"; var serverDirectory = "src/server/"; -var typingsInstallerDirectory = "src/server/typingsInstaller"; -var cancellationTokenDirectory = "src/server/cancellationToken"; -var watchGuardDirectory = "src/server/watchGuard"; var harnessDirectory = "src/harness/"; var libraryDirectory = "src/lib/"; var scriptsDirectory = "scripts/"; @@ -131,6 +127,7 @@ var harnessSources = harnessCoreSources.concat([ "matchFiles.ts", "initializeTSConfig.ts", "printer.ts", + "textChanges.ts", "transform.ts", "customTransforms.ts", ].map(function (f) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index b10f2e7cb17..616be35270e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -199,6 +199,8 @@ namespace ts { onEmitHelpers, onSetSourceFile, substituteNode, + onBeforeEmitNodeArray, + onAfterEmitNodeArray } = handlers; const newLine = getNewLineCharacter(printerOptions); @@ -631,6 +633,11 @@ namespace ts { if (isExpression(node)) { return pipelineEmitExpression(trySubstituteNode(EmitHint.Expression, node)); } + + if (isToken(node)) { + writeTokenText(kind); + return; + } } function pipelineEmitExpression(node: Node): void { @@ -1553,6 +1560,10 @@ namespace ts { emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint: EmitHint, body: Node): void { + emitBlockFunctionBody(body); + } + function emitSignatureAndBody(node: FunctionLikeDeclaration, emitSignatureHead: (node: SignatureDeclaration) => void) { const body = node.body; if (body) { @@ -1564,12 +1575,22 @@ namespace ts { if (getEmitFlags(node) & EmitFlags.ReuseTempVariableScope) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(EmitHint.Unspecified, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(EmitHint.Unspecified, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } @@ -2200,6 +2221,10 @@ namespace ts { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (isEmpty) { // Write a line terminator if the parent node was multi-line if (format & ListFormat.MultiLine) { @@ -2315,6 +2340,10 @@ namespace ts { } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } + if (format & ListFormat.BracketsMask) { write(getClosingBracket(format)); } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 3ff3bc2782f..669c66c4337 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1099,6 +1099,10 @@ namespace ts { : node; } + export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode { + return createSynthesizedNode(kind); + } + export function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.FunctionDeclaration); node.decorators = asNodeArray(decorators); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index fb91b0ff5b7..b7a3f35d728 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -333,7 +333,7 @@ namespace ts { } /* @internal */ - export function getLineStarts(sourceFile: SourceFile): number[] { + export function getLineStarts(sourceFile: SourceFileLike): number[] { return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text)); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 97b12aeb712..86895f3db6e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2205,6 +2205,16 @@ namespace ts { name: string; } + /* @internal */ + /** + * Subset of properties from SourceFile that are used in multiple utility functions + */ + export interface SourceFileLike { + readonly text: string; + lineMap: number[]; + } + + // Source files are declarations when they are external modules. export interface SourceFile extends Declaration { kind: SyntaxKind.SourceFile; @@ -4132,6 +4142,8 @@ namespace ts { /*@internal*/ onEmitSourceMapOfPosition?: (pos: number) => void; /*@internal*/ onEmitHelpers?: (node: Node, writeLines: (text: string) => void) => void; /*@internal*/ onSetSourceFile?: (node: SourceFile) => void; + /*@internal*/ onBeforeEmitNodeArray?: (nodes: NodeArray) => void; + /*@internal*/ onAfterEmitNodeArray?: (nodes: NodeArray) => void; } export interface PrinterOptions { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a5229b614be..030b66813a5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -184,7 +184,7 @@ namespace ts { return false; } - export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number { + export function getStartPositionOfLine(line: number, sourceFile: SourceFileLike): number { Debug.assert(line >= 0); return getLineStarts(sourceFile)[line]; } @@ -204,7 +204,7 @@ namespace ts { return value !== undefined; } - export function getEndLinePosition(line: number, sourceFile: SourceFile): number { + export function getEndLinePosition(line: number, sourceFile: SourceFileLike): number { Debug.assert(line >= 0); const lineStarts = getLineStarts(sourceFile); @@ -255,7 +255,11 @@ namespace ts { return !nodeIsMissing(node); } - export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile, includeJsDoc?: boolean): number { + export function isToken(n: Node): boolean { + return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; + } + + export function getTokenPosOfNode(node: Node, sourceFile?: SourceFileLike, includeJsDoc?: boolean): number { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. if (nodeIsMissing(node)) { @@ -289,7 +293,7 @@ namespace ts { return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; } - export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number { + export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number { if (nodeIsMissing(node) || !node.decorators) { return getTokenPosOfNode(node, sourceFile); } @@ -2491,7 +2495,7 @@ namespace ts { return indentStrings[1].length; } - export function createTextWriter(newLine: String): EmitTextWriter { + export function createTextWriter(newLine: string): EmitTextWriter { let output: string; let indent: number; let lineStart: boolean; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 0f4a4ed6561..133c62e1926 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -154,9 +154,9 @@ namespace ts { * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext) { + export function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes) { context.startLexicalEnvironment(); - const updated = visitNodes(nodes, visitor, isParameterDeclaration); + const updated = nodesVisitor(nodes, visitor, isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -204,9 +204,9 @@ namespace ts { * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ - export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext): T | undefined; + export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): T | undefined; - export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext): Node { + export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes): Node { if (node === undefined) { return undefined; } @@ -243,8 +243,8 @@ namespace ts { // Signature elements case SyntaxKind.Parameter: return updateParameter(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).dotDotDotToken, visitNode((node).name, visitor, isBindingName), visitNode((node).type, visitor, isTypeNode), @@ -257,55 +257,55 @@ namespace ts { // Type member case SyntaxKind.PropertyDeclaration: return updateProperty(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); case SyntaxKind.MethodDeclaration: return updateMethod(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isPropertyName), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.Constructor: return updateConstructor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.GetAccessor: return updateGetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.SetAccessor: return updateSetAccessor(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isPropertyName), - visitParameterList((node).parameters, visitor, context), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitFunctionBody((node).body, visitor, context)); // Binding patterns case SyntaxKind.ObjectBindingPattern: return updateObjectBindingPattern(node, - visitNodes((node).elements, visitor, isBindingElement)); + nodesVisitor((node).elements, visitor, isBindingElement)); case SyntaxKind.ArrayBindingPattern: return updateArrayBindingPattern(node, - visitNodes((node).elements, visitor, isArrayBindingElement)); + nodesVisitor((node).elements, visitor, isArrayBindingElement)); case SyntaxKind.BindingElement: return updateBindingElement(node, @@ -317,11 +317,11 @@ namespace ts { // Expression case SyntaxKind.ArrayLiteralExpression: return updateArrayLiteral(node, - visitNodes((node).elements, visitor, isExpression)); + nodesVisitor((node).elements, visitor, isExpression)); case SyntaxKind.ObjectLiteralExpression: return updateObjectLiteral(node, - visitNodes((node).properties, visitor, isObjectLiteralElementLike)); + nodesVisitor((node).properties, visitor, isObjectLiteralElementLike)); case SyntaxKind.PropertyAccessExpression: return updatePropertyAccess(node, @@ -336,14 +336,14 @@ namespace ts { case SyntaxKind.CallExpression: return updateCall(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); + nodesVisitor((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).arguments, visitor, isExpression)); case SyntaxKind.NewExpression: return updateNew(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).typeArguments, visitor, isTypeNode), - visitNodes((node).arguments, visitor, isExpression)); + nodesVisitor((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).arguments, visitor, isExpression)); case SyntaxKind.TaggedTemplateExpression: return updateTaggedTemplate(node, @@ -361,19 +361,19 @@ namespace ts { case SyntaxKind.FunctionExpression: return updateFunctionExpression(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.ArrowFunction: return updateArrowFunction(node, - visitNodes((node).modifiers, visitor, isModifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).modifiers, visitor, isModifier), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); @@ -415,7 +415,7 @@ namespace ts { case SyntaxKind.TemplateExpression: return updateTemplateExpression(node, visitNode((node).head, visitor, isTemplateHead), - visitNodes((node).templateSpans, visitor, isTemplateSpan)); + nodesVisitor((node).templateSpans, visitor, isTemplateSpan)); case SyntaxKind.YieldExpression: return updateYield(node, @@ -428,15 +428,15 @@ namespace ts { case SyntaxKind.ClassExpression: return updateClassExpression(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).heritageClauses, visitor, isHeritageClause), + nodesVisitor((node).members, visitor, isClassElement)); case SyntaxKind.ExpressionWithTypeArguments: return updateExpressionWithTypeArguments(node, - visitNodes((node).typeArguments, visitor, isTypeNode), + nodesVisitor((node).typeArguments, visitor, isTypeNode), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.AsExpression: @@ -457,11 +457,11 @@ namespace ts { // Element case SyntaxKind.Block: return updateBlock(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.VariableStatement: return updateVariableStatement(node, - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).declarationList, visitor, isVariableDeclarationList)); case SyntaxKind.ExpressionStatement: @@ -549,61 +549,61 @@ namespace ts { case SyntaxKind.VariableDeclarationList: return updateVariableDeclarationList(node, - visitNodes((node).declarations, visitor, isVariableDeclaration)); + nodesVisitor((node).declarations, visitor, isVariableDeclaration)); case SyntaxKind.FunctionDeclaration: return updateFunctionDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), (node).asteriskToken, visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitFunctionBody((node).body, visitor, context)); case SyntaxKind.ClassDeclaration: return updateClassDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).typeParameters, visitor, isTypeParameter), - visitNodes((node).heritageClauses, visitor, isHeritageClause), - visitNodes((node).members, visitor, isClassElement)); + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).heritageClauses, visitor, isHeritageClause), + nodesVisitor((node).members, visitor, isClassElement)); case SyntaxKind.EnumDeclaration: return updateEnumDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), - visitNodes((node).members, visitor, isEnumMember)); + nodesVisitor((node).members, visitor, isEnumMember)); case SyntaxKind.ModuleDeclaration: return updateModuleDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), visitNode((node).body, visitor, isModuleBody)); case SyntaxKind.ModuleBlock: return updateModuleBlock(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.CaseBlock: return updateCaseBlock(node, - visitNodes((node).clauses, visitor, isCaseOrDefaultClause)); + nodesVisitor((node).clauses, visitor, isCaseOrDefaultClause)); case SyntaxKind.ImportEqualsDeclaration: return updateImportEqualsDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).name, visitor, isIdentifier), visitNode((node).moduleReference, visitor, isModuleReference)); case SyntaxKind.ImportDeclaration: return updateImportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).importClause, visitor, isImportClause), visitNode((node).moduleSpecifier, visitor, isExpression)); @@ -618,7 +618,7 @@ namespace ts { case SyntaxKind.NamedImports: return updateNamedImports(node, - visitNodes((node).elements, visitor, isImportSpecifier)); + nodesVisitor((node).elements, visitor, isImportSpecifier)); case SyntaxKind.ImportSpecifier: return updateImportSpecifier(node, @@ -627,20 +627,20 @@ namespace ts { case SyntaxKind.ExportAssignment: return updateExportAssignment(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.ExportDeclaration: return updateExportDeclaration(node, - visitNodes((node).decorators, visitor, isDecorator), - visitNodes((node).modifiers, visitor, isModifier), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), visitNode((node).exportClause, visitor, isNamedExports), visitNode((node).moduleSpecifier, visitor, isExpression)); case SyntaxKind.NamedExports: return updateNamedExports(node, - visitNodes((node).elements, visitor, isExportSpecifier)); + nodesVisitor((node).elements, visitor, isExportSpecifier)); case SyntaxKind.ExportSpecifier: return updateExportSpecifier(node, @@ -656,12 +656,12 @@ namespace ts { case SyntaxKind.JsxElement: return updateJsxElement(node, visitNode((node).openingElement, visitor, isJsxOpeningElement), - visitNodes((node).children, visitor, isJsxChild), + nodesVisitor((node).children, visitor, isJsxChild), visitNode((node).closingElement, visitor, isJsxClosingElement)); case SyntaxKind.JsxAttributes: return updateJsxAttributes(node, - visitNodes((node).properties, visitor, isJsxAttributeLike)); + nodesVisitor((node).properties, visitor, isJsxAttributeLike)); case SyntaxKind.JsxSelfClosingElement: return updateJsxSelfClosingElement(node, @@ -694,15 +694,15 @@ namespace ts { case SyntaxKind.CaseClause: return updateCaseClause(node, visitNode((node).expression, visitor, isExpression), - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.DefaultClause: return updateDefaultClause(node, - visitNodes((node).statements, visitor, isStatement)); + nodesVisitor((node).statements, visitor, isStatement)); case SyntaxKind.HeritageClause: return updateHeritageClause(node, - visitNodes((node).types, visitor, isExpressionWithTypeArguments)); + nodesVisitor((node).types, visitor, isExpressionWithTypeArguments)); case SyntaxKind.CatchClause: return updateCatchClause(node, diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 35788ebca80..d7638ffc033 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -22,6 +22,10 @@ namespace FourSlash { ts.disableIncrementalParsing = false; + function normalizeNewLines(s: string) { + return s.replace(/\r\n/g, "\n"); + } + // Represents a parsed source file with metadata export interface FourSlashFile { // The contents of the file (with markers, etc stripped out) @@ -1958,8 +1962,7 @@ namespace FourSlash { public verifyCurrentFileContent(text: string) { const actual = this.getFileContent(this.activeFile.fileName); - const replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); - if (replaceNewlines(actual) !== replaceNewlines(text)) { + if (normalizeNewLines(actual) !== normalizeNewLines(text)) { throw new Error("verifyCurrentFileContent\n" + "\tExpected: \"" + text + "\"\n" + "\t Actual: \"" + actual + "\""); @@ -2135,7 +2138,7 @@ namespace FourSlash { const actualText = this.rangeText(ranges[0]); const result = includeWhiteSpace - ? actualText === expectedText + ? normalizeNewLines(actualText) === normalizeNewLines(expectedText) : this.removeWhitespace(actualText) === this.removeWhitespace(expectedText); if (!result) { @@ -2185,7 +2188,7 @@ namespace FourSlash { continue; } - const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]); + const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code], this.formatCodeSettings); if (newActions && newActions.length) { actions = actions ? actions.concat(newActions) : newActions; } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 21622325368..1bbdfa71280 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -125,6 +125,7 @@ "./unittests/projectErrors.ts", "./unittests/printer.ts", "./unittests/transform.ts", - "./unittests/customTransforms.ts" + "./unittests/customTransforms.ts", + "./unittests/textChanges.ts" ] } diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts new file mode 100644 index 00000000000..8269b6de6be --- /dev/null +++ b/src/harness/unittests/textChanges.ts @@ -0,0 +1,791 @@ +/// +/// +/// + +namespace ts { + describe("textChanges", () => { + function findChild(name: string, n: Node) { + return find(n); + + function find(node: Node): Node { + if (isDeclaration(node) && node.name && isIdentifier(node.name) && node.name.text === name) { + return node; + } + else { + return forEachChild(node, find); + } + } + } + + const printerOptions = { newLine: NewLineKind.LineFeed }; + const newLineCharacter = getNewLineCharacter(printerOptions); + + function getRuleProvider(action?: (opts: FormatCodeSettings) => void) { + const options = { + indentSize: 4, + tabSize: 4, + newLineCharacter, + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + if (action) { + action(options); + } + const rulesProvider = new formatting.RulesProvider(); + rulesProvider.ensureUpToDate(options); + return rulesProvider; + } + + // validate that positions that were recovered from the printed text actually match positions that will be created if the same text is parsed. + function verifyPositions({ text, node }: textChanges.NonFormattedText): void { + const nodeList = flattenNodes(node); + const sourceFile = createSourceFile("f.ts", text, ScriptTarget.ES2015); + const parsedNodeList = flattenNodes(sourceFile.statements[0]); + Debug.assert(nodeList.length === parsedNodeList.length); + for (let i = 0; i < nodeList.length; i++) { + const left = nodeList[i]; + const right = parsedNodeList[i]; + Debug.assert(left.pos === right.pos); + Debug.assert(left.end === right.end); + } + + function flattenNodes(n: Node) { + const data: (Node | NodeArray)[] = []; + walk(n); + return data; + + function walk(n: Node | Node[]): void { + data.push(n); + return isArray(n) ? forEach(n, walk) : forEachChild(n, walk, walk); + } + } + } + + function runSingleFileTest(caption: string, setupFormatOptions: (opts: FormatCodeSettings) => void, text: string, validateNodes: boolean, testBlock: (sourceFile: SourceFile, changeTracker: textChanges.ChangeTracker) => void) { + it(caption, () => { + Harness.Baseline.runBaseline(`textChanges/${caption}.js`, () => { + const sourceFile = createSourceFile("source.ts", text, ScriptTarget.ES2015, /*setParentNodes*/ true); + const rulesProvider = getRuleProvider(setupFormatOptions); + const changeTracker = new textChanges.ChangeTracker(printerOptions.newLine, rulesProvider, validateNodes ? verifyPositions : undefined); + testBlock(sourceFile, changeTracker); + const changes = changeTracker.getChanges(); + assert.equal(changes.length, 1); + assert.equal(changes[0].fileName, sourceFile.fileName); + const modified = textChanges.applyChanges(sourceFile.text, changes[0].textChanges); + return `===ORIGINAL===${newLineCharacter}${text}${newLineCharacter}===MODIFIED===${newLineCharacter}${modified}`; + }); + }); + } + + function setNewLineForOpenBraceInFunctions(opts: FormatCodeSettings) { + opts.placeOpenBraceOnNewLineForFunctions = true; + } + + { + const text = ` +namespace M +{ + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() { + return 100; + } + const y = 2; // comment 3 + return 1; + } + } +}`; + runSingleFileTest("extractMethodLike", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + const statements = ((findChild("foo", sourceFile)).body).statements.slice(1); + const newFunction = createFunctionDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ "bar", + /*typeParameters*/ undefined, + /*parameters*/ emptyArray, + /*type*/ createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*body */ createBlock(statements) + ); + + changeTracker.insertNodeBefore(sourceFile, /*before*/findChild("M2", sourceFile), newFunction, { suffix: newLineCharacter }); + + // replace statements with return statement + const newStatement = createReturn( + createCall( + /*expression*/ newFunction.name, + /*typeArguments*/ undefined, + /*argumentsArray*/ emptyArray + )); + changeTracker.replaceNodeRange(sourceFile, statements[0], lastOrUndefined(statements), newStatement, { suffix: newLineCharacter }); + }); + } + { + const text = ` +function foo() { + return 1; +} + +function bar() { + return 2; +} +`; + runSingleFileTest("deleteRange1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteRange(sourceFile, { pos: text.indexOf("function foo"), end: text.indexOf("function bar") }); + }); + } + function findVariableStatementContaining(name: string, sourceFile: SourceFile) { + const varDecl = findChild(name, sourceFile); + assert.equal(varDecl.kind, SyntaxKind.VariableDeclaration); + const varStatement = varDecl.parent.parent; + assert.equal(varStatement.kind, SyntaxKind.VariableStatement); + return varStatement; + } + { + const text = ` +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 +`; + runSingleFileTest("deleteNode1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile)); + }); + runSingleFileTest("deleteNode2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true }); + }); + runSingleFileTest("deleteNode3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNode4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("y", sourceFile), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNode5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findVariableStatementContaining("x", sourceFile)); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +`; + runSingleFileTest("deleteNodeRange1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile)); + }); + runSingleFileTest("deleteNodeRange2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedStartPosition: true }); + }); + runSingleFileTest("deleteNodeRange3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("deleteNodeRange4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), + { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + function createTestVariableDeclaration(name: string) { + return createVariableDeclaration(name, /*type*/ undefined, createObjectLiteral([createPropertyAssignment("p1", createLiteral(1))], /*multiline*/ true)); + } + function createTestClass() { + return createClassDeclaration( + /*decorators*/ undefined, + [ + createToken(SyntaxKind.PublicKeyword) + ], + "class1", + /*typeParameters*/ undefined, + [ + createHeritageClause( + SyntaxKind.ImplementsKeyword, + [ + createExpressionWithTypeArguments(/*typeArguments*/ undefined, createIdentifier("interface1")) + ] + ) + ], + [ + createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + "property1", + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.BooleanKeyword), + /*initializer*/ undefined + ) + ] + ); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceRange", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("replaceRangeWithForcedIndentation", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceRange(sourceFile, { pos: text.indexOf("var y"), end: text.indexOf("var a") }, createTestClass(), { suffix: newLineCharacter, indentation: 8, delta: 0 }); + }); + + runSingleFileTest("replaceRangeNoLineBreakBefore", setNewLineForOpenBraceInFunctions, `const x = 1, y = "2";`, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createTestVariableDeclaration("z1"); + changeTracker.replaceRange(sourceFile, { pos: sourceFile.text.indexOf("y"), end: sourceFile.text.indexOf(";") }, newNode); + }); + } + { + const text = ` +namespace A { + const x = 1, y = "2"; +} +`; + runSingleFileTest("replaceNode1NoLineBreakBefore", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createTestVariableDeclaration("z1"); + changeTracker.replaceNode(sourceFile, findChild("y", sourceFile), newNode); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceNode1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNode2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, suffix: newLineCharacter, prefix: newLineCharacter }); + }); + runSingleFileTest("replaceNode3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNode4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + runSingleFileTest("replaceNode5", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNode(sourceFile, findVariableStatementContaining("x", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("replaceNodeRange1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNodeRange2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, suffix: newLineCharacter, prefix: newLineCharacter }); + }); + runSingleFileTest("replaceNodeRange3", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedEndPosition: true, suffix: newLineCharacter }); + }); + runSingleFileTest("replaceNodeRange4", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.replaceNodeRange(sourceFile, findVariableStatementContaining("y", sourceFile), findVariableStatementContaining("z", sourceFile), createTestClass(), { useNonAdjustedStartPosition: true, useNonAdjustedEndPosition: true }); + }); + } + { + const text = ` +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7`; + runSingleFileTest("insertNodeAt1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAt(sourceFile, text.indexOf("var y"), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeAt2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAt(sourceFile, text.indexOf("; // comment 4"), createTestVariableDeclaration("z1")); + }); + } + { + const text = ` +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +}`; + runSingleFileTest("insertNodeBefore1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeBefore(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeBefore2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeBefore(sourceFile, findChild("M", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeAfter1", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("y", sourceFile), createTestClass(), { suffix: newLineCharacter }); + }); + runSingleFileTest("insertNodeAfter2", setNewLineForOpenBraceInFunctions, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("M", sourceFile), createTestClass(), { prefix: newLineCharacter }); + }); + } + { + function findOpenBraceForConstructor(sourceFile: SourceFile) { + const classDecl = sourceFile.statements[0]; + const constructorDecl = forEach(classDecl.members, m => m.kind === SyntaxKind.Constructor && (m).body && m); + return constructorDecl.body.getFirstToken(); + } + function createTestSuperCall() { + const superCall = createCall( + createSuper(), + /*typeArguments*/ undefined, + /*argumentsArray*/ emptyArray + ); + return createStatement(superCall); + } + const text1 = ` +class A { + constructor() { + } +} +`; + runSingleFileTest("insertNodeAfter3", noop, text1, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); + }); + const text2 = ` +class A { + constructor() { + var x = 1; + } +} +`; + runSingleFileTest("insertNodeAfter4", noop, text2, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); + }); + const text3 = ` +class A { + constructor() { + + } +} +`; + runSingleFileTest("insertNodeAfter3-block with newline", noop, text3, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findOpenBraceForConstructor(sourceFile), createTestSuperCall(), { suffix: newLineCharacter }); + }); + } + { + const text = `var a = 1, b = 2, c = 3;`; + runSingleFileTest("deleteNodeInList1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = `var a = 1,b = 2,c = 3;`; + runSingleFileTest("deleteNodeInList1_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList2_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList3_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +namespace M { + var a = 1, + b = 2, + c = 3; +}`; + runSingleFileTest("deleteNodeInList4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList6", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +}`; + runSingleFileTest("deleteNodeInList4_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList5_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList6_1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo(a: number, b: string, c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList7", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList8", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList9", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo(a: number,b: string,c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +function foo( + a: number, + b: string, + c = true) { + return 1; +}`; + runSingleFileTest("deleteNodeInList13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("a", sourceFile)); + }); + runSingleFileTest("deleteNodeInList14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("b", sourceFile)); + }); + runSingleFileTest("deleteNodeInList15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNodeInList(sourceFile, findChild("c", sourceFile)); + }); + } + { + const text = ` +const x = 1, y = 2;`; + runSingleFileTest("insertNodeInListAfter1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const /*x*/ x = 1, /*y*/ y = 2;`; + runSingleFileTest("insertNodeInListAfter3", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter4", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const x = 1;`; + runSingleFileTest("insertNodeInListAfter5", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const x = 1, + y = 2;`; + runSingleFileTest("insertNodeInListAfter6", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter7", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +const /*x*/ x = 1, + /*y*/ y = 2;`; + runSingleFileTest("insertNodeInListAfter8", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + runSingleFileTest("insertNodeInListAfter9", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("y", sourceFile), createVariableDeclaration("z", /*type*/ undefined, createLiteral(1))); + }); + } + { + const text = ` +import { + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter16", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, + x // this is x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter17", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +import { + x0, x +} from "bar"`; + runSingleFileTest("insertNodeInListAfter18", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); + }) + } + { + const text = ` +class A { + x; +}`; + runSingleFileTest("insertNodeAfterMultipleNodes", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + let newNodes = []; + for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) { + newNodes.push( + createProperty(undefined, undefined, i + "", undefined, undefined, undefined)); + } + const insertAfter = findChild("x", sourceFile); + for (const newNode of newNodes) { + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: newLineCharacter }); + } + }); + } + { + const text = ` +class A { + x +} +`; + runSingleFileTest("insertNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x; +} +`; + runSingleFileTest("insertNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x; + y = 1; +} +`; + runSingleFileTest("deleteNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + }); + } + { + const text = ` +class A { + x + y = 1; +} +`; + runSingleFileTest("deleteNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + changeTracker.deleteNode(sourceFile, findChild("x", sourceFile)); + }); + } + { + const text = ` +class A { + x = foo +} +` + runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +class A { + x() { + } +} +` + runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +interface A { + x +} +` + runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +interface A { + x() +} +` + runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createProperty( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createComputedPropertyName(createLiteral(1)), + /*questionToken*/ undefined, + createKeywordTypeNode(SyntaxKind.AnyKeyword), + /*initializer*/ undefined); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + { + const text = ` +let x = foo +` + runSingleFileTest("insertNodeInStatementListAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { + const newNode = createStatement(createParen(createLiteral(1))); + changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), newNode, { suffix: newLineCharacter }); + }); + } + }); +} \ No newline at end of file diff --git a/src/server/session.ts b/src/server/session.ts index b5e7e44970d..64fce61a095 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1420,8 +1420,9 @@ namespace ts.server { const scriptInfo = project.getScriptInfoForNormalizedPath(file); const startPosition = getStartPosition(); const endPosition = getEndPosition(); + const formatOptions = this.projectService.getFormatCodeOptions(file); - const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + const codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, formatOptions); if (!codeActions) { return undefined; } diff --git a/src/services/codeFixProvider.ts b/src/services/codeFixProvider.ts index c22ba779d19..bab5356e99c 100644 --- a/src/services/codeFixProvider.ts +++ b/src/services/codeFixProvider.ts @@ -13,6 +13,7 @@ namespace ts { newLineCharacter: string; host: LanguageServiceHost; cancellationToken: CancellationToken; + rulesProvider: formatting.RulesProvider; } export namespace codefix { diff --git a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts index 4528c48774d..6d7efb64c6f 100644 --- a/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts +++ b/src/services/codefixes/fixClassSuperMustPrecedeThisAccess.ts @@ -26,22 +26,13 @@ namespace ts.codefix { } } } - - const newPosition = getOpenBraceEnd(constructor, sourceFile); - const changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); + changeTracker.deleteNode(sourceFile, superCall); return [{ description: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes + changes: changeTracker.getChanges() }]; function findSuperCall(n: Node): ExpressionStatement { diff --git a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts index 0dede87cf28..822c34842fd 100644 --- a/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts +++ b/src/services/codefixes/fixConstructorForDerivedNeedSuperCall.ts @@ -10,10 +10,13 @@ namespace ts.codefix { return undefined; } - const newPosition = getOpenBraceEnd(token.parent, sourceFile); + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + const superCall = createStatement(createCall(createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ emptyArray)); + changeTracker.insertNodeAfter(sourceFile, getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); + return [{ description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); diff --git a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts index 1e72700ec01..80d4345a943 100644 --- a/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts +++ b/src/services/codefixes/fixExtendsInterfaceBecomesImplements.ts @@ -21,26 +21,20 @@ namespace ts.codefix { return undefined; } - let changeStart = extendsToken.getStart(sourceFile); - let changeEnd = extendsToken.getEnd(); - const textChanges: TextChange[] = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, extendsToken, createToken(SyntaxKind.ImplementsKeyword)); // We replace existing keywords with commas. for (let i = 1; i < heritageClauses.length; i++) { const keywordToken = heritageClauses[i].getFirstToken(); if (keywordToken) { - changeStart = keywordToken.getStart(sourceFile); - changeEnd = keywordToken.getEnd(); - textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + changeTracker.replaceNode(sourceFile, keywordToken, createToken(SyntaxKind.CommaToken)); } } const result = [{ description: getLocaleSpecificMessage(Diagnostics.Change_extends_to_implements), - changes: [{ - fileName: sourceFile.fileName, - textChanges: textChanges - }] + changes: changeTracker.getChanges() }]; return result; diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index c9d59dd8337..711a3289a27 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -5,11 +5,15 @@ namespace ts.codefix { getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - const start = token.getStart(sourceFile); + if (token.kind !== SyntaxKind.Identifier) { + return undefined; + } + const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token)); return [{ description: getLocaleSpecificMessage(Diagnostics.Add_this_to_unresolved_variable), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 3e07efbc3de..743c13ccf38 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -130,7 +130,7 @@ namespace ts.codefix { // this is a module id -> module import declaration map const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; - let cachedNewImportInsertPosition: number; + let lastImportDeclaration: Node; const currentTokenMeaning = getMeaningFromLocation(token); if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { @@ -138,14 +138,14 @@ namespace ts.codefix { return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); } - const allPotentialModules = checker.getAmbientModules(); + const candidateModules = checker.getAmbientModules(); for (const otherSourceFile of allSourceFiles) { if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); + candidateModules.push(otherSourceFile.symbol); } } - for (const moduleSymbol of allPotentialModules) { + for (const moduleSymbol of candidateModules) { context.cancellationToken.throwIfCancellationRequested(); // check the default export @@ -277,14 +277,12 @@ namespace ts.codefix { * If the existing import declaration already has a named import list, just * insert the identifier into that list. */ - const textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + const fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); actions.push(createCodeAction( Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], - textChange.newText, - textChange.span, - sourceFile.fileName, + fileTextChanges, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes )); @@ -302,49 +300,31 @@ namespace ts.codefix { return declaration.moduleReference.getText(); } - function getTextChangeForImportClause(importClause: ImportClause): TextChange { - const newImportText = isDefault ? `default as ${name}` : name; + function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] { + //const newImportText = isDefault ? `default as ${name}` : name; const importList = importClause.namedBindings; + const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)); // case 1: // original text: import default from "module" // change to: import default, { name } from "module" - if (!importList && importClause.name) { - const start = importClause.name.getEnd(); - return { - newText: `, { ${newImportText} }`, - span: { start, length: 0 } - }; - } - // case 2: // original text: import {} from "module" // change to: import { name } from "module" - if (importList.elements.length === 0) { - const start = importList.getStart(); - return { - newText: `{ ${newImportText} }`, - span: { start, length: importList.getEnd() - start } - }; + if (!importList || importList.elements.length === 0) { + const newImportClause = createImportClause(importClause.name, createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - // case 3: - // original text: import { foo, bar } from "module" - // change to: import { foo, bar, name } from "module" - const insertPoint = importList.elements[importList.elements.length - 1].getEnd(); /** * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element * import { * foo * } from "./module"; */ - const startLine = getLineOfLocalPosition(sourceFile, importList.getStart()); - const endLine = getLineOfLocalPosition(sourceFile, importList.getEnd()); - const oneImportPerLine = endLine - startLine > importList.elements.length; - - return { - newText: `,${oneImportPerLine ? context.newLineCharacter : " "}${newImportText}`, - span: { start: insertPoint, length: 0 } - }; + return createChangeTracker().insertNodeInListAfter( + sourceFile, + importList.elements[importList.elements.length - 1], + newImportSpecifier).getChanges(); } function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction { @@ -370,48 +350,47 @@ namespace ts.codefix { return createCodeAction( Diagnostics.Change_0_to_1, [name, `${namespacePrefix}.${name}`], - `${namespacePrefix}.`, - { start: token.getStart(), length: 0 }, - sourceFile.fileName, + createChangeTracker().replaceNode(sourceFile, token, createPropertyAccess(createIdentifier(namespacePrefix), name)).getChanges(), "CodeChange" ); } } function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction { - if (!cachedNewImportInsertPosition) { + if (!lastImportDeclaration) { // insert after any existing imports - let lastModuleSpecifierEnd = -1; - for (const moduleSpecifier of sourceFile.imports) { - const end = moduleSpecifier.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; + for (let i = sourceFile.statements.length - 1; i >= 0; i--) { + const statement = sourceFile.statements[i]; + if (statement.kind === SyntaxKind.ImportEqualsDeclaration || statement.kind === SyntaxKind.ImportDeclaration) { + lastImportDeclaration = statement; + break; } } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); } const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - const importStatementText = isDefault - ? `import ${name} from "${moduleSpecifierWithoutQuotes}"` + const changeTracker = createChangeTracker(); + const importClause = isDefault + ? createImportClause(createIdentifier(name), /*namedBindings*/ undefined) : isNamespaceImport - ? `import * as ${name} from "${moduleSpecifierWithoutQuotes}"` - : `import { ${name} } from "${moduleSpecifierWithoutQuotes}"`; + ? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name))) + : createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))])); + const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. - const newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? `${importStatementText};${context.newLineCharacter}${context.newLineCharacter}` - : `${context.newLineCharacter}${importStatementText};`; - return createCodeAction( Diagnostics.Import_0_from_1, [name, `"${moduleSpecifierWithoutQuotes}"`], - newText, - { start: cachedNewImportInsertPosition, length: 0 }, - sourceFile.fileName, + changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes ); @@ -576,17 +555,19 @@ namespace ts.codefix { } + function createChangeTracker() { + return textChanges.ChangeTracker.fromCodeFixContext(context);; + } + function createCodeAction( description: DiagnosticMessage, diagnosticArgs: string[], - newText: string, - span: TextSpan, - fileName: string, + changes: FileTextChanges[], kind: ImportCodeActionKind, moduleSpecifier?: string): ImportCodeAction { return { description: formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName, textChanges: [{ newText, span }] }], + changes, kind, moduleSpecifier }; diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 61d48bdc3bc..f77f9723d0f 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -25,17 +25,17 @@ namespace ts.codefix { const forStatement = token.parent.parent.parent; const forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFixToRemoveNode(forInitializer); + return deleteNode(forInitializer); } else { - return removeSingleItem(forInitializer.declarations, token); + return deleteNodeInList(token.parent); } case SyntaxKind.ForOfStatement: const forOfStatement = token.parent.parent.parent; if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { const forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + return replaceNode(forOfInitializer.declarations[0], createObjectLiteral()); } break; @@ -47,51 +47,59 @@ namespace ts.codefix { case SyntaxKind.CatchClause: const catchClause = token.parent.parent; const parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFixToRemoveNode(parameter); + return deleteNode(parameter); default: const variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFixToRemoveNode(variableStatement); + return deleteNode(variableStatement); } else { - const declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); + return deleteNodeInList(token.parent); } } case SyntaxKind.TypeParameter: const typeParameters = (token.parent.parent).typeParameters; if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) { + return deleteRange(typeParameters); + } + const nextToken = getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); } else { - return removeSingleItem(typeParameters, token); + return deleteNodeInList(token.parent); } case ts.SyntaxKind.Parameter: const functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else { - return removeSingleItem(functionDeclaration.parameters, token); + return deleteNodeInList(token.parent); } // handle case where 'import a = A;' case SyntaxKind.ImportEqualsDeclaration: - const importEquals = findImportDeclaration(token); - return createCodeFixToRemoveNode(importEquals); + const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration); + return deleteNode(importEquals); case SyntaxKind.ImportSpecifier: const namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. - const importSpec = findImportDeclaration(token); - return createCodeFixToRemoveNode(importSpec); + const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration); + return deleteNode(importSpec); } else { - return removeSingleItem(namedImports.elements, token); + // delete import specifier + return deleteNodeInList(token.parent); } // handle case where "import d, * as ns from './file'" @@ -99,98 +107,79 @@ namespace ts.codefix { case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' const importClause = token.parent; if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| - const importDecl = findImportDeclaration(importClause); - return createCodeFixToRemoveNode(importDecl); + const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); } else { // import |d,| * as ns from './file' - const start = importClause.name.getStart(); - let end = findFirstNonSpaceCharPosStarting(importClause.name.end); - if (sourceFile.text.charCodeAt(end) === CharacterCodes.comma) { - end = findFirstNonSpaceCharPosStarting(end + 1); + const start = importClause.name.getStart(sourceFile); + const nextToken = getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === SyntaxKind.CommaToken) { + // shift first non-whitespace position after comma to the start position of the node + return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/true) }); + } + else { + return deleteNode(importClause.name); } - - return createCodeFix("", start, end - start); } case SyntaxKind.NamespaceImport: const namespaceImport = token.parent; if (namespaceImport.name == token && !(namespaceImport.parent).name) { - const importDecl = findImportDeclaration(namespaceImport); - return createCodeFixToRemoveNode(importDecl); + const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); } else { - const start = (namespaceImport.parent).name.end; - return createCodeFix("", start, (namespaceImport.parent).namedBindings.end - start); + const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === SyntaxKind.CommaToken) { + const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); } } break; case SyntaxKind.PropertyDeclaration: case SyntaxKind.NamespaceImport: - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } if (isDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else if (isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent.parent); + return deleteNode(token.parent.parent); } else { return undefined; } - function findImportDeclaration(token: Node): Node { - let importDecl = token; - while (importDecl.kind != SyntaxKind.ImportDeclaration && importDecl.parent) { - importDecl = importDecl.parent; - } - - return importDecl; + function deleteNode(n: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); } - function createCodeFixToRemoveNode(node: Node) { - let end = node.getEnd(); - const endCharCode = sourceFile.text.charCodeAt(end); - const afterEndCharCode = sourceFile.text.charCodeAt(end + 1); - if (isLineBreak(endCharCode)) { - end += 1; - } - // in the case of CR LF, you could have two consecutive new line characters for one new line. - // this needs to be differenciated from two LF LF chars that actually mean two new lines. - if (isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { - end += 1; - } - - const start = node.getStart(); - return createCodeFix("", start, end - start); + function deleteRange(range: TextRange) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); } - function findFirstNonSpaceCharPosStarting(start: number) { - while (isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; + function deleteNodeInList(n: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); } - function createCodeFix(newText: string, start: number, length: number): CodeAction[] { + function deleteNodeRange(start: Node, end: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + } + + function replaceNode(n: Node, newNode: Node) { + return makeChange(textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + } + + function makeChange(changeTracker: textChanges.ChangeTracker) { return [{ description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText, span: { start, length } }] - }] + changes: changeTracker.getChanges() }]; } - - function removeSingleItem(elements: NodeArray, token: T): CodeAction[] { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } } }); } \ No newline at end of file diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 201d64e4d7e..4fa3b71a3a2 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -314,24 +314,55 @@ namespace ts.formatting { return 0; } + /* @internal */ + export function formatNode(node: Node, sourceFileLike: SourceFileLike, languageVariant: LanguageVariant, initialIndentation: number, delta: number, rulesProvider: RulesProvider): TextChange[] { + const range = { pos: 0, end: sourceFileLike.text.length }; + return formatSpanWorker( + range, + node, + initialIndentation, + delta, + getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), + rulesProvider.getFormatOptions(), + rulesProvider, + FormattingRequestKind.FormatSelection, + _ => false, // assume that node does not have any errors + sourceFileLike); + } + function formatSpan(originalRange: TextRange, sourceFile: SourceFile, options: FormatCodeSettings, rulesProvider: RulesProvider, requestKind: FormattingRequestKind): TextChange[] { + // find the smallest node that fully wraps the range and compute the initial indentation for the node + const enclosingNode = findEnclosingNode(originalRange, sourceFile); + return formatSpanWorker( + originalRange, + enclosingNode, + SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), + getOwnOrInheritedDelta(enclosingNode, options, sourceFile), + getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), + options, + rulesProvider, + requestKind, + prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), + sourceFile); + } - const rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); + function formatSpanWorker(originalRange: TextRange, + enclosingNode: Node, + initialIndentation: number, + delta: number, + formattingScanner: FormattingScanner, + options: FormatCodeSettings, + rulesProvider: RulesProvider, + requestKind: FormattingRequestKind, + rangeContainsError: (r: TextRange) => boolean, + sourceFile: SourceFileLike): TextChange[] { // formatting context is used by rules provider const formattingContext = new FormattingContext(sourceFile, requestKind); - - // find the smallest node that fully wraps the range and compute the initial indentation for the node - const enclosingNode = findEnclosingNode(originalRange, sourceFile); - - const formattingScanner = getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - - const initialIndentation = SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); - let previousRangeHasError: boolean; let previousRange: TextRangeWithKind; let previousParent: Node; @@ -351,7 +382,6 @@ namespace ts.formatting { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - const delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } diff --git a/src/services/formatting/formattingContext.ts b/src/services/formatting/formattingContext.ts index bd5ca352476..26b538dfc5e 100644 --- a/src/services/formatting/formattingContext.ts +++ b/src/services/formatting/formattingContext.ts @@ -15,7 +15,7 @@ namespace ts.formatting { private contextNodeBlockIsOnOneLine: boolean; private nextNodeBlockIsOnOneLine: boolean; - constructor(public sourceFile: SourceFile, public formattingRequestKind: FormattingRequestKind) { + constructor(public readonly sourceFile: SourceFileLike, public formattingRequestKind: FormattingRequestKind) { } public updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node) { diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 2020352f86b..20d190de2f3 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -30,11 +30,11 @@ namespace ts.formatting { RescanJsxText, } - export function getFormattingScanner(sourceFile: SourceFile, startPos: number, endPos: number): FormattingScanner { + export function getFormattingScanner(text: string, languageVariant: LanguageVariant, startPos: number, endPos: number): FormattingScanner { Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = sourceFile.languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; + scanner = languageVariant === LanguageVariant.JSX ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); + scanner.setText(text); scanner.setTextPos(startPos); let wasNewLine = true; @@ -276,8 +276,8 @@ namespace ts.formatting { function isOnToken(): boolean { Debug.assert(scanner !== undefined); - const current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - const startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + const current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + const startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current); } diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 14e08e4857a..660d5f34a0e 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -24,6 +24,10 @@ namespace ts.formatting { return this.rulesMap; } + public getFormatOptions(): Readonly { + return this.options; + } + public ensureUpToDate(options: ts.FormatCodeSettings) { if (!this.options || !ts.compareDataObjects(this.options, options)) { const activeRules = this.createActiveRules(options); diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index eb9e1ba04c5..b5c901482a7 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -8,7 +8,19 @@ namespace ts.formatting { Unknown = -1 } - export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings): number { + /** + * Computed indentation for a given position in source file + * @param position - position in file + * @param sourceFile - target source file + * @param options - set of editor options that control indentation + * @param assumeNewLineBeforeCloseBrace - false when getIndentation is called on the text from the real source file. + * true - when we need to assume that position is on the newline. This is usefult for codefixes, i.e. + * function f() { + * |} + * when inserting some text after open brace we would like to get the value of indentation as if newline was already there. + * However by default indentation at position | will be 0 so 'assumeNewLineBeforeCloseBrace' allows to override this behavior, + */ + export function getIndentation(position: number, sourceFile: SourceFile, options: EditorSettings, assumeNewLineBeforeCloseBrace = false): number { if (position > sourceFile.text.length) { return getBaseIndentation(options); // past EOF } @@ -71,13 +83,14 @@ namespace ts.formatting { if (positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; + const nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); + if (nextTokenKind !== NextTokenKind.Unknown) { + // handle cases when codefix is about to be inserted before the close brace + indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === NextTokenKind.CloseBrace ? options.indentSize : 0; } else { indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; } - break; } @@ -218,15 +231,21 @@ namespace ts.formatting { return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } - function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): boolean { + const enum NextTokenKind { + Unknown, + OpenBrace, + CloseBrace + } + + function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): NextTokenKind { const nextToken = findNextToken(precedingToken, current); if (!nextToken) { - return false; + return NextTokenKind.Unknown; } if (nextToken.kind === SyntaxKind.OpenBraceToken) { // open braces are always indented at the parent level - return true; + return NextTokenKind.OpenBrace; } else if (nextToken.kind === SyntaxKind.CloseBraceToken) { // close braces are indented at the parent level if they are located on the same line with cursor @@ -239,17 +258,17 @@ namespace ts.formatting { // $} const nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + return lineAtPosition === nextTokenStartLine ? NextTokenKind.CloseBrace : NextTokenKind.Unknown; } - return false; + return NextTokenKind.Unknown; } - function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter { + function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFileLike): LineAndCharacter { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } - export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean { + export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean { if (parent.kind === SyntaxKind.IfStatement && (parent).elseStatement === child) { const elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile); Debug.assert(elseKeyword !== undefined); @@ -261,15 +280,15 @@ namespace ts.formatting { return false; } - function getContainingList(node: Node, sourceFile: SourceFile): NodeArray { + function getListIfStartEndIsInListRange(list: NodeArray, start: number, end: number) { + return list && rangeContainsStartEnd(list, start, end) ? list : undefined; + } + + export function getContainingList(node: Node, sourceFile: SourceFile): NodeArray { if (node.parent) { switch (node.parent.kind) { case SyntaxKind.TypeReference: - if ((node.parent).typeArguments && - rangeContainsStartEnd((node.parent).typeArguments, node.getStart(sourceFile), node.getEnd())) { - return (node.parent).typeArguments; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeArguments, node.getStart(sourceFile), node.getEnd()); case SyntaxKind.ObjectLiteralExpression: return (node.parent).properties; case SyntaxKind.ArrayLiteralExpression: @@ -280,30 +299,26 @@ namespace ts.formatting { case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: + case SyntaxKind.Constructor: + case SyntaxKind.ConstructorType: case SyntaxKind.ConstructSignature: { const start = node.getStart(sourceFile); - if ((node.parent).typeParameters && - rangeContainsStartEnd((node.parent).typeParameters, start, node.getEnd())) { - return (node.parent).typeParameters; - } - if (rangeContainsStartEnd((node.parent).parameters, start, node.getEnd())) { - return (node.parent).parameters; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeParameters, start, node.getEnd()) || + getListIfStartEndIsInListRange((node.parent).parameters, start, node.getEnd()); } + case SyntaxKind.ClassDeclaration: + return getListIfStartEndIsInListRange((node.parent).typeParameters, node.getStart(sourceFile), node.getEnd()); case SyntaxKind.NewExpression: case SyntaxKind.CallExpression: { const start = node.getStart(sourceFile); - if ((node.parent).typeArguments && - rangeContainsStartEnd((node.parent).typeArguments, start, node.getEnd())) { - return (node.parent).typeArguments; - } - if ((node.parent).arguments && - rangeContainsStartEnd((node.parent).arguments, start, node.getEnd())) { - return (node.parent).arguments; - } - break; + return getListIfStartEndIsInListRange((node.parent).typeArguments, start, node.getEnd()) || + getListIfStartEndIsInListRange((node.parent).arguments, start, node.getEnd()); } + case SyntaxKind.VariableDeclarationList: + return getListIfStartEndIsInListRange((node.parent).declarations, node.getStart(sourceFile), node.getEnd()); + case SyntaxKind.NamedImports: + case SyntaxKind.NamedExports: + return getListIfStartEndIsInListRange((node.parent).elements, node.getStart(sourceFile), node.getEnd()); } } return undefined; @@ -400,7 +415,7 @@ namespace ts.formatting { value of 'character' for '$' is 3 value of 'column' for '$' is 6 (assuming that tab size is 4) */ - export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings) { + export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings) { let character = 0; let column = 0; for (let pos = startPos; pos < endPos; pos++) { @@ -421,7 +436,7 @@ namespace ts.formatting { return { column, character }; } - export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorSettings): number { + export function findFirstNonWhitespaceColumn(startPos: number, endPos: number, sourceFile: SourceFileLike, options: EditorSettings): number { return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column; } diff --git a/src/services/services.ts b/src/services/services.ts index df5330ebaed..e370dccac32 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -24,6 +24,7 @@ /// /// /// +/// /// /// @@ -63,7 +64,7 @@ namespace ts { return getSourceFileOfNode(this); } - public getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number { + public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number { return getTokenPosOfNode(this, sourceFile, includeJsDocComment); } @@ -129,7 +130,7 @@ namespace ts { return list; } - private createChildren(sourceFile?: SourceFile) { + private createChildren(sourceFile?: SourceFileLike) { let children: Node[]; if (this.kind >= SyntaxKind.FirstNode) { scanner.setText((sourceFile || this.getSourceFile()).text); @@ -182,7 +183,7 @@ namespace ts { return this._children[index]; } - public getChildren(sourceFile?: SourceFile): Node[] { + public getChildren(sourceFile?: SourceFileLike): Node[] { if (!this._children) this.createChildren(sourceFile); return this._children; } @@ -231,7 +232,7 @@ namespace ts { return getSourceFileOfNode(this); } - public getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number { + public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number { return getTokenPosOfNode(this, sourceFile, includeJsDocComment); } @@ -1682,7 +1683,7 @@ namespace ts { return []; } - function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const span = { start, length: end - start }; @@ -1700,7 +1701,8 @@ namespace ts { program: program, newLineCharacter: newLineChar, host: host, - cancellationToken: cancellationToken + cancellationToken: cancellationToken, + rulesProvider: getRuleProvider(formatOptions) }; const fixes = codefix.getFixes(context); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts new file mode 100644 index 00000000000..6f8a67a0535 --- /dev/null +++ b/src/services/textChanges.ts @@ -0,0 +1,666 @@ +/* @internal */ +namespace ts.textChanges { + + /** + * Currently for simplicity we store recovered positions on the node itself. + * It can be changed to side-table later if we decide that current design is too invasive. + */ + function getPos(n: TextRange) { + return (n)["__pos"]; + } + + function setPos(n: TextRange, pos: number) { + (n)["__pos"] = pos; + } + + function getEnd(n: TextRange) { + return (n)["__end"]; + } + + function setEnd(n: TextRange, end: number) { + (n)["__end"] = end; + } + + export interface ConfigurableStart { + useNonAdjustedStartPosition?: boolean; + } + export interface ConfigurableEnd { + useNonAdjustedEndPosition?: boolean; + } + + export enum Position { + FullStart, + Start + } + + function skipWhitespacesAndLineBreaks(text: string, start: number) { + return skipTrivia(text, start, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + } + + function hasCommentsBeforeLineBreak(text: string, start: number) { + let i = start; + while (i < text.length) { + const ch = text.charCodeAt(i); + if (isWhiteSpaceSingleLine(ch)) { + i++; + continue; + } + return ch === CharacterCodes.slash; + } + return false; + } + + /** + * Usually node.pos points to a position immediately after the previous token. + * If this position is used as a beginning of the span to remove - it might lead to removing the trailing trivia of the previous node, i.e: + * const x; // this is x + * ^ - pos for the next variable declaration will point here + * const y; // this is y + * ^ - end for previous variable declaration + * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding + * variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline). + * By default when removing nodes we adjust start and end positions to respect specification of the trivia above. + * If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true + */ + export type ConfigurableStartEnd = ConfigurableStart & ConfigurableEnd; + + export interface InsertNodeOptions { + /** + * Text to be inserted before the new node + */ + prefix?: string; + /** + * Text to be inserted after the new node + */ + suffix?: string; + /** + * Text of inserted node will be formatted with this indentation, otherwise indentation will be inferred from the old node + */ + indentation?: number; + /** + * Text of inserted node will be formatted with this delta, otherwise delta will be inferred from the new node kind + */ + delta?: number; + } + + export type ChangeNodeOptions = ConfigurableStartEnd & InsertNodeOptions; + + interface Change { + readonly sourceFile: SourceFile; + readonly range: TextRange; + readonly useIndentationFromFile?: boolean; + readonly node?: Node; + readonly options?: ChangeNodeOptions; + } + + export function getSeparatorCharacter(separator: Token) { + return tokenToString(separator.kind); + } + + export function getAdjustedStartPosition(sourceFile: SourceFile, node: Node, options: ConfigurableStart, position: Position) { + if (options.useNonAdjustedStartPosition) { + return node.getFullStart(); + } + const fullStart = node.getFullStart(); + const start = node.getStart(sourceFile); + if (fullStart === start) { + return start; + } + const fullStartLine = getLineStartPositionForPosition(fullStart, sourceFile); + const startLine = getLineStartPositionForPosition(start, sourceFile); + if (startLine === fullStartLine) { + // full start and start of the node are on the same line + // a, b; + // ^ ^ + // | start + // fullstart + // when b is replaced - we usually want to keep the leading trvia + // when b is deleted - we delete it + return position === Position.Start ? start : fullStart; + } + // get start position of the line following the line that contains fullstart position + let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // skip whitespaces/newlines + adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); + return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); + } + + export function getAdjustedEndPosition(sourceFile: SourceFile, node: Node, options: ConfigurableEnd) { + if (options.useNonAdjustedEndPosition) { + return node.getEnd(); + } + const end = node.getEnd(); + const newEnd = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); + // check if last character before newPos is linebreak + // if yes - considered all skipped trivia to be trailing trivia of the node + return newEnd !== end && isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) + ? newEnd + : end; + } + + /** + * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element + */ + function isSeparator(node: Node, candidate: Node): candidate is Token { + return candidate && node.parent && (candidate.kind === SyntaxKind.CommaToken || (candidate.kind === SyntaxKind.SemicolonToken && node.parent.kind === SyntaxKind.ObjectLiteralExpression)); + } + + function spaces(count: number) { + let s = ""; + for (let i = 0; i < count; i++) { + s += " "; + } + return s; + } + + export class ChangeTracker { + private changes: Change[] = []; + private readonly newLineCharacter: string; + + public static fromCodeFixContext(context: CodeFixContext) { + return new ChangeTracker(context.newLineCharacter === "\n" ? NewLineKind.LineFeed : NewLineKind.CarriageReturnLineFeed, context.rulesProvider); + } + + constructor( + private readonly newLine: NewLineKind, + private readonly rulesProvider: formatting.RulesProvider, + private readonly validator?: (text: NonFormattedText) => void) { + this.newLineCharacter = getNewLineCharacter({ newLine }); + } + + public deleteNode(sourceFile: SourceFile, node: Node, options: ConfigurableStartEnd = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + const endPosition = getAdjustedEndPosition(sourceFile, node, options); + this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public deleteRange(sourceFile: SourceFile, range: TextRange) { + this.changes.push({ sourceFile, range }); + return this; + } + + public deleteNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, options: ConfigurableStartEnd = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile, options, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public deleteNodeInList(sourceFile: SourceFile, node: Node) { + const containingList = formatting.SmartIndenter.getContainingList(node, sourceFile); + if (!containingList) { + Debug.fail("node is not a list element"); + return this; + } + const index = containingList.indexOf(node); + if (index < 0) { + return this; + } + if (containingList.length === 1) { + this.deleteNode(sourceFile, node); + return this; + } + if (index !== containingList.length - 1) { + const nextToken = getTokenAtPosition(sourceFile, node.end); + if (nextToken && isSeparator(node, nextToken)) { + // find first non-whitespace position in the leading trivia of the node + const startPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + const nextElement = containingList[index + 1]; + /// find first non-whitespace position in the leading trivia of the next node + const endPosition = skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + } + else { + const previousToken = getTokenAtPosition(sourceFile, containingList[index - 1].end); + if (previousToken && isSeparator(node, previousToken)) { + this.deleteNodeRange(sourceFile, previousToken, node); + } + } + return this; + } + + public replaceRange(sourceFile: SourceFile, range: TextRange, newNode: Node, options: InsertNodeOptions = {}) { + this.changes.push({ sourceFile, range, options, node: newNode }); + return this; + } + + public replaceNode(sourceFile: SourceFile, oldNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + const endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public replaceNodeRange(sourceFile: SourceFile, startNode: Node, endNode: Node, newNode: Node, options: ChangeNodeOptions = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + const endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + } + + public insertNodeAt(sourceFile: SourceFile, pos: number, newNode: Node, options: InsertNodeOptions = {}) { + this.changes.push({ sourceFile, options, node: newNode, range: { pos: pos, end: pos } }); + return this; + } + + public insertNodeBefore(sourceFile: SourceFile, before: Node, newNode: Node, options: InsertNodeOptions & ConfigurableStart = {}) { + const startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); + return this; + } + + public insertNodeAfter(sourceFile: SourceFile, after: Node, newNode: Node, options: InsertNodeOptions & ConfigurableEnd = {}) { + if ((isStatementButNotDeclaration(after)) || + after.kind === SyntaxKind.PropertyDeclaration || + after.kind === SyntaxKind.PropertySignature || + after.kind === SyntaxKind.MethodSignature) { + // check if previous statement ends with semicolon + // if not - insert semicolon to preserve the code from changing the meaning due to ASI + if (sourceFile.text.charCodeAt(after.end - 1) !== CharacterCodes.semicolon) { + this.changes.push({ + sourceFile, + options: {}, + range: { pos: after.end, end: after.end }, + node: createToken(SyntaxKind.SemicolonToken) + }) + } + } + const endPosition = getAdjustedEndPosition(sourceFile, after, options); + this.changes.push({ sourceFile, options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + } + + /** + * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, + * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that + * for them separators are treated as the part of the node. + */ + public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { + const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); + if (!containingList) { + Debug.fail("node is not a list element"); + return this; + } + const index = containingList.indexOf(after); + if (index < 0) { + return this; + } + const end = after.getEnd(); + if (index !== containingList.length - 1) { + // any element except the last one + // use next sibling as an anchor + const nextToken = getTokenAtPosition(sourceFile, after.end); + if (nextToken && isSeparator(after, nextToken)) { + // for list + // a, b, c + // create change for adding 'e' after 'a' as + // - find start of next element after a (it is b) + // - use this start as start and end position in final change + // - build text of change by formatting the text of node + separator + whitespace trivia of b + + // in multiline case it will work as + // a, + // b, + // c, + // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') + // a,* + //***insertedtext# + //###b, + // c, + // find line and character of the next element + const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); + // find line and character of the token that precedes next element (usually it is separator) + const lineAndCharOfNextToken = getLineAndCharacterOfPosition(sourceFile, nextToken.end); + let prefix: string; + let startPos: number; + if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { + // next element is located on the same line with separator: + // a,$$$$b + // ^ ^ + // | |-next element + // |-separator + // where $$$ is some leading trivia + // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces + // a, x,$$$$b + // ^ ^ ^ + // | | |-next element + // | |-new inserted node padded with spaces + // |-separator + startPos = nextToken.end; + prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); + } + else { + // next element is located on different line that separator + // let insert position be the beginning of the line that contains next element + startPos = getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); + } + + this.changes.push({ + sourceFile, + range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, + node: newNode, + useIndentationFromFile: true, + options: { + prefix, + // write separator and leading trivia of the next element as suffix + suffix: `${tokenToString(nextToken.kind)}${sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile))}` + } + }); + } + } + else { + const afterStart = after.getStart(sourceFile); + const afterStartLinePosition = getLineStartPositionForPosition(afterStart, sourceFile); + + let separator: SyntaxKind.CommaToken | SyntaxKind.SemicolonToken; + let multilineList = false; + + // insert element after the last element in the list that has more than one item + // pick the element preceding the after element to: + // - pick the separator + // - determine if list is a multiline + if (containingList.length === 1) { + // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise + // i.e. var x = 1 // this is x + // | new element will be inserted at this position + separator = SyntaxKind.CommaToken; + } + else { + // element has more than one element, pick separator from the list + const tokenBeforeInsertPosition = findPrecedingToken(after.pos, sourceFile); + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : SyntaxKind.CommaToken; + // determine if list is multiline by checking lines of after element and element that precedes it. + const afterMinusOneStartLinePosition = getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); + multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; + } + if (hasCommentsBeforeLineBreak(sourceFile.text, after.end)) { + // in this case we'll always treat containing list as multiline + multilineList = true; + } + if (multilineList) { + // insert separator immediately following the 'after' node to preserve comments in trailing trivia + this.changes.push({ + sourceFile, + range: { pos: end, end }, + node: createToken(separator), + options: {} + }); + // use the same indentation as 'after' item + const indentation = formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.rulesProvider.getFormatOptions()); + // insert element before the line break on the line that contains 'after' element + let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false); + if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { + insertPos-- + } + this.changes.push({ + sourceFile, + range: { pos: insertPos, end: insertPos }, + node: newNode, + options: { indentation, prefix: this.newLineCharacter } + }); + } + else { + this.changes.push({ + sourceFile, + range: { pos: end, end }, + node: newNode, + options: { prefix: `${tokenToString(separator)} ` } + }); + } + } + return this; + } + + public getChanges(): FileTextChanges[] { + const changesPerFile = createFileMap(); + // group changes per file + for (const c of this.changes) { + let changesInFile = changesPerFile.get(c.sourceFile.path); + if (!changesInFile) { + changesPerFile.set(c.sourceFile.path, changesInFile = []); + }; + changesInFile.push(c); + } + // convert changes + const fileChangesList: FileTextChanges[] = []; + changesPerFile.forEachValue(path => { + const changesInFile = changesPerFile.get(path); + const sourceFile = changesInFile[0].sourceFile; + const fileTextChanges: FileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; + for (const c of ChangeTracker.normalize(changesInFile)) { + fileTextChanges.textChanges.push({ + span: this.computeSpan(c, sourceFile), + newText: this.computeNewText(c, sourceFile) + }); + } + fileChangesList.push(fileTextChanges); + }); + + return fileChangesList; + } + + private computeSpan(change: Change, _sourceFile: SourceFile): TextSpan { + return createTextSpanFromBounds(change.range.pos, change.range.end); + } + + private computeNewText(change: Change, sourceFile: SourceFile): string { + if (!change.node) { + // deletion case + return ""; + } + const options = change.options || {}; + const nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonFormattedText); + } + + const formatOptions = this.rulesProvider.getFormatOptions(); + const pos = change.range.pos; + const posStartsLine = getLineStartPositionForPosition(pos, sourceFile) === pos; + + const initialIndentation = + change.options.indentation !== undefined + ? change.options.indentation + : change.useIndentationFromFile + ? formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix == this.newLineCharacter)) + : 0; + const delta = + change.options.delta !== undefined + ? change.options.delta + : formatting.SmartIndenter.shouldIndentChildNode(change.node) + ? formatOptions.indentSize + : 0; + + let text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line + // however keep indentation if it is was forced + text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + return (options.prefix || "") + text + (options.suffix || ""); + } + + private static normalize(changes: Change[]) { + // order changes by start position + const normalized = stableSort(changes, (a, b) => a.range.pos - b.range.pos); + // verify that end position of the change is less than start position of the next change + for (let i = 0; i < normalized.length - 2; i++) { + Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); + } + return normalized; + } + } + + export interface NonFormattedText { + readonly text: string; + readonly node: Node; + } + + export function getNonformattedText(node: Node, sourceFile: SourceFile, newLine: NewLineKind): NonFormattedText { + const options = { newLine, target: sourceFile.languageVersion }; + const writer = new Writer(getNewLineCharacter(options)); + const printer = createPrinter(options, writer); + printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer); + return { text: writer.getText(), node: assignPositionsToNode(node) }; + } + + export function applyFormatting(nonFormattedText: NonFormattedText, sourceFile: SourceFile, initialIndentation: number, delta: number, rulesProvider: formatting.RulesProvider) { + const lineMap = computeLineStarts(nonFormattedText.text); + const file: SourceFileLike = { + text: nonFormattedText.text, + lineMap, + getLineAndCharacterOfPosition: pos => computeLineAndCharacterOfPosition(lineMap, pos) + }; + const changes = formatting.formatNode(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); + return applyChanges(nonFormattedText.text, changes); + } + + export function applyChanges(text: string, changes: TextChange[]): string { + for (let i = changes.length - 1; i >= 0; i--) { + const change = changes[i]; + text = `${text.substring(0, change.span.start)}${change.newText}${text.substring(textSpanEnd(change.span))}`; + } + return text; + } + + function isTrivia(s: string) { + return skipTrivia(s, 0) === s.length; + } + + const nullTransformationContext: TransformationContext = { + enableEmitNotification: noop, + enableSubstitution: noop, + endLexicalEnvironment: () => undefined, + getCompilerOptions: notImplemented, + getEmitHost: notImplemented, + getEmitResolver: notImplemented, + hoistFunctionDeclaration: noop, + hoistVariableDeclaration: noop, + isEmitNotificationEnabled: notImplemented, + isSubstitutionEnabled: notImplemented, + onEmitNode: noop, + onSubstituteNode: notImplemented, + readEmitHelpers: notImplemented, + requestEmitHelper: noop, + resumeLexicalEnvironment: noop, + startLexicalEnvironment: noop, + suspendLexicalEnvironment: noop + }; + + function assignPositionsToNode(node: Node): Node { + const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray); + // create proxy node for non synthesized nodes + const newNode = nodeIsSynthesized(visited) + ? visited + : (Proxy.prototype = visited, new (Proxy)()); + newNode.pos = getPos(node); + newNode.end = getEnd(node); + return newNode; + + function Proxy() { } + } + + function assignPositionsToNodeArray(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number) { + const visited = visitNodes(nodes, visitor, test, start, count); + if (!visited) { + return visited; + } + // clone nodearray if necessary + const nodeArray = visited === nodes ? createNodeArray(visited.slice(0)) : visited; + nodeArray.pos = getPos(nodes); + nodeArray.end = getEnd(nodes); + return nodeArray; + } + + class Writer implements EmitTextWriter, PrintHandlers { + private lastNonTriviaPosition = 0; + private readonly writer: EmitTextWriter; + + public readonly onEmitNode: PrintHandlers["onEmitNode"]; + public readonly onBeforeEmitNodeArray: PrintHandlers["onBeforeEmitNodeArray"]; + public readonly onAfterEmitNodeArray: PrintHandlers["onAfterEmitNodeArray"]; + + constructor(newLine: string) { + this.writer = createTextWriter(newLine); + this.onEmitNode = (hint, node, printCallback) => { + if (node) { + setPos(node, this.lastNonTriviaPosition); + } + printCallback(hint, node); + if (node) { + setEnd(node, this.lastNonTriviaPosition); + } + }; + this.onBeforeEmitNodeArray = nodes => { + if (nodes) { + setPos(nodes, this.lastNonTriviaPosition); + } + }; + this.onAfterEmitNodeArray = nodes => { + if (nodes) { + setEnd(nodes, this.lastNonTriviaPosition); + } + }; + } + + private setLastNonTriviaPosition(s: string, force: boolean) { + if (force || !isTrivia(s)) { + this.lastNonTriviaPosition = this.writer.getTextPos(); + let i = 0; + while (isWhiteSpace(s.charCodeAt(s.length - i - 1))) { + i++; + } + // trim trailing whitespaces + this.lastNonTriviaPosition -= i; + } + } + + write(s: string): void { + this.writer.write(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + } + writeTextOfNode(text: string, node: Node): void { + this.writer.writeTextOfNode(text, node); + } + writeLine(): void { + this.writer.writeLine(); + } + increaseIndent(): void { + this.writer.increaseIndent(); + } + decreaseIndent(): void { + this.writer.decreaseIndent(); + } + getText(): string { + return this.writer.getText(); + } + rawWrite(s: string): void { + this.writer.rawWrite(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + } + writeLiteral(s: string): void { + this.writer.writeLiteral(s); + this.setLastNonTriviaPosition(s, /*force*/ true); + } + getTextPos(): number { + return this.writer.getTextPos(); + } + getLine(): number { + return this.writer.getLine(); + } + getColumn(): number { + return this.writer.getColumn(); + } + getIndent(): number { + return this.writer.getIndent(); + } + isAtStartOfLine(): boolean { + return this.writer.isAtStartOfLine(); + } + reset(): void { + this.writer.reset(); + this.lastNonTriviaPosition = 0; + } + } +} \ No newline at end of file diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 93f861e80aa..b1391bd7300 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -63,6 +63,7 @@ "shims.ts", "signatureHelp.ts", "symbolDisplay.ts", + "textChanges.ts", "formatting/formatting.ts", "formatting/formattingContext.ts", "formatting/formattingRequestKind.ts", diff --git a/src/services/types.ts b/src/services/types.ts index c7852db6d6e..149bb4340dc 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -4,7 +4,11 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; + /* @internal */ + getChildren(sourceFile?: SourceFileLike): Node[]; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; + /* @internal */ + getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; getWidth(sourceFile?: SourceFile): number; @@ -59,6 +63,10 @@ namespace ts { update(newText: string, textChangeRange: TextChangeRange): SourceFile; } + export interface SourceFileLike { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + } + /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the * snapshot is observably immutable. i.e. the same calls with the same parameters will return @@ -248,7 +256,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 7c5bf862fc8..1b32b3bbad7 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -394,8 +394,8 @@ namespace ts { list: Node; } - export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number { - const lineStarts = sourceFile.getLineStarts(); + export function getLineStartPositionForPosition(position: number, sourceFile: SourceFileLike): number { + const lineStarts = getLineStarts(sourceFile); const line = sourceFile.getLineAndCharacterOfPosition(position).line; return lineStarts[line]; } @@ -604,7 +604,7 @@ namespace ts { return !!findChildOfKind(n, kind, sourceFile); } - export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node | undefined { + export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFileLike): Node | undefined { return forEach(n.getChildren(sourceFile), c => c.kind === kind && c); } @@ -1003,10 +1003,6 @@ namespace ts { return undefined; } - export function isToken(n: Node): boolean { - return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken; - } - export function isWord(kind: SyntaxKind): boolean { return kind === SyntaxKind.Identifier || isKeyword(kind); } @@ -1384,8 +1380,8 @@ namespace ts { }; } - export function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { + export function getOpenBrace(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); + return constructor.body.getFirstToken(sourceFile); } } diff --git a/tests/baselines/reference/textChanges/deleteNode1.js b/tests/baselines/reference/textChanges/deleteNode1.js new file mode 100644 index 00000000000..c73c0eaf9f9 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode1.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // some comment - 1 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode2.js b/tests/baselines/reference/textChanges/deleteNode2.js new file mode 100644 index 00000000000..828a9b5b8fa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1;var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode3.js b/tests/baselines/reference/textChanges/deleteNode3.js new file mode 100644 index 00000000000..acb26c7daa7 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode3.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // some comment - 1 + // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode4.js b/tests/baselines/reference/textChanges/deleteNode4.js new file mode 100644 index 00000000000..b6edb25bc5c --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode4.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +var x = 1; // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNode5.js b/tests/baselines/reference/textChanges/deleteNode5.js new file mode 100644 index 00000000000..6f896535f0f --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNode5.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +var x = 1; // some comment - 1 +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 + +===MODIFIED=== + +/** + * comment 2 + */ +var y = 2; // comment 3 +var z = 3; // comment 4 diff --git a/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js b/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js new file mode 100644 index 00000000000..d8d54153eaa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeAfterInClass1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x; + y = 1; +} + +===MODIFIED=== + +class A { + y = 1; +} diff --git a/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js b/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js new file mode 100644 index 00000000000..8d18d820214 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeAfterInClass2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x + y = 1; +} + +===MODIFIED=== + +class A { + y = 1; +} diff --git a/tests/baselines/reference/textChanges/deleteNodeInList1.js b/tests/baselines/reference/textChanges/deleteNodeInList1.js new file mode 100644 index 00000000000..b603913566d --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var b = 2, c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList10.js b/tests/baselines/reference/textChanges/deleteNodeInList10.js new file mode 100644 index 00000000000..46da605a71a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList10.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(b: string,c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList11.js b/tests/baselines/reference/textChanges/deleteNodeInList11.js new file mode 100644 index 00000000000..f5aa666e527 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList11.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number,c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList12.js b/tests/baselines/reference/textChanges/deleteNodeInList12.js new file mode 100644 index 00000000000..db05ef06db9 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList12.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number,b: string,c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number,b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList13.js b/tests/baselines/reference/textChanges/deleteNodeInList13.js new file mode 100644 index 00000000000..599d3a31d43 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList13.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + b: string, + c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList14.js b/tests/baselines/reference/textChanges/deleteNodeInList14.js new file mode 100644 index 00000000000..da3596b38b2 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList14.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + a: number, + c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList15.js b/tests/baselines/reference/textChanges/deleteNodeInList15.js new file mode 100644 index 00000000000..02f649dabd2 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList15.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo( + a: number, + b: string, + c = true) { + return 1; +} +===MODIFIED=== + +function foo( + a: number, + b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList1_1.js b/tests/baselines/reference/textChanges/deleteNodeInList1_1.js new file mode 100644 index 00000000000..87709601c42 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList1_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var b = 2,c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList2.js b/tests/baselines/reference/textChanges/deleteNodeInList2.js new file mode 100644 index 00000000000..18e4a0cd304 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList2.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var a = 1, c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList2_1.js b/tests/baselines/reference/textChanges/deleteNodeInList2_1.js new file mode 100644 index 00000000000..b4098a89302 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList2_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var a = 1,c = 3; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList3.js b/tests/baselines/reference/textChanges/deleteNodeInList3.js new file mode 100644 index 00000000000..1c6ff4aa294 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList3.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1, b = 2, c = 3; +===MODIFIED=== +var a = 1, b = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList3_1.js b/tests/baselines/reference/textChanges/deleteNodeInList3_1.js new file mode 100644 index 00000000000..ead2a1a42f8 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList3_1.js @@ -0,0 +1,4 @@ +===ORIGINAL=== +var a = 1,b = 2,c = 3; +===MODIFIED=== +var a = 1,b = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList4.js b/tests/baselines/reference/textChanges/deleteNodeInList4.js new file mode 100644 index 00000000000..61bdf9159cb --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList4.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var b = 2, + c = 3; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList4_1.js b/tests/baselines/reference/textChanges/deleteNodeInList4_1.js new file mode 100644 index 00000000000..19ff5475d1a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList4_1.js @@ -0,0 +1,17 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList5.js b/tests/baselines/reference/textChanges/deleteNodeInList5.js new file mode 100644 index 00000000000..0ed65877d27 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList5.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var a = 1, + c = 3; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList5_1.js b/tests/baselines/reference/textChanges/deleteNodeInList5_1.js new file mode 100644 index 00000000000..224b92481d3 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList5_1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var a = 1, // comment 1 + // comment 4 + c = 3; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList6.js b/tests/baselines/reference/textChanges/deleteNodeInList6.js new file mode 100644 index 00000000000..4093329023f --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList6.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace M { + var a = 1, + b = 2, + c = 3; +} +===MODIFIED=== + +namespace M { + var a = 1, + b = 2; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList6_1.js b/tests/baselines/reference/textChanges/deleteNodeInList6_1.js new file mode 100644 index 00000000000..6acc20aa826 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList6_1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2, // comment 3 + // comment 4 + c = 3; // comment 5 +} +===MODIFIED=== + +namespace M { + var a = 1, // comment 1 + // comment 2 + b = 2; // comment 5 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList7.js b/tests/baselines/reference/textChanges/deleteNodeInList7.js new file mode 100644 index 00000000000..564ff3f86aa --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList7.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(b: string, c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList8.js b/tests/baselines/reference/textChanges/deleteNodeInList8.js new file mode 100644 index 00000000000..b3a0a0f4c47 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList8.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number, c = true) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeInList9.js b/tests/baselines/reference/textChanges/deleteNodeInList9.js new file mode 100644 index 00000000000..96878a6086d --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeInList9.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +function foo(a: number, b: string, c = true) { + return 1; +} +===MODIFIED=== + +function foo(a: number, b: string) { + return 1; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/deleteNodeRange1.js b/tests/baselines/reference/textChanges/deleteNodeRange1.js new file mode 100644 index 00000000000..f9fa45ebb1a --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange1.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange2.js b/tests/baselines/reference/textChanges/deleteNodeRange2.js new file mode 100644 index 00000000000..aacea6ff5ee --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange2.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1;// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange3.js b/tests/baselines/reference/textChanges/deleteNodeRange3.js new file mode 100644 index 00000000000..bb2bb36ca2c --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange3.js @@ -0,0 +1,17 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 + // comment 5 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteNodeRange4.js b/tests/baselines/reference/textChanges/deleteNodeRange4.js new file mode 100644 index 00000000000..3e9ad960b13 --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteNodeRange4.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 + +===MODIFIED=== + +// comment 1 +var x = 1; // comment 5 +// comment 6 +var a = 4; // comment 7 diff --git a/tests/baselines/reference/textChanges/deleteRange1.js b/tests/baselines/reference/textChanges/deleteRange1.js new file mode 100644 index 00000000000..362e678452e --- /dev/null +++ b/tests/baselines/reference/textChanges/deleteRange1.js @@ -0,0 +1,15 @@ +===ORIGINAL=== + +function foo() { + return 1; +} + +function bar() { + return 2; +} + +===MODIFIED=== + +function bar() { + return 2; +} diff --git a/tests/baselines/reference/textChanges/extractMethodLike.js b/tests/baselines/reference/textChanges/extractMethodLike.js new file mode 100644 index 00000000000..fa1d625dc4d --- /dev/null +++ b/tests/baselines/reference/textChanges/extractMethodLike.js @@ -0,0 +1,49 @@ +===ORIGINAL=== + +namespace M +{ + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() { + return 100; + } + const y = 2; // comment 3 + return 1; + } + } +} +===MODIFIED=== + +namespace M +{ + function bar(): any + { + /** + * comment 2 line 1 + * comment 2 line 2 + */ + function f() + { + return 100; + } + const y = 2; // comment 3 + return 1; + } + namespace M2 + { + function foo() { + // comment 1 + const x = 1; + + return bar(); + } + } +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter1.js b/tests/baselines/reference/textChanges/insertNodeAfter1.js new file mode 100644 index 00000000000..e6d7387f6bc --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter1.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + public class class1 implements interface1 + { + property1: boolean; + } + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter2.js b/tests/baselines/reference/textChanges/insertNodeAfter2.js new file mode 100644 index 00000000000..7c027e35b50 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter2.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +public class class1 implements interface1 +{ + property1: boolean; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js b/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js new file mode 100644 index 00000000000..41bfb72b574 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter3-block with newline.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +class A { + constructor() { + + } +} + +===MODIFIED=== + +class A { + constructor() { + super(); + + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfter3.js b/tests/baselines/reference/textChanges/insertNodeAfter3.js new file mode 100644 index 00000000000..3765bbaf032 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter3.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +class A { + constructor() { + } +} + +===MODIFIED=== + +class A { + constructor() { + super(); + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfter4.js b/tests/baselines/reference/textChanges/insertNodeAfter4.js new file mode 100644 index 00000000000..3ca51db4989 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfter4.js @@ -0,0 +1,16 @@ +===ORIGINAL=== + +class A { + constructor() { + var x = 1; + } +} + +===MODIFIED=== + +class A { + constructor() { + var x = 1; + super(); + } +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js b/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js new file mode 100644 index 00000000000..841d43fef97 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterInClass1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x +} + +===MODIFIED=== + +class A { + x; + a: boolean; +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js b/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js new file mode 100644 index 00000000000..1d583d8ac90 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterInClass2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x; +} + +===MODIFIED=== + +class A { + x; + a: boolean; +} diff --git a/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js b/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js new file mode 100644 index 00000000000..1c3bbe4d3e2 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAfterMultipleNodes.js @@ -0,0 +1,21 @@ +===ORIGINAL=== + +class A { + x; +} +===MODIFIED=== + +class A { + x; + 0; + 1; + 2; + 3; + 4; + 5; + 6; + 7; + 8; + 9; + 10; +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAt1.js b/tests/baselines/reference/textChanges/insertNodeAt1.js new file mode 100644 index 00000000000..9c7ac46f8a8 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAt1.js @@ -0,0 +1,22 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +public class class1 implements interface1 +{ + property1: boolean; +} +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeAt2.js b/tests/baselines/reference/textChanges/insertNodeAt2.js new file mode 100644 index 00000000000..81c3e2afc35 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeAt2.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var yz1 = { + p1: 1 +}; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeBefore1.js b/tests/baselines/reference/textChanges/insertNodeBefore1.js new file mode 100644 index 00000000000..deebe10b694 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeBefore1.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + public class class1 implements interface1 + { + property1: boolean; + } + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeBefore2.js b/tests/baselines/reference/textChanges/insertNodeBefore2.js new file mode 100644 index 00000000000..1792cd5e69c --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeBefore2.js @@ -0,0 +1,26 @@ +===ORIGINAL=== + +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} +===MODIFIED=== + +public class class1 implements interface1 +{ + property1: boolean; +} +namespace M { + // comment 1 + var x = 1; // comment 2 + // comment 3 + var y; // comment 4 + var z = 3; // comment 5 + // comment 6 + var a = 4; // comment 7 +} \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js new file mode 100644 index 00000000000..0c47c26221f --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +class A { + x = foo +} + +===MODIFIED=== + +class A { + x = foo; + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js new file mode 100644 index 00000000000..bd6302b29a6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInClassAfterNodeWithoutSeparator2.js @@ -0,0 +1,14 @@ +===ORIGINAL=== + +class A { + x() { + } +} + +===MODIFIED=== + +class A { + x() { + } + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js new file mode 100644 index 00000000000..61910e64dd5 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator1.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +interface A { + x +} + +===MODIFIED=== + +interface A { + x; + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js new file mode 100644 index 00000000000..6e88a371eb6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInInterfaceAfterNodeWithoutSeparator2.js @@ -0,0 +1,12 @@ +===ORIGINAL=== + +interface A { + x() +} + +===MODIFIED=== + +interface A { + x(); + [1]: any; +} diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter1.js b/tests/baselines/reference/textChanges/insertNodeInListAfter1.js new file mode 100644 index 00000000000..9b0ed7b819d --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter1.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1, y = 2; +===MODIFIED=== + +const x = 1, z = 1, y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter10.js b/tests/baselines/reference/textChanges/insertNodeInListAfter10.js new file mode 100644 index 00000000000..300230bf51c --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter10.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x +} from "bar" +===MODIFIED=== + +import { + x, b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter11.js b/tests/baselines/reference/textChanges/insertNodeInListAfter11.js new file mode 100644 index 00000000000..f0ba43a0f3a --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter11.js @@ -0,0 +1,11 @@ +===ORIGINAL=== + +import { + x // this is x +} from "bar" +===MODIFIED=== + +import { + x, // this is x + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter12.js b/tests/baselines/reference/textChanges/insertNodeInListAfter12.js new file mode 100644 index 00000000000..79e7bb2c8b6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter12.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x +} from "bar" +===MODIFIED=== + +import { + x, a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter13.js b/tests/baselines/reference/textChanges/insertNodeInListAfter13.js new file mode 100644 index 00000000000..a7ac7179ab6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter13.js @@ -0,0 +1,11 @@ +===ORIGINAL=== + +import { + x // this is x +} from "bar" +===MODIFIED=== + +import { + x, // this is x + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter14.js b/tests/baselines/reference/textChanges/insertNodeInListAfter14.js new file mode 100644 index 00000000000..e44a21723be --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter14.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x +} from "bar" +===MODIFIED=== + +import { + x0, + x, + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter15.js b/tests/baselines/reference/textChanges/insertNodeInListAfter15.js new file mode 100644 index 00000000000..a80bdc2db5e --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter15.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x // this is x +} from "bar" +===MODIFIED=== + +import { + x0, + x, // this is x + b as a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter16.js b/tests/baselines/reference/textChanges/insertNodeInListAfter16.js new file mode 100644 index 00000000000..07f8db919f8 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter16.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x +} from "bar" +===MODIFIED=== + +import { + x0, + x, + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter17.js b/tests/baselines/reference/textChanges/insertNodeInListAfter17.js new file mode 100644 index 00000000000..990139408ee --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter17.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +import { + x0, + x // this is x +} from "bar" +===MODIFIED=== + +import { + x0, + x, // this is x + a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter18.js b/tests/baselines/reference/textChanges/insertNodeInListAfter18.js new file mode 100644 index 00000000000..b25a3f46346 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter18.js @@ -0,0 +1,10 @@ +===ORIGINAL=== + +import { + x0, x +} from "bar" +===MODIFIED=== + +import { + x0, x, a +} from "bar" \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter2.js b/tests/baselines/reference/textChanges/insertNodeInListAfter2.js new file mode 100644 index 00000000000..32e8e63c0f6 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter2.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1, y = 2; +===MODIFIED=== + +const x = 1, y = 2, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter3.js b/tests/baselines/reference/textChanges/insertNodeInListAfter3.js new file mode 100644 index 00000000000..70a0b0bddcb --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter3.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const /*x*/ x = 1, /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, z = 1, /*y*/ y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter4.js b/tests/baselines/reference/textChanges/insertNodeInListAfter4.js new file mode 100644 index 00000000000..4a30acd7071 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter4.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const /*x*/ x = 1, /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, /*y*/ y = 2, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter5.js b/tests/baselines/reference/textChanges/insertNodeInListAfter5.js new file mode 100644 index 00000000000..42d5fe2ca40 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter5.js @@ -0,0 +1,6 @@ +===ORIGINAL=== + +const x = 1; +===MODIFIED=== + +const x = 1, z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter6.js b/tests/baselines/reference/textChanges/insertNodeInListAfter6.js new file mode 100644 index 00000000000..06eae7372a9 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter6.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const x = 1, + y = 2; +===MODIFIED=== + +const x = 1, + z = 1, + y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter7.js b/tests/baselines/reference/textChanges/insertNodeInListAfter7.js new file mode 100644 index 00000000000..bef01503683 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter7.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const x = 1, + y = 2; +===MODIFIED=== + +const x = 1, + y = 2, + z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter8.js b/tests/baselines/reference/textChanges/insertNodeInListAfter8.js new file mode 100644 index 00000000000..e3c44b14274 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter8.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const /*x*/ x = 1, + /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, + z = 1, + /*y*/ y = 2; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInListAfter9.js b/tests/baselines/reference/textChanges/insertNodeInListAfter9.js new file mode 100644 index 00000000000..510984b7574 --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInListAfter9.js @@ -0,0 +1,9 @@ +===ORIGINAL=== + +const /*x*/ x = 1, + /*y*/ y = 2; +===MODIFIED=== + +const /*x*/ x = 1, + /*y*/ y = 2, + z = 1; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js b/tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js new file mode 100644 index 00000000000..b28b1579dfc --- /dev/null +++ b/tests/baselines/reference/textChanges/insertNodeInStatementListAfterNodeWithoutSeparator1.js @@ -0,0 +1,8 @@ +===ORIGINAL=== + +let x = foo + +===MODIFIED=== + +let x = foo; +(1); diff --git a/tests/baselines/reference/textChanges/replaceNode1.js b/tests/baselines/reference/textChanges/replaceNode1.js new file mode 100644 index 00000000000..8511d510385 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode1.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js b/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js new file mode 100644 index 00000000000..44183d402ab --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode1NoLineBreakBefore.js @@ -0,0 +1,13 @@ +===ORIGINAL=== + +namespace A { + const x = 1, y = "2"; +} + +===MODIFIED=== + +namespace A { + const x = 1, z1 = { + p1: 1 + }; +} diff --git a/tests/baselines/reference/textChanges/replaceNode2.js b/tests/baselines/reference/textChanges/replaceNode2.js new file mode 100644 index 00000000000..66a17f7c910 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode2.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; +public class class1 implements interface1 +{ + property1: boolean; +} +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode3.js b/tests/baselines/reference/textChanges/replaceNode3.js new file mode 100644 index 00000000000..9f321a97431 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode3.js @@ -0,0 +1,21 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} + // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode4.js b/tests/baselines/reference/textChanges/replaceNode4.js new file mode 100644 index 00000000000..e5bbf0e306d --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode4.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1;public class class1 implements interface1 +{ + property1: boolean; +} // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNode5.js b/tests/baselines/reference/textChanges/replaceNode5.js new file mode 100644 index 00000000000..ad3ec0ab0ea --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNode5.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== +public class class1 implements interface1 +{ + property1: boolean; +} // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange1.js b/tests/baselines/reference/textChanges/replaceNodeRange1.js new file mode 100644 index 00000000000..5fc16960a8a --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange1.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange2.js b/tests/baselines/reference/textChanges/replaceNodeRange2.js new file mode 100644 index 00000000000..e8f9506d608 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange2.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; +public class class1 implements interface1 +{ + property1: boolean; +} +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange3.js b/tests/baselines/reference/textChanges/replaceNodeRange3.js new file mode 100644 index 00000000000..a20dddc53fe --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange3.js @@ -0,0 +1,20 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +public class class1 implements interface1 +{ + property1: boolean; +} + // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceNodeRange4.js b/tests/baselines/reference/textChanges/replaceNodeRange4.js new file mode 100644 index 00000000000..ad50a1f01fc --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceNodeRange4.js @@ -0,0 +1,18 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1;public class class1 implements interface1 +{ + property1: boolean; +} // comment 5 +// comment 6 +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRange.js b/tests/baselines/reference/textChanges/replaceRange.js new file mode 100644 index 00000000000..8cb83286169 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRange.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +public class class1 implements interface1 +{ + property1: boolean; +} +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js b/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js new file mode 100644 index 00000000000..72a45ee56e2 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRangeNoLineBreakBefore.js @@ -0,0 +1,6 @@ +===ORIGINAL=== +const x = 1, y = "2"; +===MODIFIED=== +const x = 1, z1 = { + p1: 1 +}; \ No newline at end of file diff --git a/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js b/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js new file mode 100644 index 00000000000..304b81b1359 --- /dev/null +++ b/tests/baselines/reference/textChanges/replaceRangeWithForcedIndentation.js @@ -0,0 +1,19 @@ +===ORIGINAL=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 +var y = 2; // comment 4 +var z = 3; // comment 5 +// comment 6 +var a = 4; // comment 7 +===MODIFIED=== + +// comment 1 +var x = 1; // comment 2 +// comment 3 + public class class1 implements interface1 + { + property1: boolean; + } +var a = 4; // comment 7 \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixAddForgottenThis01.ts b/tests/cases/fourslash/codeFixAddForgottenThis01.ts index 90d191b6ba5..07f06348212 100644 --- a/tests/cases/fourslash/codeFixAddForgottenThis01.ts +++ b/tests/cases/fourslash/codeFixAddForgottenThis01.ts @@ -2,9 +2,11 @@ ////class C { //// foo: number; -//// constructor() { -//// [|foo = 10|]; -//// } +//// constructor() {[| +//// foo = 10; +//// |]} ////} -verify.rangeAfterCodeFix("this.foo = 10"); \ No newline at end of file +verify.rangeAfterCodeFix(` + this.foo = 10; + `, /*includeWhitespace*/ true); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixSuperAfterThis.ts b/tests/cases/fourslash/codeFixSuperAfterThis.ts index 2bff98ceca0..55b44b07881 100644 --- a/tests/cases/fourslash/codeFixSuperAfterThis.ts +++ b/tests/cases/fourslash/codeFixSuperAfterThis.ts @@ -6,8 +6,10 @@ //// private a:number; //// constructor() {[| //// this.a = 12; -//// super();|] -//// } +//// super(); +//// |]} ////} - -verify.rangeAfterCodeFix("super(); this.a = 12;"); \ No newline at end of file +verify.rangeAfterCodeFix(` + super(); + this.a = 12; + `, /*includeWhiteSpace*/ true); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixSuperCall.ts b/tests/cases/fourslash/codeFixSuperCall.ts index c918e74dc38..f7584050a15 100644 --- a/tests/cases/fourslash/codeFixSuperCall.ts +++ b/tests/cases/fourslash/codeFixSuperCall.ts @@ -1,10 +1,11 @@ -/// +/// ////class Base{ ////} ////class C extends Base{ -//// constructor() {[| |] -//// } +//// constructor() {[| +//// |]} ////} - -verify.rangeAfterCodeFix('super();'); +verify.rangeAfterCodeFix(` + super(); + `, /*includeWhitespace*/ true); diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts b/tests/cases/fourslash/importNameCodeFixExistingImport10.ts index 25246e70123..8a178e72730 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport10.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport10.ts @@ -16,6 +16,6 @@ verify.importFixAtPosition([ `{ v1, v2, -f1 + f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts b/tests/cases/fourslash/importNameCodeFixExistingImport11.ts index 304ffb896df..8822356c13a 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport11.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport11.ts @@ -15,6 +15,7 @@ verify.importFixAtPosition([ `{ v1, v2, - v3, f1 + v3, + f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts b/tests/cases/fourslash/importNameCodeFixExistingImport9.ts index 05d17927454..51496abff12 100644 --- a/tests/cases/fourslash/importNameCodeFixExistingImport9.ts +++ b/tests/cases/fourslash/importNameCodeFixExistingImport9.ts @@ -11,7 +11,6 @@ verify.importFixAtPosition([ `{ - v1, -f1 + v1, f1 }` ]); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index 288573608f2..7a63ff13caa 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -8,5 +8,4 @@ //// } |] verify.rangeAfterCodeFix(`namespace greeter { - // some legit comments }`); diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index 5aa3251c0b4..7f99863ba46 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -1,12 +1,16 @@ /// // @noUnusedLocals: true -//// function f1 () { -//// for (const elem of ["a", "b", "c"]) { -//// elem; -//// [|var x = 20; -//// }|] -////} +////function f1 () [|{ +//// for (const elem of ["a", "b", "c"]) { +//// elem; +//// var x = 20; +//// } +////}|] //// -verify.rangeAfterCodeFix("}"); +verify.rangeAfterCodeFix(`{ + for (const elem of ["a", "b", "c"]) { + elem; + } +}`, /*includeWhiteSpace*/ true); From 798062944ba3add53e264b3b77c5c9cf55e18523 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 12:27:47 -0700 Subject: [PATCH 109/207] Code review comments --- src/services/codefixes/fixAddMissingMember.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index bc2ee6fe0f8..765ffa818b6 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -31,7 +31,7 @@ namespace ts.codefix { return undefined; } - const isStatic = hasModifier(getThisContainer(token, /*includeArrowFunctions*/ false), ModifierFlags.Static); + const isStatic = hasModifier(classMemberDeclaration, ModifierFlags.Static); return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); @@ -54,7 +54,7 @@ namespace ts.codefix { fileName: sourceFile.fileName, textChanges: [{ span: { start: startPos, length: 0 }, - newText: `${isStatic ? "static " : ""}${token.getFullText(sourceFile)}: ${typeString};` + newText: `${isStatic ? "static " : ""}${token.getText(sourceFile)}: ${typeString};` }] }] }]; From 3b57b5d4d570beccd2d87df9812dc90941897c21 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 15:17:33 -0700 Subject: [PATCH 110/207] Refactor checking for checkJs value in a common helper --- src/compiler/core.ts | 6 +++++- src/compiler/program.ts | 5 ++--- src/services/codefixes/disableJsDiagnostics.ts | 8 ++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c380a39611d..14aeb35dc89 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -2360,4 +2360,8 @@ namespace ts { return Extension.Jsx; } } + + export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index bdc8f76cf60..8f1bd4ba36e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1,4 +1,4 @@ -/// +/// /// /// @@ -918,8 +918,7 @@ namespace ts { Debug.assert(!!sourceFile.bindDiagnostics); const bindDiagnostics = sourceFile.bindDiagnostics; // For JavaScript files, we don't want to report semantic errors unless explicitly requested. - const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || - (sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : options.checkJs); + const includeCheckDiagnostics = !isSourceFileJavaScript(sourceFile) || isCheckJsEnabledForFile(sourceFile, options); const checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts index c18c0153a03..621555cf84b 100644 --- a/src/services/codefixes/disableJsDiagnostics.ts +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { registerCodeFix({ errorCodes: getApplicableDiagnosticCodes(), @@ -12,10 +12,6 @@ namespace ts.codefix { .map(d => allDiagnostcs[d].code); } - function shouldCheckJsFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { - return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; - } - function getSuppressCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) { let { line } = getLineAndCharacterOfPosition(sourceFile, position); const lineStartPosition = getStartPositionOfLine(line, sourceFile); @@ -46,7 +42,7 @@ namespace ts.codefix { function getDisableJsDiagnosticsCodeActions(context: CodeFixContext): CodeAction[] | undefined { const { sourceFile, program, newLineCharacter, span } = context; - if (!isInJavaScriptFile(sourceFile) || !shouldCheckJsFile(sourceFile, program.getCompilerOptions())) { + if (!isInJavaScriptFile(sourceFile) || !isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { return undefined; } From f2654c65d958b5cf4a47bcde2c0de5b093ca78b8 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 15:40:01 -0700 Subject: [PATCH 111/207] Remove compileOnSave from compiler option --- src/compiler/commandLineParser.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b07bdcc9fe5..724c580acec 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -479,14 +479,12 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files }, - { name: "charset", type: "string", category: Diagnostics.Advanced_Options, description: Diagnostics.The_character_set_of_the_input_files }, - compileOnSaveCommandLineOption, { name: "emitBOM", type: "boolean", From efa3093eced433e7c58b93b0777440cdc468c4de Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 16:08:32 -0700 Subject: [PATCH 112/207] Print comments in a diffrent column --- src/compiler/commandLineParser.ts | 62 ++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 724c580acec..f5cddf0e659 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -980,7 +980,12 @@ namespace ts { } } + function makePadding(paddingLength: number): string { + return Array(paddingLength + 1).join(" "); + } + function writeConfigurations() { + // Filter applicable options to place in the file const categorizedOptions = reduceLeft( filter(optionDeclarations, o => o.category !== Diagnostics.CommandLine_Options && o.category !== Diagnostics.Advanced_Options), (memo, value) => { @@ -990,44 +995,59 @@ namespace ts { } return memo; }, >{}); - const knownKesyCount = getOwnKeys(configurations.compilerOptions).length; - const newLine = "\n"; - const tab = " "; - - let result = ""; + // Serialize all options and thier descriptions + let marginLength = 0; let seenKnownKeys = 0; - result += `{${newLine}`; - result += `${tab}"compilerOptions": {${newLine}`; + const nameColumn: string[] = []; + const descriptionColumn: string[] = []; + const knownKesyCount = getOwnKeys(configurations.compilerOptions).length; for (const category in categorizedOptions) { - result += `${tab}${tab}// ${category}${newLine}`; - result += `${newLine}`; + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push(`/* ${category} */`); + descriptionColumn.push(""); for (const option of categorizedOptions[category]) { - result += `${tab}${tab}// ${option.description && getLocaleSpecificMessage(option.description) || option.name}${newLine}`; + let optionName; if (configurations.compilerOptions[option.name]) { - result += `${tab}${tab}"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${(seenKnownKeys += 1) === knownKesyCount ? "" : ","}${newLine}`; + optionName = `"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${(seenKnownKeys += 1) === knownKesyCount ? "" : ","}`; } else { - result += `${tab}${tab}// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},${newLine}`; + optionName = `// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},`; } - result += `${newLine}`; + nameColumn.push(optionName); + descriptionColumn.push(`/* ${option.description && getLocaleSpecificMessage(option.description) || option.name} */`); + marginLength = Math.max(optionName.length, marginLength); } - result += `${newLine}`; + } + + // Write the output + const tab = makePadding(2); + const result: string[] = []; + result.push(`{`); + result.push(`${tab}"compilerOptions": {`); + // Print out each row, aligning all the descriptions on the same column. + for (let i = 0; i < nameColumn.length; i++) { + const optionName = nameColumn[i]; + const description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); } if (configurations.files && configurations.files.length) { - result += `${tab}},${newLine}`; - result += `${tab}"files": [${newLine}`; + result.push(`${tab}},`); + result.push(`${tab}"files": [`); for (let i = 0; i < configurations.files.length; i++) { - result += `${tab}${tab}${JSON.stringify(configurations.files[i])}${i === configurations.files.length - 1 ? "" : ","}${newLine}`; + result.push(`${tab}${tab}${JSON.stringify(configurations.files[i])}${i === configurations.files.length - 1 ? "" : ","}`); } - result += `${tab}]${newLine}`; + result.push(`${tab}]`); } else { - result += `${tab}}${newLine}`; + result.push(`${tab}}`); } - result += `}${newLine}`; + result.push(`}`); - return result; + return result.join(sys.newLine); } } From 5bbd8f809a7765f231e1b5a0e4e3f653993a1c57 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 16:15:59 -0700 Subject: [PATCH 113/207] rename catogories, and reorder options --- src/compiler/commandLineParser.ts | 48 ++++++++++++++-------------- src/compiler/diagnosticMessages.json | 4 +-- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f5cddf0e659..1e6a89d4440 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -238,68 +238,70 @@ namespace ts { description: Diagnostics.Unconditionally_emit_imports_for_unresolved_files }, - // Strict Checks + // Strict Type Checks { name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Strict_Type_Checks, description: Diagnostics.Enable_all_strict_type_checks }, { name: "noImplicitAny", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Strict_Type_Checks, description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "strictNullChecks", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Strict_Type_Checks, description: Diagnostics.Enable_strict_null_checks }, { name: "noImplicitThis", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Strict_Type_Checks, description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "alwaysStrict", + type: "boolean", + showInSimplifiedHelpView: true, + category: Diagnostics.Strict_Type_Checks, + description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file + }, + + // Additional Checks { name: "noUnusedLocals", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Additional_Checks, description: Diagnostics.Report_errors_on_unused_locals, }, { name: "noUnusedParameters", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Additional_Checks, description: Diagnostics.Report_errors_on_unused_parameters, }, - { - name: "alwaysStrict", - type: "boolean", - showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, - description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file - }, { name: "noImplicitReturns", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Additional_Checks, description: Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value }, { name: "noFallthroughCasesInSwitch", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Checks, + category: Diagnostics.Additional_Checks, description: Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement }, @@ -404,14 +406,6 @@ namespace ts { description: Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, - // JSX - { - name: "jsxFactory", - type: "string", - category: Diagnostics.JSX_Options, - description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - // Experimental { name: "experimentalDecorators", @@ -427,6 +421,12 @@ namespace ts { }, // Advanced + { + name: "jsxFactory", + type: "string", + category: Diagnostics.Advanced_Options, + description: Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, { name: "diagnostics", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6546408fdce..e833d77651b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3137,7 +3137,7 @@ "category": "Message", "code": 6172 }, - "Strict Checks": { + "Strict Type Checks": { "category": "Message", "code": 6173 }, @@ -3149,7 +3149,7 @@ "category": "Message", "code": 6175 }, - "JSX Options": { + "Additional Checks": { "category": "Message", "code": 6176 }, From 5016141b94b0578ad3e9f0395d4a1e5a7ba444b5 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 16:41:39 -0700 Subject: [PATCH 114/207] Remove `sourceMap:false` from default compiler optios now that we have all options generated --- src/compiler/commandLineParser.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1e6a89d4440..6c8c8bb1b23 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -665,8 +665,7 @@ namespace ts { export const defaultInitCompilerOptions: CompilerOptions = { module: ModuleKind.CommonJS, target: ScriptTarget.ES5, - strict: true, - sourceMap: false, + strict: true }; let optionNameMapCache: OptionNameMap; @@ -1011,7 +1010,7 @@ namespace ts { descriptionColumn.push(""); for (const option of categorizedOptions[category]) { let optionName; - if (configurations.compilerOptions[option.name]) { + if (hasProperty(configurations.compilerOptions, option.name)) { optionName = `"${option.name}": ${JSON.stringify(configurations.compilerOptions[option.name])}${(seenKnownKeys += 1) === knownKesyCount ? "" : ","}`; } else { From b6ccad4b54e362fff37e45d29fc75e4df52fb6d4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 17:21:07 -0700 Subject: [PATCH 115/207] Fix bad merge --- src/compiler/commandLineParser.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6c8c8bb1b23..bc9d090edd9 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -119,6 +119,7 @@ namespace ts { "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", // Host only "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", From 0112a38ec9460dbcd51e77e2124f074d2090bfd3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 17:21:28 -0700 Subject: [PATCH 116/207] Accept baselines --- .../tsconfig.json | 185 +++++------------ .../tsconfig.json | 185 +++++------------ .../tsconfig.json | 185 +++++------------ .../tsconfig.json | 195 +++++------------- .../tsconfig.json | 185 +++++------------ .../tsconfig.json | 185 +++++------------ .../tsconfig.json | 185 +++++------------ .../tsconfig.json | 185 +++++------------ 8 files changed, 421 insertions(+), 1069 deletions(-) diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 452c0314089..13e3bdb0f40 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -1,133 +1,52 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - // "lib": [], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - // "jsx": "preserve", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - // "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - // "types": [], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - } -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index f4c45f1674a..39dd00c2007 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -1,133 +1,52 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - // "lib": [], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - // "jsx": "preserve", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - // "types": [], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - } -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true, /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index e02e2cf1ca8..401ae3185f1 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -1,133 +1,52 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - // "lib": [], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - "jsx": "react", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - // "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - // "types": [], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - } -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index f413bdd2a67..9e991495472 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -1,138 +1,57 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - // "lib": [], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - // "jsx": "preserve", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - // "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - // "types": [], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - }, - "files": [ - "file0.st", - "file1.ts", - "file2.ts" - ] -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + }, + "files": [ + "file0.st", + "file1.ts", + "file2.ts" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 09b72cfa428..976f8c984ea 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -1,133 +1,52 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - "lib": ["es5","es2015.promise"], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - // "jsx": "preserve", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - // "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - // "types": [], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - } -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 452c0314089..13e3bdb0f40 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -1,133 +1,52 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - // "lib": [], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - // "jsx": "preserve", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - // "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - // "types": [], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - } -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 45915ac0380..f4bc1dc9ef2 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -1,133 +1,52 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - "lib": ["es5","es2015.core"], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - // "jsx": "preserve", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - // "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - // "types": [], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - } -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 33b17b3cf5c..434e886b250 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -1,133 +1,52 @@ -{ - "compilerOptions": { - // Basic Options - - // Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. - "target": "es5", - - // Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. - "module": "commonjs", - - // Specify library files to be included in the compilation: - // "lib": [], - - // Allow javascript files to be compiled. - // "allowJs": true, - - // Specify JSX code generation: 'preserve', 'react-native', or 'react'. - // "jsx": "preserve", - - // Generates corresponding '.d.ts' file. - // "declaration": true, - - // Generates corresponding '.map' file. - // "sourceMap": true, - - // Concatenate and emit output to single file. - // "outFile": "./", - - // Redirect output structure to the directory. - // "outDir": "./", - - // Specify the root directory of input files. Use to control the output directory structure with --outDir. - // "rootDir": "./", - - // Do not emit comments to output. - // "removeComments": true, - - // Do not emit outputs. - // "noEmit": true, - - // Import emit helpers from 'tslib'. - // "importHelpers": true, - - // Unconditionally emit imports for unresolved files. - // "isolatedModules": true, - - - // Strict Checks - - // Enable all strict type checks. - "strict": true, - - // Raise error on expressions and declarations with an implied 'any' type. - // "noImplicitAny": true, - - // Enable strict null checks. - // "strictNullChecks": true, - - // Raise error on 'this' expressions with an implied 'any' type. - // "noImplicitThis": true, - - // Report errors on unused locals. - // "noUnusedLocals": true, - - // Report errors on unused parameters. - // "noUnusedParameters": true, - - // Parse in strict mode and emit "use strict" for each source file. - // "alwaysStrict": true, - - // Report error when not all code paths in function return a value. - // "noImplicitReturns": true, - - // Report errors for fallthrough cases in switch statement. - // "noFallthroughCasesInSwitch": true, - - - // Module Resolution Options - - // Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). - // "moduleResolution": "node", - - // Base directory to resolve non-absolute module names. - // "baseUrl": "./", - - // List of path mapping entries for module names to locations relative to the 'baseUrl'. - // "paths": {}, - - // List of root folders whose combined content represent the structure of the project at runtime. - // "rootDirs": [], - - // List of folders to include type definitions from. - // "typeRoots": [], - - // Type declaration files to be included in compilation. - "types": ["jquery","mocha"], - - // Allow default imports from modules with no default export. This does not affect code emit, just typechecking. - // "allowSyntheticDefaultImports": true, - - - // SourceMap Options - - // Specify the location where debugger should locate TypeScript files instead of source locations. - // "sourceRoot": "./", - - // Specify the location where debugger should locate map files instead of generated locations. - // "mapRoot": "./", - - // Emit a single file with source maps instead of having a separate file. - // "inlineSourceMap": true, - - // Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. - // "inlineSources": true, - - - // JSX Options - - // Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'. - // "jsxFactory": "", - - - // Experimental Options - - // Enables experimental support for ES7 decorators. - // "experimentalDecorators": true, - - // Enables experimental support for emitting type metadata for decorators. - // "emitDecoratorMetadata": true, - - - } -} +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true, /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } +} \ No newline at end of file From 0a2d7a7f94406d6c1a5c8d187171ac60cb7b56ca Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 15 Mar 2017 18:09:55 -0700 Subject: [PATCH 117/207] temp * added signature factory/visitor entry --- src/compiler/checker.ts | 34 ++++++++--- src/compiler/factory.ts | 34 +++++++++++ src/compiler/types.ts | 1 + src/compiler/utilities.ts | 4 ++ src/compiler/visitor.ts | 20 +++++-- src/harness/fourslash.ts | 2 +- .../codeFixClassImplementInterfaceComments.ts | 14 +++++ ...aceComputedPropertyNameWellKnownSymbols.ts | 1 - ...ClassImplementInterfaceEmptyTypeLiteral.ts | 13 +++++ ...ixClassImplementInterfaceMemberOrdering.ts | 58 +++++++++++++++++++ 10 files changed, 166 insertions(+), 15 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceEmptyTypeLiteral.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bc718e4c1d2..625f4d75eba 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2322,10 +2322,18 @@ namespace ts { if (objectFlags & ObjectFlags.Mapped) { Debug.assert(!!(type.flags & TypeFlags.Object)); - // const typeParameter = getTypeParameterFromMappedType(type); + + // TODO: does typeParameter have the same constraint or do we need to overwrite it somehow? + const typeParameter = getTypeParameterFromMappedType(type); // const constraintType = getConstraintTypeFromMappedType(type); - // const templateType = getTemplateTypeFromMappedType(type); - throw new Error("Mapped types not implemented"); + const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter); + + const templateTypeNode = createTypeNode(getTemplateTypeFromMappedType(type)); + const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; + const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + + // TODO: test. + return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); } if (objectFlags & ObjectFlags.Anonymous) { @@ -2334,6 +2342,7 @@ namespace ts { if (!type.symbol) { // Anonymous types without symbols are literals. // TODO: handle this case correctly. + // TODO: test. noop(); } @@ -2343,9 +2352,11 @@ namespace ts { // TODO: string or number literal here or above? if (type.flags & TypeFlags.Index) { + // TODO: implement and test. throw new Error("index not implemented"); } if (type.flags & TypeFlags.IndexedAccess) { + // TODO: implement and test. throw new Error("indexed access not implemented"); } @@ -2414,7 +2425,6 @@ namespace ts { } function createTypeLiteralNodeFromType(type: ObjectType) { - // TODO: do we need to do something for mapped types here??? const resolvedType = resolveStructuredTypeMembers(type); const newMembers = createTypeNodesFromResolvedType(resolvedType); return createTypeLiteralNode(newMembers); @@ -2446,21 +2456,29 @@ namespace ts { } const kind = oldDeclaration.kind; - const memberName = symbolToString(memberSymbol); + const memberName = getSynthesizedDeepClone(oldDeclaration.name); + const memberType = getTypeOfSymbol(memberSymbol); switch (kind) { case SyntaxKind.PropertySignature: const optional = !!oldDeclaration.questionToken; - const typeOfOldMember = getTypeOfSymbol(memberSymbol); typeElements.push(createPropertySignature( - createIdentifier(memberName) + memberName , optional ? createToken(SyntaxKind.QuestionToken) : undefined - , createTypeNode(typeOfOldMember) + , createTypeNode(memberType) , /*initializer*/undefined)); break; case SyntaxKind.MethodSignature: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: + const signatureType = getSignaturesOfSymbol(memberSymbol); + signatureType + createSignatureDeclaration + throw new Error("signature problems."); + // name ?: PropertyName; + // typeParameters ?: NodeArray; + // parameters: NodeArray; + // type ?: TypeNode; case SyntaxKind.IndexSignature: throw new Error("type literal constituent not implemented."); default: diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index bd46e208784..c9fef5b0263 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -255,6 +255,22 @@ namespace ts { : node; } + export function createSignatureDeclaration(kind: SyntaxKind, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { + const signatureDeclaration = createSynthesizedNode(kind) as T; + signatureDeclaration.name = asName(name); + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + + export function updateSignatureDeclaration(node: T, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { + return node.name !== name + || node.typeParameters !== typeParameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, name, typeParameters, parameters, type), node) + : node; + } + export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: NodeArray | undefined) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; @@ -321,6 +337,24 @@ namespace ts { : node; } + export function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + const mappedTypeNode = createSynthesizedNode(SyntaxKind.MappedType) as MappedTypeNode; + mappedTypeNode.readonlyToken = readonlyToken; + mappedTypeNode.typeParameter = typeParameter; + mappedTypeNode.questionToken = questionToken; + mappedTypeNode.type = type; + return mappedTypeNode; + } + + export function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + // Type Declarations export function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultParameter: TypeNode | undefined) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 28c293ae533..7f6c56aa1ff 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -856,6 +856,7 @@ namespace ts { | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword + | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b4d65958f3c..47642291c2c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3717,10 +3717,14 @@ namespace ts { return (kind >= SyntaxKind.FirstTypeNode && kind <= SyntaxKind.LastTypeNode) || kind === SyntaxKind.AnyKeyword || kind === SyntaxKind.NumberKeyword + || kind === SyntaxKind.ObjectKeyword || kind === SyntaxKind.BooleanKeyword || kind === SyntaxKind.StringKeyword || kind === SyntaxKind.SymbolKeyword + || kind === SyntaxKind.ThisKeyword || kind === SyntaxKind.VoidKeyword + || kind === SyntaxKind.UndefinedKeyword + || kind === SyntaxKind.NullKeyword || kind === SyntaxKind.NeverKeyword || kind === SyntaxKind.ExpressionWithTypeArguments; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index ba348a558bd..206e269f366 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -258,13 +258,23 @@ namespace ts { return updateComputedPropertyName(node, visitNode((node).expression, visitor, isExpression)); - // Signature elements + // Signatures and Signature Elements + case SyntaxKind.FunctionType: + case SyntaxKind.CallSignature: + case SyntaxKind.ConstructSignature: + case SyntaxKind.MethodSignature: + return updateSignatureDeclaration(node + , visitNode((node).name, visitor, isPropertyName) + , nodesVisitor((node).typeParameters, visitor, isTypeParameter) + , nodesVisitor((node).parameters, visitor, isParameter) + , visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.IndexSignature: return updateIndexSignatureDeclaration(node - , nodesVisitor((node).parameters, visitor) - , visitNode((node).type, visitor) - , nodesVisitor((node).decorators, visitor, isDecorator) - , nodesVisitor((node).modifiers, visitor, isModifier)); + , nodesVisitor((node).parameters, visitor) + , visitNode((node).type, visitor, isTypeNode) + , nodesVisitor((node).decorators, visitor, isDecorator) + , nodesVisitor((node).modifiers, visitor, isModifier)); case SyntaxKind.Parameter: return updateParameter(node, diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d7638ffc033..08370480aa4 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1673,7 +1673,7 @@ namespace FourSlash { // We get back a set of edits, but langSvc.editScript only accepts one at a time. Use this to keep track // of the incremental offset from each edit to the next. Assumption is that these edit ranges don't overlap let runningOffset = 0; - edits = edits.sort((a, b) => a.span.start - b.span.start); + edits = ts.stableSort(edits, (a, b) => a.span.start - b.span.start); // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters const oldContent = this.getFileContent(fileName); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts new file mode 100644 index 00000000000..56d56a5a504 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts @@ -0,0 +1,14 @@ +/// + +// @lib: es2017 + +//// /** interface prefix */ +//// interface /**interface name prefix */ I /**open-brace prefix*/{ +//// /** property prefix*/ x /**colon prefix*/: /**number prefix*/ number; +//// +//// /**close-brace prefix*/ } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + x: number; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts index 61b4267e7f0..31fc167bb97 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComputedPropertyNameWellKnownSymbols.ts @@ -17,7 +17,6 @@ //// [Symbol.toStringTag]: string; //// [Symbol.unscopables]: any; //// } -//// //// class C implements I {[| |]} verify.rangeAfterCodeFix(` diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyTypeLiteral.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyTypeLiteral.ts new file mode 100644 index 00000000000..98059017098 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceEmptyTypeLiteral.ts @@ -0,0 +1,13 @@ +/// + +//// interface I { +//// x: {}; +//// } +//// +//// class C implements I {[| +//// |]constructor() { } +//// } + +verify.rangeAfterCodeFix(` +x: {}; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts new file mode 100644 index 00000000000..dbfd623be17 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMemberOrdering.ts @@ -0,0 +1,58 @@ +/// + +// @lib: es2017 + +//// /** asdf */ +//// interface I { +//// 1; +//// 2; +//// 3; +//// 4; +//// 5; +//// 6; +//// 7; +//// 8; +//// 9; +//// 10; +//// 11; +//// 12; +//// 13; +//// 14; +//// 15; +//// 16; +//// 17; +//// 18; +//// 19; +//// 20; +//// 21; +//// 22; +//// /** a nice safe prime */ +//// 23; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + 1: any; + 2: any; + 3: any; + 4: any; + 5: any; + 6: any; + 7: any; + 8: any; + 9: any; + 10: any; + 11: any; + 12: any; + 13: any; + 14: any; + 15: any; + 16: any; + 17: any; + 18: any; + 19: any; + 20: any; + 21: any; + 22: any; + 23: any; +`); From d78e5a1db52a2ec72724461a600ea07ab57191e6 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 15 Mar 2017 18:39:44 -0700 Subject: [PATCH 118/207] Normalize line endings when validating baselines --- src/harness/unittests/initializeTSConfig.ts | 5 +- .../tsconfig.json | 102 ++++++++-------- .../tsconfig.json | 102 ++++++++-------- .../tsconfig.json | 102 ++++++++-------- .../tsconfig.json | 112 +++++++++--------- .../tsconfig.json | 102 ++++++++-------- .../tsconfig.json | 102 ++++++++-------- .../tsconfig.json | 102 ++++++++-------- .../tsconfig.json | 102 ++++++++-------- 9 files changed, 416 insertions(+), 415 deletions(-) diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts index 7163ab3e34b..4f193d358f2 100644 --- a/src/harness/unittests/initializeTSConfig.ts +++ b/src/harness/unittests/initializeTSConfig.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { @@ -12,7 +12,8 @@ namespace ts { it(`Correct output for ${outputFileName}`, () => { Harness.Baseline.runBaseline(outputFileName, () => { if (initResult) { - return initResult; + // normalize line endings + return initResult.replace(new RegExp(sys.newLine, "g"), "\n"); } else { // This can happen if compiler recieve invalid compiler-options diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 13e3bdb0f40..f26b471d2cb 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -1,52 +1,52 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - // "lib": [], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 39dd00c2007..2dc7f0564bf 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -1,52 +1,52 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - // "lib": [], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true, /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true, /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 401ae3185f1..48a7fd7784e 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -1,52 +1,52 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - // "lib": [], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 9e991495472..a2f4e6bd992 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -1,57 +1,57 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - // "lib": [], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - }, - "files": [ - "file0.st", - "file1.ts", - "file2.ts" - ] +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + }, + "files": [ + "file0.st", + "file1.ts", + "file2.ts" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 976f8c984ea..62bfc7ca265 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -1,52 +1,52 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 13e3bdb0f40..f26b471d2cb 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -1,52 +1,52 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - // "lib": [], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index f4bc1dc9ef2..02a1724add3 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -1,52 +1,52 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + // "types": [], /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 434e886b250..b1e048551d3 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -1,52 +1,52 @@ -{ - "compilerOptions": { - /* Basic Options */ - "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ - "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ - // "lib": [], /* Specify library files to be included in the compilation: */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - // "outDir": "./", /* Redirect output structure to the directory. */ - // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ - - /* Strict Type Checks */ - "strict": true, /* Enable all strict type checks. */ - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - - /* SourceMap Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - } +{ + "compilerOptions": { + /* Basic Options */ + "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */ + "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ + // "lib": [], /* Specify library files to be included in the compilation: */ + // "allowJs": true, /* Allow javascript files to be compiled. */ + // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ + // "declaration": true, /* Generates corresponding '.d.ts' file. */ + // "sourceMap": true, /* Generates corresponding '.map' file. */ + // "outFile": "./", /* Concatenate and emit output to single file. */ + // "outDir": "./", /* Redirect output structure to the directory. */ + // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ + // "removeComments": true, /* Do not emit comments to output. */ + // "noEmit": true, /* Do not emit outputs. */ + // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ + // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + + /* Strict Type Checks */ + "strict": true, /* Enable all strict type checks. */ + // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* Enable strict null checks. */ + // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ + // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ + + /* Additional Checks */ + // "noUnusedLocals": true, /* Report errors on unused locals. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + + /* Module Resolution Options */ + // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "typeRoots": [], /* List of folders to include type definitions from. */ + "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ + // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + + /* SourceMap Options */ + // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ + // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ + // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ + + /* Experimental Options */ + // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ + // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ + } } \ No newline at end of file From ec997f329914663b16948eaa06fe1a3ba99f910c Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 09:52:19 -0700 Subject: [PATCH 119/207] more temp --- src/compiler/checker.ts | 233 +++++++++++++++++- src/compiler/factory.ts | 72 ++++-- src/compiler/visitor.ts | 10 +- ...FixClassImplementInterfaceCallSignature.ts | 10 + ...assImplementInterfaceConstructSignature.ts | 10 + ...ImplementInterfacePropertyCallSignature.ts | 13 + ...ntInterfacePropertyConstructSignature.1.ts | 12 + ...plementInterfacePropertyMethodSignature.ts | 11 + 8 files changed, 340 insertions(+), 31 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceCallSignature.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceConstructSignature.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 625f4d75eba..d650865ef73 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2208,6 +2208,8 @@ namespace ts { let encounteredError = false; let inObjectTypeLiteral = false; let checkAlias = true; + let enclosingDeclaration: Node = undefined; // TODO: add parameter. + let symbolStack: Symbol[] = undefined; let result = createTypeNodeWorker(type); if (result) { @@ -2224,7 +2226,6 @@ namespace ts { const typeString = typeToString(type); typeString; // TODO: remove. - if (type.flags & TypeFlags.Any) { // TODO: add other case where type ends up being `any`. return createKeywordTypeNode(SyntaxKind.AnyKeyword); @@ -2239,7 +2240,7 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.BooleanKeyword); } if (type.flags & TypeFlags.Enum) { - throw new Error("enum not implemented"); + throw new Error ("enums not implemented") } if (type.flags & (TypeFlags.StringLiteral)) { return createLiteralTypeNode((createLiteral((type).text))); @@ -2316,6 +2317,7 @@ namespace ts { if (type.flags & TypeFlags.Union) { return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray(formatUnionTypes((type).types))); } + if (type.flags & TypeFlags.Intersection) { return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); } @@ -2336,7 +2338,7 @@ namespace ts { return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); } - if (objectFlags & ObjectFlags.Anonymous) { + if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { Debug.assert(!!(type.flags & TypeFlags.Object)); // The type is an object literal type. if (!type.symbol) { @@ -2346,18 +2348,20 @@ namespace ts { noop(); } - return createTypeLiteralNodeFromType(type); + return createAnonymousTypeNode(type); } - // TODO: string or number literal here or above? - if (type.flags & TypeFlags.Index) { - // TODO: implement and test. - throw new Error("index not implemented"); + // TODO: test. + const indexType = getIndexType(getApparentType((type).type)); + const indexTypeNode = createTypeNodeWorker(indexType); + return createTypeOperatorNode(indexTypeNode); } if (type.flags & TypeFlags.IndexedAccess) { - // TODO: implement and test. - throw new Error("indexed access not implemented"); + // TODO: test. + const objectTypeNode = createTypeNodeWorker((type).objectType); + const indexTypeNode = createTypeNodeWorker((type).indexType); + return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } Debug.fail("Should be unreachable."); @@ -2367,6 +2371,214 @@ namespace ts { return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); } + /******** START COPY *********/ + + // function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { + // const globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; + // let inObjectTypeLiteral = false; + // return writeType(type, globalFlags); + + // function writeType(type: Type, flags: TypeFormatFlags) { + // // const nextFlags = flags & ~TypeFormatFlags.InTypeAlias; + // // // Write undefined/null type as any + // // if (type.flags & TypeFlags.Intrinsic) { + // // // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving + // // writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && isTypeAny(type) + // // ? "any" + // // : (type).intrinsicName); + // // } + // // else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { + // // if (inObjectTypeLiteral) { + // // writer.reportInaccessibleThisError(); + // // } + // // writer.writeKeyword("this"); + // // } + // else if (getObjectFlags(type) & ObjectFlags.Reference) { + // writeTypeReference(type, nextFlags); + // } + // else if (type.flags & TypeFlags.EnumLiteral) { + // buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); + // writePunctuation(writer, SyntaxKind.DotToken); + // appendSymbolNameOnly(type.symbol, writer); + // } + // else if (getObjectFlags(type) & ObjectFlags.ClassOrInterface || type.flags & (TypeFlags.Enum | TypeFlags.TypeParameter)) { + // // The specified symbol flags need to be reinterpreted as type flags + // buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); + // } + // else if (!(flags & TypeFormatFlags.InTypeAlias) && type.aliasSymbol && + // isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) { + // const typeArguments = type.aliasTypeArguments; + // writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, length(typeArguments), nextFlags); + // } + // else if (type.flags & TypeFlags.UnionOrIntersection) { + // writeUnionOrIntersectionType(type, nextFlags); + // } + // else if (getObjectFlags(type) & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { + // writeAnonymousType(type, nextFlags); + // } + // else if (type.flags & TypeFlags.StringOrNumberLiteral) { + // writer.writeStringLiteral(literalTypeToString(type)); + // } + // } + + /******** END COPY *********/ + + function createAnonymousTypeNode(type: ObjectType): TypeNode { + const symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || + shouldWriteTypeOfFunctionSymbol()) { + // TODO: test. + // TODO: get entity name from symbol. + return createTypeQueryNodeFromType(type); + } + else if (contains(symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + const typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + const entityName = getEntityNameFromSymbol(typeAlias, enclosingDeclaration); + return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + } + else { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!symbolStack) { + symbolStack = []; + } + symbolStack.push(symbol); + let result = createTypeLiteralNodeFromType(type); + symbolStack.pop(); + return result; + } + } + else { + // Anonymous types with no symbol are never circular + return createTypeLiteralNodeFromType(type); + } + + function shouldWriteTypeOfFunctionSymbol() { + const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method + forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); + const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && + (symbol.parent || // is exported function symbol + forEach(symbol.declarations, declaration => + declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return contains(symbolStack, symbol); // it is type of the symbol uses itself recursively + } + } + } + + function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { + if (type.objectFlags & ObjectFlags.Mapped) { + if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { + writeMappedType(type); + return; + } + } + + const resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + writePunctuation(writer, SyntaxKind.OpenBraceToken); + writePunctuation(writer, SyntaxKind.CloseBraceToken); + return; + } + + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + const parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); + if (parenthesizeSignature) { + writePunctuation(writer, SyntaxKind.OpenParenToken); + } + buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack); + if (parenthesizeSignature) { + writePunctuation(writer, SyntaxKind.CloseParenToken); + } + return; + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.OpenParenToken); + } + writeKeyword(writer, SyntaxKind.NewKeyword); + writeSpace(writer); + buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack); + if (flags & TypeFormatFlags.InElementType) { + writePunctuation(writer, SyntaxKind.CloseParenToken); + } + return; + } + } + + const saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; + writePunctuation(writer, SyntaxKind.OpenBraceToken); + writer.writeLine(); + writer.increaseIndent(); + writeObjectLiteralType(resolved); + writer.decreaseIndent(); + writePunctuation(writer, SyntaxKind.CloseBraceToken); + inObjectTypeLiteral = saveInObjectTypeLiteral; + } + + function writeObjectLiteralType(resolved: ResolvedType) { + for (const signature of resolved.callSignatures) { + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + for (const signature of resolved.constructSignatures) { + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, SignatureKind.Construct, symbolStack); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, IndexKind.String, enclosingDeclaration, globalFlags, symbolStack); + buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, IndexKind.Number, enclosingDeclaration, globalFlags, symbolStack); + for (const p of resolved.properties) { + const t = getTypeOfSymbol(p); + if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(t).length) { + const signatures = getSignaturesOfType(t, SignatureKind.Call); + for (const signature of signatures) { + writePropertyWithModifiers(p); + buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + } + else { + writePropertyWithModifiers(p); + writePunctuation(writer, SyntaxKind.ColonToken); + writeSpace(writer); + writeType(t, TypeFormatFlags.None); + writePunctuation(writer, SyntaxKind.SemicolonToken); + writer.writeLine(); + } + } + } + + function createTypeQueryNodeFromType(type: Type) { + const symbol = type.symbol; + if (symbol) { + // TODO: get entity name instead. + const entityName = createIdentifier(symbolToString(symbol)); + return createTypeQueryNode(entityName); + } + } + + function getEntityNameFromSymbol(symbol: Symbol, enclosingDeclaration: Node): EntityName { + symbol; enclosingDeclaration; + // TODO: actually implement this + return createIdentifier(symbolToString(symbol, enclosingDeclaration)); + } + function createTypeReferenceNodeFromType(type: TypeReference) { const typeArguments: Type[] = type.typeArguments || emptyArray; if (type.target === globalArrayType) { @@ -2778,6 +2990,7 @@ namespace ts { } } + function writeTypeList(types: Type[], delimiter: SyntaxKind) { for (let i = 0; i < types.length; i++) { if (i > 0) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index c9fef5b0263..ebb4bbe5a9a 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -255,25 +255,8 @@ namespace ts { : node; } - export function createSignatureDeclaration(kind: SyntaxKind, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { - const signatureDeclaration = createSynthesizedNode(kind) as T; - signatureDeclaration.name = asName(name); - signatureDeclaration.typeParameters = asNodeArray(typeParameters); - signatureDeclaration.type = type; - return signatureDeclaration; - } - - export function updateSignatureDeclaration(node: T, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { - return node.name !== name - || node.typeParameters !== typeParameters - || node.type !== type - ? updateNode(createSignatureDeclaration(node.kind, name, typeParameters, parameters, type), node) - : node; - } - export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: NodeArray | undefined) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; - typeReference.typeName = isQualifiedName(typeName) ? typeName : asName(typeName); typeReference.typeArguments = typeArguments; return typeReference; @@ -286,6 +269,16 @@ namespace ts { : node; } + export function createTypeQueryNode(exprName: EntityName) { + const typeQueryNode = createSynthesizedNode(SyntaxKind.TypeQuery) as TypeQueryNode; + typeQueryNode.exprName = exprName; + return typeQueryNode; + } + + export function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName) { + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName) , node) : node; + } + export function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode { const arrayTypeNode = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode; arrayTypeNode.elementType = elementType; @@ -355,6 +348,33 @@ namespace ts { : node; } + export function createTypeOperatorNode(type: TypeNode) { + const typeOperatorNode = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode; + typeOperatorNode.operator = SyntaxKind.KeyOfKeyword; + typeOperatorNode.type = type + return typeOperatorNode; + } + + export function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + + export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) { + const indexedAccessTypeNode = createSynthesizedNode(SyntaxKind.IndexedAccessType) as IndexedAccessTypeNode; + indexedAccessTypeNode.objectType = objectType; + indexedAccessTypeNode.indexType = indexType; + return indexedAccessTypeNode; + } + + + export function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + + // Type Declarations export function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultParameter: TypeNode | undefined) { @@ -374,6 +394,24 @@ namespace ts { : node; } + export function createSignatureDeclaration(kind: SyntaxKind, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { + const signatureDeclaration = createSynthesizedNode(kind) as T; + signatureDeclaration.name = asName(name); + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + + export function updateSignatureDeclaration(node: T, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { + return node.name !== name + || node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, name, typeParameters, parameters, type), node) + : node; + } + // Signature elements export function createPropertySignature(name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 206e269f366..afe236859a4 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -320,13 +320,13 @@ namespace ts { case SyntaxKind.ConstructorType: throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeQuery: - throw new Error("reached unsupported type in visitor."); + return updateTypeQueryNode((node), visitNode((node).exprName, visitor, isEntityName)); case SyntaxKind.TypeLiteral: return updateTypeLiteralNode((node), nodesVisitor((node).members, visitor)); case SyntaxKind.ArrayType: return updateArrayTypeNode(node, visitNode((node).elementType, visitor, isTypeNode)); case SyntaxKind.TupleType: - throw new Error("reached unsupported type in visitor."); + return updateTypleTypeNode((node), nodesVisitor((node).elementTypes, visitor, isTypeNode)); case SyntaxKind.UnionType: case SyntaxKind.IntersectionType: return updateUnionOrIntersectionTypeNode(node @@ -336,9 +336,11 @@ namespace ts { case SyntaxKind.ThisType: throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeOperator: - throw new Error("reached unsupported type in visitor."); + return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.IndexedAccessType: - throw new Error("reached unsupported type in visitor."); + return updateIndexedAccessTypeNode((node) + , visitNode((node).objectType, visitor, isTypeNode) + , visitNode((node).indexType, visitor, isTypeNode)); case SyntaxKind.MappedType: throw new Error("reached unsupported type in visitor."); case SyntaxKind.LiteralType: diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceCallSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceCallSignature.ts new file mode 100644 index 00000000000..4b472683962 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceCallSignature.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// (x: number, b: string): number; +//// } +//// class C implements I {[| |]} + +verify.not.codeFixAvailable(); + + diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceConstructSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceConstructSignature.ts new file mode 100644 index 00000000000..1700f7ec880 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceConstructSignature.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// new (x: number, b: string); +//// } +//// class C implements I {[| |]} + +verify.not.codeFixAvailable(); + + diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts new file mode 100644 index 00000000000..7f0eddfb14a --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts @@ -0,0 +1,13 @@ +/// + +//// interface I { +//// a1: { (b1: number, c1: string): number; }; +//// a2: (b2: number, c2: string) => number; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + a1: (b1: number, c1: string) => number; + a2: (b2: number, c2: string) => number; +`); + diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts new file mode 100644 index 00000000000..2b27fab376d --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts @@ -0,0 +1,12 @@ +/// + +//// interface I { +//// a1: { new (b1: number, c1: string): number; }; +//// a2: new (b2: number, c2: string) => number; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + a1: new (b1: number, c1: string) => number; + a2: new (b2: number, c2: string) => number; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts new file mode 100644 index 00000000000..3d3505e1d68 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts @@ -0,0 +1,11 @@ +/// + +//// interface I { +//// x: { a(b: number, c: string): number }; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + a: { (b: number, c: string): number; }; +`); + From 5040e1d279e12784ef3375b0acc27ba986054b82 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 16 Mar 2017 11:01:48 -0700 Subject: [PATCH 120/207] Mark occurence item in string with a special property (#14677) * mark occurence item in string with a special property * Adding trailing commas --- src/harness/fourslash.ts | 8 +++- .../unittests/tsserverProjectSystem.ts | 46 +++++++++++++++++++ src/server/protocol.ts | 5 ++ src/server/session.ts | 9 +++- src/services/documentHighlights.ts | 3 +- src/services/findAllReferences.ts | 4 +- src/services/services.ts | 3 +- src/services/types.ts | 2 + .../findAllRefsForStringLiteralTypes.ts | 4 +- .../fourslash/referencesForIndexProperty2.ts | 2 +- 10 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d7638ffc033..3507d0f7b71 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -928,9 +928,13 @@ namespace FourSlash { } function rangeToReferenceEntry(r: Range) { - let { isWriteAccess, isDefinition } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false }; + let { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; - return { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; + const result: any = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; + if (isInString !== undefined) { + result.isInString = isInString; + } + return result; } } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 4d1b2a0b10c..a13835fa7f3 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3489,6 +3489,52 @@ namespace ts.projectSystem { }); }); + describe("occurence highlight on string", () => { + it("should be marked if only on string values", () => { + const file1: FileOrFolder = { + path: "/a/b/file1.ts", + content: `let t1 = "div";\nlet t2 = "div";\nlet t3 = { "div": 123 };\nlet t4 = t3["div"];` + }; + + const host = createServerHost([file1]); + const session = createSession(host); + const projectService = session.getProjectService(); + + projectService.openClientFile(file1.path); + { + const highlightRequest = makeSessionRequest( + CommandNames.Occurrences, + { file: file1.path, line: 1, offset: 11 } + ); + const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; + const firstOccurence = highlightResponse[0]; + assert.isTrue(firstOccurence.isInString, "Highlights should be marked with isInString"); + } + + { + const highlightRequest = makeSessionRequest( + CommandNames.Occurrences, + { file: file1.path, line: 3, offset: 13 } + ); + const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; + assert.isTrue(highlightResponse.length === 2); + const firstOccurence = highlightResponse[0]; + assert.isUndefined(firstOccurence.isInString, "Highlights should not be marked with isInString if on property name"); + } + + { + const highlightRequest = makeSessionRequest( + CommandNames.Occurrences, + { file: file1.path, line: 4, offset: 14 } + ); + const highlightResponse = session.executeCommand(highlightRequest).response as protocol.OccurrencesResponseItem[]; + assert.isTrue(highlightResponse.length === 2); + const firstOccurence = highlightResponse[0]; + assert.isUndefined(firstOccurence.isInString, "Highlights should not be marked with isInString if on indexer"); + } + }); + }); + describe("maxNodeModuleJsDepth for inferred projects", () => { it("should be set to 2 if the project has js root files", () => { const file1: FileOrFolder = { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index d12aa2e0a48..5096eefc1fc 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -621,6 +621,11 @@ namespace ts.server.protocol { * True if the occurrence is a write location, false otherwise. */ isWriteAccess: boolean; + + /** + * True if the occurrence is in a string, undefined otherwise; + */ + isInString?: true; } export interface OccurrencesResponse extends Response { diff --git a/src/server/session.ts b/src/server/session.ts index 64fce61a095..f82d11ba91b 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -651,16 +651,21 @@ namespace ts.server { } return occurrences.map(occurrence => { - const { fileName, isWriteAccess, textSpan } = occurrence; + const { fileName, isWriteAccess, textSpan, isInString } = occurrence; const scriptInfo = project.getScriptInfo(fileName); const start = scriptInfo.positionToLineOffset(textSpan.start); const end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { + const result: protocol.OccurrencesResponseItem = { start, end, file: fileName, isWriteAccess, }; + // no need to serialize the property if it is not true + if (isInString) { + result.isInString = isInString; + } + return result; }); } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index ff2b819ec26..502dfc59825 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -37,7 +37,8 @@ namespace ts.DocumentHighlights { documentHighlights.highlightSpans.push({ textSpan: referenceEntry.textSpan, - kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference + kind: referenceEntry.isWriteAccess ? HighlightSpanKind.writtenReference : HighlightSpanKind.reference, + isInString: referenceEntry.isInString }); } } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index bc1e50391c8..9e5eb0351cc 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1044,7 +1044,9 @@ namespace ts.FindAllReferences { const type = getStringLiteralTypeForNode(node, typeChecker); if (type === searchType) { - references.push(getReferenceEntryFromNode(node)); + const reference = getReferenceEntryFromNode(node); + reference.isInString = true; + references.push(reference); } } } diff --git a/src/services/services.ts b/src/services/services.ts index e370dccac32..a2931a39ab0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1396,7 +1396,8 @@ namespace ts { fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference, - isDefinition: false + isDefinition: false, + isInString: highlightSpan.isInString, }); } } diff --git a/src/services/types.ts b/src/services/types.ts index 149bb4340dc..3e5d31b586b 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -364,6 +364,7 @@ namespace ts { fileName: string; isWriteAccess: boolean; isDefinition: boolean; + isInString?: true; } export interface ImplementationLocation { @@ -385,6 +386,7 @@ namespace ts { export interface HighlightSpan { fileName?: string; + isInString?: true; textSpan: TextSpan; kind: string; } diff --git a/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts index e450102c127..312bce4a3ad 100644 --- a/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts +++ b/tests/cases/fourslash/findAllRefsForStringLiteralTypes.ts @@ -1,6 +1,6 @@ /// -////type Options = "[|option 1|]" | "option 2"; -////let myOption: Options = "[|option 1|]"; +////type Options = "[|{| "isInString": true |}option 1|]" | "option 2"; +////let myOption: Options = "[|{| "isInString": true |}option 1|]"; verify.singleReferenceGroup('"option 1"'); diff --git a/tests/cases/fourslash/referencesForIndexProperty2.ts b/tests/cases/fourslash/referencesForIndexProperty2.ts index a4d5c75a908..0f87c82f7d3 100644 --- a/tests/cases/fourslash/referencesForIndexProperty2.ts +++ b/tests/cases/fourslash/referencesForIndexProperty2.ts @@ -3,6 +3,6 @@ // References to a unknown index property ////var a; -////a["[|blah|]"]; +////a["[|{| "isInString": true |}blah|]"]; verify.singleReferenceGroup('"blah"'); From 9c0f77091c0b956282a33e101ec6c9173a9c201e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 7 Mar 2017 06:42:50 -0800 Subject: [PATCH 121/207] Clean up code in parser --- src/compiler/parser.ts | 52 +++++++++++++++++++++++------------------- src/compiler/types.ts | 3 +-- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 308d3a317f9..6db26355d92 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1309,7 +1309,7 @@ namespace ts { case ParsingContext.ObjectBindingElements: return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName(); case ParsingContext.HeritageClauseElement: - // If we see { } then only consume it as an expression if it is followed by , or { + // If we see { } then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. if (token() === SyntaxKind.OpenBraceToken) { return lookAhead(isValidHeritageClauseObjectLiteral); @@ -2113,7 +2113,7 @@ namespace ts { return finishNode(node); } - function parseTypeParameters(): NodeArray { + function parseTypeParameters(): NodeArray | undefined { if (token() === SyntaxKind.LessThanToken) { return parseBracketedList(ParsingContext.TypeParameters, parseTypeParameter, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); } @@ -2183,7 +2183,7 @@ namespace ts { } function fillSignature( - returnToken: SyntaxKind, + returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, yieldContext: boolean, awaitContext: boolean, requireCompleteParameterList: boolean, @@ -2373,14 +2373,14 @@ namespace ts { } function isTypeMemberStart(): boolean { - let idToken: SyntaxKind; // Return true if we have the start of a signature member if (token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) { return true; } + let idToken: boolean; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (isModifierKind(token())) { - idToken = token(); + idToken = true; nextToken(); } // Index signatures and computed property names are type members @@ -2389,7 +2389,7 @@ namespace ts { } // Try to get the first property-like token following all modifiers if (isLiteralPropertyName()) { - idToken = token(); + idToken = true; nextToken(); } // If we were able to get any potential identifier, check that it is @@ -2497,7 +2497,7 @@ namespace ts { return finishNode(node); } - function parseKeywordAndNoDot(): TypeNode { + function parseKeywordAndNoDot(): TypeNode | undefined { const node = parseTokenNode(); return token() === SyntaxKind.DotToken ? undefined : node; } @@ -2635,7 +2635,7 @@ namespace ts { return parseArrayTypeOrHigher(); } - function parseUnionOrIntersectionType(kind: SyntaxKind, parseConstituentType: () => TypeNode, operator: SyntaxKind): TypeNode { + function parseUnionOrIntersectionType(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, parseConstituentType: () => TypeNode, operator: SyntaxKind.BarToken | SyntaxKind.AmpersandToken): TypeNode { parseOptional(operator); let type = parseConstituentType(); if (token() === operator) { @@ -5281,8 +5281,8 @@ namespace ts { * * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ - function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray { - let modifiers: NodeArray; + function parseModifiers(permitInvalidConstAsModifier?: boolean): NodeArray | undefined { + let modifiers: NodeArray | undefined; while (true) { const modifierStart = scanner.getStartPos(); const modifierKind = token(); @@ -5422,7 +5422,7 @@ namespace ts { return token() === SyntaxKind.ImplementsKeyword && lookAhead(nextTokenIsIdentifierOrKeyword); } - function parseHeritageClauses(): NodeArray { + function parseHeritageClauses(): NodeArray | undefined { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } @@ -5433,7 +5433,7 @@ namespace ts { return undefined; } - function parseHeritageClause() { + function parseHeritageClause(): HeritageClause | undefined { if (token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword) { const node = createNode(SyntaxKind.HeritageClause); node.token = token(); @@ -5459,7 +5459,7 @@ namespace ts { return token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword; } - function parseClassMembers() { + function parseClassMembers(): NodeArray { return parseList(ParsingContext.ClassMembers, parseClassElement); } @@ -5618,17 +5618,7 @@ namespace ts { if (isIdentifier()) { identifier = parseIdentifier(); if (token() !== SyntaxKind.CommaToken && token() !== SyntaxKind.FromKeyword) { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; - const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; - parseExpected(SyntaxKind.EqualsToken); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); } } @@ -5652,6 +5642,20 @@ namespace ts { return finishNode(importDeclaration); } + function parseImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, identifier: ts.Identifier): ImportEqualsDeclaration { + // ImportEquals declaration of type: + // import x = require("mod"); or + // import x = M.x; + const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); + importEqualsDeclaration.decorators = decorators; + importEqualsDeclaration.modifiers = modifiers; + importEqualsDeclaration.name = identifier; + parseExpected(SyntaxKind.EqualsToken); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return addJSDocComment(finishNode(importEqualsDeclaration)); + } + function parseImportClause(identifier: Identifier, fullStart: number) { // ImportClause: // ImportedDefaultBinding diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 86895f3db6e..7728c2b8519 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1813,7 +1813,7 @@ namespace ts { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; - body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; + body?: ModuleBody | JSDocNamespaceDeclaration; } export type NamespaceBody = ModuleBlock | NamespaceDeclaration; @@ -1889,7 +1889,6 @@ namespace ts { export interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; - moduleReference: LiteralLikeNode; } export interface ExportDeclaration extends DeclarationStatement { From 18f283f68adbeeca78d70c6c7474eda46133a545 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 16 Mar 2017 14:43:56 -0700 Subject: [PATCH 122/207] Add more missing quotes --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6db26355d92..f5c4d880072 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1309,7 +1309,7 @@ namespace ts { case ParsingContext.ObjectBindingElements: return token() === SyntaxKind.OpenBracketToken || token() === SyntaxKind.DotDotDotToken || isLiteralPropertyName(); case ParsingContext.HeritageClauseElement: - // If we see { } then only consume it as an expression if it is followed by `,` or `{` + // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. if (token() === SyntaxKind.OpenBraceToken) { return lookAhead(isValidHeritageClauseObjectLiteral); From 595342615b8e9c729626668f3a1eff3c764fb77b Mon Sep 17 00:00:00 2001 From: Vladimir Matveev Date: Thu, 16 Mar 2017 15:53:05 -0700 Subject: [PATCH 123/207] abstract code in FindReferences from concrete way of creating result reference entry to seamlessly reuse the same code for gotoImplementation (#14637) --- src/harness/fourslash.ts | 28 +++ src/server/client.ts | 4 +- src/services/documentHighlights.ts | 3 +- src/services/findAllReferences.ts | 181 +++++++++++------- src/services/goToImplementation.ts | 12 +- src/services/types.ts | 22 ++- .../goToImplementationClassMethod_00.ts | 2 +- .../goToImplementationInterface_00.ts | 4 +- .../goToImplementationInterface_07.ts | 2 + 9 files changed, 172 insertions(+), 86 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 3507d0f7b71..8ef4d946694 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1859,17 +1859,41 @@ namespace FourSlash { const unsatisfiedRanges: Range[] = []; + const delayedErrors: string[] = []; for (const range of ranges) { const length = range.end - range.start; const matchingImpl = ts.find(implementations, impl => range.fileName === impl.fileName && range.start === impl.textSpan.start && length === impl.textSpan.length); if (matchingImpl) { + if (range.marker && range.marker.data) { + const expected = <{ displayParts?: ts.SymbolDisplayPart[], parts: string[], kind?: string }>range.marker.data; + if (expected.displayParts) { + if (!ts.arrayIsEqualTo(expected.displayParts, matchingImpl.displayParts, displayPartIsEqualTo)) { + delayedErrors.push(`Mismatched display parts: expected ${JSON.stringify(expected.displayParts)}, actual ${JSON.stringify(matchingImpl.displayParts)}`); + } + } + else if (expected.parts) { + const actualParts = matchingImpl.displayParts.map(p => p.text); + if (!ts.arrayIsEqualTo(expected.parts, actualParts)) { + delayedErrors.push(`Mismatched non-tagged display parts: expected ${JSON.stringify(expected.parts)}, actual ${JSON.stringify(actualParts)}`); + } + } + if (expected.kind !== undefined) { + if (expected.kind !== matchingImpl.kind) { + delayedErrors.push(`Mismatched kind: expected ${JSON.stringify(expected.kind)}, actual ${JSON.stringify(matchingImpl.kind)}`); + } + } + } + matchingImpl.matched = true; } else { unsatisfiedRanges.push(range); } } + if (delayedErrors.length) { + this.raiseError(delayedErrors.join("\n")); + } const unmatchedImplementations = implementations.filter(impl => !impl.matched); if (unmatchedImplementations.length || unsatisfiedRanges.length) { @@ -1894,6 +1918,10 @@ namespace FourSlash { function implementationsAreEqual(a: ImplementationLocationInformation, b: ImplementationLocationInformation) { return a.fileName === b.fileName && TestState.textSpansEqual(a.textSpan, b.textSpan); } + + function displayPartIsEqualTo(a: ts.SymbolDisplayPart, b: ts.SymbolDisplayPart): boolean { + return a.kind === b.kind && a.text === b.text; + } } public getMarkers(): Marker[] { diff --git a/src/server/client.ts b/src/server/client.ts index 6f784db1682..8e81a423837 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -382,7 +382,9 @@ namespace ts.server { const end = this.lineOffsetToPosition(fileName, entry.end); return { fileName, - textSpan: ts.createTextSpanFromBounds(start, end) + textSpan: ts.createTextSpanFromBounds(start, end), + kind: ScriptElementKind.unknown, + displayParts: [] }; }); } diff --git a/src/services/documentHighlights.ts b/src/services/documentHighlights.ts index 502dfc59825..7308ad235fc 100644 --- a/src/services/documentHighlights.ts +++ b/src/services/documentHighlights.ts @@ -17,7 +17,8 @@ namespace ts.DocumentHighlights { } function getSemanticDocumentHighlights(node: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFilesToSearch: SourceFile[]): DocumentHighlights[] { - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFilesToSearch); + const context = new FindAllReferences.DefaultFindReferencesContext(typeChecker, cancellationToken); + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(context, node, sourceFilesToSearch); return referencedSymbols && convertReferencedSymbols(referencedSymbols); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 9e5eb0351cc..725b9b99506 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1,21 +1,75 @@ /* @internal */ namespace ts.FindAllReferences { + + export interface FindReferencesContext { + readonly typeChecker: TypeChecker; + readonly cancellationToken: CancellationToken; + getReferenceEntryFromNode(node: Node, isInString?: boolean): T; + getReferenceEntryForSpanInFile(fileName: string, span: TextSpan): T; + } + + export class DefaultFindReferencesContext implements FindReferencesContext { + constructor(readonly typeChecker: TypeChecker, readonly cancellationToken: CancellationToken) { + } + getReferenceEntryFromNode(node: Node, isInString?: boolean): ReferenceEntry { + const reference = getReferenceEntryFromNode(node); + if (isInString) { + reference.isInString = true; + } + return reference; + } + getReferenceEntryForSpanInFile(fileName: string, textSpan: TextSpan): ReferenceEntry { + return { textSpan, fileName, isWriteAccess: false, isDefinition: false }; + } + } + + export class FindImplementationsContext implements FindReferencesContext { + constructor(readonly typeChecker: TypeChecker, readonly cancellationToken: CancellationToken) { + } + getReferenceEntryFromNode(node: Node): ImplementationLocation { + const entry = getReferenceEntryFromNode(node); + const symbol = this.typeChecker.getSymbolAtLocation(isDeclaration(node) && node.name ? node.name : node); + if (symbol) { + const def = getDefinition(symbol, node, this.typeChecker); + entry.kind = def.kind; + entry.displayParts = def.displayParts; + } + else if (node.kind === SyntaxKind.ObjectLiteralExpression) { + entry.kind = ScriptElementKind.interfaceElement; + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)] + } + else if (node.kind === SyntaxKind.ClassExpression) { + entry.kind = ScriptElementKind.localClassElement; + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)] + } + else { + entry.kind = getNodeKind(node); + entry.displayParts = []; + } + return entry; + } + getReferenceEntryForSpanInFile(fileName: string, textSpan: TextSpan): ImplementationLocation { + return { textSpan, fileName, kind: ScriptElementKind.unknown, displayParts: [] }; + } + } + export function findReferencedSymbols(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], sourceFile: SourceFile, position: number, findInStrings: boolean, findInComments: boolean, isForRename: boolean): ReferencedSymbol[] | undefined { const node = getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); + return getReferencedSymbolsForNode(new DefaultFindReferencesContext(typeChecker, cancellationToken), node, sourceFiles, findInStrings, findInComments, isForRename); } export function convertReferences(referenceSymbols: ReferencedSymbol[]): ReferenceEntry[] { return referenceSymbols && flatMap(referenceSymbols, r => r.references); } - export function getReferencedSymbolsForNode(typeChecker: TypeChecker, cancellationToken: CancellationToken, node: Node, sourceFiles: SourceFile[], findInStrings?: boolean, findInComments?: boolean, isForRename?: boolean, implementations?: boolean): ReferencedSymbol[] | undefined { + export function getReferencedSymbolsForNode(context: FindReferencesContext, node: Node, sourceFiles: SourceFile[], findInStrings?: boolean, findInComments?: boolean, isForRename?: boolean, implementations?: boolean): ReferencedSymbolOf[] | undefined { if (!implementations) { - const special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); + const special = getReferencedSymbolsSpecial(node, sourceFiles, context); if (special) { return special; } } + const { typeChecker, cancellationToken } = context; // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. @@ -24,7 +78,7 @@ namespace ts.FindAllReferences { // Could not find a symbol e.g. unknown identifier if (!symbol) { if (!implementations && node.kind === SyntaxKind.StringLiteral) { - return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + return getReferencesForStringLiteral(node, sourceFiles, context); } // Can't have references to something that we have no symbol for. return undefined; @@ -49,7 +103,7 @@ namespace ts.FindAllReferences { // Compute the meaning from the location and the symbol it references const searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - const result: ReferencedSymbol[] = []; + const result: ReferencedSymbolOf[] = []; // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. const symbolToIndex: number[] = []; const inheritsFromCache: Map = createMap(); @@ -81,14 +135,14 @@ namespace ts.FindAllReferences { function getRefs(scope: ts.Node, searchName: string): void { getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, - symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); + symbolToIndex, implementations, context, searchSymbols, inheritsFromCache); } } /** getReferencedSymbols for special node kinds. */ - function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] | undefined { + function getReferencedSymbolsSpecial(node: Node, sourceFiles: SourceFile[], context: FindReferencesContext): ReferencedSymbolOf[] | undefined { if (isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + return getAllReferencesForKeyword(context, sourceFiles, node.kind); } // Labels @@ -97,20 +151,20 @@ namespace ts.FindAllReferences { const labelDefinition = getTargetLabel((node.parent), (node).text); // if we have a label definition, look within its statement for references, if not, then // the label is undefined and we have no results.. - return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, context); } else { // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node, cancellationToken); + return getLabelReferencesInNode(node.parent, node, context); } } if (isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + return getReferencesForThisKeyword(node, sourceFiles, context); } if (node.kind === SyntaxKind.SuperKeyword) { - return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + return getReferencesForSuperKeyword(node, context); } return undefined; @@ -352,10 +406,11 @@ namespace ts.FindAllReferences { return positions; } - function getLabelReferencesInNode(container: Node, targetLabel: Identifier, cancellationToken: CancellationToken): ReferencedSymbol[] { - const references: ReferenceEntry[] = []; + function getLabelReferencesInNode(container: Node, targetLabel: Identifier, context: FindReferencesContext): ReferencedSymbolOf[] { + const references: T[] = []; const sourceFile = container.getSourceFile(); const labelName = targetLabel.text; + const { cancellationToken } = context; const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); @@ -368,7 +423,7 @@ namespace ts.FindAllReferences { // Only pick labels that are either the target label, or have a target that is the target label if (node === targetLabel || (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); + references.push(context.getReferenceEntryFromNode(node)); } }); @@ -404,12 +459,13 @@ namespace ts.FindAllReferences { } } - function getAllReferencesForKeyword(sourceFiles: SourceFile[], keywordKind: ts.SyntaxKind, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getAllReferencesForKeyword(context: FindReferencesContext, sourceFiles: SourceFile[], keywordKind: ts.SyntaxKind): ReferencedSymbolOf[] { + const { cancellationToken } = context; const name = tokenToString(keywordKind); - const references: ReferenceEntry[] = []; + const references: T[] = []; for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); + addReferencesForKeywordInFile(sourceFile, keywordKind, name, context, references); } if (!references.length) return undefined; @@ -427,18 +483,14 @@ namespace ts.FindAllReferences { return [{ definition, references }]; } - function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, cancellationToken: CancellationToken, references: Push): void { + function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, context: FindReferencesContext, references: Push): void { + const { cancellationToken } = context; const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); for (const position of possiblePositions) { cancellationToken.throwIfCancellationRequested(); const referenceLocation = getTouchingPropertyName(sourceFile, position); if (referenceLocation.kind === kind) { - references.push({ - textSpan: createTextSpanFromNode(referenceLocation), - fileName: sourceFile.fileName, - isWriteAccess: false, - isDefinition: false, - }); + references.push(context.getReferenceEntryForSpanInFile(sourceFile.fileName, createTextSpanFromNode(referenceLocation))); } } } @@ -447,22 +499,22 @@ namespace ts.FindAllReferences { * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). * searchLocation: a node where the search value */ - function getReferencesInNode(container: Node, + function getReferencesInNode(container: Node, searchSymbol: Symbol, searchText: string, searchLocation: Node, searchMeaning: SemanticMeaning, findInStrings: boolean, findInComments: boolean, - result: ReferencedSymbol[], + result: ReferencedSymbolOf[], symbolToIndex: number[], implementations: boolean, - typeChecker: TypeChecker, - cancellationToken: CancellationToken, + context: FindReferencesContext, searchSymbols: Symbol[], inheritsFromCache: Map): void { const sourceFile = container.getSourceFile(); + const { typeChecker, cancellationToken } = context; const start = findInComments ? container.getFullStart() : container.getStart(); const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); @@ -486,12 +538,7 @@ namespace ts.FindAllReferences { // 'FindReferences' will just filter out these results. result.push({ definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] + references: [context.getReferenceEntryForSpanInFile(sourceFile.fileName, createTextSpan(position, searchText.length))] }); } continue; @@ -571,11 +618,11 @@ namespace ts.FindAllReferences { function addReferences(references: Node[]): void { if (references.length) { const referencedSymbol = getReferencedSymbol(searchSymbol); - addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); + addRange(referencedSymbol.references, map(references, n => context.getReferenceEntryFromNode(n))); } } - function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { + function getReferencedSymbol(symbol: Symbol): ReferencedSymbolOf { const symbolId = getSymbolId(symbol); let index = symbolToIndex[symbolId]; if (index === undefined) { @@ -594,10 +641,10 @@ namespace ts.FindAllReferences { function addReferenceToRelatedSymbol(node: Node, relatedSymbol: Symbol) { const references = getReferencedSymbol(relatedSymbol).references; if (implementations) { - getImplementationReferenceEntryForNode(node, references, typeChecker); + getImplementationReferenceEntryForNode(node, references, context); } else { - references.push(getReferenceEntryFromNode(node)); + references.push(context.getReferenceEntryFromNode(node)); } } } @@ -658,21 +705,21 @@ namespace ts.FindAllReferences { return result; } - function getImplementationReferenceEntryForNode(refNode: Node, result: ReferenceEntry[], typeChecker: TypeChecker): void { + function getImplementationReferenceEntryForNode(refNode: Node, result: T[], context: FindReferencesContext): void { // Check if we found a function/propertyAssignment/method with an implementation or initializer if (isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); + result.push(context.getReferenceEntryFromNode(refNode.parent)); } else if (refNode.kind === SyntaxKind.Identifier) { if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + getReferenceEntriesForShorthandPropertyAssignment(refNode, context, result); } // Check if the node is within an extends or implements clause const containingClass = getContainingClassIfInHeritageClause(refNode); if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); + result.push(context.getReferenceEntryFromNode(containingClass)); return; } @@ -681,22 +728,22 @@ namespace ts.FindAllReferences { if (containingTypeReference) { const parent = containingTypeReference.parent; if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); + maybeAdd(context.getReferenceEntryFromNode(parent.initializer)); } else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { if (parent.body.kind === SyntaxKind.Block) { forEachReturnStatement(parent.body, returnStatement => { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + maybeAdd(context.getReferenceEntryFromNode(returnStatement.expression)); } }); } else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); + maybeAdd(context.getReferenceEntryFromNode(parent.body)); } } else if (isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); + maybeAdd(context.getReferenceEntryFromNode(parent.expression)); } } } @@ -706,7 +753,7 @@ namespace ts.FindAllReferences { // Because we are returning the implementation locations and not the identifier locations, // duplicate entries would be returned here as each of the type references is part of // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a: ReferenceEntry) { + function maybeAdd(a: T) { if (!forEach(result, b => a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length)) { result.push(a); } @@ -845,7 +892,7 @@ namespace ts.FindAllReferences { } } - function getReferencesForSuperKeyword(superKeyword: Node, typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getReferencesForSuperKeyword(superKeyword: Node, context: FindReferencesContext): ReferencedSymbolOf[] { let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); if (!searchSpaceNode) { return undefined; @@ -868,7 +915,8 @@ namespace ts.FindAllReferences { return undefined; } - const references: ReferenceEntry[] = []; + const references: T[] = []; + const { typeChecker, cancellationToken } = context; const sourceFile = searchSpaceNode.getSourceFile(); const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); @@ -887,7 +935,7 @@ namespace ts.FindAllReferences { // 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 && (ModifierFlags.Static & getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); + references.push(context.getReferenceEntryFromNode(node)); } } @@ -895,8 +943,9 @@ namespace ts.FindAllReferences { return [{ definition, references }]; } - function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getReferencesForThisKeyword(thisOrSuperKeyword: Node, sourceFiles: SourceFile[], context: FindReferencesContext): ReferencedSymbolOf[] { let searchSpaceNode = getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + const { typeChecker, cancellationToken } = context; // Whether 'this' occurs in a static context within a class. let staticFlag = ModifierFlags.Static; @@ -930,7 +979,7 @@ namespace ts.FindAllReferences { return undefined; } - const references: ReferenceEntry[] = []; + const references: T[] = []; let possiblePositions: number[]; if (searchSpaceNode.kind === SyntaxKind.SourceFile) { @@ -963,7 +1012,7 @@ namespace ts.FindAllReferences { references: references }]; - function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: ReferenceEntry[]): void { + function getThisReferencesInFile(sourceFile: SourceFile, searchSpaceNode: Node, possiblePositions: number[], result: T[]): void { forEach(possiblePositions, position => { cancellationToken.throwIfCancellationRequested(); @@ -978,13 +1027,13 @@ namespace ts.FindAllReferences { case SyntaxKind.FunctionExpression: case SyntaxKind.FunctionDeclaration: if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: if (isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; case SyntaxKind.ClassExpression: @@ -992,12 +1041,12 @@ namespace ts.FindAllReferences { // 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 && (getModifierFlags(container) & ModifierFlags.Static) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; case SyntaxKind.SourceFile: if (container.kind === SyntaxKind.SourceFile && !isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); + result.push(context.getReferenceEntryFromNode(node)); } break; } @@ -1005,7 +1054,8 @@ namespace ts.FindAllReferences { } } - function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], typeChecker: TypeChecker, cancellationToken: CancellationToken): ReferencedSymbol[] { + function getReferencesForStringLiteral(node: StringLiteral, sourceFiles: SourceFile[], context: FindReferencesContext): ReferencedSymbolOf[] { + const { typeChecker, cancellationToken } = context; const type = getStringLiteralTypeForNode(node, typeChecker); if (!type) { @@ -1013,7 +1063,7 @@ namespace ts.FindAllReferences { return undefined; } - const references: ReferenceEntry[] = []; + const references: T[] = []; for (const sourceFile of sourceFiles) { const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); @@ -1033,7 +1083,7 @@ namespace ts.FindAllReferences { references: references }]; - function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: ReferenceEntry[]): void { + function getReferencesForStringLiteralInFile(sourceFile: SourceFile, searchType: Type, possiblePositions: number[], references: T[]): void { for (const position of possiblePositions) { cancellationToken.throwIfCancellationRequested(); @@ -1044,9 +1094,7 @@ namespace ts.FindAllReferences { const type = getStringLiteralTypeForNode(node, typeChecker); if (type === searchType) { - const reference = getReferenceEntryFromNode(node); - reference.isInString = true; - references.push(reference); + references.push(context.getReferenceEntryFromNode(node, /*isInString*/ true)); } } } @@ -1359,14 +1407,15 @@ namespace ts.FindAllReferences { } } - export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker, result: ReferenceEntry[]): void { + export function getReferenceEntriesForShorthandPropertyAssignment(node: Node, context: FindReferencesContext, result: T[]): void { + const { typeChecker } = context; const refSymbol = typeChecker.getSymbolAtLocation(node); const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); if (shorthandSymbol) { for (const declaration of shorthandSymbol.getDeclarations()) { if (getMeaningFromDeclaration(declaration) & SemanticMeaning.Value) { - result.push(getReferenceEntryFromNode(declaration)); + result.push(context.getReferenceEntryFromNode(declaration)); } } } diff --git a/src/services/goToImplementation.ts b/src/services/goToImplementation.ts index 9135e1fe0f0..dd3c06174af 100644 --- a/src/services/goToImplementation.ts +++ b/src/services/goToImplementation.ts @@ -1,25 +1,25 @@ /* @internal */ namespace ts.GoToImplementation { export function getImplementationAtPosition(typeChecker: TypeChecker, cancellationToken: CancellationToken, sourceFiles: SourceFile[], node: Node): ImplementationLocation[] { + const context = new FindAllReferences.FindImplementationsContext(typeChecker, cancellationToken); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { - const result: ReferenceEntry[] = []; - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); + const result: ImplementationLocation[] = []; + FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, context, result); return result.length > 0 ? result : undefined; } else if (node.kind === SyntaxKind.SuperKeyword || isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" const symbol = typeChecker.getSymbolAtLocation(node); - return symbol.valueDeclaration && [FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; + return symbol.valueDeclaration && [context.getReferenceEntryFromNode(symbol.valueDeclaration)]; } else { // Perform "Find all References" and retrieve only those that are implementations - const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, + const referencedSymbols = FindAllReferences.getReferencedSymbolsForNode(context, node, sourceFiles, /*findInStrings*/false, /*findInComments*/false, /*isForRename*/false, /*implementations*/true); - const result = flatMap(referencedSymbols, symbol => - map(symbol.references, ({ textSpan, fileName }) => ({ textSpan, fileName }))); + const result = flatMap(referencedSymbols, symbol => symbol.references); return result && result.length > 0 ? result : undefined; } diff --git a/src/services/types.ts b/src/services/types.ts index 3e5d31b586b..856b03330bf 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -354,22 +354,23 @@ namespace ts { caretOffset: number; } - export interface RenameLocation { + export interface DocumentSpan { textSpan: TextSpan; fileName: string; } - export interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; + export interface RenameLocation extends DocumentSpan { + } + + export interface ReferenceEntry extends DocumentSpan { isWriteAccess: boolean; isDefinition: boolean; isInString?: true; } - export interface ImplementationLocation { - textSpan: TextSpan; - fileName: string; + export interface ImplementationLocation extends DocumentSpan { + kind: string; + displayParts: SymbolDisplayPart[]; } export interface DocumentHighlights { @@ -478,9 +479,12 @@ namespace ts { displayParts: SymbolDisplayPart[]; } - export interface ReferencedSymbol { + export interface ReferencedSymbolOf { definition: ReferencedSymbolDefinitionInfo; - references: ReferenceEntry[]; + references: T[]; + } + + export interface ReferencedSymbol extends ReferencedSymbolOf { } export enum SymbolDisplayPartKind { diff --git a/tests/cases/fourslash/goToImplementationClassMethod_00.ts b/tests/cases/fourslash/goToImplementationClassMethod_00.ts index 6fc8d9bf7cc..09bece0c1a2 100644 --- a/tests/cases/fourslash/goToImplementationClassMethod_00.ts +++ b/tests/cases/fourslash/goToImplementationClassMethod_00.ts @@ -3,7 +3,7 @@ // Should handle calls made on members declared in a class //// class Bar { -//// [|hello() {}|] +//// [|{|"parts": ["(","method",")"," ","Bar",".","hello","(",")",":"," ","void"], "kind": "method"|}hello() {}|] //// } //// //// new Bar().hel/*reference*/lo; diff --git a/tests/cases/fourslash/goToImplementationInterface_00.ts b/tests/cases/fourslash/goToImplementationInterface_00.ts index 8fc36b4bab5..33ff9fbd045 100644 --- a/tests/cases/fourslash/goToImplementationInterface_00.ts +++ b/tests/cases/fourslash/goToImplementationInterface_00.ts @@ -8,12 +8,12 @@ //// //// interface Baz extends Foo {} //// -//// var bar: Foo = [|{ hello: helloImpl /**0*/ }|]; +//// var bar: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello: helloImpl /**0*/ }|]; //// var baz: Foo[] = [|[{ hello: helloImpl /**4*/ }]|]; //// //// function helloImpl () {} //// -//// function whatever(x: Foo = [|{ hello() {/**1*/} }|] ) { +//// function whatever(x: Foo = [|{|"parts": ["(","object literal",")"], "kind": "interface"|}{ hello() {/**1*/} }|] ) { //// } //// //// class Bar { diff --git a/tests/cases/fourslash/goToImplementationInterface_07.ts b/tests/cases/fourslash/goToImplementationInterface_07.ts index 6d874b3dc76..960072004b4 100644 --- a/tests/cases/fourslash/goToImplementationInterface_07.ts +++ b/tests/cases/fourslash/goToImplementationInterface_07.ts @@ -19,6 +19,8 @@ //// let x7: (new() => Foo) = [|class { hello () { /**constructorType*/} }|]; //// let x8: Foo[] = [|[{ hello () { /**arrayType*/} }]|]; //// let x9: { y: Foo } = [|{ y: { hello () { /**typeLiteral*/} } }|]; +//// let x10 = [|{|"parts": ["(","anonymous local class",")"], "kind": "local class"|}class implements Foo { hello() {} }|] +//// let x11 = [|{|"parts": ["(","local class",")"," ","C"], "kind": "local class"|}class C implements Foo { hello() {} }|] //// //// // Should not do anything for type predicates //// function isFoo(a: any): a is Foo { From 451b2d648fcc1f36fccf0c604c8f20f893f23dc9 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 16:09:54 -0700 Subject: [PATCH 124/207] Add signatures test --- ...ImplementInterfacePropertyCallSignature.ts | 13 ------- ...ntInterfacePropertyConstructSignature.1.ts | 12 ------- ...plementInterfacePropertyMethodSignature.ts | 11 ------ ...assImplementInterfacePropertySignatures.ts | 34 +++++++++++++++++++ 4 files changed, 34 insertions(+), 36 deletions(-) delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts deleted file mode 100644 index 7f0eddfb14a..00000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyCallSignature.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -//// interface I { -//// a1: { (b1: number, c1: string): number; }; -//// a2: (b2: number, c2: string) => number; -//// } -//// class C implements I {[| |]} - -verify.rangeAfterCodeFix(` - a1: (b1: number, c1: string) => number; - a2: (b2: number, c2: string) => number; -`); - diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts deleted file mode 100644 index 2b27fab376d..00000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyConstructSignature.1.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// interface I { -//// a1: { new (b1: number, c1: string): number; }; -//// a2: new (b2: number, c2: string) => number; -//// } -//// class C implements I {[| |]} - -verify.rangeAfterCodeFix(` - a1: new (b1: number, c1: string) => number; - a2: new (b2: number, c2: string) => number; -`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts deleted file mode 100644 index 3d3505e1d68..00000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyMethodSignature.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// - -//// interface I { -//// x: { a(b: number, c: string): number }; -//// } -//// class C implements I {[| |]} - -verify.rangeAfterCodeFix(` - a: { (b: number, c: string): number; }; -`); - diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts new file mode 100644 index 00000000000..94382410054 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertySignatures.ts @@ -0,0 +1,34 @@ +/// + +//// interface I { +//// a0: {}; +//// a1: { (b1: number, c1: string): number; }; +//// a2: (b2: number, c2: string) => number; +//// a3: { (b3: number, c3: string): number, x: number }; +//// +//// a4: { new (b1: number, c1: string): number; }; +//// a5: new (b2: number, c2: string) => number; +//// a6: { new (b3: number, c3: string): number, x: number }; +//// +//// a7: { foo(b7: number, c7: string): number }; +//// +//// a8: { (b81: number, c81: string): number, new (b82: number, c82: string): number; }; +//// +//// a9: { (b9: number, c9: string): number; [d9: number]: I }; +//// a10: { (b10: number, c10: string): number; [d10: string]: I }; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + a0: {}; + a1: (b1: number, c1: string) => number; + a2: (b2: number, c2: string) => number; + a3: { (b3: number, c3: string): number; x: number; }; + a4: new (b1: number, c1: string) => number; + a5: new (b2: number, c2: string) => number; + a6: { new (b3: number, c3: string): number; x: number; }; + a7: { foo(b7: number, c7: string): number; }; + a8: { (b81: number, c81: string): number; new (b82: number, c82: string): number; }; + a9: { (b9: number, c9: string): number; [d9: number]: I; }; + a10: { (b10: number, c10: string): number; [d10: string]: I; }; +`); \ No newline at end of file From 0fa4f112a33a8f7fdc12b61e9e5a8418b9bf95eb Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 16:41:26 -0700 Subject: [PATCH 125/207] signatures, parameter, literals, anyonymous types --- src/compiler/checker.ts | 283 +++++++++++------------------- src/compiler/factory.ts | 31 ++-- src/compiler/types.ts | 2 + src/compiler/visitor.ts | 56 +++--- src/services/codefixes/helpers.ts | 66 ++++--- 5 files changed, 181 insertions(+), 257 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d650865ef73..7545430717e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -109,6 +109,7 @@ namespace ts { createTypeNode, createTypeParameterDeclarationFromType, createIndexSignatureFromIndexInfo, + createParameterDeclarationFromSymbol, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2203,6 +2204,45 @@ namespace ts { return createTypeParameterDeclaration(name, constraint, defaultParameter); } + // TODO: enclosing declaration appears to be unused in getTypeOfSymbolAtLocation + function createParameterDeclarationFromSymbol(parameterSymbol: Symbol): ParameterDeclaration { + const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; + const parameterType = getTypeOfSymbol(parameterSymbol); + const parameterTypeNode = checker.createTypeNode(parameterType); + // TODO: clone binding names correctly. + // TODO: copy initialzer in a way that checks whether all symbols used in expression are accessible here, and qualify them appropriately. + const parameterNode = createParameter( + parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedDeepClone) + , parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedDeepClone) + , parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken) + , getSynthesizedDeepClone(parameterDeclaration.name) + , parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken) + , parameterTypeNode + , /*initializer*/ undefined); + return parameterNode; + } + + /* @internal */ + type SignatureParts = { + typeParameters: TypeParameterDeclaration[] | undefined; + parameters: ParameterDeclaration[]; + type: TypeNode; + } + + // TODO: expose this, remove copy from helper, possibly don't expose createParameter/TypeParameter? + function createSignatureParts(signature: Signature): SignatureParts { + return { + typeParameters: signature.typeParameters && signature.typeParameters.map(createTypeParameterDeclarationFromType), + parameters: signature.parameters.map(createParameterDeclarationFromSymbol), + type: createTypeNodeExceptAny(getReturnTypeOfSignature(signature)) + } + + function createTypeNodeExceptAny(type: Type): TypeNode | undefined { + const typeNode = createTypeNode(type); + return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; + } + } + function createTypeNode(type: Type): TypeNode { let undefinedArgumentIsError = true; let encounteredError = false; @@ -2322,22 +2362,6 @@ namespace ts { return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); } - if (objectFlags & ObjectFlags.Mapped) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - - // TODO: does typeParameter have the same constraint or do we need to overwrite it somehow? - const typeParameter = getTypeParameterFromMappedType(type); - // const constraintType = getConstraintTypeFromMappedType(type); - const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter); - - const templateTypeNode = createTypeNode(getTemplateTypeFromMappedType(type)); - const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; - const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; - - // TODO: test. - return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); - } - if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { Debug.assert(!!(type.flags & TypeFlags.Object)); // The type is an object literal type. @@ -2371,57 +2395,25 @@ namespace ts { return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); } - /******** START COPY *********/ - - // function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { - // const globalFlagsToPass = globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike; - // let inObjectTypeLiteral = false; - // return writeType(type, globalFlags); - - // function writeType(type: Type, flags: TypeFormatFlags) { - // // const nextFlags = flags & ~TypeFormatFlags.InTypeAlias; - // // // Write undefined/null type as any - // // if (type.flags & TypeFlags.Intrinsic) { - // // // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving - // // writer.writeKeyword(!(globalFlags & TypeFormatFlags.WriteOwnNameForAnyLike) && isTypeAny(type) - // // ? "any" - // // : (type).intrinsicName); - // // } - // // else if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { - // // if (inObjectTypeLiteral) { - // // writer.reportInaccessibleThisError(); - // // } - // // writer.writeKeyword("this"); - // // } - // else if (getObjectFlags(type) & ObjectFlags.Reference) { - // writeTypeReference(type, nextFlags); - // } - // else if (type.flags & TypeFlags.EnumLiteral) { - // buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); - // writePunctuation(writer, SyntaxKind.DotToken); - // appendSymbolNameOnly(type.symbol, writer); - // } - // else if (getObjectFlags(type) & ObjectFlags.ClassOrInterface || type.flags & (TypeFlags.Enum | TypeFlags.TypeParameter)) { - // // The specified symbol flags need to be reinterpreted as type flags - // buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); - // } - // else if (!(flags & TypeFormatFlags.InTypeAlias) && type.aliasSymbol && - // isSymbolAccessible(type.aliasSymbol, enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) { - // const typeArguments = type.aliasTypeArguments; - // writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, length(typeArguments), nextFlags); - // } - // else if (type.flags & TypeFlags.UnionOrIntersection) { - // writeUnionOrIntersectionType(type, nextFlags); - // } - // else if (getObjectFlags(type) & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { - // writeAnonymousType(type, nextFlags); - // } + // TODO: implement when this is testable. // else if (type.flags & TypeFlags.StringOrNumberLiteral) { // writer.writeStringLiteral(literalTypeToString(type)); - // } - // } - /******** END COPY *********/ + function createMappedTypeNodeFromType(type: MappedType) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + + // TODO: does typeParameter have the same constraint or do we need to overwrite it somehow? + const typeParameter = getTypeParameterFromMappedType(type); + // const constraintType = getConstraintTypeFromMappedType(type); + const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter); + + const templateTypeNode = createTypeNode(getTemplateTypeFromMappedType(type)); + const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; + const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + + // TODO: test. + return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } function createAnonymousTypeNode(type: ObjectType): TypeNode { const symbol = type.symbol; @@ -2439,7 +2431,7 @@ namespace ts { const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - const entityName = getEntityNameFromSymbol(typeAlias, enclosingDeclaration); + const entityName = createNameFromSymbol(typeAlias, enclosingDeclaration); return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); } else { @@ -2453,14 +2445,14 @@ namespace ts { symbolStack = []; } symbolStack.push(symbol); - let result = createTypeLiteralNodeFromType(type); + let result = createTypeNodeFromObjectType(type); symbolStack.pop(); return result; } } else { // Anonymous types with no symbol are never circular - return createTypeLiteralNodeFromType(type); + return createTypeNodeFromObjectType(type); } function shouldWriteTypeOfFunctionSymbol() { @@ -2477,103 +2469,48 @@ namespace ts { } } - function writeLiteralType(type: ObjectType, flags: TypeFormatFlags) { + function createTypeNodeFromObjectType(type: ObjectType): TypeNode { if (type.objectFlags & ObjectFlags.Mapped) { if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { - writeMappedType(type); - return; + return createMappedTypeNodeFromType(type); } } const resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, SyntaxKind.OpenBraceToken); - writePunctuation(writer, SyntaxKind.CloseBraceToken); - return; + return createTypeLiteralNode(/*members*/ undefined); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - const parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); - if (parenthesizeSignature) { - writePunctuation(writer, SyntaxKind.OpenParenToken); - } - buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack); - if (parenthesizeSignature) { - writePunctuation(writer, SyntaxKind.CloseParenToken); - } - return; + const signature = resolved.callSignatures[0]; + const signatureParts = createSignatureParts(signature); + return createSignatureDeclaration(SyntaxKind.FunctionType, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - if (flags & TypeFormatFlags.InElementType) { - writePunctuation(writer, SyntaxKind.OpenParenToken); - } - writeKeyword(writer, SyntaxKind.NewKeyword); - writeSpace(writer); - buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | TypeFormatFlags.WriteArrowStyleSignature, /*kind*/ undefined, symbolStack); - if (flags & TypeFormatFlags.InElementType) { - writePunctuation(writer, SyntaxKind.CloseParenToken); - } - return; + const signature = resolved.constructSignatures[0]; + const signatureParts = createSignatureParts(signature); + return createSignatureDeclaration(SyntaxKind.ConstructorType, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); } } const saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, SyntaxKind.OpenBraceToken); - writer.writeLine(); - writer.increaseIndent(); - writeObjectLiteralType(resolved); - writer.decreaseIndent(); - writePunctuation(writer, SyntaxKind.CloseBraceToken); + const members = createTypeNodesFromResolvedType(resolved); inObjectTypeLiteral = saveInObjectTypeLiteral; - } - - function writeObjectLiteralType(resolved: ResolvedType) { - for (const signature of resolved.callSignatures) { - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - for (const signature of resolved.constructSignatures) { - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, SignatureKind.Construct, symbolStack); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, IndexKind.String, enclosingDeclaration, globalFlags, symbolStack); - buildIndexSignatureDisplay(resolved.numberIndexInfo, writer, IndexKind.Number, enclosingDeclaration, globalFlags, symbolStack); - for (const p of resolved.properties) { - const t = getTypeOfSymbol(p); - if (p.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(t).length) { - const signatures = getSignaturesOfType(t, SignatureKind.Call); - for (const signature of signatures) { - writePropertyWithModifiers(p); - buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - } - else { - writePropertyWithModifiers(p); - writePunctuation(writer, SyntaxKind.ColonToken); - writeSpace(writer); - writeType(t, TypeFormatFlags.None); - writePunctuation(writer, SyntaxKind.SemicolonToken); - writer.writeLine(); - } - } + return createTypeLiteralNode(members); } function createTypeQueryNodeFromType(type: Type) { const symbol = type.symbol; if (symbol) { // TODO: get entity name instead. - const entityName = createIdentifier(symbolToString(symbol)); + const entityName = createNameFromSymbol(symbol); return createTypeQueryNode(entityName); } } - function getEntityNameFromSymbol(symbol: Symbol, enclosingDeclaration: Node): EntityName { + function createNameFromSymbol(symbol: Symbol): EntityName { symbol; enclosingDeclaration; // TODO: actually implement this return createIdentifier(symbolToString(symbol, enclosingDeclaration)); @@ -2636,67 +2573,53 @@ namespace ts { } } - function createTypeLiteralNodeFromType(type: ObjectType) { - const resolvedType = resolveStructuredTypeMembers(type); - const newMembers = createTypeNodesFromResolvedType(resolvedType); - return createTypeLiteralNode(newMembers); - } - function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { const typeElements: TypeElement[] = []; - for(const signature of resolvedType.callSignatures) { - signature; - throw new Error("call signatures not implemented"); + for (const signature of resolvedType.callSignatures) { + const signatureParts = createSignatureParts(signature); + typeElements.push(createSignatureDeclaration(SyntaxKind.CallSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); } for (const signature of resolvedType.constructSignatures) { - signature; - throw new Error("Construct signatures not implemented"); + const signatureParts = createSignatureParts(signature); + typeElements.push(createSignatureDeclaration(SyntaxKind.ConstructSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); } if (resolvedType.stringIndexInfo) { typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.stringIndexInfo, IndexKind.String)); } if (resolvedType.numberIndexInfo) { - typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.stringIndexInfo, IndexKind.Number)); + typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.numberIndexInfo, IndexKind.Number)); } - const members = resolvedType.members; + const properties = resolvedType.properties; + if (!properties) { + return typeElements; + } - members.forEach(memberSymbol => { - const oldDeclaration = memberSymbol.declarations && memberSymbol.declarations[0] as TypeElement; + for (const propertySymbol of properties) { + const propertyType = getTypeOfSymbol(propertySymbol); + const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; if (!oldDeclaration) { return; } - - const kind = oldDeclaration.kind; - const memberName = getSynthesizedDeepClone(oldDeclaration.name); - const memberType = getTypeOfSymbol(memberSymbol); - - switch (kind) { - case SyntaxKind.PropertySignature: - const optional = !!oldDeclaration.questionToken; - typeElements.push(createPropertySignature( - memberName - , optional ? createToken(SyntaxKind.QuestionToken) : undefined - , createTypeNode(memberType) - , /*initializer*/undefined)); - break; - case SyntaxKind.MethodSignature: - case SyntaxKind.CallSignature: - case SyntaxKind.ConstructSignature: - const signatureType = getSignaturesOfSymbol(memberSymbol); - signatureType - createSignatureDeclaration - throw new Error("signature problems."); - // name ?: PropertyName; - // typeParameters ?: NodeArray; - // parameters: NodeArray; - // type ?: TypeNode; - case SyntaxKind.IndexSignature: - throw new Error("type literal constituent not implemented."); - default: - throw new Error("Unknown resolved member kind."); + const propertyName = getSynthesizedDeepClone(oldDeclaration.name); + const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;; + if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { + const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); + for (const signature of signatures) { + const signatureParts = createSignatureParts(signature); + const methodDeclaration = createSignatureDeclaration(SyntaxKind.MethodSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type, propertyName, optionalToken); + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } } - }); + else { + typeElements.push(createPropertySignature( + propertyName + , optionalToken + , createTypeNode(propertyType) + , /*initializer*/undefined)); + } + } return typeElements.length ? typeElements : undefined; } } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index ebb4bbe5a9a..d91076dcde2 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -394,29 +394,37 @@ namespace ts { : node; } - export function createSignatureDeclaration(kind: SyntaxKind, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { + // TODO: ask if we should have multiple implementations. Some T's can't have question token. + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): T; + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): T; + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name?: string | PropertyName, questionToken?: QuestionToken): T { const signatureDeclaration = createSynthesizedNode(kind) as T; - signatureDeclaration.name = asName(name); signatureDeclaration.typeParameters = asNodeArray(typeParameters); signatureDeclaration.parameters = asNodeArray(parameters); signatureDeclaration.type = type; + signatureDeclaration.name = asName(name); + signatureDeclaration.questionToken = questionToken; return signatureDeclaration; } - export function updateSignatureDeclaration(node: T, name: string | PropertyName | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { - return node.name !== name - || node.typeParameters !== typeParameters + // TODO: figure out right type annotation for this function. + export function updateSignatureDeclaration(node: T, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T; + export function updateSignatureDeclaration(node: T, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): T; + export function updateSignatureDeclaration(node: T, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name?: PropertyName, questionToken?: QuestionToken): T { + return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateNode(createSignatureDeclaration(node.kind, name, typeParameters, parameters, type), node) + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type, name, questionToken), node) : node; } // Signature elements - export function createPropertySignature(name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature { + export function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature { const propertySignature = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; - propertySignature.name = name; + propertySignature.name = asName(name); propertySignature.questionToken = questionToken; propertySignature.type = type; propertySignature.initializer = initializer; @@ -511,12 +519,13 @@ namespace ts { : node; } - export function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + export function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.MethodDeclaration); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); + node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); node.parameters = asNodeArray(parameters); node.type = type; @@ -524,7 +533,7 @@ namespace ts { return node; } - export function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + export function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { return node.decorators !== decorators || node.modifiers !== modifiers || node.asteriskToken !== asteriskToken @@ -533,7 +542,7 @@ namespace ts { || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7f6c56aa1ff..acca1b7398c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2474,6 +2474,8 @@ namespace ts { createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration; /** Note that the resulting type node cannot be checked. */ createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration + /** Note that the resulting type node cannot be checked. */ + createParameterDeclarationFromSymbol(parameterSymbol: Symbol): ParameterDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index afe236859a4..5d63126ad0a 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -245,6 +245,8 @@ namespace ts { case SyntaxKind.EmptyStatement: case SyntaxKind.OmittedExpression: case SyntaxKind.DebuggerStatement: + case SyntaxKind.EndOfDeclarationMarker: + case SyntaxKind.MissingDeclaration: // No need to visit nodes with no children. return node; @@ -260,18 +262,25 @@ namespace ts { // Signatures and Signature Elements case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: - case SyntaxKind.MethodSignature: return updateSignatureDeclaration(node - , visitNode((node).name, visitor, isPropertyName) , nodesVisitor((node).typeParameters, visitor, isTypeParameter) - , nodesVisitor((node).parameters, visitor, isParameter) + , visitParameterList((node).parameters, visitor, context, nodesVisitor) , visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.MethodSignature: + return updateSignatureDeclaration(node + , nodesVisitor((node).typeParameters, visitor, isTypeParameter) + , visitParameterList((node).parameters, visitor, context, nodesVisitor) + , visitNode((node).type, visitor, isTypeNode) + , visitNode((node).name, visitor, isPropertyName) + , visitNode((node).questionToken, visitor, isToken)); + case SyntaxKind.IndexSignature: return updateIndexSignatureDeclaration(node - , nodesVisitor((node).parameters, visitor) + , visitParameterList((node).parameters, visitor, context, nodesVisitor) , visitNode((node).type, visitor, isTypeNode) , nodesVisitor((node).decorators, visitor, isDecorator) , nodesVisitor((node).modifiers, visitor, isModifier)); @@ -290,47 +299,32 @@ namespace ts { return updateDecorator(node, visitNode((node).expression, visitor, isExpression)); - // Keyword Types and This - - case SyntaxKind.AnyKeyword: - case SyntaxKind.NumberKeyword: - case SyntaxKind.ObjectKeyword: - case SyntaxKind.BooleanKeyword: - case SyntaxKind.StringKeyword: - case SyntaxKind.SymbolKeyword: - case SyntaxKind.VoidKeyword: - case SyntaxKind.UndefinedKeyword: - case SyntaxKind.NullKeyword: - case SyntaxKind.NeverKeyword: - case SyntaxKind.NeverKeyword: - case SyntaxKind.ThisKeyword: - throw new Error("should be caught above"); - // Types case SyntaxKind.TypePredicate: throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeReference: return updateTypeReferenceNode(node - , visitNode((node).typeName, visitor, isEntityName) - , nodesVisitor((node).typeArguments, visitor, isTypeNode)); + , visitNode((node).typeName, visitor, isEntityName) + , nodesVisitor((node).typeArguments, visitor, isTypeNode)); - case SyntaxKind.FunctionType: - throw new Error("reached unsupported type in visitor."); - case SyntaxKind.ConstructorType: - throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeQuery: return updateTypeQueryNode((node), visitNode((node).exprName, visitor, isEntityName)); + case SyntaxKind.TypeLiteral: return updateTypeLiteralNode((node), nodesVisitor((node).members, visitor)); + case SyntaxKind.ArrayType: return updateArrayTypeNode(node, visitNode((node).elementType, visitor, isTypeNode)); + case SyntaxKind.TupleType: return updateTypleTypeNode((node), nodesVisitor((node).elementTypes, visitor, isTypeNode)); + case SyntaxKind.UnionType: case SyntaxKind.IntersectionType: return updateUnionOrIntersectionTypeNode(node - , nodesVisitor((node).types, visitor, isTypeNode)); + , nodesVisitor((node).types, visitor, isTypeNode)); + case SyntaxKind.ParenthesizedType: throw new Error("reached unsupported type in visitor."); case SyntaxKind.ThisType: @@ -366,7 +360,7 @@ namespace ts { case SyntaxKind.IndexSignature: return updateIndexSignatureDeclaration(node - , nodesVisitor((node).parameters, visitor, isParameter) + , visitParameterList((node).parameters, visitor, context, nodesVisitor) , visitNode((node).type, visitor, isTypeNode) , nodesVisitor((node).decorators, visitor, isDecorator) , nodesVisitor((node).modifiers, visitor, isModifier)); @@ -383,8 +377,9 @@ namespace ts { return updateMethod(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - (node).asteriskToken, + visitNode((node).asteriskToken, visitor, isToken), visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, visitor, isToken), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), @@ -857,8 +852,7 @@ namespace ts { visitNode((node).expression, visitor, isExpression)); default: - throw new Error("not handled"); - // return node; + return node; } } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 37ea8bab1a9..e98235c3c8b 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -85,56 +85,66 @@ namespace ts.codefix { if (!(signatures && signatures.length > 0)) { return undefined; } + + const optional = !!(symbol.flags & SymbolFlags.Optional); if (declarations.length === 1) { Debug.assert(signatures.length === 1); // TODO: suppress any return type // TODO: get parameters working. // TODO: add support for type parameters. const signature = signatures[0]; - const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); - const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - - const returnType = createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker); - return createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType); + const signatureParts = getSignatureParts(signature); + return createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); } let signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { // TODO: make signatures instead of methods const signature = signatures[i]; - const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); - const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker); + const signatureParts = getSignatureParts(signature); signatureDeclarations.push(createMethod( /*decorators*/ undefined , modifiers , /*asteriskToken*/ undefined , name - , newTypeParameters - , newParameterNodes - , returnType + , optional ? createToken(SyntaxKind.QuestionToken) : undefined + , signatureParts.typeParameters + , signatureParts.parameters + , signatureParts.type , /*body*/undefined)); } if (declarations.length > signatures.length) { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); - const newTypeParameters = signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType); - const newParameterNodes = signature.getParameters().map(symbol => createParameterDeclarationFromSymbol(symbol, enclosingDeclaration, checker)); - const returnType = createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker); - signatureDeclarations.push(createStubbedMethod(modifiers, name, newTypeParameters, newParameterNodes, returnType)); + const signatureParts = getSignatureParts(signature); + signatureDeclarations.push(createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); } else { Debug.assert(declarations.length === signatures.length); - const methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, modifiers); + const methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, optional, modifiers); signatureDeclarations.push(methodImplementingSignatures); } return signatureDeclarations; default: return undefined; } + + type SignatureParts = { + typeParameters: TypeParameterDeclaration[]; + parameters: ParameterDeclaration[]; + type: TypeNode; + } + + function getSignatureParts(signature: Signature): SignatureParts { + return { + typeParameters: signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType), + parameters: signature.getParameters().map(symbol => checker.createParameterDeclarationFromSymbol(symbol)), + type: createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker) + } + } } - function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, modifiers: Modifier[] | undefined): MethodDeclaration { + function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration { Debug.assert(signatures && signatures.length > 0); let maxArgsIndex = 0; @@ -153,7 +163,7 @@ namespace ts.codefix { maxArgsSignature = sig; } } - const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName()); const parameters: ParameterDeclaration[] = []; @@ -186,17 +196,19 @@ namespace ts.codefix { return createStubbedMethod( modifiers , name + , optional , /*typeParameters*/undefined , parameters , /*returnType*/ undefined); } - export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { + export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { return createMethod( /*decorators*/undefined , modifiers , /*asteriskToken*/undefined , name + , optional ? createToken(SyntaxKind.QuestionToken) : undefined , typeParameters , parameters , returnType @@ -223,22 +235,6 @@ namespace ts.codefix { return undefined; } - function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: ClassLikeDeclaration, checker: TypeChecker) { - const parameterDeclaration = parameterSymbol.getDeclarations()[0] as ParameterDeclaration; - const parameterType = checker.getTypeOfSymbolAtLocation(parameterSymbol, enclosingDeclaration); - const parameterTypeNode = checker.createTypeNode(parameterType); - // TODO: deep cloning of decorators/any node. - const parameterNode = createParameter( - parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedDeepClone) - , parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedDeepClone) - , parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken) - , getSynthesizedDeepClone(parameterDeclaration.name) - , parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken) - , parameterTypeNode - , /*initializer*/ undefined); - return parameterNode; - } - function createTypeNodeExceptAny(type: Type, checker: TypeChecker) { const typeNode = checker.createTypeNode(type); return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; From 69587a286afeebe2fa6456e1e8d99b214a3a26a1 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 16:41:38 -0700 Subject: [PATCH 126/207] transformers tests --- src/compiler/transformers/es2017.ts | 1 + src/compiler/transformers/esnext.ts | 1 + src/compiler/transformers/ts.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 31aae5055a0..9c7bcf5b2ae 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -125,6 +125,7 @@ namespace ts { visitNodes(node.modifiers, visitor, isModifier), node.asteriskToken, node.name, + node.questionToken, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index f66bf14da53..2475e511196 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -541,6 +541,7 @@ namespace ts { ? undefined : node.asteriskToken, visitNode(node.name, visitor, isPropertyName), + visitNode(node.questionToken, visitor, isToken), /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 885f8fad898..bbc588ee9fe 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2049,6 +2049,7 @@ namespace ts { visitNodes(node.modifiers, modifierVisitor, isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), + node.questionToken, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, From 41e511efd24dd0f2d143b99121ff0cc261478511 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 16:51:18 -0700 Subject: [PATCH 127/207] fix call --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7545430717e..294c4991286 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2431,7 +2431,7 @@ namespace ts { const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - const entityName = createNameFromSymbol(typeAlias, enclosingDeclaration); + const entityName = createNameFromSymbol(typeAlias); return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); } else { From a88be7c6f9c93b686562519ef59ecd413bdbcec3 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 16:59:01 -0700 Subject: [PATCH 128/207] consolidate SignatureParts --- src/compiler/checker.ts | 10 +--------- src/compiler/types.ts | 18 +++++++++++------- src/services/codefixes/helpers.ts | 25 +++---------------------- 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 294c4991286..4ccc8f84de9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -107,9 +107,8 @@ namespace ts { getReturnTypeOfSignature, getNonNullableType, createTypeNode, - createTypeParameterDeclarationFromType, createIndexSignatureFromIndexInfo, - createParameterDeclarationFromSymbol, + createSignatureParts, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2222,13 +2221,6 @@ namespace ts { return parameterNode; } - /* @internal */ - type SignatureParts = { - typeParameters: TypeParameterDeclaration[] | undefined; - parameters: ParameterDeclaration[]; - type: TypeNode; - } - // TODO: expose this, remove copy from helper, possibly don't expose createParameter/TypeParameter? function createSignatureParts(signature: Signature): SignatureParts { return { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index acca1b7398c..679e11fa255 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2468,14 +2468,12 @@ namespace ts { /* @internal */ getParameterType(signature: Signature, parameterIndex: number): Type; getNonNullableType(type: Type): Type; - /** Note that the resulting type node cannot be checked. */ + /** Note that the resulting nodes cannot be checked. */ createTypeNode(type: Type): TypeNode; - /** Note that the resulting type node cannot be checked. */ - createTypeParameterDeclarationFromType(type: Type): TypeParameterDeclaration; - /** Note that the resulting type node cannot be checked. */ - createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration - /** Note that the resulting type node cannot be checked. */ - createParameterDeclarationFromSymbol(parameterSymbol: Symbol): ParameterDeclaration; + /** Note that the resulting nodes cannot be checked. */ + createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration; + /** Note that the resulting nodes cannot be checked. */ + createSignatureParts(signature: Signature): SignatureParts; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -3230,6 +3228,12 @@ namespace ts { declaration?: SignatureDeclaration; } + export interface SignatureParts { + typeParameters: TypeParameterDeclaration[] | undefined; + parameters: ParameterDeclaration[]; + type: TypeNode; + } + /* @internal */ export interface TypeMapper { (t: TypeParameter): Type; diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index e98235c3c8b..a8347cb0a9b 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -93,7 +93,7 @@ namespace ts.codefix { // TODO: get parameters working. // TODO: add support for type parameters. const signature = signatures[0]; - const signatureParts = getSignatureParts(signature); + const signatureParts = checker.createSignatureParts(signature); return createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); } @@ -101,7 +101,7 @@ namespace ts.codefix { for (let i = 0; i < signatures.length; i++) { // TODO: make signatures instead of methods const signature = signatures[i]; - const signatureParts = getSignatureParts(signature); + const signatureParts = checker.createSignatureParts(signature); signatureDeclarations.push(createMethod( /*decorators*/ undefined , modifiers @@ -116,7 +116,7 @@ namespace ts.codefix { if (declarations.length > signatures.length) { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); - const signatureParts = getSignatureParts(signature); + const signatureParts = checker.createSignatureParts(signature); signatureDeclarations.push(createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); } else { @@ -128,20 +128,6 @@ namespace ts.codefix { default: return undefined; } - - type SignatureParts = { - typeParameters: TypeParameterDeclaration[]; - parameters: ParameterDeclaration[]; - type: TypeNode; - } - - function getSignatureParts(signature: Signature): SignatureParts { - return { - typeParameters: signature.typeParameters && signature.typeParameters.map(checker.createTypeParameterDeclarationFromType), - parameters: signature.getParameters().map(symbol => checker.createParameterDeclarationFromSymbol(symbol)), - type: createTypeNodeExceptAny(checker.getReturnTypeOfSignature(signature), checker) - } - } } function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration { @@ -234,9 +220,4 @@ namespace ts.codefix { } return undefined; } - - function createTypeNodeExceptAny(type: Type, checker: TypeChecker) { - const typeNode = checker.createTypeNode(type); - return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; - } } \ No newline at end of file From 7318c2c5a9a0a559ab27b5584dd4025d546f33d5 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 17:18:28 -0700 Subject: [PATCH 129/207] some cleanup --- src/compiler/checker.ts | 49 ++++++++----------- src/compiler/factory.ts | 10 +--- ...lassImplementInterfaceNamespaceConflict.ts | 3 +- 3 files changed, 24 insertions(+), 38 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4ccc8f84de9..7af5b877b53 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2327,22 +2327,22 @@ namespace ts { if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); // TODO: Detect whether class is named and fail if not. - const name = getNameOfSymbol(type.symbol); + const name = createNameFromSymbol(type.symbol); // TODO: handle type arguments. return createTypeReferenceNode(name, /*typeParameters*/undefined); } if (type.flags & TypeFlags.TypeParameter) { // TODO: get qualified name when necessary instead of string. - const name = symbolToString(type.symbol); + const name = createNameFromSymbol(type.symbol); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } // TODO: move back up later on? if (checkAlias && type.aliasSymbol) { - const name = getNameOfSymbol(type.aliasSymbol); + const name = createNameFromSymbol(type.aliasSymbol); const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(createIdentifier(name), typeArgumentNodes); + return createTypeReferenceNode(name, typeArgumentNodes); } checkAlias = false; @@ -2357,15 +2357,12 @@ namespace ts { if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { Debug.assert(!!(type.flags & TypeFlags.Object)); // The type is an object literal type. - if (!type.symbol) { - // Anonymous types without symbols are literals. - // TODO: handle this case correctly. - // TODO: test. - noop(); - } - return createAnonymousTypeNode(type); } + + // TODO: implement when this is testable. + // else if (type.flags & TypeFlags.StringOrNumberLiteral) { + // writer.writeStringLiteral(literalTypeToString(type)); if (type.flags & TypeFlags.Index) { // TODO: test. @@ -2382,14 +2379,17 @@ namespace ts { Debug.fail("Should be unreachable."); - /** Note that mapToTypeNodeArray(undefined) === undefined. */ function mapToTypeNodeArray(types: Type[]): NodeArray { - return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); + return types && asNodeArray(types.map(createTypeNodeWorker) as TypeNode[]); } - // TODO: implement when this is testable. - // else if (type.flags & TypeFlags.StringOrNumberLiteral) { - // writer.writeStringLiteral(literalTypeToString(type)); + function createNameFromSymbol(symbol: Symbol): Identifier; + function createNameFromSymbol(symbol: Symbol): EntityName; + function createNameFromSymbol(symbol: Symbol): EntityName { + symbol; enclosingDeclaration; + // TODO: actually implement this + return createIdentifier(symbolToString(symbol, enclosingDeclaration)); + } function createMappedTypeNodeFromType(type: MappedType) { Debug.assert(!!(type.flags & TypeFlags.Object)); @@ -2414,8 +2414,6 @@ namespace ts { if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || shouldWriteTypeOfFunctionSymbol()) { - // TODO: test. - // TODO: get entity name from symbol. return createTypeQueryNodeFromType(type); } else if (contains(symbolStack, symbol)) { @@ -2443,7 +2441,7 @@ namespace ts { } } else { - // Anonymous types with no symbol are never circular + // Anonymous types without a symbol are never circular. return createTypeNodeFromObjectType(type); } @@ -2496,18 +2494,11 @@ namespace ts { function createTypeQueryNodeFromType(type: Type) { const symbol = type.symbol; if (symbol) { - // TODO: get entity name instead. const entityName = createNameFromSymbol(symbol); return createTypeQueryNode(entityName); } } - function createNameFromSymbol(symbol: Symbol): EntityName { - symbol; enclosingDeclaration; - // TODO: actually implement this - return createIdentifier(symbolToString(symbol, enclosingDeclaration)); - } - function createTypeReferenceNodeFromType(type: TypeReference) { const typeArguments: Type[] = type.typeArguments || emptyArray; if (type.target === globalArrayType) { @@ -2535,8 +2526,8 @@ namespace ts { // the default outer type arguments), we don't show the group. // TODO: figure out how to handle type arguments if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const name = symbolToString(parent); - const qualifiedNamePart = createIdentifier(name); // createTypeReferenceNode(name, mapToTypeNodeArray(typeArguments.slice(start, i - start))); + const name = createNameFromSymbol(parent); + const qualifiedNamePart = name; // createTypeReferenceNode(name, mapToTypeNodeArray(typeArguments.slice(start, i - start))); if (!qualifiedName) { qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/undefined); } @@ -2549,7 +2540,7 @@ namespace ts { } } let entityName: EntityName = undefined; - const nameIdentifier = createIdentifier(symbolToString(type.symbol)); + const nameIdentifier = createNameFromSymbol(type.symbol); if (qualifiedName) { // TODO: handle checking of type arguments for qualified names? Debug.assert(!qualifiedName.right); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index d91076dcde2..e60ed0009e5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -68,18 +68,12 @@ namespace ts { } /* @internal */ - /** - * Note this implementation is inefficient in that all nodes except leaves are cloned twice, - * First by the explicit call below and then again as part of updateNode. - * We need to clone before visiting the children because otherwise updateNode - * will overwrite the synthesized span with the original node's span. - */ export function getSynthesizedDeepClone(node: T | undefined): T { if (node === undefined) { return undefined; } - const clone = getSynthesizedClone(node); - return visitEachChild(clone, getSynthesizedDeepClone, nullTransformationContext); + const clone = visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext); + return clone === node ? getSynthesizedClone(node) : clone; } // Literals diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts index 4ca42640c2c..b8b389c4631 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts @@ -3,14 +3,15 @@ //// namespace N1 { //// export interface I1 { //// x: number; +//// y: I1; //// } //// } //// interface I1 { //// f1(); //// } -//// //// class C1 implements N1.I1 {[| |]} verify.rangeAfterCodeFix(` x: number; +y: N1.I1; `); \ No newline at end of file From 28df2ab2df340d343a477e467f8ce4721d83e47d Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 17:21:12 -0700 Subject: [PATCH 130/207] some cleanup --- src/compiler/checker.ts | 49 +++++++++++++++++------------------------ src/compiler/factory.ts | 10 ++------- 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4ccc8f84de9..7af5b877b53 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2327,22 +2327,22 @@ namespace ts { if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); // TODO: Detect whether class is named and fail if not. - const name = getNameOfSymbol(type.symbol); + const name = createNameFromSymbol(type.symbol); // TODO: handle type arguments. return createTypeReferenceNode(name, /*typeParameters*/undefined); } if (type.flags & TypeFlags.TypeParameter) { // TODO: get qualified name when necessary instead of string. - const name = symbolToString(type.symbol); + const name = createNameFromSymbol(type.symbol); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } // TODO: move back up later on? if (checkAlias && type.aliasSymbol) { - const name = getNameOfSymbol(type.aliasSymbol); + const name = createNameFromSymbol(type.aliasSymbol); const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(createIdentifier(name), typeArgumentNodes); + return createTypeReferenceNode(name, typeArgumentNodes); } checkAlias = false; @@ -2357,15 +2357,12 @@ namespace ts { if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { Debug.assert(!!(type.flags & TypeFlags.Object)); // The type is an object literal type. - if (!type.symbol) { - // Anonymous types without symbols are literals. - // TODO: handle this case correctly. - // TODO: test. - noop(); - } - return createAnonymousTypeNode(type); } + + // TODO: implement when this is testable. + // else if (type.flags & TypeFlags.StringOrNumberLiteral) { + // writer.writeStringLiteral(literalTypeToString(type)); if (type.flags & TypeFlags.Index) { // TODO: test. @@ -2382,14 +2379,17 @@ namespace ts { Debug.fail("Should be unreachable."); - /** Note that mapToTypeNodeArray(undefined) === undefined. */ function mapToTypeNodeArray(types: Type[]): NodeArray { - return asNodeArray(types && types.map(createTypeNodeWorker) as TypeNode[]); + return types && asNodeArray(types.map(createTypeNodeWorker) as TypeNode[]); } - // TODO: implement when this is testable. - // else if (type.flags & TypeFlags.StringOrNumberLiteral) { - // writer.writeStringLiteral(literalTypeToString(type)); + function createNameFromSymbol(symbol: Symbol): Identifier; + function createNameFromSymbol(symbol: Symbol): EntityName; + function createNameFromSymbol(symbol: Symbol): EntityName { + symbol; enclosingDeclaration; + // TODO: actually implement this + return createIdentifier(symbolToString(symbol, enclosingDeclaration)); + } function createMappedTypeNodeFromType(type: MappedType) { Debug.assert(!!(type.flags & TypeFlags.Object)); @@ -2414,8 +2414,6 @@ namespace ts { if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || shouldWriteTypeOfFunctionSymbol()) { - // TODO: test. - // TODO: get entity name from symbol. return createTypeQueryNodeFromType(type); } else if (contains(symbolStack, symbol)) { @@ -2443,7 +2441,7 @@ namespace ts { } } else { - // Anonymous types with no symbol are never circular + // Anonymous types without a symbol are never circular. return createTypeNodeFromObjectType(type); } @@ -2496,18 +2494,11 @@ namespace ts { function createTypeQueryNodeFromType(type: Type) { const symbol = type.symbol; if (symbol) { - // TODO: get entity name instead. const entityName = createNameFromSymbol(symbol); return createTypeQueryNode(entityName); } } - function createNameFromSymbol(symbol: Symbol): EntityName { - symbol; enclosingDeclaration; - // TODO: actually implement this - return createIdentifier(symbolToString(symbol, enclosingDeclaration)); - } - function createTypeReferenceNodeFromType(type: TypeReference) { const typeArguments: Type[] = type.typeArguments || emptyArray; if (type.target === globalArrayType) { @@ -2535,8 +2526,8 @@ namespace ts { // the default outer type arguments), we don't show the group. // TODO: figure out how to handle type arguments if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const name = symbolToString(parent); - const qualifiedNamePart = createIdentifier(name); // createTypeReferenceNode(name, mapToTypeNodeArray(typeArguments.slice(start, i - start))); + const name = createNameFromSymbol(parent); + const qualifiedNamePart = name; // createTypeReferenceNode(name, mapToTypeNodeArray(typeArguments.slice(start, i - start))); if (!qualifiedName) { qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/undefined); } @@ -2549,7 +2540,7 @@ namespace ts { } } let entityName: EntityName = undefined; - const nameIdentifier = createIdentifier(symbolToString(type.symbol)); + const nameIdentifier = createNameFromSymbol(type.symbol); if (qualifiedName) { // TODO: handle checking of type arguments for qualified names? Debug.assert(!qualifiedName.right); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index d91076dcde2..e60ed0009e5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -68,18 +68,12 @@ namespace ts { } /* @internal */ - /** - * Note this implementation is inefficient in that all nodes except leaves are cloned twice, - * First by the explicit call below and then again as part of updateNode. - * We need to clone before visiting the children because otherwise updateNode - * will overwrite the synthesized span with the original node's span. - */ export function getSynthesizedDeepClone(node: T | undefined): T { if (node === undefined) { return undefined; } - const clone = getSynthesizedClone(node); - return visitEachChild(clone, getSynthesizedDeepClone, nullTransformationContext); + const clone = visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext); + return clone === node ? getSynthesizedClone(node) : clone; } // Literals From 621c04479077badda6ac777a160db67224b86c8b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 17:22:57 -0700 Subject: [PATCH 131/207] remove test --- ...xClassImplementInterfaceNamespaceConflict.ts | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts deleted file mode 100644 index b8b389c4631..00000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts +++ /dev/null @@ -1,17 +0,0 @@ -/// - -//// namespace N1 { -//// export interface I1 { -//// x: number; -//// y: I1; -//// } -//// } -//// interface I1 { -//// f1(); -//// } -//// class C1 implements N1.I1 {[| |]} - -verify.rangeAfterCodeFix(` -x: number; -y: N1.I1; -`); \ No newline at end of file From dee9ced0608f847962d3c4352608847fa021f898 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 18:02:34 -0700 Subject: [PATCH 132/207] add tests --- .../codeFixClassImplementInterfaceArrayTuple.ts | 15 +++++++++++++++ ...FixClassImplementInterfaceNamespaceConflict.ts | 15 +++++++++++++++ ...codeFixClassImplementInterfaceQualifiedName.ts | 12 ++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts new file mode 100644 index 00000000000..4550e5ca31a --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceArrayTuple.ts @@ -0,0 +1,15 @@ +/// + +//// interface I { +//// x: number[]; +//// y: Array; +//// z: [number, string, I]; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +x: number[]; +y: number[]; +z: [number, string, I]; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts new file mode 100644 index 00000000000..1d71ce3c470 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceNamespaceConflict.ts @@ -0,0 +1,15 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// x: number; +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// class C1 implements N1.I1 {[| |]} + +verify.rangeAfterCodeFix(` +x: number; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts new file mode 100644 index 00000000000..e29f4501b18 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceQualifiedName.ts @@ -0,0 +1,12 @@ +/// + +//// namespace N { +//// export interface I { +//// y: I; +//// } +//// } +//// class C1 implements N.I {[| |]} + +verify.rangeAfterCodeFix(` +y: N.I; +`); \ No newline at end of file From 4fa32a29ce42761f9a20172aad47d3bb60ed11b8 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 16 Mar 2017 18:02:57 -0700 Subject: [PATCH 133/207] make enclosingdeclaration arg required --- src/compiler/checker.ts | 54 ++++++++----------- src/compiler/types.ts | 6 +-- src/services/codefixes/fixAddMissingMember.ts | 2 +- .../fixClassIncorrectlyImplementsInterface.ts | 14 ++--- src/services/codefixes/helpers.ts | 11 ++-- 5 files changed, 38 insertions(+), 49 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7af5b877b53..960a36e3476 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2191,23 +2191,23 @@ namespace ts { return result; } - function createTypeParameterDeclarationFromType(type: TypeParameter): TypeParameterDeclaration { + function createTypeParameterDeclarationFromType(type: TypeParameter, enclosingDeclaration: Node): TypeParameterDeclaration { if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { return undefined; } - const constraint = createTypeNode(getConstraintFromTypeParameter(type)) as TypeNode; - const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type)) as TypeNode; + const constraint = createTypeNode(getConstraintFromTypeParameter(type), enclosingDeclaration); + const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type), enclosingDeclaration); const name = symbolToString(type.symbol); return createTypeParameterDeclaration(name, constraint, defaultParameter); } // TODO: enclosing declaration appears to be unused in getTypeOfSymbolAtLocation - function createParameterDeclarationFromSymbol(parameterSymbol: Symbol): ParameterDeclaration { + function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: Node): ParameterDeclaration { const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; const parameterType = getTypeOfSymbol(parameterSymbol); - const parameterTypeNode = checker.createTypeNode(parameterType); + const parameterTypeNode = createTypeNode(parameterType, enclosingDeclaration); // TODO: clone binding names correctly. // TODO: copy initialzer in a way that checks whether all symbols used in expression are accessible here, and qualify them appropriately. const parameterNode = createParameter( @@ -2222,25 +2222,24 @@ namespace ts { } // TODO: expose this, remove copy from helper, possibly don't expose createParameter/TypeParameter? - function createSignatureParts(signature: Signature): SignatureParts { + function createSignatureParts(signature: Signature, enclosingDeclaration: Node): SignatureParts { return { - typeParameters: signature.typeParameters && signature.typeParameters.map(createTypeParameterDeclarationFromType), - parameters: signature.parameters.map(createParameterDeclarationFromSymbol), + typeParameters: signature.typeParameters && signature.typeParameters.map(parameter => createTypeParameterDeclarationFromType(parameter,enclosingDeclaration)), + parameters: signature.parameters.map(parameter => createParameterDeclarationFromSymbol(parameter,enclosingDeclaration)), type: createTypeNodeExceptAny(getReturnTypeOfSignature(signature)) } function createTypeNodeExceptAny(type: Type): TypeNode | undefined { - const typeNode = createTypeNode(type); + const typeNode = createTypeNode(type, enclosingDeclaration); return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; } } - function createTypeNode(type: Type): TypeNode { + function createTypeNode(type: Type, enclosingDeclaration: Node): TypeNode { let undefinedArgumentIsError = true; let encounteredError = false; let inObjectTypeLiteral = false; let checkAlias = true; - let enclosingDeclaration: Node = undefined; // TODO: add parameter. let symbolStack: Symbol[] = undefined; let result = createTypeNodeWorker(type); @@ -2256,7 +2255,7 @@ namespace ts { return undefined; } - const typeString = typeToString(type); typeString; // TODO: remove. + const typeString = typeToString(type, enclosingDeclaration); typeString; // TODO: remove. if (type.flags & TypeFlags.Any) { // TODO: add other case where type ends up being `any`. @@ -2315,15 +2314,8 @@ namespace ts { if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); - // and vice versa. - // this case includes tuple types - // TODO: test empty tuples, see if they are coherent. return createTypeReferenceNodeFromType(type); } - - if (type.flags & TypeFlags.EnumLiteral) { - throw new Error("Enum literal not implemented"); - } if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); // TODO: Detect whether class is named and fail if not. @@ -2397,9 +2389,9 @@ namespace ts { // TODO: does typeParameter have the same constraint or do we need to overwrite it somehow? const typeParameter = getTypeParameterFromMappedType(type); // const constraintType = getConstraintTypeFromMappedType(type); - const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter); + const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter, enclosingDeclaration); - const templateTypeNode = createTypeNode(getTemplateTypeFromMappedType(type)); + const templateTypeNode = createTypeNode(getTemplateTypeFromMappedType(type), enclosingDeclaration); const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -2474,12 +2466,12 @@ namespace ts { if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { const signature = resolved.callSignatures[0]; - const signatureParts = createSignatureParts(signature); + const signatureParts = createSignatureParts(signature, enclosingDeclaration); return createSignatureDeclaration(SyntaxKind.FunctionType, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { const signature = resolved.constructSignatures[0]; - const signatureParts = createSignatureParts(signature); + const signatureParts = createSignatureParts(signature, enclosingDeclaration); return createSignatureDeclaration(SyntaxKind.ConstructorType, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); } } @@ -2559,18 +2551,18 @@ namespace ts { function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { const typeElements: TypeElement[] = []; for (const signature of resolvedType.callSignatures) { - const signatureParts = createSignatureParts(signature); + const signatureParts = createSignatureParts(signature, enclosingDeclaration); typeElements.push(createSignatureDeclaration(SyntaxKind.CallSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); } for (const signature of resolvedType.constructSignatures) { - const signatureParts = createSignatureParts(signature); + const signatureParts = createSignatureParts(signature, enclosingDeclaration); typeElements.push(createSignatureDeclaration(SyntaxKind.ConstructSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); } if (resolvedType.stringIndexInfo) { - typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.stringIndexInfo, IndexKind.String)); + typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration)); } if (resolvedType.numberIndexInfo) { - typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.numberIndexInfo, IndexKind.Number)); + typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration)); } const properties = resolvedType.properties; @@ -2589,7 +2581,7 @@ namespace ts { if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); for (const signature of signatures) { - const signatureParts = createSignatureParts(signature); + const signatureParts = createSignatureParts(signature, enclosingDeclaration); const methodDeclaration = createSignatureDeclaration(SyntaxKind.MethodSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type, propertyName, optionalToken); methodDeclaration.questionToken = optionalToken; typeElements.push(methodDeclaration); @@ -2599,7 +2591,7 @@ namespace ts { typeElements.push(createPropertySignature( propertyName , optionalToken - , createTypeNode(propertyType) + , createTypeNodeWorker(propertyType) , /*initializer*/undefined)); } } @@ -2608,7 +2600,7 @@ namespace ts { } } - function createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration { + function createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration { const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); const name = getNameFromIndexInfo(indexInfo); @@ -2620,7 +2612,7 @@ namespace ts { , /*questionToken*/ undefined , indexerTypeNode , /*initializer*/ undefined); - const typeNode = createTypeNode(indexInfo.type); + const typeNode = createTypeNode(indexInfo.type, enclosingDeclaration); return createIndexSignatureDeclaration( [indexingParameter] , typeNode diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 679e11fa255..d802adf67ec 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2469,11 +2469,11 @@ namespace ts { getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - createTypeNode(type: Type): TypeNode; + createTypeNode(type: Type, enclosingDeclaration: Node): TypeNode; /** Note that the resulting nodes cannot be checked. */ - createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration; + createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration; /** Note that the resulting nodes cannot be checked. */ - createSignatureParts(signature: Signature): SignatureParts; + createSignatureParts(signature: Signature, enclosingDeclaration: Node): SignatureParts; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index ace11cda807..ab973bb5772 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -38,7 +38,7 @@ namespace ts.codefix { const checker = context.program.getTypeChecker(); const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); - typeNode = checker.createTypeNode(widenedType) || typeNode; + typeNode = checker.createTypeNode(widenedType, classDeclaration) || typeNode; } const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 33b4a10dffc..de34676eda0 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -11,14 +11,14 @@ namespace ts.codefix { const token = getTokenAtPosition(sourceFile, start); const checker = context.program.getTypeChecker(); - const classDecl = getContainingClass(token); - if (!classDecl) { + const classDeclaration = getContainingClass(token); + if (!classDeclaration) { return undefined; } - const openBrace = getOpenBraceOfClassLike(classDecl, sourceFile); - const classType = checker.getTypeAtLocation(classDecl) as InterfaceType; - const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDecl); + const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); + const classType = checker.getTypeAtLocation(classDeclaration) as InterfaceType; + const implementedTypeNodes = getClassImplementsHeritageClauseElements(classDeclaration); const hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.Number); const hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, IndexKind.String); @@ -34,7 +34,7 @@ namespace ts.codefix { let newNodes: Node[] = []; createAndAddMissingIndexSignatureDeclaration(implementedType, IndexKind.Number, hasNumericIndexSignature, newNodes); createAndAddMissingIndexSignatureDeclaration(implementedType, IndexKind.String, hasStringIndexSignature, newNodes); - newNodes = newNodes.concat(createMissingMemberNodes(classDecl, nonPrivateMembers, checker)); + newNodes = newNodes.concat(createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker)); const message = formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); if (newNodes.length > 0) { pushAction(result, newNodes, message); @@ -53,7 +53,7 @@ namespace ts.codefix { if (!indexInfoOfKind) { return undefined; } - const newIndexSignatureDeclaration = checker.createIndexSignatureFromIndexInfo(indexInfoOfKind, kind); + const newIndexSignatureDeclaration = checker.createIndexSignatureFromIndexInfo(indexInfoOfKind, kind, classDeclaration); newNodes.push(newIndexSignatureDeclaration); } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index a8347cb0a9b..8693cc453bb 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -62,7 +62,7 @@ namespace ts.codefix { case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - const typeNode = checker.createTypeNode(type); + const typeNode = checker.createTypeNode(type, enclosingDeclaration); // TODO: add modifiers. const property = createProperty( /*decorators*/undefined @@ -89,11 +89,8 @@ namespace ts.codefix { const optional = !!(symbol.flags & SymbolFlags.Optional); if (declarations.length === 1) { Debug.assert(signatures.length === 1); - // TODO: suppress any return type - // TODO: get parameters working. - // TODO: add support for type parameters. const signature = signatures[0]; - const signatureParts = checker.createSignatureParts(signature); + const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); return createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); } @@ -101,7 +98,7 @@ namespace ts.codefix { for (let i = 0; i < signatures.length; i++) { // TODO: make signatures instead of methods const signature = signatures[i]; - const signatureParts = checker.createSignatureParts(signature); + const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); signatureDeclarations.push(createMethod( /*decorators*/ undefined , modifiers @@ -116,7 +113,7 @@ namespace ts.codefix { if (declarations.length > signatures.length) { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); - const signatureParts = checker.createSignatureParts(signature); + const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); signatureDeclarations.push(createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); } else { From 2ff19f492b762b022d46c575a0c35f1d8cb15f06 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 17 Mar 2017 11:22:01 -0700 Subject: [PATCH 134/207] Update the logo to the one which our website uses. --- doc/logo.svg | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/doc/logo.svg b/doc/logo.svg index fc7e0fadd66..2c0dd017a1b 100644 --- a/doc/logo.svg +++ b/doc/logo.svg @@ -1,15 +1,10 @@ - - - - - - - - - - - - - - - + + + + + \ No newline at end of file From ac7fc8fe75af8b0bc062fa67ebbe3d8692933545 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 17 Mar 2017 11:54:51 -0700 Subject: [PATCH 135/207] Handle TODO's --- src/compiler/checker.ts | 113 +++++++++++------- src/compiler/visitor.ts | 13 +- src/services/codefixes/fixAddMissingMember.ts | 1 - src/services/codefixes/helpers.ts | 5 +- ...codeFixClassImplementInterfaceIndexType.ts | 10 ++ ...odeFixClassImplementInterfaceMappedType.ts | 10 ++ 6 files changed, 102 insertions(+), 50 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 960a36e3476..58186560e8b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2203,13 +2203,12 @@ namespace ts { return createTypeParameterDeclaration(name, constraint, defaultParameter); } - // TODO: enclosing declaration appears to be unused in getTypeOfSymbolAtLocation function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: Node): ParameterDeclaration { const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; const parameterType = getTypeOfSymbol(parameterSymbol); const parameterTypeNode = createTypeNode(parameterType, enclosingDeclaration); - // TODO: clone binding names correctly. - // TODO: copy initialzer in a way that checks whether all symbols used in expression are accessible here, and qualify them appropriately. + // TODO: how should we clone members/modifiers? + // TODO: check initializer accessibility correctly. const parameterNode = createParameter( parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedDeepClone) , parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedDeepClone) @@ -2217,11 +2216,10 @@ namespace ts { , getSynthesizedDeepClone(parameterDeclaration.name) , parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken) , parameterTypeNode - , /*initializer*/ undefined); + , parameterDeclaration.initializer && getSynthesizedDeepClone(parameterDeclaration.initializer)); return parameterNode; } - // TODO: expose this, remove copy from helper, possibly don't expose createParameter/TypeParameter? function createSignatureParts(signature: Signature, enclosingDeclaration: Node): SignatureParts { return { typeParameters: signature.typeParameters && signature.typeParameters.map(parameter => createTypeParameterDeclarationFromType(parameter,enclosingDeclaration)), @@ -2242,12 +2240,8 @@ namespace ts { let checkAlias = true; let symbolStack: Symbol[] = undefined; - let result = createTypeNodeWorker(type); - if (result) { - (result).__type_source = type; - (result).__type_source_str = typeToString(type); - } - return result; + const result = createTypeNodeWorker(type); + return encounteredError ? undefined: result; function createTypeNodeWorker(type: Type): TypeNode { if (!type) { @@ -2255,10 +2249,7 @@ namespace ts { return undefined; } - const typeString = typeToString(type, enclosingDeclaration); typeString; // TODO: remove. - if (type.flags & TypeFlags.Any) { - // TODO: add other case where type ends up being `any`. return createKeywordTypeNode(SyntaxKind.AnyKeyword); } if (type.flags & TypeFlags.String) { @@ -2318,19 +2309,16 @@ namespace ts { } if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); - // TODO: Detect whether class is named and fail if not. const name = createNameFromSymbol(type.symbol); // TODO: handle type arguments. - return createTypeReferenceNode(name, /*typeParameters*/undefined); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (type.flags & TypeFlags.TypeParameter) { - // TODO: get qualified name when necessary instead of string. const name = createNameFromSymbol(type.symbol); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } - // TODO: move back up later on? if (checkAlias && type.aliasSymbol) { const name = createNameFromSymbol(type.aliasSymbol); const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); @@ -2352,18 +2340,14 @@ namespace ts { return createAnonymousTypeNode(type); } - // TODO: implement when this is testable. - // else if (type.flags & TypeFlags.StringOrNumberLiteral) { - // writer.writeStringLiteral(literalTypeToString(type)); + // TODO (aozgaa): implement string and number literals here once there is a testable case. if (type.flags & TypeFlags.Index) { - // TODO: test. - const indexType = getIndexType(getApparentType((type).type)); - const indexTypeNode = createTypeNodeWorker(indexType); + const indexedType = (type).type; + const indexTypeNode = createTypeNodeWorker(indexedType); return createTypeOperatorNode(indexTypeNode); } if (type.flags & TypeFlags.IndexedAccess) { - // TODO: test. const objectTypeNode = createTypeNodeWorker((type).objectType); const indexTypeNode = createTypeNodeWorker((type).indexType); return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); @@ -2375,27 +2359,15 @@ namespace ts { return types && asNodeArray(types.map(createTypeNodeWorker) as TypeNode[]); } - function createNameFromSymbol(symbol: Symbol): Identifier; - function createNameFromSymbol(symbol: Symbol): EntityName; - function createNameFromSymbol(symbol: Symbol): EntityName { - symbol; enclosingDeclaration; - // TODO: actually implement this - return createIdentifier(symbolToString(symbol, enclosingDeclaration)); - } - function createMappedTypeNodeFromType(type: MappedType) { Debug.assert(!!(type.flags & TypeFlags.Object)); - - // TODO: does typeParameter have the same constraint or do we need to overwrite it somehow? const typeParameter = getTypeParameterFromMappedType(type); - // const constraintType = getConstraintTypeFromMappedType(type); const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter, enclosingDeclaration); const templateTypeNode = createTypeNode(getTemplateTypeFromMappedType(type), enclosingDeclaration); const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; - // TODO: test. return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); } @@ -2501,7 +2473,6 @@ namespace ts { return createTupleTypeNode(typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))) : undefined); } else { - // TODO: handle type parameters in qualified names... const outerTypeParameters = type.target.outerTypeParameters; let i = 0; let qualifiedName: QualifiedName | undefined = undefined; @@ -2516,10 +2487,9 @@ namespace ts { } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. - // TODO: figure out how to handle type arguments if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { const name = createNameFromSymbol(parent); - const qualifiedNamePart = name; // createTypeReferenceNode(name, mapToTypeNodeArray(typeArguments.slice(start, i - start))); + const qualifiedNamePart = name; if (!qualifiedName) { qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/undefined); } @@ -2534,7 +2504,6 @@ namespace ts { let entityName: EntityName = undefined; const nameIdentifier = createNameFromSymbol(type.symbol); if (qualifiedName) { - // TODO: handle checking of type arguments for qualified names? Debug.assert(!qualifiedName.right); qualifiedName.right = nameIdentifier; entityName = qualifiedName; @@ -2597,6 +2566,68 @@ namespace ts { } return typeElements.length ? typeElements : undefined; } + + function createNameFromSymbol(symbol: Symbol): Identifier; + function createNameFromSymbol(symbol: Symbol): EntityName; + function createNameFromSymbol(symbol: Symbol): EntityName { + let parentSymbol: Symbol; + symbol; enclosingDeclaration; + let meaning: SymbolFlags; + + // Get qualified name if the symbol is not a type parameter + // and there is an enclosing declaration. + let chain: Symbol[]; + const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; + if (!isTypeParameter && enclosingDeclaration) { + chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); + Debug.assert(chain && chain.length > 0); + } + else { + chain = [symbol]; + } + + const result = createEntityNameFromSymbolChain(chain, chain.length - 1); + return result; + + function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { + Debug.assert(chain && 0 <= index && index < chain.length); + const identifier = createIdentifier(getNameOfSymbol(chain[index])); + return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; + } + + /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ + function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { + let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); + + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + + // Go up and add our parent. + const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + } + } + } + + if (accessibleSymbolChain) { + return accessibleSymbolChain; + } + + else if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { + + return [symbol]; + } + } + } } } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 5d63126ad0a..1410c7aaabd 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -333,13 +333,18 @@ namespace ts { return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.IndexedAccessType: return updateIndexedAccessTypeNode((node) - , visitNode((node).objectType, visitor, isTypeNode) - , visitNode((node).indexType, visitor, isTypeNode)); + , visitNode((node).objectType, visitor, isTypeNode) + , visitNode((node).indexType, visitor, isTypeNode)); case SyntaxKind.MappedType: - throw new Error("reached unsupported type in visitor."); + return updateMappedTypeNode((node) + , visitNode((node).readonlyToken, visitor, isToken) + , visitNode((node).typeParameter, visitor, isTypeParameter) + , visitNode((node).questionToken, visitor, isToken) + , visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.LiteralType: return updateLiteralTypeNode(node - , visitNode((node).literal, visitor, isExpression)); + , visitNode((node).literal, visitor, isExpression)); // Type Declarations diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index ab973bb5772..53990927575 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -50,7 +50,6 @@ namespace ts.codefix { , /*questionToken*/ undefined , typeNode , /*initializer*/ undefined); - // TODO: make index signature. const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 8693cc453bb..e642da2159a 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -4,7 +4,6 @@ namespace ts.codefix { export function newNodesToChanges(newNodes: Node[], insertAfter: Node, context: CodeFixContext) { const sourceFile = context.sourceFile; if (!(newNodes)) { - // TODO: make the appropriate value flow through gracefully. throw new Error("newNodesToChanges expects an array"); } @@ -13,6 +12,7 @@ namespace ts.codefix { for (const newNode of newNodes) { changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); } + // TODO (aozgaa): concatenate changes into a single change. return changeTracker.getChanges(); } @@ -51,7 +51,6 @@ namespace ts.codefix { } const declaration = declarations[0] as Declaration; - // TODO: get name as identifier or computer property name, etc. const name = declaration.name ? getSynthesizedDeepClone(declaration.name) as PropertyName : undefined; const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); const modifiers = visibilityModifier ? [visibilityModifier] : undefined; @@ -63,7 +62,6 @@ namespace ts.codefix { case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: const typeNode = checker.createTypeNode(type, enclosingDeclaration); - // TODO: add modifiers. const property = createProperty( /*decorators*/undefined , modifiers @@ -96,7 +94,6 @@ namespace ts.codefix { let signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { - // TODO: make signatures instead of methods const signature = signatures[i]; const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); signatureDeclarations.push(createMethod( diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts new file mode 100644 index 00000000000..ed5ea06ebb6 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceIndexType.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// x: keyof X; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +x: keyof Y; +`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts new file mode 100644 index 00000000000..64676bce860 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMappedType.ts @@ -0,0 +1,10 @@ +/// + +//// interface I { +//// x: { readonly [K in keyof X]: X[K] }; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +x: { readonly [K in keyof X]: Y[K]; }; +`); From 944b34fd4e96edb9dcb54313aabe0455b3ab51c6 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 17 Mar 2017 12:08:38 -0700 Subject: [PATCH 136/207] move commas to end of line --- src/compiler/checker.ts | 44 ++++----- src/compiler/visitor.ts | 92 +++++++++--------- src/services/codefixes/fixAddMissingMember.ts | 34 +++---- src/services/codefixes/helpers.ts | 96 +++++++++---------- 4 files changed, 132 insertions(+), 134 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 58186560e8b..bb5046a8d66 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2210,13 +2210,13 @@ namespace ts { // TODO: how should we clone members/modifiers? // TODO: check initializer accessibility correctly. const parameterNode = createParameter( - parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedDeepClone) - , parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedDeepClone) - , parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken) - , getSynthesizedDeepClone(parameterDeclaration.name) - , parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken) - , parameterTypeNode - , parameterDeclaration.initializer && getSynthesizedDeepClone(parameterDeclaration.initializer)); + parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedDeepClone), + parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedDeepClone), + parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), + getSynthesizedDeepClone(parameterDeclaration.name), + parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), + parameterTypeNode, + parameterDeclaration.initializer && getSynthesizedDeepClone(parameterDeclaration.initializer)); return parameterNode; } @@ -2558,10 +2558,10 @@ namespace ts { } else { typeElements.push(createPropertySignature( - propertyName - , optionalToken - , createTypeNodeWorker(propertyType) - , /*initializer*/undefined)); + propertyName, + optionalToken, + createTypeNodeWorker(propertyType), + /*initializer*/undefined)); } } return typeElements.length ? typeElements : undefined; @@ -2636,19 +2636,19 @@ namespace ts { const name = getNameFromIndexInfo(indexInfo); const indexingParameter = createParameter( - /*decorators*/ undefined - , /*modifiers*/ undefined - , /*dotDotDotToken*/ undefined - , name - , /*questionToken*/ undefined - , indexerTypeNode - , /*initializer*/ undefined); + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + name, + /*questionToken*/ undefined, + indexerTypeNode, + /*initializer*/ undefined); const typeNode = createTypeNode(indexInfo.type, enclosingDeclaration); return createIndexSignatureDeclaration( - [indexingParameter] - , typeNode - , /*decorators*/ undefined - , indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); + [indexingParameter], + typeNode, + /*decorators*/ undefined, + indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); } function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 1410c7aaabd..44b994ce57a 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -2,9 +2,7 @@ /// /// -namespace ts { - - +namespace ts { export const nullTransformationContext: TransformationContext = { enableEmitNotification: noop, enableSubstitution: noop, @@ -265,25 +263,25 @@ namespace ts { case SyntaxKind.ConstructorType: case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: - return updateSignatureDeclaration(node - , nodesVisitor((node).typeParameters, visitor, isTypeParameter) - , visitParameterList((node).parameters, visitor, context, nodesVisitor) - , visitNode((node).type, visitor, isTypeNode)); + return updateSignatureDeclaration(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.MethodSignature: - return updateSignatureDeclaration(node - , nodesVisitor((node).typeParameters, visitor, isTypeParameter) - , visitParameterList((node).parameters, visitor, context, nodesVisitor) - , visitNode((node).type, visitor, isTypeNode) - , visitNode((node).name, visitor, isPropertyName) - , visitNode((node).questionToken, visitor, isToken)); + return updateSignatureDeclaration(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, visitor, isToken)); case SyntaxKind.IndexSignature: - return updateIndexSignatureDeclaration(node - , visitParameterList((node).parameters, visitor, context, nodesVisitor) - , visitNode((node).type, visitor, isTypeNode) - , nodesVisitor((node).decorators, visitor, isDecorator) - , nodesVisitor((node).modifiers, visitor, isModifier)); + return updateIndexSignatureDeclaration(node, + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier)); case SyntaxKind.Parameter: return updateParameter(node, @@ -304,9 +302,9 @@ namespace ts { case SyntaxKind.TypePredicate: throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeReference: - return updateTypeReferenceNode(node - , visitNode((node).typeName, visitor, isEntityName) - , nodesVisitor((node).typeArguments, visitor, isTypeNode)); + return updateTypeReferenceNode(node, + visitNode((node).typeName, visitor, isEntityName), + nodesVisitor((node).typeArguments, visitor, isTypeNode)); case SyntaxKind.TypeQuery: return updateTypeQueryNode((node), visitNode((node).exprName, visitor, isEntityName)); @@ -322,8 +320,8 @@ namespace ts { case SyntaxKind.UnionType: case SyntaxKind.IntersectionType: - return updateUnionOrIntersectionTypeNode(node - , nodesVisitor((node).types, visitor, isTypeNode)); + return updateUnionOrIntersectionTypeNode(node, + nodesVisitor((node).types, visitor, isTypeNode)); case SyntaxKind.ParenthesizedType: throw new Error("reached unsupported type in visitor."); @@ -332,43 +330,43 @@ namespace ts { case SyntaxKind.TypeOperator: return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.IndexedAccessType: - return updateIndexedAccessTypeNode((node) - , visitNode((node).objectType, visitor, isTypeNode) - , visitNode((node).indexType, visitor, isTypeNode)); + return updateIndexedAccessTypeNode((node), + visitNode((node).objectType, visitor, isTypeNode), + visitNode((node).indexType, visitor, isTypeNode)); case SyntaxKind.MappedType: - return updateMappedTypeNode((node) - , visitNode((node).readonlyToken, visitor, isToken) - , visitNode((node).typeParameter, visitor, isTypeParameter) - , visitNode((node).questionToken, visitor, isToken) - , visitNode((node).type, visitor, isTypeNode)); + return updateMappedTypeNode((node), + visitNode((node).readonlyToken, visitor, isToken), + visitNode((node).typeParameter, visitor, isTypeParameter), + visitNode((node).questionToken, visitor, isToken), + visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.LiteralType: - return updateLiteralTypeNode(node - , visitNode((node).literal, visitor, isExpression)); + return updateLiteralTypeNode(node, + visitNode((node).literal, visitor, isExpression)); // Type Declarations case SyntaxKind.TypeParameter: - return updateTypeParameterDeclaration(node - , visitNode((node).name, visitor, isIdentifier) - , visitNode((node).constraint, visitor, isTypeNode) - , visitNode((node).default, visitor, isTypeNode)); + return updateTypeParameterDeclaration(node, + visitNode((node).name, visitor, isIdentifier), + visitNode((node).constraint, visitor, isTypeNode), + visitNode((node).default, visitor, isTypeNode)); // Type members case SyntaxKind.PropertySignature: - return updatePropertySignature((node) - , visitNode((node).name, visitor, isPropertyName) - , visitNode((node).questionToken, visitor, isToken) - , visitNode((node).type, visitor, isTypeNode) - , visitNode((node).initializer, visitor, isExpression)); + return updatePropertySignature((node), + visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, visitor, isToken), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).initializer, visitor, isExpression)); case SyntaxKind.IndexSignature: - return updateIndexSignatureDeclaration(node - , visitParameterList((node).parameters, visitor, context, nodesVisitor) - , visitNode((node).type, visitor, isTypeNode) - , nodesVisitor((node).decorators, visitor, isDecorator) - , nodesVisitor((node).modifiers, visitor, isModifier)); + return updateIndexSignatureDeclaration(node, + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode), + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier)); case SyntaxKind.PropertyDeclaration: return updateProperty(node, diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 53990927575..a67c6791ba3 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -44,29 +44,29 @@ namespace ts.codefix { const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); const property = createProperty( - /*decorators*/undefined - , /*modifiers*/ undefined - , token.getText(sourceFile) - , /*questionToken*/ undefined - , typeNode - , /*initializer*/ undefined); + /*decorators*/undefined, + /*modifiers*/ undefined, + token.getText(sourceFile), + /*questionToken*/ undefined, + typeNode, + /*initializer*/ undefined); const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword); const indexingParameter = createParameter( - /*decorators*/ undefined - , /*modifiers*/ undefined - , /*dotDotDotToken*/ undefined - , "x" - , /*questionToken*/ undefined - , stringTypeNode - , /*initializer*/ undefined); + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + "x", + /*questionToken*/ undefined, + stringTypeNode, + /*initializer*/ undefined); const indexSignature = createIndexSignatureDeclaration( - [indexingParameter] - , typeNode - , /*decorators*/undefined - , /*modifiers*/ undefined); + [indexingParameter], + typeNode, + /*decorators*/undefined, + /*modifiers*/ undefined); const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index e642da2159a..2d1d76ac8a6 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -63,12 +63,12 @@ namespace ts.codefix { case SyntaxKind.PropertyDeclaration: const typeNode = checker.createTypeNode(type, enclosingDeclaration); const property = createProperty( - /*decorators*/undefined - , modifiers - , name - , /*questionToken*/ undefined - , typeNode - , /*initializer*/ undefined); + /*decorators*/undefined, + modifiers, + name, + /*questionToken*/ undefined, + typeNode, + /*initializer*/ undefined); return property; case SyntaxKind.MethodSignature: case SyntaxKind.MethodDeclaration: @@ -97,15 +97,15 @@ namespace ts.codefix { const signature = signatures[i]; const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); signatureDeclarations.push(createMethod( - /*decorators*/ undefined - , modifiers - , /*asteriskToken*/ undefined - , name - , optional ? createToken(SyntaxKind.QuestionToken) : undefined - , signatureParts.typeParameters - , signatureParts.parameters - , signatureParts.type - , /*body*/undefined)); + /*decorators*/ undefined, + modifiers, + /*asteriskToken*/ undefined, + name, + optional ? createToken(SyntaxKind.QuestionToken) : undefined, + signatureParts.typeParameters, + signatureParts.parameters, + signatureParts.type, + /*body*/undefined)); } if (declarations.length > signatures.length) { @@ -150,59 +150,59 @@ namespace ts.codefix { for (let i = 0; i < maxNonRestArgs; i++) { const anyType = createKeywordTypeNode(SyntaxKind.AnyKeyword); const newParameter = createParameter( - /*decorators*/ undefined - , /*modifiers*/ undefined - , /*dotDotDotToken*/ undefined - , maxArgsParameterSymbolNames[i] - , /*questionToken*/ i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined - , anyType - , /*initializer*/ undefined); + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + maxArgsParameterSymbolNames[i], + /*questionToken*/ i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined, + anyType, + /*initializer*/ undefined); parameters.push(newParameter); } if (someSigHasRestParameter) { const anyArrayType = createArrayTypeNode(createKeywordTypeNode(SyntaxKind.AnyKeyword)); const restParameter = createParameter( - /*decorators*/ undefined - , /*modifiers*/ undefined - , createToken(SyntaxKind.DotDotDotToken) - , maxArgsParameterSymbolNames[maxNonRestArgs] || "rest" - , /*questionToken*/ maxNonRestArgs >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined - , anyArrayType - , /*initializer*/ undefined); + /*decorators*/ undefined, + /*modifiers*/ undefined, + createToken(SyntaxKind.DotDotDotToken), + maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined, + anyArrayType, + /*initializer*/ undefined); parameters.push(restParameter); } return createStubbedMethod( - modifiers - , name - , optional - , /*typeParameters*/undefined - , parameters - , /*returnType*/ undefined); + modifiers, + name, + optional, + /*typeParameters*/undefined, + parameters, + /*returnType*/ undefined); } export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { return createMethod( - /*decorators*/undefined - , modifiers - , /*asteriskToken*/undefined - , name - , optional ? createToken(SyntaxKind.QuestionToken) : undefined - , typeParameters - , parameters - , returnType - , createStubbedMethodBody()); + /*decorators*/undefined, + modifiers, + /*asteriskToken*/undefined, + name, + optional ? createToken(SyntaxKind.QuestionToken) : undefined, + typeParameters, + parameters, + returnType, + createStubbedMethodBody()); } function createStubbedMethodBody() { return createBlock( [createThrow( createNew( - createIdentifier('Error') - , /*typeArguments*/undefined - , [createLiteral('Method not implemented.')]))] - , /*multiline*/true); + createIdentifier('Error'), + /*typeArguments*/undefined, + [createLiteral('Method not implemented.')]))], + /*multiline*/true); } function createVisibilityModifier(flags: ModifierFlags) { From 2305c10a651390c71c6f4edc2454c10e99cb11bd Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 17 Mar 2017 13:37:12 -0700 Subject: [PATCH 137/207] Fix lint errors --- src/compiler/moduleNameResolver.ts | 2 +- src/compiler/program.ts | 6 +- src/harness/fourslash.ts | 10 +-- .../formatting/getFormattingEditsForRange.ts | 88 ------------------- src/harness/unittests/textChanges.ts | 33 +++---- src/lib/dom.iterable.d.ts | 24 +++-- src/lib/es2015.collection.d.ts | 2 +- src/lib/es2015.core.d.ts | 6 +- src/lib/es2015.iterable.d.ts | 2 +- src/lib/es2015.proxy.d.ts | 4 +- src/lib/es2015.symbol.d.ts | 10 +-- src/lib/es2015.symbol.wellknown.d.ts | 54 ++++++------ src/lib/es2017.sharedmemory.d.ts | 4 +- src/lib/es2017.string.d.ts | 54 ++++++------ src/lib/es5.d.ts | 18 ++-- src/lib/scripthost.d.ts | 2 +- src/lib/webworker.importscripts.d.ts | 4 +- src/server/builder.ts | 2 +- src/server/client.ts | 2 +- src/server/server.ts | 10 +-- .../typingsInstaller/nodeTypingsInstaller.ts | 2 +- src/services/codefixes/importFixes.ts | 3 +- src/services/findAllReferences.ts | 4 +- src/services/textChanges.ts | 14 +-- ...ariableDeclarationInStrictMode1.errors.txt | 2 +- tslint.json | 3 +- 26 files changed, 139 insertions(+), 226 deletions(-) delete mode 100644 src/harness/unittests/services/formatting/getFormattingEditsForRange.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 1911605a0a6..699919e0566 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e117761a3a3..cffb6df1e3d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -298,8 +298,8 @@ namespace ts { let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; - let cachedSemanticDiagnosticsForFile: DiagnosticCache = {}; - let cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; + const cachedSemanticDiagnosticsForFile: DiagnosticCache = {}; + const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; let resolvedTypeReferenceDirectives = createMap(); let fileProcessingDiagnostics = createDiagnosticCollection(); @@ -1105,7 +1105,7 @@ namespace ts { return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); } - function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile| undefined, cancellationToken: CancellationToken) { + function getDeclarationDiagnosticsForFileNoCache(sourceFile: SourceFile | undefined, cancellationToken: CancellationToken) { return runWithCancellationToken(() => { const resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8ef4d946694..092c84996f1 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -927,12 +927,11 @@ namespace FourSlash { this.assertObjectsEqual(fullActual, fullExpected); } - function rangeToReferenceEntry(r: Range) { - let { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; - isWriteAccess = !!isWriteAccess; isDefinition = !!isDefinition; - const result: any = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess, isDefinition }; + function rangeToReferenceEntry(r: Range): ts.ReferenceEntry { + const { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; + const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess: !!isWriteAccess, isDefinition: !!isDefinition }; if (isInString !== undefined) { - result.isInString = isInString; + result.isInString = isInString } return result; } @@ -2291,7 +2290,6 @@ namespace FourSlash { else { if (actual === undefined) { this.raiseError(`${name} failed - expected the template {newText: "${expected.newText}", caretOffset: "${expected.caretOffset}"} but got nothing instead`); - } if (actual.newText !== expected.newText) { diff --git a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts deleted file mode 100644 index b369ba4374b..00000000000 --- a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts +++ /dev/null @@ -1,88 +0,0 @@ -/// - -describe('getFormattingEditsForRange', function() { - // - // Verify that formatting the typescript file "sourceFileName" results in the - // baseline file "baselineFileName". - // - function getFormattingEditsForRange(sourceFileName: string) { - var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts"; - sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts"; - - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addDefaultLibrary(); - typescriptLS.addFile(sourceFileName); - - var ls = typescriptLS.getLanguageService(); - var script = ls.languageService.getScriptAST(sourceFileName); - assert.notNull(script); - - var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions()); - typescriptLS.checkEdits(sourceFileName, baselineFileName, edits); - } - - describe('test cases for formatting engine', function() { - it("formats typescript constructs properly", function() { - getFormattingEditsForRange('typescriptConstructs'); - }); - it("formats document ready function properly", function() { - getFormattingEditsForRange('documentReadyFunction'); - }); - it("formats on closing bracket properly", function() { - getFormattingEditsForRange('onClosingBracket'); - }); - it("formats various javascript constructs", function() { - getFormattingEditsForRange('various'); - }); - it("formats main javascript program", function() { - getFormattingEditsForRange('main'); - }); - it("formats on semicolon properly", function() { - getFormattingEditsForRange('onSemiColon'); - }); - it("formats enum with trailling tab characters properly", function() { - getFormattingEditsForRange('tabAfterCloseCurly'); - }); - it("formats object literal", function() { - getFormattingEditsForRange('objectLiteral'); - }); - it("formats with statements", function() { - getFormattingEditsForRange('withStatement'); - }); - it("formats ':' and '?' in parameters", function() { - getFormattingEditsForRange('colonAndQMark'); - }); - it("formats 'import' declaration", function() { - getFormattingEditsForRange('importDeclaration'); - }); - it("formats exported class with implicit module", function() { - //TODO: this is to force generation of implicit module in AST - var svGenTarget = TypeScript.moduleGenTarget; - try { - TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous; - getFormattingEditsForRange('implicitModule'); - } - finally { - TypeScript.moduleGenTarget = svGenTarget; - } - }); - it("formats constructor statements correctelly", function() { - getFormattingEditsForRange('spaceAfterConstructor'); - }); - it("formats classes and interfaces correctelly", function() { - getFormattingEditsForRange('classes'); - }); - it("formats modules correctly", function() { - getFormattingEditsForRange('modules'); - }); - it("formats fat arrow expressions correctelly", function() { - getFormattingEditsForRange('fatArrowFunctions'); - }); - it("formats empty object/interface literals correctelly", function() { - getFormattingEditsForRange('emptyInterfaceLiteral'); - }); - it("formats variable declaration lists", function() { - getFormattingEditsForRange('formatVariableDeclarationList'); - }); - }); -}); diff --git a/src/harness/unittests/textChanges.ts b/src/harness/unittests/textChanges.ts index 8269b6de6be..3625b30a009 100644 --- a/src/harness/unittests/textChanges.ts +++ b/src/harness/unittests/textChanges.ts @@ -2,6 +2,9 @@ /// /// +// Some tests have trailing whitespace +// tslint:disable trim-trailing-whitespace + namespace ts { describe("textChanges", () => { function findChild(name: string, n: Node) { @@ -572,7 +575,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter10", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -581,7 +584,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter11", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -590,7 +593,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter12", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -599,7 +602,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter13", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -609,7 +612,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter14", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -619,7 +622,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter15", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(createIdentifier("b"), createIdentifier("a"))); - }) + }); } { const text = ` @@ -629,7 +632,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter16", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -639,7 +642,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter17", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -648,7 +651,7 @@ import { } from "bar"`; runSingleFileTest("insertNodeInListAfter18", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { changeTracker.insertNodeInListAfter(sourceFile, findChild("x", sourceFile), createImportSpecifier(undefined, createIdentifier("a"))); - }) + }); } { const text = ` @@ -656,7 +659,7 @@ class A { x; }`; runSingleFileTest("insertNodeAfterMultipleNodes", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { - let newNodes = []; + const newNodes = []; for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) { newNodes.push( createProperty(undefined, undefined, i + "", undefined, undefined, undefined)); @@ -714,7 +717,7 @@ class A { class A { x = foo } -` +`; runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -732,7 +735,7 @@ class A { x() { } } -` +`; runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -749,7 +752,7 @@ class A { interface A { x } -` +`; runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -766,7 +769,7 @@ interface A { interface A { x() } -` +`; runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createProperty( /*decorators*/ undefined, @@ -781,7 +784,7 @@ interface A { { const text = ` let x = foo -` +`; runSingleFileTest("insertNodeInStatementListAfterNodeWithoutSeparator1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = createStatement(createParen(createLiteral(1))); changeTracker.insertNodeAfter(sourceFile, findVariableStatementContaining("x", sourceFile), newNode, { suffix: newLineCharacter }); diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index e4da7a62763..9a04b723ac2 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -5,9 +5,7 @@ interface DOMTokenList { } interface NodeList { - - - /** + /** * Returns an array of key, value pairs for every entry in the list */ entries(): IterableIterator<[number, Node]>; @@ -17,23 +15,23 @@ interface NodeList { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; - /** + /** * Returns an list of keys in the list */ keys(): IterableIterator; - /** + /** * Returns an list of values in the list */ values(): IterableIterator; - - [Symbol.iterator](): IterableIterator + + [Symbol.iterator](): IterableIterator; } interface NodeListOf { - /** + /** * Returns an array of key, value pairs for every entry in the list */ entries(): IterableIterator<[number, TNode]>; @@ -44,14 +42,14 @@ interface NodeListOf { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; - /** + /** * Returns an list of keys in the list */ keys(): IterableIterator; - /** + /** * Returns an list of values in the list */ - values(): IterableIterator; - - [Symbol.iterator](): IterableIterator + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; } diff --git a/src/lib/es2015.collection.d.ts b/src/lib/es2015.collection.d.ts index 5b90333f1d5..b2255dab881 100644 --- a/src/lib/es2015.collection.d.ts +++ b/src/lib/es2015.collection.d.ts @@ -17,7 +17,7 @@ declare var Map: MapConstructor; interface ReadonlyMap { forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; - get(key: K): V|undefined; + get(key: K): V | undefined; has(key: K): boolean; readonly size: number; } diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 88f70758e5a..2e56221fe9a 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -268,7 +268,7 @@ interface Object { * Determines whether an object has a property with the specified name. * @param v A property name. */ - hasOwnProperty(v: PropertyKey): boolean + hasOwnProperty(v: PropertyKey): boolean; /** * Determines whether a specified property is enumerable. @@ -486,10 +486,10 @@ interface String { bold(): string; /** Returns a HTML element */ - fixed(): string + fixed(): string; /** Returns a HTML element and sets the color attribute value */ - fontcolor(color: string): string + fontcolor(color: string): string; /** Returns a HTML element and sets the size attribute value */ fontsize(size: number): string; diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index fe56c6e8bfb..73f0d45cda7 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -91,7 +91,7 @@ interface IArguments { } interface Map { - [Symbol.iterator](): IterableIterator<[K,V]>; + [Symbol.iterator](): IterableIterator<[K, V]>; entries(): IterableIterator<[K, V]>; keys(): IterableIterator; values(): IterableIterator; diff --git a/src/lib/es2015.proxy.d.ts b/src/lib/es2015.proxy.d.ts index efccfd47cc5..89f9ebf55c0 100644 --- a/src/lib/es2015.proxy.d.ts +++ b/src/lib/es2015.proxy.d.ts @@ -12,11 +12,11 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): object + construct? (target: T, argArray: any, newTarget?: any): object; } interface ProxyConstructor { revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; - new (target: T, handler: ProxyHandler): T + new (target: T, handler: ProxyHandler): T; } declare var Proxy: ProxyConstructor; diff --git a/src/lib/es2015.symbol.d.ts b/src/lib/es2015.symbol.d.ts index d7ea4fa0328..44a5f17d742 100644 --- a/src/lib/es2015.symbol.d.ts +++ b/src/lib/es2015.symbol.d.ts @@ -7,8 +7,8 @@ interface Symbol { } interface SymbolConstructor { - /** - * A reference to the prototype. + /** + * A reference to the prototype. */ readonly prototype: Symbol; @@ -16,17 +16,17 @@ interface SymbolConstructor { * Returns a new unique Symbol value. * @param description Description of the new Symbol object. */ - (description?: string|number): symbol; + (description?: string | number): symbol; /** - * Returns a Symbol object from the global symbol registry matching the given key if found. + * Returns a Symbol object from the global symbol registry matching the given key if found. * Otherwise, returns a new symbol with this key. * @param key key to search for. */ for(key: string): symbol; /** - * Returns a key from the global symbol registry matching the given Symbol if found. + * Returns a key from the global symbol registry matching the given Symbol if found. * Otherwise, returns a undefined. * @param sym Symbol to find the key for. */ diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 7177b78e483..71e4cb7c893 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -1,55 +1,55 @@ /// interface SymbolConstructor { - /** - * A method that determines if a constructor object recognizes an object as one of the - * constructor’s instances. Called by the semantics of the instanceof operator. + /** + * A method that determines if a constructor object recognizes an object as one of the + * constructor’s instances. Called by the semantics of the instanceof operator. */ readonly hasInstance: symbol; - /** + /** * A Boolean value that if true indicates that an object should flatten to its array elements * by Array.prototype.concat. */ readonly isConcatSpreadable: symbol; /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.match method. + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.match method. */ readonly match: symbol; - /** - * A regular expression method that replaces matched substrings of a string. Called by the + /** + * A regular expression method that replaces matched substrings of a string. Called by the * String.prototype.replace method. */ readonly replace: symbol; /** - * A regular expression method that returns the index within a string that matches the + * A regular expression method that returns the index within a string that matches the * regular expression. Called by the String.prototype.search method. */ readonly search: symbol; - /** - * A function valued property that is the constructor function that is used to create + /** + * A function valued property that is the constructor function that is used to create * derived objects. */ readonly species: symbol; /** - * A regular expression method that splits a string at the indices that match the regular + * A regular expression method that splits a string at the indices that match the regular * expression. Called by the String.prototype.split method. */ readonly split: symbol; - /** + /** * A method that converts an object to a corresponding primitive value. * Called by the ToPrimitive abstract operation. */ readonly toPrimitive: symbol; - /** + /** * A String value that is used in the creation of the default string description of an object. * Called by the built-in method Object.prototype.toString. */ @@ -165,7 +165,7 @@ interface RegExp { * Replaces text in a string, using this regular expression. * @param string A String object or string literal whose contents matching against * this regular expression will be replaced - * @param replaceValue A String object or string literal containing the text to replace for every + * @param replaceValue A String object or string literal containing the text to replace for every * successful match of this regular expression. */ [Symbol.replace](string: string, replaceValue: string): string; @@ -241,10 +241,10 @@ interface String { } /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; @@ -255,7 +255,7 @@ interface DataView { } /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { @@ -263,7 +263,7 @@ interface Int8Array { } /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { @@ -271,7 +271,7 @@ interface Uint8Array { } /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { @@ -279,7 +279,7 @@ interface Uint8ClampedArray { } /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { @@ -287,7 +287,7 @@ interface Int16Array { } /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { @@ -295,7 +295,7 @@ interface Uint16Array { } /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { @@ -303,7 +303,7 @@ interface Int32Array { } /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { @@ -319,7 +319,7 @@ interface Float32Array { } /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { diff --git a/src/lib/es2017.sharedmemory.d.ts b/src/lib/es2017.sharedmemory.d.ts index 440b74ff016..d9f986627ca 100644 --- a/src/lib/es2017.sharedmemory.d.ts +++ b/src/lib/es2017.sharedmemory.d.ts @@ -13,8 +13,8 @@ interface SharedArrayBuffer { length: number; /** * Returns a section of an SharedArrayBuffer. - */ - slice(begin:number, end?:number): SharedArrayBuffer; + */ + slice(begin: number, end?: number): SharedArrayBuffer; readonly [Symbol.species]: SharedArrayBuffer; readonly [Symbol.toStringTag]: "SharedArrayBuffer"; } diff --git a/src/lib/es2017.string.d.ts b/src/lib/es2017.string.d.ts index 51f8e410ecf..3a440f887e9 100644 --- a/src/lib/es2017.string.d.ts +++ b/src/lib/es2017.string.d.ts @@ -1,27 +1,27 @@ -interface String { - /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the start (left) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ - padStart(maxLength: number, fillString?: string): string; - - /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the end (right) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ - padEnd(maxLength: number, fillString?: string): string; -} +interface String { + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the start (left) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padStart(maxLength: number, fillString?: string): string; + + /** + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the end (right) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ + padEnd(maxLength: number, fillString?: string): string; +} diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 7d3a2179a38..97a1b6e74cb 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -2,6 +2,8 @@ /// ECMAScript APIs ///////////////////////////// +// tslint:disable no-var-keyword + declare const NaN: number; declare const Infinity: number; @@ -490,7 +492,7 @@ interface NumberConstructor { declare const Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray + readonly raw: ReadonlyArray; } interface Math { @@ -1354,14 +1356,14 @@ type Readonly = { */ type Pick = { [P in K]: T[P]; -} +}; /** * Construct a type with a set of properties K of type T */ type Record = { [P in K]: T; -} +}; /** * Marker for contextual 'this' type @@ -1383,7 +1385,7 @@ interface ArrayBuffer { /** * Returns a section of an ArrayBuffer. */ - slice(begin:number, end?:number): ArrayBuffer; + slice(begin: number, end?: number): ArrayBuffer; } interface ArrayBufferConstructor { @@ -4169,7 +4171,7 @@ declare const Float64Array: Float64ArrayConstructor; /// ECMAScript Internationalization API ///////////////////////////// -declare module Intl { +declare namespace Intl { interface CollatorOptions { usage?: string; localeMatcher?: string; @@ -4197,7 +4199,7 @@ declare module Intl { new (locales?: string | string[], options?: CollatorOptions): Collator; (locales?: string | string[], options?: CollatorOptions): Collator; supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[]; - } + }; interface NumberFormatOptions { localeMatcher?: string; @@ -4234,7 +4236,7 @@ declare module Intl { new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; - } + }; interface DateTimeFormatOptions { localeMatcher?: string; @@ -4277,7 +4279,7 @@ declare module Intl { new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[]; - } + }; } interface String { diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index b163a7e5154..8f10c631ec7 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -29,7 +29,7 @@ interface TextStreamBase { /** * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If + * It is not necessary to close standard streams; they close automatically when the process ends. If * you close a standard stream, be aware that any other pointers to that standard stream become invalid. */ Close(): void; diff --git a/src/lib/webworker.importscripts.d.ts b/src/lib/webworker.importscripts.d.ts index f48f75ee87a..1c4c4f4e953 100644 --- a/src/lib/webworker.importscripts.d.ts +++ b/src/lib/webworker.importscripts.d.ts @@ -1,6 +1,6 @@ ///////////////////////////// -/// WorkerGlobalScope APIs +/// WorkerGlobalScope APIs ///////////////////////////// -// These are only available in a Web Worker +// These are only available in a Web Worker declare function importScripts(...urls: string[]): void; diff --git a/src/server/builder.ts b/src/server/builder.ts index e056f0ae8c7..108c0a0c64b 100644 --- a/src/server/builder.ts +++ b/src/server/builder.ts @@ -1,4 +1,4 @@ -/// +/// /// /// diff --git a/src/server/client.ts b/src/server/client.ts index 8e81a423837..ce7cef12c11 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -33,7 +33,7 @@ namespace ts.server { } export class SessionClient implements LanguageService { - private sequence: number = 0; + private sequence = 0; private lineMaps: ts.Map = ts.createMap(); private messages: string[] = []; private lastRenameEntry: RenameEntry; diff --git a/src/server/server.ts b/src/server/server.ts index bfd4e422047..4e443add779 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -135,7 +135,7 @@ namespace ts.server { try { this.fd = fs.openSync(this.logFilename, "w"); } - catch(_) { + catch (_) { // swallow the error and keep logging disabled if file cannot be opened } } @@ -315,7 +315,7 @@ namespace ts.server { } const body: protocol.TypesInstallerInitializationFailedEventBody = { message: response.message - } + }; const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; this.eventSender.event(body, eventName); return; @@ -473,14 +473,14 @@ namespace ts.server { const cmdLineVerbosity = getLogLevel(findArgument("--logVerbosity")); const envLogOptions = parseLoggingEnvironmentString(process.env["TSS_LOG"]); - const logFileName = cmdLineLogFileName - ? stripQuotes(cmdLineLogFileName) + const logFileName = cmdLineLogFileName + ? stripQuotes(cmdLineLogFileName) : envLogOptions.logToFile ? envLogOptions.file || (__dirname + "/.log" + process.pid.toString()) : undefined; const logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel; - return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity) + return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity); } // This places log file in the directory containing editorServices.js // TODO: check that this location is writable diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 74497504ba3..0a9d8ee29f4 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -24,7 +24,7 @@ namespace ts.server.typingsInstaller { try { fs.appendFileSync(this.logFile, text + sys.newLine); } - catch(e) { + catch (e) { this.logEnabled = false; } } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 743c13ccf38..0c1511ff1eb 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -301,7 +301,6 @@ namespace ts.codefix { } function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] { - //const newImportText = isDefault ? `default as ${name}` : name; const importList = importClause.namedBindings; const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)); // case 1: @@ -556,7 +555,7 @@ namespace ts.codefix { } function createChangeTracker() { - return textChanges.ChangeTracker.fromCodeFixContext(context);; + return textChanges.ChangeTracker.fromCodeFixContext(context); } function createCodeAction( diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 725b9b99506..4f60f7ed160 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -36,11 +36,11 @@ namespace ts.FindAllReferences { } else if (node.kind === SyntaxKind.ObjectLiteralExpression) { entry.kind = ScriptElementKind.interfaceElement; - entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)] + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("object literal"), punctuationPart(SyntaxKind.CloseParenToken)]; } else if (node.kind === SyntaxKind.ClassExpression) { entry.kind = ScriptElementKind.localClassElement; - entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)] + entry.displayParts = [punctuationPart(SyntaxKind.OpenParenToken), textPart("anonymous local class"), punctuationPart(SyntaxKind.CloseParenToken)]; } else { entry.kind = getNodeKind(node); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 6f8a67a0535..424399db72e 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -57,7 +57,7 @@ namespace ts.textChanges { * ^ - pos for the next variable declaration will point here * const y; // this is y * ^ - end for previous variable declaration - * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding + * Usually leading trivia of the variable declaration 'y' should not include trailing trivia (whitespace, comment 'this is x' and newline) from the preceding * variable declaration and trailing trivia for 'y' should include (whitespace, comment 'this is y', newline). * By default when removing nodes we adjust start and end positions to respect specification of the trivia above. * If pos\end should be interpreted literally 'useNonAdjustedStartPosition' or 'useNonAdjustedEndPosition' should be set to true @@ -265,7 +265,7 @@ namespace ts.textChanges { options: {}, range: { pos: after.end, end: after.end }, node: createToken(SyntaxKind.SemicolonToken) - }) + }); } } const endPosition = getAdjustedEndPosition(sourceFile, after, options); @@ -275,7 +275,7 @@ namespace ts.textChanges { /** * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, - * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that + * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that * for them separators are treated as the part of the node. */ public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { @@ -307,8 +307,8 @@ namespace ts.textChanges { // c, // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') // a,* - //***insertedtext# - //###b, + // ***insertedtext# + // ###b, // c, // find line and character of the next element const lineAndCharOfNextElement = getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); @@ -317,7 +317,7 @@ namespace ts.textChanges { let prefix: string; let startPos: number; if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { - // next element is located on the same line with separator: + // next element is located on the same line with separator: // a,$$$$b // ^ ^ // | |-next element @@ -393,7 +393,7 @@ namespace ts.textChanges { // insert element before the line break on the line that contains 'after' element let insertPos = skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false); if (insertPos !== end && isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { - insertPos-- + insertPos--; } this.changes.push({ sourceFile, diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index 46782aaa1d6..ed6ee0dcd87 100644 --- a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt @@ -1,4 +1,4 @@ -lib.d.ts(32,18): error TS2300: Duplicate identifier 'eval'. +lib.d.ts(34,18): error TS2300: Duplicate identifier 'eval'. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'. diff --git a/tslint.json b/tslint.json index 5e72aedf065..920f6087909 100644 --- a/tslint.json +++ b/tslint.json @@ -1,4 +1,5 @@ { + "rulesDirectory": "built/local/tslint", "rules": { "no-bom": true, "class-name": true, @@ -49,5 +50,5 @@ "object-literal-surrounding-space": true, "no-type-assertion-whitespace": true, "no-in-operator": true - } + } } From d3661f5b6ad801922e11f937c658ce002d2d0109 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 17 Mar 2017 13:55:39 -0700 Subject: [PATCH 138/207] add tokenVisitor --- src/compiler/core.ts | 3 +++ src/compiler/visitor.ts | 28 ++++++++++++++-------------- src/services/textChanges.ts | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c380a39611d..3f466e726dc 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1067,6 +1067,9 @@ namespace ts { /** Does nothing. */ export function noop(): void {} + /** Returns its first argument. */ + export function identity(x: X): X { return x; } + /** Throws an error because a function is not implemented. */ export function notImplemented(): never { throw new Error("Not implemented"); diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 44b994ce57a..57de104b0ca 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -224,9 +224,9 @@ namespace ts { * @param visitor The callback used to visit each child. * @param context A lexical environment context for the visitor. */ - export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): T | undefined; + export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; - export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes): Node { + export function visitEachChild(node: Node, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes, tokenVisitor?: Visitor): Node { if (node === undefined) { return undefined; } @@ -274,7 +274,7 @@ namespace ts { visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), visitNode((node).name, visitor, isPropertyName), - visitNode((node).questionToken, visitor, isToken)); + visitNode((node).questionToken, tokenVisitor, isToken)); case SyntaxKind.IndexSignature: return updateIndexSignatureDeclaration(node, @@ -287,9 +287,9 @@ namespace ts { return updateParameter(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - visitNode((node).dotDotDotToken, visitor), + visitNode((node).dotDotDotToken, tokenVisitor, isToken), visitNode((node).name, visitor, isBindingName), - visitNode((node).questionToken, visitor, isToken), + visitNode((node).questionToken, tokenVisitor, isToken), visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); @@ -335,9 +335,9 @@ namespace ts { visitNode((node).indexType, visitor, isTypeNode)); case SyntaxKind.MappedType: return updateMappedTypeNode((node), - visitNode((node).readonlyToken, visitor, isToken), + visitNode((node).readonlyToken, tokenVisitor, isToken), visitNode((node).typeParameter, visitor, isTypeParameter), - visitNode((node).questionToken, visitor, isToken), + visitNode((node).questionToken, tokenVisitor, isToken), visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.LiteralType: @@ -357,7 +357,7 @@ namespace ts { case SyntaxKind.PropertySignature: return updatePropertySignature((node), visitNode((node).name, visitor, isPropertyName), - visitNode((node).questionToken, visitor, isToken), + visitNode((node).questionToken, tokenVisitor, isToken), visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); @@ -380,9 +380,9 @@ namespace ts { return updateMethod(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - visitNode((node).asteriskToken, visitor, isToken), + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).name, visitor, isPropertyName), - visitNode((node).questionToken, visitor, isToken), + visitNode((node).questionToken, tokenVisitor, isToken), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitParameterList((node).parameters, visitor, context, nodesVisitor), visitNode((node).type, visitor, isTypeNode), @@ -423,7 +423,7 @@ namespace ts { case SyntaxKind.BindingElement: return updateBindingElement(node, - (node).dotDotDotToken, + visitNode((node).dotDotDotToken, tokenVisitor, isToken), visitNode((node).propertyName, visitor, isPropertyName), visitNode((node).name, visitor, isBindingName), visitNode((node).initializer, visitor, isExpression)); @@ -476,7 +476,7 @@ namespace ts { case SyntaxKind.FunctionExpression: return updateFunctionExpression(node, nodesVisitor((node).modifiers, visitor, isModifier), - (node).asteriskToken, + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).name, visitor, isIdentifier), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitParameterList((node).parameters, visitor, context, nodesVisitor), @@ -533,7 +533,7 @@ namespace ts { case SyntaxKind.YieldExpression: return updateYield(node, - (node).asteriskToken, + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).expression, visitor, isExpression)); case SyntaxKind.SpreadElement: @@ -669,7 +669,7 @@ namespace ts { return updateFunctionDeclaration(node, nodesVisitor((node).decorators, visitor, isDecorator), nodesVisitor((node).modifiers, visitor, isModifier), - (node).asteriskToken, + visitNode((node).asteriskToken, tokenVisitor, isToken), visitNode((node).name, visitor, isIdentifier), nodesVisitor((node).typeParameters, visitor, isTypeParameter), visitParameterList((node).parameters, visitor, context, nodesVisitor), diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index b7a8b101c09..ddcbf2fa2f5 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -529,7 +529,7 @@ namespace ts.textChanges { } function assignPositionsToNode(node: Node): Node { - const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray); + const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes const newNode = nodeIsSynthesized(visited) ? visited From 6234cbb82f18cb7d8634f33dfd8c37139c7d0e2e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 17 Mar 2017 14:04:36 -0700 Subject: [PATCH 139/207] Move comment to JSDoc --- src/compiler/parser.ts | 3 --- src/compiler/types.ts | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f5c4d880072..5d585e2658a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5643,9 +5643,6 @@ namespace ts { } function parseImportEqualsDeclaration(fullStart: number, decorators: NodeArray, modifiers: NodeArray, identifier: ts.Identifier): ImportEqualsDeclaration { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; const importEqualsDeclaration = createNode(SyntaxKind.ImportEqualsDeclaration, fullStart); importEqualsDeclaration.decorators = decorators; importEqualsDeclaration.modifiers = modifiers; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7728c2b8519..a7adf28ac8e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1838,6 +1838,11 @@ namespace ts { export type ModuleReference = EntityName | ExternalModuleReference; + /** + * One of: + * - import x = require("mod"); + * - import x = M.x; + */ export interface ImportEqualsDeclaration extends DeclarationStatement { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; From ff061a1b934406a41f0fe5f3d95be5fae5793743 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 17 Mar 2017 14:56:04 -0700 Subject: [PATCH 140/207] consolidate edits --- ...sDoesntImplementInheritedAbstractMember.ts | 2 +- .../fixClassIncorrectlyImplementsInterface.ts | 4 ++-- src/services/codefixes/helpers.ts | 21 ++++++++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts index 513853e4614..62f89b1a21a 100644 --- a/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts +++ b/src/services/codefixes/fixClassDoesntImplementInheritedAbstractMember.ts @@ -31,7 +31,7 @@ namespace ts.codefix { const newNodes = createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker); const changes = newNodesToChanges(newNodes, getOpenBraceOfClassLike(classDeclaration, sourceFile), context); - if(changes && changes.length > 0) { + if (changes && changes.length > 0) { return [{ description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), changes diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index de34676eda0..365fd358011 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -45,13 +45,13 @@ namespace ts.codefix { function createAndAddMissingIndexSignatureDeclaration(type: InterfaceType, kind: IndexKind, hasIndexSigOfKind: boolean, newNodes: Node[]): void { if (hasIndexSigOfKind) { - return undefined; + return; } const indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (!indexInfoOfKind) { - return undefined; + return; } const newIndexSignatureDeclaration = checker.createIndexSignatureFromIndexInfo(indexInfoOfKind, kind, classDeclaration); newNodes.push(newIndexSignatureDeclaration); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 2d1d76ac8a6..4a9ee25228f 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -3,17 +3,28 @@ namespace ts.codefix { export function newNodesToChanges(newNodes: Node[], insertAfter: Node, context: CodeFixContext) { const sourceFile = context.sourceFile; - if (!(newNodes)) { - throw new Error("newNodesToChanges expects an array"); - } const changeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); for (const newNode of newNodes) { changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); } - // TODO (aozgaa): concatenate changes into a single change. - return changeTracker.getChanges(); + + const changes = changeTracker.getChanges(); + if (!(changes && changes.length > 0)) { + return changes; + } + + Debug.assert(changes.length === 1); + const consolidatedChanges: FileTextChanges[] = [{ + fileName: changes[0].fileName, + textChanges: [{ + span: changes[0].textChanges[0].span, + newText: changes[0].textChanges.reduce((prev, cur) => prev + cur.newText, "") + }] + + }] + return consolidatedChanges; } /** From a710e9433b28c0c9b692ad6244415777ec3d565d Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Fri, 17 Mar 2017 17:20:43 -0700 Subject: [PATCH 141/207] Do not report semantic diagnostics for infered and external projects with only .js files --- .../unittests/tsserverProjectSystem.ts | 36 +++++++++++++++++++ src/server/session.ts | 9 +---- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index a13835fa7f3..5ea0df91caa 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -3006,6 +3006,42 @@ namespace ts.projectSystem { const errorResult = session.executeCommand(dTsFileGetErrRequest).response; assert.isTrue(errorResult.length === 0); }); + + it("should be turned on for js-only external projects with skipLibCheck=false", () => { + const jsFile = { + path: "/a/b/file1.js", + content: "let x =1;" + }; + const dTsFile = { + path: "/a/b/file2.d.ts", + content: ` + interface T { + name: string; + }; + interface T { + name: number; + };` + }; + const host = createServerHost([jsFile, dTsFile]); + const session = createSession(host); + + const openExternalProjectRequest = makeSessionRequest( + CommandNames.OpenExternalProject, + { + projectFileName: "project1", + rootFiles: toExternalFiles([jsFile.path, dTsFile.path]), + options: { skipLibCheck: false } + } + ); + session.executeCommand(openExternalProjectRequest); + + const dTsFileGetErrRequest = makeSessionRequest( + CommandNames.SemanticDiagnosticsSync, + { file: dTsFile.path } + ); + const errorResult = session.executeCommand(dTsFileGetErrRequest).response; + assert.isTrue(errorResult.length === 0); + }); }); describe("non-existing directories listed in config file input array", () => { diff --git a/src/server/session.ts b/src/server/session.ts index f82d11ba91b..8dd0411d077 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -26,14 +26,7 @@ namespace ts.server { } function shouldSkipSematicCheck(project: Project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - - if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject()) { - return true; - } - return false; + return (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject(); } interface FileStart { From cc6140f6e92280096de0a9b8964e9b865ad9b573 Mon Sep 17 00:00:00 2001 From: Yui T Date: Fri, 17 Mar 2017 17:22:02 -0700 Subject: [PATCH 142/207] Only emit "use strict" when users ask for or the file is external module --- src/compiler/transformers/module/module.ts | 3 ++- src/compiler/transformers/module/system.ts | 3 ++- tests/baselines/reference/importHelpersInIsolatedModules.js | 1 - tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js | 1 - tests/baselines/reference/isolatedModulesPlainFile-System.js | 1 - .../transpile/Does not generate semantic diagnostics.js | 1 - .../transpile/Generates expected syntactic diagnostics.js | 1 - .../Generates no diagnostics for missing file references.js | 1 - .../transpile/Generates no diagnostics with valid inputs.js | 1 - ... error when compiler-options module-kind is out-of-range.js | 1 - ...rror when compiler-options target-script is out-of-range.js | 1 - tests/baselines/reference/transpile/Sets module name.js | 1 - .../reference/transpile/Support options with lib values.js | 1 - .../reference/transpile/Support options with types values.js | 1 - .../reference/transpile/Supports backslashes in file name.js | 1 - .../baselines/reference/transpile/Supports setting allowJs.js | 1 - .../transpile/Supports setting allowSyntheticDefaultImports.js | 1 - .../transpile/Supports setting allowUnreachableCode.js | 1 - .../reference/transpile/Supports setting allowUnusedLabels.js | 1 - .../baselines/reference/transpile/Supports setting baseUrl.js | 1 - .../baselines/reference/transpile/Supports setting charset.js | 1 - .../reference/transpile/Supports setting declaration.js | 1 - .../reference/transpile/Supports setting declarationDir.js | 1 - .../baselines/reference/transpile/Supports setting emitBOM.js | 1 - .../transpile/Supports setting emitDecoratorMetadata.js | 1 - .../transpile/Supports setting experimentalDecorators.js | 1 - .../Supports setting forceConsistentCasingInFileNames.js | 1 - .../reference/transpile/Supports setting isolatedModules.js | 1 - tests/baselines/reference/transpile/Supports setting jsx.js | 1 - .../reference/transpile/Supports setting jsxFactory.js | 1 - tests/baselines/reference/transpile/Supports setting lib.js | 1 - tests/baselines/reference/transpile/Supports setting locale.js | 1 - tests/baselines/reference/transpile/Supports setting module.js | 1 - .../reference/transpile/Supports setting moduleResolution.js | 1 - .../baselines/reference/transpile/Supports setting newLine.js | 1 - tests/baselines/reference/transpile/Supports setting noEmit.js | 1 - .../reference/transpile/Supports setting noEmitHelpers.js | 1 - .../reference/transpile/Supports setting noEmitOnError.js | 1 - .../reference/transpile/Supports setting noErrorTruncation.js | 1 - .../transpile/Supports setting noFallthroughCasesInSwitch.js | 1 - .../reference/transpile/Supports setting noImplicitAny.js | 1 - .../reference/transpile/Supports setting noImplicitReturns.js | 1 - .../reference/transpile/Supports setting noImplicitThis.js | 1 - tests/baselines/reference/transpile/Supports setting noLib.js | 1 - .../reference/transpile/Supports setting noResolve.js | 1 - tests/baselines/reference/transpile/Supports setting out.js | 1 - tests/baselines/reference/transpile/Supports setting outDir.js | 1 - .../baselines/reference/transpile/Supports setting outFile.js | 1 - tests/baselines/reference/transpile/Supports setting paths.js | 1 - .../reference/transpile/Supports setting preserveConstEnums.js | 1 - .../reference/transpile/Supports setting reactNamespace.js | 1 - .../reference/transpile/Supports setting removeComments.js | 1 - .../baselines/reference/transpile/Supports setting rootDir.js | 1 - .../baselines/reference/transpile/Supports setting rootDirs.js | 1 - .../transpile/Supports setting skipDefaultLibCheck.js | 1 - .../reference/transpile/Supports setting skipLibCheck.js | 1 - .../reference/transpile/Supports setting strictNullChecks.js | 1 - .../reference/transpile/Supports setting stripInternal.js | 1 - .../transpile/Supports setting suppressExcessPropertyErrors.js | 1 - .../Supports setting suppressImplicitAnyIndexErrors.js | 1 - .../reference/transpile/Supports setting typeRoots.js | 1 - tests/baselines/reference/transpile/Supports setting types.js | 1 - .../reference/transpile/Supports urls in file name.js | 1 - .../reference/transpile/Uses correct newLine character.js | 1 - tests/baselines/reference/transpile/transpile .js files.js | 1 - .../transpile/transpile file as tsx if jsx is specified.js | 1 - 66 files changed, 4 insertions(+), 66 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 80a8c985c56..4ef9c674ad9 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -89,7 +89,8 @@ namespace ts { startLexicalEnvironment(); const statements: Statement[] = []; - const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile)); + const statementOffset = addPrologueDirectives(statements, node.statements, ensureUseStrict, sourceElementVisitor); if (shouldEmitUnderscoreUnderscoreESModule()) { append(statements, createUnderscoreUnderscoreESModule()); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 1a362c47fd1..642ac1ce6fb 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -225,7 +225,8 @@ namespace ts { startLexicalEnvironment(); // Add any prologue directives. - const statementOffset = addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + const ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && isExternalModule(currentSourceFile)); + const statementOffset = addPrologueDirectives(statements, node.statements, ensureUseStrict, sourceElementVisitor); // var __moduleName = context_1 && context_1.id; statements.push( diff --git a/tests/baselines/reference/importHelpersInIsolatedModules.js b/tests/baselines/reference/importHelpersInIsolatedModules.js index 454fde430d3..26a9cafa188 100644 --- a/tests/baselines/reference/importHelpersInIsolatedModules.js +++ b/tests/baselines/reference/importHelpersInIsolatedModules.js @@ -68,7 +68,6 @@ C = tslib_1.__decorate([ dec ], C); //// [script.js] -"use strict"; var tslib_1 = require("tslib"); var A = (function () { function A() { diff --git a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js index f40d2173685..7026a7d9bed 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-CommonJS.js @@ -5,5 +5,4 @@ run(1); //// [isolatedModulesPlainFile-CommonJS.js] -"use strict"; run(1); diff --git a/tests/baselines/reference/isolatedModulesPlainFile-System.js b/tests/baselines/reference/isolatedModulesPlainFile-System.js index 39b648e071a..43cad51d213 100644 --- a/tests/baselines/reference/isolatedModulesPlainFile-System.js +++ b/tests/baselines/reference/isolatedModulesPlainFile-System.js @@ -6,7 +6,6 @@ run(1); //// [isolatedModulesPlainFile-System.js] System.register([], function (exports_1, context_1) { - "use strict"; var __moduleName = context_1 && context_1.id; return { setters: [], diff --git a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js index 61a703e13bb..eb8be3556a1 100644 --- a/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js +++ b/tests/baselines/reference/transpile/Does not generate semantic diagnostics.js @@ -1,3 +1,2 @@ -"use strict"; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js index 9d108d63313..c2c5134015c 100644 --- a/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js +++ b/tests/baselines/reference/transpile/Generates expected syntactic diagnostics.js @@ -1,4 +1,3 @@ -"use strict"; a; b; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js index 88d98628eee..9324d64de1e 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics for missing file references.js @@ -1,4 +1,3 @@ -"use strict"; /// var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js index 61a703e13bb..eb8be3556a1 100644 --- a/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js +++ b/tests/baselines/reference/transpile/Generates no diagnostics with valid inputs.js @@ -1,3 +1,2 @@ -"use strict"; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js index 1ceb1bcd146..c7570e81192 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js @@ -1,2 +1 @@ -"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js index 1ceb1bcd146..c7570e81192 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js @@ -1,2 +1 @@ -"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Sets module name.js b/tests/baselines/reference/transpile/Sets module name.js index dfe9605fc9e..72164ed6b16 100644 --- a/tests/baselines/reference/transpile/Sets module name.js +++ b/tests/baselines/reference/transpile/Sets module name.js @@ -1,5 +1,4 @@ System.register("NamedModule", [], function (exports_1, context_1) { - "use strict"; var __moduleName = context_1 && context_1.id; var x; return { diff --git a/tests/baselines/reference/transpile/Support options with lib values.js b/tests/baselines/reference/transpile/Support options with lib values.js index 36c68f08b9f..1c5faaae678 100644 --- a/tests/baselines/reference/transpile/Support options with lib values.js +++ b/tests/baselines/reference/transpile/Support options with lib values.js @@ -1,3 +1,2 @@ -"use strict"; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Support options with types values.js b/tests/baselines/reference/transpile/Support options with types values.js index 36c68f08b9f..1c5faaae678 100644 --- a/tests/baselines/reference/transpile/Support options with types values.js +++ b/tests/baselines/reference/transpile/Support options with types values.js @@ -1,3 +1,2 @@ -"use strict"; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports backslashes in file name.js b/tests/baselines/reference/transpile/Supports backslashes in file name.js index 942449753b0..7e5b546deba 100644 --- a/tests/baselines/reference/transpile/Supports backslashes in file name.js +++ b/tests/baselines/reference/transpile/Supports backslashes in file name.js @@ -1,3 +1,2 @@ -"use strict"; var x; //# sourceMappingURL=b.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowJs.js b/tests/baselines/reference/transpile/Supports setting allowJs.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowJs.js +++ b/tests/baselines/reference/transpile/Supports setting allowJs.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js +++ b/tests/baselines/reference/transpile/Supports setting allowSyntheticDefaultImports.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnreachableCode.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js +++ b/tests/baselines/reference/transpile/Supports setting allowUnusedLabels.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting baseUrl.js b/tests/baselines/reference/transpile/Supports setting baseUrl.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting baseUrl.js +++ b/tests/baselines/reference/transpile/Supports setting baseUrl.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting charset.js b/tests/baselines/reference/transpile/Supports setting charset.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting charset.js +++ b/tests/baselines/reference/transpile/Supports setting charset.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declaration.js b/tests/baselines/reference/transpile/Supports setting declaration.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting declaration.js +++ b/tests/baselines/reference/transpile/Supports setting declaration.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting declarationDir.js b/tests/baselines/reference/transpile/Supports setting declarationDir.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting declarationDir.js +++ b/tests/baselines/reference/transpile/Supports setting declarationDir.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitBOM.js b/tests/baselines/reference/transpile/Supports setting emitBOM.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting emitBOM.js +++ b/tests/baselines/reference/transpile/Supports setting emitBOM.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js +++ b/tests/baselines/reference/transpile/Supports setting emitDecoratorMetadata.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js +++ b/tests/baselines/reference/transpile/Supports setting experimentalDecorators.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js +++ b/tests/baselines/reference/transpile/Supports setting forceConsistentCasingInFileNames.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting isolatedModules.js b/tests/baselines/reference/transpile/Supports setting isolatedModules.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting isolatedModules.js +++ b/tests/baselines/reference/transpile/Supports setting isolatedModules.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsx.js b/tests/baselines/reference/transpile/Supports setting jsx.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting jsx.js +++ b/tests/baselines/reference/transpile/Supports setting jsx.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting jsxFactory.js b/tests/baselines/reference/transpile/Supports setting jsxFactory.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting jsxFactory.js +++ b/tests/baselines/reference/transpile/Supports setting jsxFactory.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting lib.js b/tests/baselines/reference/transpile/Supports setting lib.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting lib.js +++ b/tests/baselines/reference/transpile/Supports setting lib.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting locale.js b/tests/baselines/reference/transpile/Supports setting locale.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting locale.js +++ b/tests/baselines/reference/transpile/Supports setting locale.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting module.js b/tests/baselines/reference/transpile/Supports setting module.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting module.js +++ b/tests/baselines/reference/transpile/Supports setting module.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting moduleResolution.js b/tests/baselines/reference/transpile/Supports setting moduleResolution.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting moduleResolution.js +++ b/tests/baselines/reference/transpile/Supports setting moduleResolution.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting newLine.js b/tests/baselines/reference/transpile/Supports setting newLine.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting newLine.js +++ b/tests/baselines/reference/transpile/Supports setting newLine.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmit.js b/tests/baselines/reference/transpile/Supports setting noEmit.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmit.js +++ b/tests/baselines/reference/transpile/Supports setting noEmit.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitHelpers.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noEmitOnError.js +++ b/tests/baselines/reference/transpile/Supports setting noEmitOnError.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js +++ b/tests/baselines/reference/transpile/Supports setting noErrorTruncation.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js +++ b/tests/baselines/reference/transpile/Supports setting noFallthroughCasesInSwitch.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitAny.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitAny.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitReturns.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noImplicitThis.js +++ b/tests/baselines/reference/transpile/Supports setting noImplicitThis.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noLib.js b/tests/baselines/reference/transpile/Supports setting noLib.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noLib.js +++ b/tests/baselines/reference/transpile/Supports setting noLib.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting noResolve.js b/tests/baselines/reference/transpile/Supports setting noResolve.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting noResolve.js +++ b/tests/baselines/reference/transpile/Supports setting noResolve.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting out.js b/tests/baselines/reference/transpile/Supports setting out.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting out.js +++ b/tests/baselines/reference/transpile/Supports setting out.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outDir.js b/tests/baselines/reference/transpile/Supports setting outDir.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting outDir.js +++ b/tests/baselines/reference/transpile/Supports setting outDir.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting outFile.js b/tests/baselines/reference/transpile/Supports setting outFile.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting outFile.js +++ b/tests/baselines/reference/transpile/Supports setting outFile.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting paths.js b/tests/baselines/reference/transpile/Supports setting paths.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting paths.js +++ b/tests/baselines/reference/transpile/Supports setting paths.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js +++ b/tests/baselines/reference/transpile/Supports setting preserveConstEnums.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting reactNamespace.js b/tests/baselines/reference/transpile/Supports setting reactNamespace.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting reactNamespace.js +++ b/tests/baselines/reference/transpile/Supports setting reactNamespace.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting removeComments.js b/tests/baselines/reference/transpile/Supports setting removeComments.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting removeComments.js +++ b/tests/baselines/reference/transpile/Supports setting removeComments.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDir.js b/tests/baselines/reference/transpile/Supports setting rootDir.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDir.js +++ b/tests/baselines/reference/transpile/Supports setting rootDir.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting rootDirs.js b/tests/baselines/reference/transpile/Supports setting rootDirs.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting rootDirs.js +++ b/tests/baselines/reference/transpile/Supports setting rootDirs.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipDefaultLibCheck.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting skipLibCheck.js +++ b/tests/baselines/reference/transpile/Supports setting skipLibCheck.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting strictNullChecks.js +++ b/tests/baselines/reference/transpile/Supports setting strictNullChecks.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting stripInternal.js b/tests/baselines/reference/transpile/Supports setting stripInternal.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting stripInternal.js +++ b/tests/baselines/reference/transpile/Supports setting stripInternal.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressExcessPropertyErrors.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js +++ b/tests/baselines/reference/transpile/Supports setting suppressImplicitAnyIndexErrors.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting typeRoots.js b/tests/baselines/reference/transpile/Supports setting typeRoots.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting typeRoots.js +++ b/tests/baselines/reference/transpile/Supports setting typeRoots.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports setting types.js b/tests/baselines/reference/transpile/Supports setting types.js index 8d91090453b..8394371f908 100644 --- a/tests/baselines/reference/transpile/Supports setting types.js +++ b/tests/baselines/reference/transpile/Supports setting types.js @@ -1,3 +1,2 @@ -"use strict"; x; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Supports urls in file name.js b/tests/baselines/reference/transpile/Supports urls in file name.js index 3923d3c9a41..50fa840c62e 100644 --- a/tests/baselines/reference/transpile/Supports urls in file name.js +++ b/tests/baselines/reference/transpile/Supports urls in file name.js @@ -1,3 +1,2 @@ -"use strict"; var x; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Uses correct newLine character.js b/tests/baselines/reference/transpile/Uses correct newLine character.js index bab9c3c4443..976498c2da8 100644 --- a/tests/baselines/reference/transpile/Uses correct newLine character.js +++ b/tests/baselines/reference/transpile/Uses correct newLine character.js @@ -1,3 +1,2 @@ -"use strict"; var x = 0; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile .js files.js b/tests/baselines/reference/transpile/transpile .js files.js index c17099d84ba..36551461def 100644 --- a/tests/baselines/reference/transpile/transpile .js files.js +++ b/tests/baselines/reference/transpile/transpile .js files.js @@ -1,3 +1,2 @@ -"use strict"; var a = 10; //# sourceMappingURL=input.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js index baa27ee64ce..8620309214f 100644 --- a/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js +++ b/tests/baselines/reference/transpile/transpile file as tsx if jsx is specified.js @@ -1,3 +1,2 @@ -"use strict"; var x = React.createElement("div", null); //# sourceMappingURL=file.js.map \ No newline at end of file From 50c18bbea07b0ec169c417e9aa002c2caf97adcc Mon Sep 17 00:00:00 2001 From: andy-ms Date: Sun, 19 Mar 2017 09:57:14 -0700 Subject: [PATCH 143/207] Fix typo --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a7adf28ac8e..363187e9cf3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2226,7 +2226,7 @@ namespace ts { endOfFileToken: Token; fileName: string; - /* internal */ path: Path; + /* @internal */ path: Path; text: string; amdDependencies: AmdDependency[]; From 2a2c1a9c1445cfea3f3767b3e7ecb8cc2b701be2 Mon Sep 17 00:00:00 2001 From: andy-ms Date: Sun, 19 Mar 2017 10:02:00 -0700 Subject: [PATCH 144/207] Add comment --- src/compiler/sys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 3f585900654..5275d210172 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -202,7 +202,7 @@ namespace ts { if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, // flip all byte pairs and treat as little endian. - len &= ~1; + len &= ~1; // Round down to a multiple of 2 for (let i = 0; i < len; i += 2) { const temp = buffer[i]; buffer[i] = buffer[i + 1]; From 76ffba60fb101f49b2ac7c719d53da58320b10ab Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 20 Mar 2017 09:07:04 -0700 Subject: [PATCH 145/207] Fix `gulp runtests-browser` --- Gulpfile.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index e025ce6eaa8..738ec107862 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -749,7 +749,7 @@ gulp.task("browserify", "Runs browserify on run.js to produce a file suitable fo const originalMap = file.sourceMap; const prebundledContent = file.contents.toString(); // Make paths absolute to help sorcery deal with all the terrible paths being thrown around - originalMap.sources = originalMap.sources.map(s => path.resolve(s)); + originalMap.sources = originalMap.sources.map(s => path.resolve(path.join("src/harness", s))); // intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap originalMap.file = "built/local/_stream_0.js"; From 0152e8c4bb0b700d551c7d04a7413470bae44217 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 20 Mar 2017 08:42:27 -0700 Subject: [PATCH 146/207] Fix lint scripts --- Gulpfile.ts | 39 ++------ Jakefile.js | 49 +++-------- src/harness/fourslash.ts | 2 +- .../formatting/getFormattingEditsForRange.ts | 88 +++++++++++++++++++ src/lib/es5.d.ts | 2 - ...ariableDeclarationInStrictMode1.errors.txt | 2 +- 6 files changed, 109 insertions(+), 73 deletions(-) create mode 100644 src/harness/unittests/services/formatting/getFormattingEditsForRange.ts diff --git a/Gulpfile.ts b/Gulpfile.ts index e025ce6eaa8..cc506c44ee9 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -2,6 +2,7 @@ import * as cp from "child_process"; import * as path from "path"; import * as fs from "fs"; +import child_process = require("child_process"); import originalGulp = require("gulp"); import helpMaker = require("gulp-help"); import runSequence = require("run-sequence"); @@ -1019,40 +1020,16 @@ function spawnLintWorker(files: {path: string}[], callback: (failures: number) = } gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => { - const fileMatcher = RegExp(cmdLineOptions["files"]); if (fold.isTravis()) console.log(fold.start("lint")); - - let files: {stat: fs.Stats, path: string}[] = []; - return gulp.src(lintTargets, { read: false }) - .pipe(through2.obj((chunk, enc, cb) => { - files.push(chunk); - cb(); - }, (cb) => { - files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size); - const workerCount = cmdLineOptions["workers"]; - for (let i = 0; i < workerCount; i++) { - spawnLintWorker(files, finished); - } - - let completed = 0; - let failures = 0; - function finished(fails) { - completed++; - failures += fails; - if (completed === workerCount) { - if (fold.isTravis()) console.log(fold.end("lint")); - if (failures > 0) { - throw new Error(`Linter errors: ${failures}`); - } - else { - cb(); - } - } - } - })); + const fileMatcher = cmdLineOptions["files"]; + const files = fileMatcher + ? `src/**/${fileMatcher}` + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + console.log("Linting: " + cmd); + child_process.execSync(cmd, { stdio: [0, 1, 2] }); }); - gulp.task("default", "Runs 'local'", ["local"]); gulp.task("watch", "Watches the src/ directory for changes and executes runtests-parallel.", [], () => { diff --git a/Jakefile.js b/Jakefile.js index 2b0f0fe1f42..9c2b3d38d10 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1177,43 +1177,16 @@ function spawnLintWorker(files, callback) { } desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); -task("lint", ["build-rules"], function () { +task("lint", ["build-rules"], () => { if (fold.isTravis()) console.log(fold.start("lint")); - var startTime = mark(); - var failed = 0; - var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || ""); - var done = {}; - for (var i in lintTargets) { - var target = lintTargets[i]; - if (!done[target] && fileMatcher.test(target)) { - done[target] = fs.statSync(target).size; - } - } - - var workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; - - var names = Object.keys(done).sort(function (namea, nameb) { - return done[namea] - done[nameb]; + const fileMatcher = process.env.f || process.env.file || process.env.files; + const files = fileMatcher + ? `src/**/${fileMatcher}` + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + console.log("Linting: " + cmd); + jake.exec([cmd], { interactive: true }, () => { + if (fold.isTravis()) console.log(fold.end("lint")); + complete(); }); - - for (var i = 0; i < workerCount; i++) { - spawnLintWorker(names, finished); - } - - var completed = 0; - var failures = 0; - function finished(fails) { - completed++; - failures += fails; - if (completed === workerCount) { - measure(startTime); - if (fold.isTravis()) console.log(fold.end("lint")); - if (failures > 0) { - fail('Linter errors.', failed); - } - else { - complete(); - } - } - } -}, { async: true }); +}); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 092c84996f1..98ebacd49b1 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -931,7 +931,7 @@ namespace FourSlash { const { isWriteAccess, isDefinition, isInString } = (r.marker && r.marker.data) || { isWriteAccess: false, isDefinition: false, isInString: undefined }; const result: ts.ReferenceEntry = { fileName: r.fileName, textSpan: { start: r.start, length: r.end - r.start }, isWriteAccess: !!isWriteAccess, isDefinition: !!isDefinition }; if (isInString !== undefined) { - result.isInString = isInString + result.isInString = isInString; } return result; } diff --git a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts new file mode 100644 index 00000000000..9ad1102d2f4 --- /dev/null +++ b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts @@ -0,0 +1,88 @@ +/// + +describe('getFormattingEditsForRange', function() { + // + // Verify that formatting the typescript file "sourceFileName" results in the + // baseline file "baselineFileName". + // + function getFormattingEditsForRange(sourceFileName: string) { + var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts"; + sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts"; + + var typescriptLS = new Harness.TypeScriptLS(); + typescriptLS.addDefaultLibrary(); + typescriptLS.addFile(sourceFileName); + + var ls = typescriptLS.getLanguageService(); + var script = ls.languageService.getScriptAST(sourceFileName); + assert.notNull(script); + + var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions()); + typescriptLS.checkEdits(sourceFileName, baselineFileName, edits); + } + + describe('test cases for formatting engine', function() { + it("formats typescript constructs properly", function() { + getFormattingEditsForRange('typescriptConstructs'); + }); + it("formats document ready function properly", function() { + getFormattingEditsForRange('documentReadyFunction'); + }); + it("formats on closing bracket properly", function() { + getFormattingEditsForRange('onClosingBracket'); + }); + it("formats various javascript constructs", function() { + getFormattingEditsForRange('various'); + }); + it("formats main javascript program", function() { + getFormattingEditsForRange('main'); + }); + it("formats on semicolon properly", function() { + getFormattingEditsForRange('onSemiColon'); + }); + it("formats enum with trailling tab characters properly", function() { + getFormattingEditsForRange('tabAfterCloseCurly'); + }); + it("formats object literal", function() { + getFormattingEditsForRange('objectLiteral'); + }); + it("formats with statements", function() { + getFormattingEditsForRange('withStatement'); + }); + it("formats ':' and '?' in parameters", function() { + getFormattingEditsForRange('colonAndQMark'); + }); + it("formats 'import' declaration", function() { + getFormattingEditsForRange('importDeclaration'); + }); + it("formats exported class with implicit module", function() { + //TODO: this is to force generation of implicit module in AST + var svGenTarget = TypeScript.moduleGenTarget; + try { + TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous; + getFormattingEditsForRange('implicitModule'); + } + finally { + TypeScript.moduleGenTarget = svGenTarget; + } + }); + it("formats constructor statements correctelly", function() { + getFormattingEditsForRange('spaceAfterConstructor'); + }); + it("formats classes and interfaces correctelly", function() { + getFormattingEditsForRange('classes'); + }); + it("formats modules correctly", function() { + getFormattingEditsForRange('modules'); + }); + it("formats fat arrow expressions correctelly", function() { + getFormattingEditsForRange('fatArrowFunctions'); + }); + it("formats empty object/interface literals correctelly", function() { + getFormattingEditsForRange('emptyInterfaceLiteral'); + }); + it("formats variable declaration lists", function() { + getFormattingEditsForRange('formatVariableDeclarationList'); + }); + }); +}); diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 97a1b6e74cb..b92d335457a 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -2,8 +2,6 @@ /// ECMAScript APIs ///////////////////////////// -// tslint:disable no-var-keyword - declare const NaN: number; declare const Infinity: number; diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt index ed6ee0dcd87..46782aaa1d6 100644 --- a/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.errors.txt @@ -1,4 +1,4 @@ -lib.d.ts(34,18): error TS2300: Duplicate identifier 'eval'. +lib.d.ts(32,18): error TS2300: Duplicate identifier 'eval'. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS1100: Invalid use of 'eval' in strict mode. tests/cases/compiler/variableDeclarationInStrictMode1.ts(2,5): error TS2300: Duplicate identifier 'eval'. From b8aa84e8bf53f0c4ee2c5d590ba76831172545a7 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 3 Mar 2017 14:36:16 -0800 Subject: [PATCH 147/207] Use more specific types in a few cases --- src/compiler/factory.ts | 2 +- src/compiler/parser.ts | 5 +++-- src/compiler/types.ts | 23 ++++++++++------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 669c66c4337..453cd041148 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1486,7 +1486,7 @@ namespace ts { // Clauses - export function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]) { + export function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]) { const node = createSynthesizedNode(SyntaxKind.HeritageClause); node.token = token; node.types = createNodeArray(types); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f2175f385ec..ee74ce9c9a5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5437,9 +5437,10 @@ namespace ts { } function parseHeritageClause(): HeritageClause | undefined { - if (token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword) { + const tok = token(); + if (tok === SyntaxKind.ExtendsKeyword || tok === SyntaxKind.ImplementsKeyword) { const node = createNode(SyntaxKind.HeritageClause); - node.token = token(); + node.token = tok; nextToken(); node.types = parseDelimitedList(ParsingContext.HeritageClauseElement, parseExpressionWithTypeArguments); return finishNode(node); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a7adf28ac8e..f5bec267ed2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -863,15 +863,13 @@ namespace ts { kind: SyntaxKind.ThisType; } - export interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; - } + export type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - export interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + export interface FunctionTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.FunctionType; } - export interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + export interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.ConstructorType; } @@ -908,17 +906,16 @@ namespace ts { elementTypes: NodeArray; } - export interface UnionOrIntersectionTypeNode extends TypeNode { - kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; + export type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + + export interface UnionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType; types: NodeArray; } - export interface UnionTypeNode extends UnionOrIntersectionTypeNode { - kind: SyntaxKind.UnionType; - } - - export interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + export interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; + types: NodeArray; } export interface ParenthesizedTypeNode extends TypeNode { @@ -1779,7 +1776,7 @@ namespace ts { export interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; - token: SyntaxKind; + token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types?: NodeArray; } From 0c1642a8b778e9f117beb341b3b0ba20f4c5ca7d Mon Sep 17 00:00:00 2001 From: Mine Starks Date: Mon, 20 Mar 2017 16:07:20 -0700 Subject: [PATCH 148/207] Allow specifying location of typingSafeList.json --- src/server/server.ts | 10 +++++++++- src/server/shared.ts | 1 + src/server/typingsInstaller/nodeTypingsInstaller.ts | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index 4e443add779..e80b6f6b7b1 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -219,6 +219,7 @@ namespace ts.server { host: ServerHost, eventPort: number, readonly globalTypingsCacheLocation: string, + readonly typingSafeListLocation: string, private newLine: string) { this.throttledOperations = new ThrottledOperations(host); if (eventPort) { @@ -260,6 +261,9 @@ namespace ts.server { if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { args.push(Arguments.LogFile, combinePaths(getDirectoryPath(normalizeSlashes(this.logger.getLogFileName())), `ti-${process.pid}.log`)); } + if (this.typingSafeListLocation) { + args.push(Arguments.TypingSafeListLocation, this.typingSafeListLocation); + } const execArgv: string[] = []; { for (const arg of process.execArgv) { @@ -378,11 +382,12 @@ namespace ts.server { useSingleInferredProject: boolean, disableAutomaticTypingAcquisition: boolean, globalTypingsCacheLocation: string, + typingSafeListLocation: string, telemetryEnabled: boolean, logger: server.Logger) { const typingsInstaller = disableAutomaticTypingAcquisition ? undefined - : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); + : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, host.newLine); super( host, @@ -728,6 +733,8 @@ namespace ts.server { if (localeStr) { validateLocaleAndSetLanguage(localeStr, sys); } + + const typingSafeListLocation = findArgument("--typingSafeListLocation"); const useSingleInferredProject = hasArgument("--useSingleInferredProject"); const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition"); @@ -741,6 +748,7 @@ namespace ts.server { useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), + typingSafeListLocation, telemetryEnabled, logger); process.on("uncaughtException", function (err: Error) { diff --git a/src/server/shared.ts b/src/server/shared.ts index 5d65f8c90e9..6dcf8881927 100644 --- a/src/server/shared.ts +++ b/src/server/shared.ts @@ -11,6 +11,7 @@ namespace ts.server { export const GlobalCacheLocation = "--globalTypingsCacheLocation"; export const LogFile = "--logFile"; export const EnableTelemetry = "--enableTelemetry"; + export const TypingSafeListLocation = "--typingSafeListLocation"; } export function hasArgument(argumentName: string) { diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 0a9d8ee29f4..1018b37d90d 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -76,11 +76,11 @@ namespace ts.server.typingsInstaller { private delayedInitializationError: InitializationFailedResponse; - constructor(globalTypingsCacheLocation: string, throttleLimit: number, log: Log) { + constructor(globalTypingsCacheLocation: string, typingSafeListLocation: string, throttleLimit: number, log: Log) { super( sys, globalTypingsCacheLocation, - toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + typingSafeListLocation ? toPath(typingSafeListLocation, "", createGetCanonicalFileName(sys.useCaseSensitiveFileNames)) : toPath("typingSafeList.json", __dirname, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), throttleLimit, log); if (this.log.isEnabled()) { @@ -164,6 +164,7 @@ namespace ts.server.typingsInstaller { const logFilePath = findArgument(server.Arguments.LogFile); const globalTypingsCacheLocation = findArgument(server.Arguments.GlobalCacheLocation); + const typingSafeListLocation = findArgument(server.Arguments.TypingSafeListLocation); const log = new FileLog(logFilePath); if (log.isEnabled()) { @@ -177,6 +178,6 @@ namespace ts.server.typingsInstaller { } process.exit(0); }); - const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, /*throttleLimit*/5, log); + const installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, /*throttleLimit*/5, log); installer.listen(); } \ No newline at end of file From a8ffb5cad97e6cf04d8042e69dd6594c08b4633e Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 21 Mar 2017 07:26:47 -0700 Subject: [PATCH 149/207] Address code review --- ...ckUsedBeforeDefinitionInFunctionDeclaration.js | 15 +++++++++++++++ ...dBeforeDefinitionInFunctionDeclaration.symbols | 10 ++++++++++ ...sedBeforeDefinitionInFunctionDeclaration.types | 11 +++++++++++ ...eclarationCheckUsedBeforeDefinitionInItself.js | 9 +++++++++ ...ationCheckUsedBeforeDefinitionInItself.symbols | 8 ++++++++ ...arationCheckUsedBeforeDefinitionInItself.types | 9 +++++++++ ...ckUsedBeforeDefinitionInFunctionDeclaration.ts | 4 ++++ ...eclarationCheckUsedBeforeDefinitionInItself.ts | 4 ++++ 8 files changed, 70 insertions(+) create mode 100644 tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js create mode 100644 tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.symbols create mode 100644 tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.types create mode 100644 tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.js create mode 100644 tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.symbols create mode 100644 tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.types create mode 100644 tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts create mode 100644 tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js new file mode 100644 index 00000000000..195cd78f359 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js @@ -0,0 +1,15 @@ +//// [classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts] +function f() { + new C2(); // OK +} +class C2 { } + +//// [classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.js] +function f() { + new C2(); // OK +} +var C2 = (function () { + function C2() { + } + return C2; +}()); diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.symbols b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.symbols new file mode 100644 index 00000000000..19e4620b5cf --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts === +function f() { +>f : Symbol(f, Decl(classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts, 0, 0)) + + new C2(); // OK +>C2 : Symbol(C2, Decl(classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts, 2, 1)) +} +class C2 { } +>C2 : Symbol(C2, Decl(classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts, 2, 1)) + diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.types b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.types new file mode 100644 index 00000000000..62550065239 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts === +function f() { +>f : () => void + + new C2(); // OK +>new C2() : C2 +>C2 : typeof C2 +} +class C2 { } +>C2 : C2 + diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.js b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.js new file mode 100644 index 00000000000..b3a3d25a819 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.js @@ -0,0 +1,9 @@ +//// [classDeclarationCheckUsedBeforeDefinitionInItself.ts] +class C3 { + static intance = new C3(); // ok +} + +//// [classDeclarationCheckUsedBeforeDefinitionInItself.js] +class C3 { +} +C3.intance = new C3(); // ok diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.symbols b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.symbols new file mode 100644 index 00000000000..f0e6f2a5a71 --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts === +class C3 { +>C3 : Symbol(C3, Decl(classDeclarationCheckUsedBeforeDefinitionInItself.ts, 0, 0)) + + static intance = new C3(); // ok +>intance : Symbol(C3.intance, Decl(classDeclarationCheckUsedBeforeDefinitionInItself.ts, 0, 10)) +>C3 : Symbol(C3, Decl(classDeclarationCheckUsedBeforeDefinitionInItself.ts, 0, 0)) +} diff --git a/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.types b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.types new file mode 100644 index 00000000000..e4f36dda38c --- /dev/null +++ b/tests/baselines/reference/classDeclarationCheckUsedBeforeDefinitionInItself.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts === +class C3 { +>C3 : C3 + + static intance = new C3(); // ok +>intance : C3 +>new C3() : C3 +>C3 : typeof C3 +} diff --git a/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts new file mode 100644 index 00000000000..cf09163ed5a --- /dev/null +++ b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInFunctionDeclaration.ts @@ -0,0 +1,4 @@ +function f() { + new C2(); // OK +} +class C2 { } \ No newline at end of file diff --git a/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts new file mode 100644 index 00000000000..389c669e740 --- /dev/null +++ b/tests/cases/compiler/classDeclarationCheckUsedBeforeDefinitionInItself.ts @@ -0,0 +1,4 @@ +// @target: es6 +class C3 { + static intance = new C3(); // ok +} \ No newline at end of file From bb5b20b587d89a01d2e4a3bb8235205553006e38 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 21 Mar 2017 08:07:11 -0700 Subject: [PATCH 150/207] Address code review --- src/compiler/checker.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 56306fb772f..56b3a0704b8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14964,11 +14964,10 @@ namespace ts { } else { let yieldTypes: Type[]; - let returnTypes: Type[]; + let types: Type[]; if (functionFlags & FunctionFlags.Generator) { // Generator or AsyncGenerator function - yieldTypes = checkAndAggregateYieldOperandTypes(func, contextualMapper); - returnTypes = checkAndAggregateReturnExpressionTypes(func, contextualMapper); - if (yieldTypes.length === 0 && (!returnTypes || returnTypes.length === 0)) { + types = concatenate(checkAndAggregateYieldOperandTypes(func, contextualMapper), checkAndAggregateReturnExpressionTypes(func, contextualMapper)); + if (!types || types.length === 0) { const iterableIteratorAny = functionFlags & FunctionFlags.Async ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function : createIterableIteratorType(anyType); // Generator function @@ -14980,14 +14979,14 @@ namespace ts { } } else { - returnTypes = checkAndAggregateReturnExpressionTypes(func, contextualMapper); - if (!returnTypes) { + types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. return functionFlags & FunctionFlags.Async ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } - if (returnTypes.length === 0) { + if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. return functionFlags & FunctionFlags.Async ? createPromiseReturnType(func, voidType) // Async function @@ -14995,7 +14994,7 @@ namespace ts { } } // Return a union of the return expression types. - type = getUnionType(yieldTypes ? yieldTypes.concat(returnTypes) : returnTypes, /*subtypeReduction*/ true); + type = getUnionType(yieldTypes ? yieldTypes.concat(types) : types, /*subtypeReduction*/ true); if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function type = functionFlags & FunctionFlags.Async From 71e52dea923670fac1b8373ec041009bd0cc95ba Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Tue, 21 Mar 2017 08:38:01 -0700 Subject: [PATCH 151/207] finish remove unused yieldTypes --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f550fcf9c35..43311c81f7b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15138,7 +15138,7 @@ namespace ts { } } // Return a union of the return expression types. - type = getUnionType(yieldTypes ? yieldTypes.concat(types) : types, /*subtypeReduction*/ true); + type = getUnionType(types, /*subtypeReduction*/ true); if (functionFlags & FunctionFlags.Generator) { // AsyncGenerator function or Generator function type = functionFlags & FunctionFlags.Async From 1b2cd3e01a7bfa7e3986f9d95c56db79e5e722c9 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 20 Mar 2017 07:28:55 -0700 Subject: [PATCH 152/207] Remove unused test files --- Gulpfile.ts | 2 +- Jakefile.js | 2 +- .../formatting/documentFormattingTests.json | 80 ---- .../formatting/formatDiffTemplate.html | 66 --- .../formatting/getFormattingEditsForRange.ts | 88 ---- .../formatting/getSmartIndentAtLineNumber.ts | 410 ------------------ .../importedJavaScriptFormatting.ts | 212 --------- .../formatting/ruleFormattingTests.json | 284 ------------ .../formatting/testCode/formatting/classes.ts | 79 ---- .../testCode/formatting/classesBaseline.ts | 79 ---- .../testCode/formatting/colonAndQMark.ts | 4 - .../formatting/colonAndQMarkBaseline.ts | 4 - .../formatting/documentReadyFunction.ts | 3 - .../documentReadyFunctionBaseLine.ts | 3 - .../testCode/formatting/emptyBlock.ts | 1 - .../testCode/formatting/emptyBlockBaseline.ts | 1 - .../formatting/emptyInterfaceLiteral.ts | 10 - .../emptyInterfaceLiteralBaseLine.ts | 10 - .../testCode/formatting/fatArrowFunctions.ts | 112 ----- .../formatting/fatArrowFunctionsBaseline.ts | 112 ----- .../formatting/formatDebuggerStatement.ts | 2 - .../formatDebuggerStatementBaseline.ts | 2 - .../formatvariableDeclarationList.ts | 13 - .../formatvariableDeclarationListBaseline.ts | 13 - .../testCode/formatting/implicitModule.ts | 3 - .../formatting/implicitModuleBaseline.ts | 3 - .../testCode/formatting/importDeclaration.ts | 6 - .../formatting/importDeclarationBaseline.ts | 6 - .../formatting/testCode/formatting/main.ts | 95 ---- .../testCode/formatting/mainBaseline.ts | 98 ----- .../testCode/formatting/moduleIndentation.ts | 3 - .../formatting/moduleIndentationBaseline.ts | 3 - .../formatting/testCode/formatting/modules.ts | 76 ---- .../testCode/formatting/modulesBaseline.ts | 76 ---- .../testCode/formatting/objectLiteral.ts | 27 -- .../formatting/objectLiteralBaseline.ts | 31 -- .../testCode/formatting/onClosingBracket.ts | 32 -- .../formatting/onClosingBracketBaseLine.ts | 28 -- .../testCode/formatting/onSemiColon.ts | 1 - .../formatting/onSemiColonBaseline.ts | 1 - .../formatting/spaceAfterConstructor.ts | 1 - .../spaceAfterConstructorBaseline.ts | 1 - .../testCode/formatting/tabAfterCloseCurly.ts | 10 - .../formatting/tabAfterCloseCurlyBaseline.ts | 9 - .../formatting/typescriptConstructs.ts | 65 --- .../typescriptConstructsBaseline.ts | 58 --- .../formatting/testCode/formatting/various.ts | 17 - .../testCode/formatting/variousBaseline.ts | 17 - .../testCode/formatting/withStatement.ts | 9 - .../formatting/withStatementBaseline.ts | 6 - .../fourslash_old/callOrderDependence.ts | 9 - .../chainedFunctionCallsErrorSpan.ts | 5 - .../completionListGenericConstraintsNames.ts | 24 - .../completionListInTypedObjectLiterals.ts | 142 ------ ...onstructorOverloadWithoutImplementation.ts | 9 - ...nstructorOverloadWithoutImplementation2.ts | 9 - .../fourslash_old/exportEqualIncremental.ts | 20 - tests/cases/fourslash_old/findReferences.ts | 62 --- tests/cases/fourslash_old/findReferences1.ts | 28 -- .../fourslash_old/findReferencesAliases1.ts | 20 - .../fourslash_old/findReferencesModules1.ts | 27 -- .../funduleDefinedInADifferentFile.ts | 12 - .../funduleDefinedInADifferentFile2.ts | 29 -- .../fourslash_old/genericIncrementalParse.ts | 30 -- .../genericStructuralTypeConstraint.ts | 37 -- .../getTypeOfUnresolvedGenericExtension.ts | 10 - .../fourslash_old/overloadResolutionErrors.ts | 38 -- tests/cases/fourslash_old/thisRefGotoDef.ts | 12 - 68 files changed, 2 insertions(+), 2795 deletions(-) delete mode 100644 src/harness/unittests/services/formatting/documentFormattingTests.json delete mode 100644 src/harness/unittests/services/formatting/formatDiffTemplate.html delete mode 100644 src/harness/unittests/services/formatting/getFormattingEditsForRange.ts delete mode 100644 src/harness/unittests/services/formatting/getSmartIndentAtLineNumber.ts delete mode 100644 src/harness/unittests/services/formatting/importedJavaScriptFormatting.ts delete mode 100644 src/harness/unittests/services/formatting/ruleFormattingTests.json delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/classes.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/classesBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/colonAndQMark.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/colonAndQMarkBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunction.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunctionBaseLine.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/emptyBlock.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/emptyBlockBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteral.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteralBaseLine.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctions.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctionsBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatement.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatementBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationList.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationListBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/implicitModule.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/implicitModuleBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/importDeclaration.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/importDeclarationBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/main.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/mainBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/moduleIndentation.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/moduleIndentationBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/modules.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/modulesBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/objectLiteral.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/objectLiteralBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/onClosingBracket.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/onClosingBracketBaseLine.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/onSemiColon.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/onSemiColonBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructor.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructorBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurly.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurlyBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructs.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructsBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/various.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/variousBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/withStatement.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/formatting/withStatementBaseline.ts delete mode 100644 tests/cases/fourslash_old/callOrderDependence.ts delete mode 100644 tests/cases/fourslash_old/chainedFunctionCallsErrorSpan.ts delete mode 100644 tests/cases/fourslash_old/completionListGenericConstraintsNames.ts delete mode 100644 tests/cases/fourslash_old/completionListInTypedObjectLiterals.ts delete mode 100644 tests/cases/fourslash_old/constructorOverloadWithoutImplementation.ts delete mode 100644 tests/cases/fourslash_old/constructorOverloadWithoutImplementation2.ts delete mode 100644 tests/cases/fourslash_old/exportEqualIncremental.ts delete mode 100644 tests/cases/fourslash_old/findReferences.ts delete mode 100644 tests/cases/fourslash_old/findReferences1.ts delete mode 100644 tests/cases/fourslash_old/findReferencesAliases1.ts delete mode 100644 tests/cases/fourslash_old/findReferencesModules1.ts delete mode 100644 tests/cases/fourslash_old/funduleDefinedInADifferentFile.ts delete mode 100644 tests/cases/fourslash_old/funduleDefinedInADifferentFile2.ts delete mode 100644 tests/cases/fourslash_old/genericIncrementalParse.ts delete mode 100644 tests/cases/fourslash_old/genericStructuralTypeConstraint.ts delete mode 100644 tests/cases/fourslash_old/getTypeOfUnresolvedGenericExtension.ts delete mode 100644 tests/cases/fourslash_old/overloadResolutionErrors.ts delete mode 100644 tests/cases/fourslash_old/thisRefGotoDef.ts diff --git a/Gulpfile.ts b/Gulpfile.ts index 296e374a53f..022606e133b 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -1024,7 +1024,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: const fileMatcher = cmdLineOptions["files"]; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; console.log("Linting: " + cmd); child_process.execSync(cmd, { stdio: [0, 1, 2] }); diff --git a/Jakefile.js b/Jakefile.js index 9c2b3d38d10..100ebc63f44 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1182,7 +1182,7 @@ task("lint", ["build-rules"], () => { const fileMatcher = process.env.f || process.env.file || process.env.files; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts' --exclude 'src/harness/unittests/services/**/*.ts'"; + : "Gulpfile.ts 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; console.log("Linting: " + cmd); jake.exec([cmd], { interactive: true }, () => { diff --git a/src/harness/unittests/services/formatting/documentFormattingTests.json b/src/harness/unittests/services/formatting/documentFormattingTests.json deleted file mode 100644 index f7d48dba8c7..00000000000 --- a/src/harness/unittests/services/formatting/documentFormattingTests.json +++ /dev/null @@ -1,80 +0,0 @@ -{ input: "function foo () {}", rules: [ ], span: { start: 0, length: 20 }, expected: "function foo() { }" }, -{ input: "var a = (0);\r\na = (1 % 2);\r\nvar b = new Array(1, 2);\r\nfunction c(d) {\r\n try { }\r\n catch (e) { }\r\n for (f = 0; f < 10; ++f) { }\r\n for (g in h) { }\r\n if (true) {\r\n } else if (false) { }\r\n switch (i) {\r\n case (0):\r\n break;\r\n }\r\n do { } while (true);\r\n with (j) {\r\n }\r\n delete (h);\r\n void (i);\r\n}", rules: [ "SpaceAfterOpenParen", "SpaceBeforeCloseParen", "NoSpaceBetweenParens" ], span: { start: 0, length: 349 }, expected: "var a = ( 0 );\r\na = ( 1 % 2 );\r\nvar b = new Array( 1, 2 );\r\nfunction c( d ) {\r\n try { }\r\n catch ( e ) { }\r\n for ( f = 0; f < 10; ++f ) { }\r\n for ( g in h ) { }\r\n if ( true ) {\r\n } else if ( false ) { }\r\n switch ( i ) {\r\n case ( 0 ):\r\n break;\r\n }\r\n do { } while ( true );\r\n with ( j ) {\r\n }\r\n delete ( h );\r\n void ( i );\r\n}" }, -{ input: "var a = ( 0 );\r\na = ( 1 % 2 );\r\nvar b = new Array( 1, 2 );\r\nfunction c( d ) {\r\n try { }\r\n catch ( e ) { }\r\n for ( f = 0; f < 10; ++f ) { }\r\n for ( g in h ) { }\r\n if ( true ) {\r\n } else if ( false ) { }\r\n switch ( i ) {\r\n case ( 0 ):\r\n break;\r\n }\r\n do { } while ( true );\r\n with ( j ) {\r\n }\r\n delete ( h );\r\n void ( i );\r\n}", rules: [ "NoSpaceAfterOpenParen", "NoSpaceBeforeCloseParen", "NoSpaceBetweenParens" ], span: { start: 0, length: 379 }, expected: "var a = (0);\r\na = (1 % 2);\r\nvar b = new Array(1, 2);\r\nfunction c(d) {\r\n try { }\r\n catch (e) { }\r\n for (f = 0; f < 10; ++f) { }\r\n for (g in h) { }\r\n if (true) {\r\n } else if (false) { }\r\n switch (i) {\r\n case (0):\r\n break;\r\n }\r\n do { } while (true);\r\n with (j) {\r\n }\r\n delete (h);\r\n void (i);\r\n}" }, -{ input: "this . alert( \"Hello, World!\" );", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 32 }, expected: "this.alert( \"Hello, World!\" );" }, -{ input: "a\r\n;b;", rules: [ ], span: { start: 0, length: 6 }, expected: "a\r\n; b;" }, -{ input: "a\r\n; b;", rules: [ ], span: { start: 0, length: 8 }, expected: "a\r\n; b;" }, -{ input: "var a , b;\r\nf(a , b);", rules: [ ], span: { start: 0, length: 40 }, expected: "var a, b;\r\nf(a, b);" }, -{ input: "function a() {\r\n while(false)\r\n switch(b) { }\r\n\r\n for(c in d)\r\n if(c)\r\n break;\r\n\r\n do { } while(true);\r\n with(f)\r\n g = null;\r\n}", rules: [ "SpaceAfterKeywordInControl" ], span: { start: 0, length: 171 }, expected: "function a() {\r\n while (false)\r\n switch (b) { }\r\n\r\n for (c in d)\r\n if (c)\r\n break;\r\n\r\n do { } while (true);\r\n with (f)\r\n g = null;\r\n}" }, -{ input: "function a() {\r\n while (false)\r\n switch (b) { }\r\n\r\n for (c in d)\r\n if (c)\r\n break;\r\n\r\n do { } while (true);\r\n with (f)\r\n g = null;\r\n}", rules: [ "NoSpaceAfterKeywordInControl" ], span: { start: 0, length: 177 }, expected: "function a() {\r\n while(false)\r\n switch(b) { }\r\n\r\n for(c in d)\r\n if(c)\r\n break;\r\n\r\n do { } while(true);\r\n with(f)\r\n g = null;\r\n}" }, -{ input: "{\r\n(a);\r\n}", rules: [ ], span: { start: 0, length: 10 }, expected: "{\r\n (a);\r\n}" }, -{ input: "var a=[1,2];\r\nvar b=8>>2 ;\r\nvar c=1+2;", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 14, length: 12 }, expected: "var a=[1,2];\r\nvar b = 8 >> 2;\r\nvar c=1+2;" }, -{ input: "if (true) {\r\n(a);\r\n}", rules: [ ], span: { start: 0, length: 20 }, expected: "if (true) {\r\n (a);\r\n}" }, -{ input: " // var a=[1,2];\r\n /*var a=[3,4];*/\r\n /*\r\n var a=[5,6];\r\n */", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 62 }, expected: "// var a=[1,2];\r\n/*var a=[3,4];*/\r\n/*\r\n var a=[5,6];\r\n */" }, -{ input: "f ();", rules: [ ], span: { start: 0, length: 14 }, expected: "f();" }, -{ input: "var a = { b: 1 , c: 2 };\r\nvar d = [1 , 2];", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 44 }, expected: "var a = { b: 1, c: 2 };\r\nvar d = [1, 2];" }, -{ input: "if (a)\r\n if (b)\r\n if (c)\r\n c();\r\n else\r\n b();\r\n else\r\n b();\r\nelse\r\n a();", rules: [ ], span: { start: 0, length: 124 }, expected: "if (a)\r\n if (b)\r\n if (c)\r\n c();\r\n else\r\n b();\r\n else\r\n b();\r\nelse\r\n a();" }, -{ input: "function a() { };", rules: [ ], span: { start: 0, length: 20 }, expected: "function a() { };" }, -{ input: "var a =[1.2,\"JavaScript\",true,{ x: 1,y: 3 }];\r\nvar b =[[1,2],[3,4]];\r\nvar c =[1,,,,5];\r\nvar d =[\r\n [1,2],\r\n [3,4]\r\n];", rules: [ "SpaceAfterComma" ], span: { start: 0, length: 123 }, expected: "var a =[1.2, \"JavaScript\", true, { x: 1, y: 3 }];\r\nvar b =[[1, 2], [3, 4]];\r\nvar c =[1, , , , 5];\r\nvar d =[\r\n [1, 2],\r\n [3, 4]\r\n];" }, -{ input: "var a =[1.2, \"JavaScript\", true, { x: 1, y: 3 }];\r\nvar b =[[1, 2], [3, 4]];\r\nvar c =[1, , , , 5];\r\nvar d =[\r\n [1, 2],\r\n [3, 4]\r\n];", rules: [ "NoSpaceAfterComma" ], span: { start: 0, length: 136 }, expected: "var a =[1.2,\"JavaScript\",true,{ x: 1,y: 3 }];\r\nvar b =[[1,2],[3,4]];\r\nvar c =[1,,,,5];\r\nvar d =[\r\n [1,2],\r\n [3,4]\r\n];" }, -{ input: "function a(b,c) { }\r\na(0,1);\r\nvar a =[,];\r\nvar a =[0,1];\r\nvar a,b,c = 0,d = 0;\r\nfor (var a = 0,b = 10; a < 10,b >= 0; ++a,--b) { }\r\nvar a = new ActiveXObject(\"\",\"\");\r\nswitch (a) {\r\n case 1,2,3:\r\n break;\r\n}", rules: [ "SpaceAfterComma" ], span: { start: 0, length: 215 }, expected: "function a(b, c) { }\r\na(0, 1);\r\nvar a =[, ];\r\nvar a =[0, 1];\r\nvar a, b, c = 0, d = 0;\r\nfor (var a = 0, b = 10; a < 10, b >= 0; ++a, --b) { }\r\nvar a = new ActiveXObject(\"\", \"\");\r\nswitch (a) {\r\n case 1, 2, 3:\r\n break;\r\n}" }, -{ input: "function a(b, c) { }\r\na(0, 1);\r\nvar a =[, ];\r\nvar a =[0, 1];\r\nvar a, b, c = 0, d = 0;\r\nfor (var a = 0, b = 10; a < 10, b >= 0; ++a, --b) { }\r\nvar a = new ActiveXObject(\"\", \"\");\r\nswitch (a) {\r\n case 1, 2, 3:\r\n break;\r\n}", rules: [ "NoSpaceAfterComma" ], span: { start: 0, length: 228 }, expected: "function a(b,c) { }\r\na(0,1);\r\nvar a =[,];\r\nvar a =[0,1];\r\nvar a,b,c = 0,d = 0;\r\nfor (var a = 0,b = 10; a < 10,b >= 0; ++a,--b) { }\r\nvar a = new ActiveXObject(\"\",\"\");\r\nswitch (a) {\r\n case 1,2,3:\r\n break;\r\n}" }, -{ input: "function Sum(a, b, c) {\r\nvar d = 1;\r\n}", rules: [ ], span: { start: 0, length: 38 }, expected: "function Sum(a, b, c) {\r\n var d = 1;\r\n}" }, -{ input: "(function() { })();\r\nvar a = function() { };\r\nvar a = { b: function() { } };", rules: [ "SpaceAfterAnonymousFunctionKeyword" ], span: { start: 0, length: 76 }, expected: "(function () { })();\r\nvar a = function () { };\r\nvar a = { b: function () { } };" }, -{ input: "(function () { })();\r\nvar a = function () { };\r\nvar a = { b: function () { } };", rules: [ "NoSpaceAfterAnonymousFunctionKeyword" ], span: { start: 0, length: 79 }, expected: "(function() { })();\r\nvar a = function() { };\r\nvar a = { b: function() { } };" }, -{ input: "function a() {\r\n}b;", rules: [ ], span: { start: 0, length: 19 }, expected: "function a() {\r\n} b;" }, -{ input: "function a() {\r\n} b;", rules: [ ], span: { start: 0, length: 21 }, expected: "function a() {\r\n} b;" }, -{ input: "function a(){return 0;}\r\nfunction b(){toString();return 0;}", rules: [ ], span: { start: 0, length: 59 }, expected: "function a() { return 0; }\r\nfunction b() { toString(); return 0; }" }, -{ input: "for (var i = 0;i < 10;++i) { }", rules: [ "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 30 }, expected: "for (var i = 0; i < 10; ++i) { }" }, -{ input: "for (var i = 0; i < 10; ++i) { }", rules: [ "NoSpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "for (var i = 0;i < 10;++i) { }" }, -{ input: "function f() {\r\nif (1)\r\n{\r\nvar a=0;\r\n}\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl", "NewLineBeforeOpenCurlyInFunction" ], span: { start: 0, length: 41 }, expected: "function f()\n{\r\n if (1) {\r\n var a=0;\r\n }\r\n}" }, -{ input: "function a(b) {\r\n a({\r\n});\r\n}", rules: [ ], span: { start: 0, length: 32 }, expected: "function a(b) {\r\n a({\r\n });\r\n}" }, -{ input: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 3, length: 12 }, expected: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/" }, -{ input: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 21, length: 12 }, expected: "// var a=[1,2];\r\n/*\r\nvar a=[1,2];\r\n*/" }, -{ input: "eval(\"var a=b[1,2+3];\");", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 6, length: 15 }, expected: "eval(\"var a=b[1,2+3];\");" }, -{ input: "0 + +1;\r\n0 + +a;\r\n0 + +(1);\r\n0 + +(+1);\r\n0 + +[1];\r\n0 + +[+1];\r\n0 + +this.a;\r\n0 + +new Number(+1);\r\n\r\n0 - -1;\r\n0 - -a;\r\n0 - -(1);\r\n0 - -(-1);\r\n0 - -[1];\r\n0 - -[-1];\r\n0 - -this.a;\r\n0 - -new Number(-1);\r\n\r\n0 + ~1;\r\n0 - ~a;\r\n0 + ~(1);\r\n0 - ~(~1);\r\n0 + ~[1];\r\n0 - ~[~1];\r\n0 + ~this.a;\r\n0 - ~new Number(~1);\r\n\r\n0 - !1;\r\n0 + !a;\r\n0 - !(1);\r\n0 + !(!1);\r\n0 - ![1];\r\n0 + ![!1];\r\n0 - !this.a;\r\n0 + !new Number(!1);", rules: [ "NoSpaceBeforeBinaryOperator", "NoSpaceAfterBinaryOperator" ], span: { start: 0, length: 404 }, expected: "0+ +1;\r\n0+ +a;\r\n0+ +(1);\r\n0+ +(+1);\r\n0+ +[1];\r\n0+ +[+1];\r\n0+ +this.a;\r\n0+ +new Number(+1);\r\n\r\n0- -1;\r\n0- -a;\r\n0- -(1);\r\n0- -(-1);\r\n0- -[1];\r\n0- -[-1];\r\n0- -this.a;\r\n0- -new Number(-1);\r\n\r\n0+~1;\r\n0-~a;\r\n0+~(1);\r\n0-~(~1);\r\n0+~[1];\r\n0-~[~1];\r\n0+~this.a;\r\n0-~new Number(~1);\r\n\r\n0-!1;\r\n0+!a;\r\n0-!(1);\r\n0+!(!1);\r\n0-![1];\r\n0+![!1];\r\n0-!this.a;\r\n0+!new Number(!1);" }, -{ input: "0+ +1;\r\n0+ +a;\r\n0+ +(1);\r\n0+ +(+1);\r\n0+ +[1];\r\n0+ +[+1];\r\n0+ +this.a;\r\n0+ +new Number(+1);\r\n\r\n0- -1;\r\n0- -a;\r\n0- -(1);\r\n0- -(-1);\r\n0- -[1];\r\n0- -[-1];\r\n0- -this.a;\r\n0- -new Number(-1);\r\n\r\n0+~1;\r\n0-~a;\r\n0+~(1);\r\n0-~(~1);\r\n0+~[1];\r\n0-~[~1];\r\n0+~this.a;\r\n0-~new Number(~1);\r\n\r\n0-!1;\r\n0+!a;\r\n0-!(1);\r\n0+!(!1);\r\n0-![1];\r\n0+![!1];\r\n0-!this.a;\r\n0+!new Number(!1);", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 356 }, expected: "0 + +1;\r\n0 + +a;\r\n0 + +(1);\r\n0 + +(+1);\r\n0 + +[1];\r\n0 + +[+1];\r\n0 + +this.a;\r\n0 + +new Number(+1);\r\n\r\n0 - -1;\r\n0 - -a;\r\n0 - -(1);\r\n0 - -(-1);\r\n0 - -[1];\r\n0 - -[-1];\r\n0 - -this.a;\r\n0 - -new Number(-1);\r\n\r\n0 + ~1;\r\n0 - ~a;\r\n0 + ~(1);\r\n0 - ~(~1);\r\n0 + ~[1];\r\n0 - ~[~1];\r\n0 + ~this.a;\r\n0 - ~new Number(~1);\r\n\r\n0 - !1;\r\n0 + !a;\r\n0 - !(1);\r\n0 + !(!1);\r\n0 - ![1];\r\n0 + ![!1];\r\n0 - !this.a;\r\n0 + !new Number(!1);" }, -{ input: "for (var a = 0; a < 2; ++a) {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl", "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "for (var a = 0; a < 2; ++a)\n{\r\n}" }, -{ input: "for (var a = 0; a < 2; ++a)\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl", "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "for (var a = 0; a < 2; ++a) {\r\n}" }, -{ input: "function foo(a, b, c) { a = b + c;\n}", rules: [ "NewLineBeforeOpenCurlyInFunction", "NewLineAfterOpenCurlyInBlockContext", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 36 }, expected: "function foo(a, b, c)\n{\n a = b + c;\n}" }, -{ input: "function a() {\r\n // comment\r\n}", rules: [ ], span: { start: 0, length: 33 }, expected: "function a() {\r\n // comment\r\n}" }, -{ input: "if (false) {\r\n} else if (true) {\r\n} else {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 45 }, expected: "if (false)\n{\r\n} else if (true)\n{\r\n} else\n{\r\n}" }, -{ input: "if (false)\n{\r\n} else if (true)\n{\r\n} else\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 45 }, expected: "if (false) {\r\n} else if (true) {\r\n} else {\r\n}" }, -{ input: "var a = (0);\r\nvar b = (1);\r\nvar c = (1 + 2);\r\nvar d = ((1 + 2)-(3 + 4));\r\n\r\nvar e = ( 0 );\r\nvar f = ( 1 );\r\nvar g = ( 1 + 2 );\r\nvar h = ( ( 1 + 2 ) - ( 3 + 4 ) );", rules: [ "SpaceAfterOpenParen", "SpaceBeforeCloseParen", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 162 }, expected: "var a = ( 0 );\r\nvar b = ( 1 );\r\nvar c = ( 1 + 2 );\r\nvar d = ( ( 1 + 2 ) - ( 3 + 4 ) );\r\n\r\nvar e = ( 0 );\r\nvar f = ( 1 );\r\nvar g = ( 1 + 2 );\r\nvar h = ( ( 1 + 2 ) - ( 3 + 4 ) );" }, -{ input: "eval(\"var a=b[1,2+3];\");", rules: [ "SpaceAfterComma", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 24 }, expected: "eval(\"var a=b[1,2+3];\");" }, -{ input: "for (a in b)\r\n\r\n{ i++; }\r\n\r\nfor (a in b)\r\n\r\n{\r\ni++; }", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 53 }, expected: "for (a in b)\r\n\r\n{ i++; }\r\n\r\nfor (a in b) {\r\n i++;\n}" }, -{ input: "for (a in b) {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "for (a in b)\n{\r\n}" }, -{ input: "for (a in b)\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "for (a in b) {\r\n}" }, -{ input: " var a = { } ; \r\nvar b = { c : d, e : { } };\r\n ", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 59 }, expected: "var a = {};\r\nvar b = { c: d, e: {} };\r\n" }, -{ input: "while (true) { }", rules: [ ], span: { start: 0, length: 19 }, expected: "while (true) { }" }, -{ input: "for (a in b){ i++; }\r\n\r\nfor (a in b){ i++; }", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 44 }, expected: "for (a in b) { i++; }\r\n\r\nfor (a in b) { i++; }" }, -{ input: "function a() {\r\n}", rules: [ "NewLineBeforeOpenCurlyInFunction" ], span: { start: 0, length: 17 }, expected: "function a()\n{\r\n}" }, -{ input: "function a()\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInFunction" ], span: { start: 0, length: 17 }, expected: "function a() {\r\n}" }, -{ input: "a;\r\nb;c;\r\nd;", rules: [ ], span: { start: 0, length: 12 }, expected: "a;\r\nb; c;\r\nd;" }, -{ input: "a;\r\nb; c;\r\nd;", rules: [ ], span: { start: 0, length: 14 }, expected: "a;\r\nb; c;\r\nd;" }, -{ input: " var a = 0;\r\n function b() {\r\n var c = 0;\r\n }", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 61 }, expected: "var a = 0;\r\nfunction b() {\r\n var c = 0;\r\n}" }, -{ input: "a;b;", rules: [ ], span: { start: 0, length: 4 }, expected: "a; b;" }, -{ input: "a; b;", rules: [ ], span: { start: 0, length: 6 }, expected: "a; b;" }, -{ input: "var a = (0);\r\nvar b = (1);\r\nvar c = (1 + 2);\r\nvar d = ((1 + 2)-(3 + 4));\r\n\r\nvar e = ( 0 );\r\nvar f = ( 1 );\r\nvar g = ( 1 + 2 );\r\nvar h = ( ( 1 + 2 ) - ( 3 + 4 ) );", rules: [ "NoSpaceAfterOpenParen", "NoSpaceBeforeCloseParen", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 162 }, expected: "var a = (0);\r\nvar b = (1);\r\nvar c = (1 + 2);\r\nvar d = ((1 + 2) - (3 + 4));\r\n\r\nvar e = (0);\r\nvar f = (1);\r\nvar g = (1 + 2);\r\nvar h = ((1 + 2) - (3 + 4));" }, -{ input: "function a() {\r\n(b);\r\n}", rules: [ ], span: { start: 0, length: 23 }, expected: "function a() {\r\n (b);\r\n}" }, -{ input: "function test(a) {\n var i;\n for (i = 0;i < 1; i++){ //select\n a++;//select\n }\n}", rules: [ "NewLineBeforeOpenCurlyInControl", "NewLineAfterOpenCurlyInBlockContext", "NewLineBeforeOpenCurlyInFunction", "SpaceAfterSemicolonInFor" ], span: { start: 30, length: 50 }, expected: "function test(a) {\n var i;\n for (i = 0; i < 1; i++)\n { //select\n a++;//select\n }\n}" }, -{ input: "function a(){ return 1; }", rules: [ "SpaceBeforeOpenCurlyInFunction" ], span: { start: 0, length: 25 }, expected: "function a() { return 1; }" }, -{ input: "do {\r\n} while (true);", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 21 }, expected: "do\n{\r\n} while (true);" }, -{ input: "do\n{\r\n} while (true);", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 21 }, expected: "do {\r\n} while (true);" }, -{ input: "for (;;) { a = b + c; b = 2;\n}", rules: [ "NewLineBeforeOpenCurlyInControl", "NewLineAfterOpenCurlyInBlockContext", "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator", "NoSpaceAfterSemicolonInFor" ], span: { start: 0, length: 30 }, expected: "for (;;)\n{\n a = b + c; b = 2;\n}" }, -{ input: "var a =0;\r\n\r\n+ 1;\r\n+ a;\r\n+ (1);\r\n+ (+ 1);\r\n+ [1];\r\n+ [+ 1];\r\n+ this.a;\r\n+ new Number(+ 1);\r\n\r\n- 1;\r\n- a;\r\n- (1);\r\n- (- 1);\r\n- [1];\r\n- [- 1];\r\n- this.a;\r\n- new Number(- 1);\r\n\r\n~ 1;\r\n~ a;\r\n~ (1);\r\n~ (~ 1);\r\n~ [1];\r\n~ [~ 1];\r\n~ this.a;\r\n~ new Number(~ 1);\r\n\r\n! 1;\r\n! a;\r\n! (1);\r\n! (! 1);\r\n! [1];\r\n! [! 1];\r\n! this.a;\r\n! new Number(! 1);\r\n\r\n++ a;\r\n++ (a);\r\n++ this.a;\r\n++ new f().a;\r\n\r\n-- a;\r\n-- (a);\r\n-- this.a;\r\n-- new f().a;\r\n\r\na ++;\r\n(a) ++;\r\nthis.a ++;\r\nnew f().a ++;\r\n\r\na --;\r\n(a) --;\r\nthis.a --;\r\nnew f().a --;", rules: [ ], span: { start: 0, length: 513 }, expected: "var a =0;\r\n\r\n+1;\r\n+a;\r\n+(1);\r\n+(+1);\r\n+[1];\r\n+[+1];\r\n+this.a;\r\n+new Number(+1);\r\n\r\n-1;\r\n-a;\r\n-(1);\r\n-(-1);\r\n-[1];\r\n-[-1];\r\n-this.a;\r\n-new Number(-1);\r\n\r\n~1;\r\n~a;\r\n~(1);\r\n~(~1);\r\n~[1];\r\n~[~1];\r\n~this.a;\r\n~new Number(~1);\r\n\r\n!1;\r\n!a;\r\n!(1);\r\n!(!1);\r\n![1];\r\n![!1];\r\n!this.a;\r\n!new Number(!1);\r\n\r\n++a;\r\n++(a);\r\n++this.a;\r\n++new f().a;\r\n\r\n--a;\r\n--(a);\r\n--this.a;\r\n--new f().a;\r\n\r\na++;\r\n(a)++;\r\nthis.a++;\r\nnew f().a++;\r\n\r\na--;\r\n(a)--;\r\nthis.a--;\r\nnew f().a--;" }, -{ input: "switch (a) {\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 74 }, expected: "switch (a)\n{\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}" }, -{ input: "switch (a)\n{\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 74 }, expected: "switch (a) {\r\n case 0:\r\n break;\r\n default:\r\n break;\r\n}" }, -{ input: "function a()\r\n\r\n\r\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInFunction" ], span: { start: 0, length: 22 }, expected: "function a() {\r\n}" }, -{ input: "try {\r\n} catch (e) {\r\n} finally {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 36 }, expected: "try\n{\r\n} catch (e)\n{\r\n} finally\n{\r\n}" }, -{ input: "try\n{\r\n} catch (e)\n{\r\n} finally\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 36 }, expected: "try {\r\n} catch (e) {\r\n} finally {\r\n}" }, -{ input: "with (a) {\r\n b = 0;\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 25 }, expected: "with (a)\n{\r\n b = 0;\r\n}" }, -{ input: "with (a)\n{\r\n b = 0;\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 25 }, expected: "with (a) {\r\n b = 0;\r\n}" }, -{ input: "var a=0+1-2*3/4%5;\r\na+=6;\r\na-=7;\r\na*=7;\r\na/=8;\r\na%=9;\r\na=+1- -2+ +3;\r\na=1.0+2.+.0;\r\n++a+a++;\r\n--a-a--;\r\n\r\nvar b=~1&2|3^4<<1>>1>>>2;\r\nb&=5;\r\nb^=6;\r\nb|=7;\r\nb<<=8;\r\nb>>=9;\r\nb>>>=10;\r\n\r\nvar c=a>b;\r\nc=b=b;\r\nc=!c;\r\n\r\n++a+ ++a+a++ +a++ + ++a;\r\n--a- --a-a-- -a-- - --a;\r\n\r\nfunction d::e() { }", rules: [ "SpaceBeforeBinaryOperator", "SpaceAfterBinaryOperator" ], span: { start: 0, length: 366 }, expected: "var a = 0 + 1 - 2 * 3 / 4 % 5;\r\na += 6;\r\na -= 7;\r\na *= 7;\r\na /= 8;\r\na %= 9;\r\na = +1 - -2 + +3;\r\na = 1.0 + 2. + .0;\r\n++a + a++;\r\n--a - a--;\r\n\r\nvar b = ~1 & 2 | 3 ^ 4 << 1 >> 1 >>> 2;\r\nb &= 5;\r\nb ^= 6;\r\nb |= 7;\r\nb <<= 8;\r\nb >>= 9;\r\nb >>>= 10;\r\n\r\nvar c = a > b;\r\nc = b < a ? a : b;\r\nc = true && false || true;\r\nc = a == b;\r\nc = a === b;\r\nc = a != b;\r\nc = a !== b;\r\nc = a <= b;\r\nc = a >= b;\r\nc = !c;\r\n\r\n++a + ++a + a++ + a++ + ++a;\r\n--a - --a - a-- - a-- - --a;\r\n\r\nfunction d::e() { }" }, -{ input: "var a = 0 + 1 - 2 * 3 / 4 % 5;\r\na += 6;\r\na -= 7;\r\na *= 7;\r\na /= 8;\r\na %= 9;\r\na = +1 - -2 + +3;\r\na = 1.0 + 2. + .0;\r\n++a + a++;\r\n--a - a--;\r\n\r\nvar b = ~1 & 2 | 3 ^ 4 << 1 >> 1 >>> 2;\r\nb &= 5;\r\nb ^= 6;\r\nb |= 7;\r\nb <<= 8;\r\nb >>= 9;\r\nb >>>= 10;\r\n\r\nvar c = a > b;\r\nc = b < a ? a : b;\r\nc = true && false || true;\r\nc = a == b;\r\nc = a === b;\r\nc = a != b;\r\nc = a !== b;\r\nc = a <= b;\r\nc = a >= b;\r\nc = !c;\r\n\r\n++a + ++a + a++ + a++ + ++a;\r\n--a - --a - a-- - a-- - --a;\r\n\r\nfunction d::e() { }", rules: [ "NoSpaceBeforeBinaryOperator", "NoSpaceAfterBinaryOperator" ], span: { start: 0, length: 480 }, expected: "var a=0+1-2*3/4%5;\r\na+=6;\r\na-=7;\r\na*=7;\r\na/=8;\r\na%=9;\r\na=+1- -2+ +3;\r\na=1.0+2.+.0;\r\n++a+a++;\r\n--a-a--;\r\n\r\nvar b=~1&2|3^4<<1>>1>>>2;\r\nb&=5;\r\nb^=6;\r\nb|=7;\r\nb<<=8;\r\nb>>=9;\r\nb>>>=10;\r\n\r\nvar c=a>b;\r\nc=b=b;\r\nc=!c;\r\n\r\n++a+ ++a+a++ +a++ + ++a;\r\n--a- --a-a-- -a-- - --a;\r\n\r\nfunction d::e() { }" }, -{ input: "function foo()\n\n{ a = 1\n}", rules: [ "NewLineBeforeOpenCurlyInFunction" ], span: { start: 0, length: 25 }, expected: "function foo()\n{\n a = 1\n}" }, -{ input: "while (true) {\r\n}", rules: [ "NewLineBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "while (true)\n{\r\n}" }, -{ input: "while (true)\n{\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl" ], span: { start: 0, length: 17 }, expected: "while (true) {\r\n}" }, -{ input: "var z = 1;\r\n for (i = 0; i < 10; i++)\r\n for (j = 0; j < 10; j++)\r\nfor (k = 0; k < 10; ++k)\r\n{\r\nz++;\r\n}", rules: [ "SpaceBeforeOpenCurlyInControl", "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 117 }, expected: "var z = 1;\r\nfor (i = 0; i < 10; i++)\r\n for (j = 0; j < 10; j++)\r\n for (k = 0; k < 10; ++k) {\r\n z++;\r\n }" }, -{ input: "a++;b++;\nfor (; ; ) {\nx++;m++;\n}", rules: [ "SpaceAfterSemicolonInFor" ], span: { start: 0, length: 32 }, expected: "a++; b++;\nfor (; ; ) {\n x++; m++;\n}" }, -{ input: "var a;\r\n $(document).ready(function() {\r\n alert('hello');\r\n});\r\n", rules: [ ], span: { start: 0, length: 117 }, expected: "var a;\r\n$(document).ready(function () {\r\n alert('hello');\r\n});\r\n" } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/formatDiffTemplate.html b/src/harness/unittests/services/formatting/formatDiffTemplate.html deleted file mode 100644 index d5bc6537cc7..00000000000 --- a/src/harness/unittests/services/formatting/formatDiffTemplate.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts b/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts deleted file mode 100644 index 9ad1102d2f4..00000000000 --- a/src/harness/unittests/services/formatting/getFormattingEditsForRange.ts +++ /dev/null @@ -1,88 +0,0 @@ -/// - -describe('getFormattingEditsForRange', function() { - // - // Verify that formatting the typescript file "sourceFileName" results in the - // baseline file "baselineFileName". - // - function getFormattingEditsForRange(sourceFileName: string) { - var baselineFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + "BaseLine.ts"; - sourceFileName = "tests/cases/unittests/services/testCode/formatting/" + sourceFileName + ".ts"; - - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addDefaultLibrary(); - typescriptLS.addFile(sourceFileName); - - var ls = typescriptLS.getLanguageService(); - var script = ls.languageService.getScriptAST(sourceFileName); - assert.notNull(script); - - var edits = ls.languageService.getFormattingEditsForRange(sourceFileName, 0, script.limChar, new Services.FormatCodeOptions()); - typescriptLS.checkEdits(sourceFileName, baselineFileName, edits); - } - - describe('test cases for formatting engine', function() { - it("formats typescript constructs properly", function() { - getFormattingEditsForRange('typescriptConstructs'); - }); - it("formats document ready function properly", function() { - getFormattingEditsForRange('documentReadyFunction'); - }); - it("formats on closing bracket properly", function() { - getFormattingEditsForRange('onClosingBracket'); - }); - it("formats various javascript constructs", function() { - getFormattingEditsForRange('various'); - }); - it("formats main javascript program", function() { - getFormattingEditsForRange('main'); - }); - it("formats on semicolon properly", function() { - getFormattingEditsForRange('onSemiColon'); - }); - it("formats enum with trailling tab characters properly", function() { - getFormattingEditsForRange('tabAfterCloseCurly'); - }); - it("formats object literal", function() { - getFormattingEditsForRange('objectLiteral'); - }); - it("formats with statements", function() { - getFormattingEditsForRange('withStatement'); - }); - it("formats ':' and '?' in parameters", function() { - getFormattingEditsForRange('colonAndQMark'); - }); - it("formats 'import' declaration", function() { - getFormattingEditsForRange('importDeclaration'); - }); - it("formats exported class with implicit module", function() { - //TODO: this is to force generation of implicit module in AST - var svGenTarget = TypeScript.moduleGenTarget; - try { - TypeScript.moduleGenTarget = TypeScript.ModuleGenTarget.Asynchronous; - getFormattingEditsForRange('implicitModule'); - } - finally { - TypeScript.moduleGenTarget = svGenTarget; - } - }); - it("formats constructor statements correctelly", function() { - getFormattingEditsForRange('spaceAfterConstructor'); - }); - it("formats classes and interfaces correctelly", function() { - getFormattingEditsForRange('classes'); - }); - it("formats modules correctly", function() { - getFormattingEditsForRange('modules'); - }); - it("formats fat arrow expressions correctelly", function() { - getFormattingEditsForRange('fatArrowFunctions'); - }); - it("formats empty object/interface literals correctelly", function() { - getFormattingEditsForRange('emptyInterfaceLiteral'); - }); - it("formats variable declaration lists", function() { - getFormattingEditsForRange('formatVariableDeclarationList'); - }); - }); -}); diff --git a/src/harness/unittests/services/formatting/getSmartIndentAtLineNumber.ts b/src/harness/unittests/services/formatting/getSmartIndentAtLineNumber.ts deleted file mode 100644 index 52e7982bd4a..00000000000 --- a/src/harness/unittests/services/formatting/getSmartIndentAtLineNumber.ts +++ /dev/null @@ -1,410 +0,0 @@ -/// - -describe('getSmartIndentAtLineNumber', function() { - var typescriptLS = new Harness.TypeScriptLS(); - - typescriptLS.addDefaultLibrary(); - - var fileName = 'tests/cases/unittests/services/testCode/getSmartIndentAtLineNumber.ts'; - var fileName2 = 'tests/cases/unittests/services/testCode/getSmartIndentAtLineNumber2.ts'; - var fileName3 = 'tests/cases/unittests/services/testCode/getSmartIndentAtLineNumber3.ts'; - - typescriptLS.addFile(fileName); - typescriptLS.addFile(fileName2); - typescriptLS.addFile(fileName3); - - var ls = typescriptLS.getLanguageService(); - - // - // line is 1-based - // - function getSmartIndent(fileName: string, line: number): number { - assert.is(line >= 1); - var options = new Services.EditorOptions(); - var position = typescriptLS.lineColToPosition(fileName, line, 1); - return ls.languageService.getSmartIndentAtLineNumber(fileName, position, options); - } - - describe("test cases for smart indent", function() { - - it("smart indent inside module", function() { - var result = getSmartIndent(fileName, 2); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside class", function() { - var result = getSmartIndent(fileName, 4); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after property in class", function() { - var result = getSmartIndent(fileName, 6); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent inside method in class ", function() { - var result = getSmartIndent(fileName, 9); - - assert.notNull(result); - assert.equal(12, result); - }); - - it("smart indent after after method in class", function() { - var result = getSmartIndent(fileName, 12); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after class", function() { - var result = getSmartIndent(fileName, 17); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent in interface", function() { - var result = getSmartIndent(fileName, 19); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after property in interface", function() { - var result = getSmartIndent(fileName, 21); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after method in interface", function() { - var result = getSmartIndent(fileName, 23); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after interface", function() { - var result = getSmartIndent(fileName, 25); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent in nested module", function() { - var result = getSmartIndent(fileName, 27); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after function in nested module", function() { - var result = getSmartIndent(fileName, 30); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after variable in nested module", function() { - var result = getSmartIndent(fileName, 32); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after nested module", function() { - var result = getSmartIndent(fileName, 34); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent in enum", function() { - var result = getSmartIndent(fileName, 36); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after variable in enum", function() { - var result = getSmartIndent(fileName, 38); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 2nd variable in enum", function() { - var result = getSmartIndent(fileName, 40); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after enum", function() { - var result = getSmartIndent(fileName, 42); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent after module", function() { - var result = getSmartIndent(fileName, 44); - - assert.notNull(result); - assert.equal(0, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent after an aligned function argument", function() { - var result = getSmartIndent(fileName, 47); - - assert.notNull(result); - assert.equal(13, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent inside a 'for' statement", function() { - var result = getSmartIndent(fileName, 53); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'for' statement", function() { - var result = getSmartIndent(fileName, 55); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'for in' statement", function() { - var result = getSmartIndent(fileName, 57); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'for in' statement", function() { - var result = getSmartIndent(fileName, 59); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'with' statement", function() { - var result = getSmartIndent(fileName, 61); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'with' statement", function() { - var result = getSmartIndent(fileName, 63); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'switch' statement", function() { - var result = getSmartIndent(fileName, 65); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'switch' statement", function() { - var result = getSmartIndent(fileName, 67); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside a 'break' statement", function() { - var result = getSmartIndent(fileName, 69); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after a 'break' statement", function() { - var result = getSmartIndent(fileName, 71); - - assert.notNull(result); - assert.equal(12, result); - }); - - it("smart indent after a 'break' statement", function() { - var result = getSmartIndent(fileName, 73); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after last 'switch' statement", function() { - var result = getSmartIndent(fileName, 75); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent before 'try' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 79); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent insde 'try' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 81); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'catch' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 83); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'catch' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 85); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 'catch' in 'try/catch' statement", function() { - var result = getSmartIndent(fileName, 87); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent before 'try' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 92); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent insde 'try' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 94); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'finally' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 96); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'finally' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 98); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 'finally' in 'try/finally' statement", function() { - var result = getSmartIndent(fileName, 100); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent before 'try' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 104); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent insde 'try' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 106); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'catch' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 108); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'catch' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 110); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent before 'finally' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 112); - - assert.notNull(result); - assert.equal(4, result); - }); - - it("smart indent inside 'finally' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 114); - - assert.notNull(result); - assert.equal(8, result); - }); - - it("smart indent after 'finally' in 'try/catch/finally' statement", function() { - var result = getSmartIndent(fileName, 116); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent inside a block inside case", function() { - var result = getSmartIndent(fileName, 127); - - assert.notNull(result); - assert.equal(20, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent works for a non terminated argument list at the end of a file", function() { - var result = getSmartIndent(fileName2, 8); - - assert.notNull(result); - assert.equal(4, result); - }); - - /////////////////////////////////////////////////////////////////////// - - it("smart indent works for a non terminated if statement at the end of a file", function() { - var result = getSmartIndent(fileName3, 7); - - assert.notNull(result); - assert.equal(4, result); - }); - }); -}); diff --git a/src/harness/unittests/services/formatting/importedJavaScriptFormatting.ts b/src/harness/unittests/services/formatting/importedJavaScriptFormatting.ts deleted file mode 100644 index 2fcb9977678..00000000000 --- a/src/harness/unittests/services/formatting/importedJavaScriptFormatting.ts +++ /dev/null @@ -1,212 +0,0 @@ -/// -/// - -interface DocumentTestJson { - input: string; - rules: string[]; - span: { start: number; length: number; }; - expected: string; -} - -interface FormatOperationTestJson { - input: string; - operations: { - operation: string; - point: { position: number; }; - span: { start: number; length: number; }; - }[]; - expected: string; -} - -function markupCodeForHtml(code: string) { - var formatted = code.replace(/'); - var escaped = encodeURIComponent(code).replace(/'/g, '%27'); - - return formatted + '
Copy'; -} - -describe('importedJavaScriptFormatting - formatting rules', function() { - var documentTests: DocumentTestJson[] = eval('[' + IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/documentFormattingTests.json').contents() + ']'); - - var outputFile = 'diff-1.html'; - IO.writeFile(outputFile, IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/formatDiffTemplate.html').contents(), false); - - var checkTest = function(test: DocumentTestJson) { - var filename = 'temp.ts'; - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addScript(filename, test.input); - - var ls = typescriptLS.getLanguageService().languageService; - - var unsupportedRules = []; - var ruleMap = { - 'SpaceAfterSemicolonInFor': 'InsertSpaceAfterSemicolonInForStatements', - 'SpaceAfterComma': 'InsertSpaceAfterCommaDelimiter', - 'NewLineBeforeOpenCurlyInControl': 'PlaceOpenBraceOnNewLineForControlBlocks', - 'NewLineBeforeOpenCurlyInFunction': 'PlaceOpenBraceOnNewLineForFunctions' - }; - - var options = new Services.FormatCodeOptions(); - if (test.rules.indexOf('SpaceBeforeBinaryOperator') >= 0 && test.rules.indexOf('SpaceAfterBinaryOperator') >= 0) { - test.rules.splice(test.rules.indexOf('SpaceBeforeBinaryOperator'), 1); - test.rules.splice(test.rules.indexOf('SpaceAfterBinaryOperator'), 1); - options.InsertSpaceBeforeAndAfterBinaryOperators = true; - } - - test.rules.forEach(ruleName => { - if (options[ruleName] !== undefined) { - // The options struct has a matching property, just set it directly - options[ruleName] = true; - } else { - if (ruleMap[ruleName] !== undefined) { - // We have a remapping of this name, use that instead - options[ruleMap[ruleName]] = true; - } else { - if (ruleName.indexOf('No') === 0) { - // This is a 'NoFoo', set 'Foo' to false - options[ruleMap[ruleName.substr(2)]] = false; - } else { - // ?? - IO.printLine('Unsupported rule name ' + ruleName); - return; - } - } - } - }); - - var edits = ls.getFormattingEditsForRange(filename, test.span.start, test.span.start + test.span.length, options); - - var output = typescriptLS.applyEdits(test.input, edits); - - // Normalize line endings - output = output.replace(/\r\n/g, '\n'); - test.expected = test.expected.replace(/\r\n/g, '\n'); - - if (output != test.expected) { - var outputHtml = ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += '
InputOutputExpected
' + markupCodeForHtml(test.input) + '' + markupCodeForHtml(output) + '' + markupCodeForHtml(test.expected) + '
Format from character ' + test.span.start + ' to ' + (test.span.start + test.span.length) + ' with rules: ' + test.rules.join(', ') + '
'; // test-table - - IO.writeFile(outputFile, IO.readFile(outputFile).contents() + outputHtml, false); - - // TODO: Uncomment when things are working - // throw new Error("Formatting failed - refer to diff-1.html"); - } - } - - var i = 0; - - for (var i = 0; i < documentTests.length; i++) { - var test = documentTests[i]; - - var msg = 'formats the code (index ' + i + ') from ' + test.span.start + ' to ' + (test.span.start + test.span.length) + ' with rules = [' + test.rules.join(', ') + '] correctly'; - it(msg, function(t) { - return function() { - checkTest(t); - } - }(test)); - } -}); - -describe('importedJavaScriptFormatting - formatting operations', function() { - var outputFile = 'diff-2.html'; - IO.writeFile(outputFile, IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/formatDiffTemplate.html').contents(), false); - - var checkTest = function(test: FormatOperationTestJson) { - var filename = 'temp.ts'; - var typescriptLS = new Harness.TypeScriptLS(); - typescriptLS.addScript(filename, test.input); - - var ls = typescriptLS.getLanguageService(); - - var operationsText = ''; - - var markedUpInput = test.input; - var output = test.input; - - for (var i = 0; i < test.operations.length; i++) { - var options = new Services.FormatCodeOptions(); - var op = test.operations[i]; - var edits: Services.TextEdit[]; - - if (op.operation === 'CloseBrace') { - edits = ls.languageService.getFormattingEditsAfterKeystroke(filename, op.point.position, '}', options); - operationsText += 'Format for } at position ' + op.point.position.toString(); - markedUpInput = markedUpInput.substring(0, op.point.position) + '✪' + markedUpInput.substring(op.point.position); - } else if (op.operation === 'Enter') { - edits = ls.languageService.getFormattingEditsAfterKeystroke(filename, op.point.position, '\n', options); - operationsText += 'Format for [enter] at position ' + op.point.position.toString(); - markedUpInput = markedUpInput.substring(0, op.point.position) + '✪' + markedUpInput.substring(op.point.position); - } else if (op.operation === 'Semicolon') { - edits = ls.languageService.getFormattingEditsAfterKeystroke(filename, op.point.position, ';', options); - operationsText += 'Format for ; at position ' + op.point.position.toString(); - markedUpInput = markedUpInput.substring(0, op.point.position) + '✪' + markedUpInput.substring(op.point.position); - } else if (op.operation === 'Document') { - edits = ls.languageService.getFormattingEditsForRange(filename, 0, output.length, options); - operationsText += 'Format Document'; - } else if (op.operation === 'Selection') { - edits = ls.languageService.getFormattingEditsForRange(filename, op.span.start, op.span.start + op.span.length, options); - operationsText += 'Format selection from ' + op.span.start + ', length = ' + op.span.length; - } else if (op.operation === 'Paste') { - edits = ls.languageService.getFormattingEditsForRange(filename, op.span.start, op.span.start + op.span.length, options); - operationsText += 'Format pasted content from ' + op.span.start + ', length = ' + op.span.length; - } else { - throw new Error('Unknown operation: ' + op.operation); - } - - output = typescriptLS.applyEdits(test.input, edits); - typescriptLS.updateScript(filename, output); - } - - // Normalize line endings - output = output.replace(/\r\n/g, '\n'); - test.expected = test.expected.replace(/\r\n/g, '\n'); - - var outputHtml = ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += ''; - outputHtml += '
InputOutputExpected
' + markupCodeForHtml(markedUpInput) + '' + markupCodeForHtml(output) + '' + markupCodeForHtml(test.expected) + '
' + operationsText + '
'; // test-table - - if (test.expected == output) { - // Pass - } else { - IO.writeFile(outputFile, IO.readFile(outputFile).contents() + outputHtml, false); - // TODO: Uncomment when things are working - // throw new Error('Format test failed - refer to ' + outputFile); - } - } - - var operationsTests: FormatOperationTestJson[] = eval('[' + IO.readFile(Harness.userSpecifiedroot + 'tests/cases/unittests/services/ruleFormattingTests.json').contents() + ']'); - for (var i = 0; i < operationsTests.length; i++) { - var test = operationsTests[i]; - - var msg = 'formats the text correctly, line = ' + i; - it(msg, function(t) { - return function() { - checkTest(t); - } - }(test)); - } -}); - diff --git a/src/harness/unittests/services/formatting/ruleFormattingTests.json b/src/harness/unittests/services/formatting/ruleFormattingTests.json deleted file mode 100644 index 8f330156f61..00000000000 --- a/src/harness/unittests/services/formatting/ruleFormattingTests.json +++ /dev/null @@ -1,284 +0,0 @@ -{ input: "function a() {\r\nvar b = 0;//}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 31 } } ], expected: "function a() {\r\nvar b = 0;//}\r\n}" }, -{ input: "function foo() {\n do {\n } while (y < 10)\n\n}", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "function foo() {\n do {\n } while (y < 10)\n\n}" }, -{ input: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n}\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 87 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n }\r\n\r\n}" }, -{ input: "function a() {\r\n return (\r\n {\r\n x: 0\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 76 } } ], expected: "function a() {\r\n return (\r\n {\r\n x: 0\r\n }\r\n}" }, -{ input: " if ( a[\";\"])\r\nb++;", operations: [ { operation: "Semicolon", point: { position: 10 } } ], expected: " if ( a[\";\"])\r\nb++;" }, -{ input: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();", operations: [ { operation: "Enter", point: { position: 48 } } ], expected: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();" }, -{ input: "var obj={a:{b:2,c:{d:{e:{\r\n}}}}}", operations: [ { operation: "Enter", point: { position: 27 } } ], expected: "var obj = {\n a: {\n b: 2, c: {\n d: {\n e: {\r\n }\n }\n }\n }\n}" }, -{ input: "if(1)if(1)if(1)if(1)x+=2;", operations: [ { operation: "Semicolon", point: { position: 25 } } ], expected: "if (1) if (1) if (1) if (1) x += 2;" }, -{ input: "\r\nvar webclass = [\r\n { 'student':\r\n { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }\r\n }\r\n]", operations: [ { operation: "Document" } ], expected: "\r\nvar webclass = [\r\n {\n 'student':\r\n { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }\r\n }\r\n]" }, -{ input: "function f(x){ return x }\nwhile (f(true))\n y++;\n", operations: [ { operation: "Enter", point: { position: 51 } } ], expected: "function f(x){ return x }\nwhile (f(true))\n y++;\n" }, -{ input: "throw e;", operations: [ { operation: "Document" } ], expected: "throw e;" }, -{ input: "x = {\n a: 1,\n b: 1\n +\n // test\n 2\n}", operations: [ { operation: "Document" } ], expected: "x = {\n a: 1,\n b: 1\n +\n // test\n 2\n}" }, -{ input: "return 1;", operations: [ { operation: "Document" } ], expected: "return 1;" }, -{ input: "var x = [\n 1,\n 2,\n 3\n]", operations: [ { operation: "Document" } ], expected: "var x = [\n 1,\n 2,\n 3\n]" }, -{ input: "switch \r\n( a ){\r\n case 1:x+=2; break\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 9 } } ], expected: "switch\r\n(a) {\r\n case 1:x+=2; break\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "if (a)\r\ntest;\r\nelse\r\nif (b)\r\ntest;\r\n", operations: [ { operation: "Enter", point: { position: 36 } } ], expected: "if (a)\r\ntest;\r\nelse\r\nif (b)\r\n test;\r\n" }, -{ input: "do{\r\ndo{\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "CloseBrace", point: { position: 16 } } ], expected: "do{\r\ndo{\r\n do {\r\n } while (a !== b)\r\n}while(a!==b)\r\n}while(a!==b)" }, -{ input: "label1:\r\nvar a;\r\nvar b;", operations: [ { operation: "Document" } ], expected: "label1:\r\n var a;\r\nvar b;" }, -{ input: "\r\nfunction a() {\r\nfunction test() // test\r\n{\r\nif (test) // test\r\n{\r\n}\r\n}\r\n}", operations: [ { operation: "Document" } ], expected: "\r\nfunction a() {\r\n function test() // test\r\n {\r\n if (test) // test\r\n {\r\n }\r\n }\r\n}" }, -{ input: "var obj = {\r\na:{\r\nb:2,c:{\r\nd: {\r\ne: function f() {\r\nreturn obj.a.c.d.e() +f();\r\n}\r\n}\r\n}\r\n}\r\n};", operations: [ { operation: "Semicolon", point: { position: 94 } } ], expected: "var obj = {\r\n a: {\r\n b: 2, c: {\r\n d: {\r\n e: function f() {\r\n return obj.a.c.d.e() + f();\r\n }\r\n }\r\n }\r\n }\r\n};" }, -{ input: "function f() {\r\n do{\r\nx++ }\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "function f() {\r\n do{\r\n x++\n }\r\n\r\n}" }, -{ input: "function foo (a, b, c)", operations: [ { operation: "Document" } ], expected: "function foo(a, b, c)" }, -{ input: "{ var b;\n}", operations: [ { operation: "Document" } ], expected: "{\n var b;\n}" }, -{ input: "var z = {\na: 1};", operations: [ { operation: "Document" } ], expected: "var z = {\n a: 1\n};" }, -{ input: "for (var i = 0; i < 10; i++)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "for (var i = 0; i < 10; i++) {\n var a\n}" }, -{ input: "if (1)\n {\nvar a }", operations: [ { operation: "Document" } ], expected: "if (1) {\n var a\n}" }, -{ input: "while (1)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "while (1) {\n var a\n}" }, -{ input: "do\n { var a\n} while (1)", operations: [ { operation: "Document" } ], expected: "do {\n var a\n} while (1)" }, -{ input: "for (var a in b)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "for (var a in b) {\n var a\n}" }, -{ input: "with (x)\n { var a\n}", operations: [ { operation: "Document" } ], expected: "with (x) {\n var a\n}" }, -{ input: "try\n { var a\n} \ncatch (e)\n { var a\n} \nfinally\n {\n}", operations: [ { operation: "Document" } ], expected: "try {\n var a\n}\ncatch (e) {\n var a\n}\nfinally {\n}" }, -{ input: "switch (x)\n { case 1: { var a }\n}", operations: [ { operation: "Document" } ], expected: "switch (x) {\n case 1: { var a }\n}" }, -{ input: "function f()\n { var x\n}", operations: [ { operation: "Document" } ], expected: "function f() {\n var x\n}" }, -{ input: "if(1)if(1)if(1)if(1){x+=2\r\n}", operations: [ { operation: "CloseBrace", point: { position: 28 } } ], expected: "if (1) if (1) if (1) if (1) {\n x += 2\r\n}" }, -{ input: "switch (a){\r\n case 1: x += 2;\r\n case 2 : \r\n for (var i=0;i<10;i++)\r\ni --;\r\n}\r\n", operations: [ { operation: "Semicolon", point: { position: 84 } } ], expected: "switch (a){\r\n case 1: x += 2;\r\n case 2 : \r\n for (var i = 0; i < 10; i++)\r\n i--;\r\n}\r\n" }, -{ input: "do{for(var i=0;i<10;i++)i-=2}while(1!==1);", operations: [ { operation: "Semicolon", point: { position: 42 } } ], expected: "do { for (var i = 0; i < 10; i++) i -= 2 } while (1 !== 1);" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++)\r\n{j-=i}}", operations: [ { operation: "Enter", point: { position: 45 } } ], expected: "for (var i = 0; i < 10; i++) {\n for (var j = 0; j < 10; j++)\r\n { j -= i }\n}" }, -{ input: "function f() {\r\nstring='string\\r\n line2' + 'other part'}", operations: [ { operation: "CloseBrace", point: { position: 63 } } ], expected: "function f() {\r\n string = 'string\\r\n line2' + 'other part'\n}" }, -{ input: "x =\r\n function ()\r\n{\r\n var a\r\n}", operations: [ { operation: "Document" } ], expected: "x =\r\n function () {\r\n var a\r\n }" }, -{ input: "if (a instanceof b) { }", operations: [ { operation: "Document" } ], expected: "if (a instanceof b) { }" }, -{ input: "do a++; while (0)", operations: [ { operation: "Document" } ], expected: "do a++; while (0)" }, -{ input: "foo\r\n(1, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo\r\n(1, 2, 3)" }, -{ input: "if(1) //comment\r\n{\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "if (1) //comment\r\n{\r\n}\r\n" }, -{ input: "var x =\n [\n1\n]", operations: [ { operation: "Document" } ], expected: "var x =\n [\n1\n ]" }, -{ input: "\r\n{\r\n function f() {\r\n var s = 1\r\n }\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 59 } } ], expected: "\r\n{\r\n function f() {\r\n var s = 1\r\n }\r\n\r\n}" }, -{ input: "\r\ndefine(null,\r\n function test() {\r\nvar a;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\ndefine(null,\r\n function test() {\r\n var a;\r\n }\r\n" }, -{ input: "x = [\r\n 1,\r\n\r\n]", operations: [ { operation: "Enter", point: { position: 15 } } ], expected: "x = [\r\n 1,\r\n\r\n]" }, -{ input: "var x =\n {\na: 1\n}", operations: [ { operation: "Document" } ], expected: "var x =\n {\n a: 1\n }" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "CloseBrace", point: { position: 50 } } ], expected: "for (var i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { j -= i } }" }, -{ input: "function f()\n{\n for (a in b)\n a++;\n}", operations: [ { operation: "Semicolon", point: { position: 40 } } ], expected: "function f()\n{\n for (a in b)\n a++;\n}" }, -{ input: "if(x!=1^y===2) \r\nx+=2\r\n", operations: [ { operation: "Enter", point: { position: 25 } } ], expected: "if(x!=1^y===2) \r\n x += 2\r\n" }, -{ input: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x--\r\nelse\r\n x+=2\r\n", operations: [ { operation: "Enter", point: { position: 81 } } ], expected: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x--\r\n else\r\n x += 2\r\n" }, -{ input: "switch (a){\r\ncase 1 : x+=2 ; break;\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Semicolon", point: { position: 44 } } ], expected: "switch (a){\r\n case 1: x += 2; break;\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "{ { {\r\n{\r\ntest\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 7, length: 19 } } ], expected: "{ { {\r\n {\r\n test\r\n }\r\n}\r\n}\r\n}" }, -{ input: "do {\r\n do {\r\n do {\r\n }while(a!==b)\r\n\r\n} while (a !== b)\r\n} while (a !== b)", operations: [ { operation: "Enter", point: { position: 55 } } ], expected: "do {\r\n do {\r\n do {\r\n }while(a!==b)\r\n\r\n } while (a !== b)\r\n} while (a !== b)" }, -{ input: "\r\nswitch (t) {\r\n case 1:\r\n{\r\ntest\r\n}\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\nswitch (t) {\r\n case 1:\r\n {\r\n test\r\n }\r\n}\r\n" }, -{ input: "if (true) {\r\n \r\n}", operations: [ { operation: "Document" } ], expected: "if (true) {\r\n\r\n}" }, -{ input: "for(var j=0;j<10;j++)\r\nj-=i;", operations: [ { operation: "Semicolon", point: { position: 28 } } ], expected: "for (var j = 0; j < 10; j++)\r\n j -= i;" }, -{ input: "function a() {\r\n function b() {\r\n //\r\n\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 48 } } ], expected: "function a() {\r\n function b() {\r\n //\r\n\r\n }\r\n}" }, -{ input: "if(1)if(1)if(1)if(1)x+=2\r\n", operations: [ { operation: "Enter", point: { position: 26 } } ], expected: "if (1) if (1) if (1) if (1) x += 2\r\n" }, -{ input: "do{do{do{}while(a!==b)}while(a!==b)}while(a!==b)\r\n", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "do { do { do { } while (a !== b) } while (a !== b) } while (a !== b)\r\n" }, -{ input: "foo(\r\n)", operations: [ { operation: "Document" } ], expected: "foo(\r\n)" }, -{ input: "function f() {\r\n'use strict';\r\n}", operations: [ { operation: "Semicolon", point: { position: 29 } } ], expected: "function f() {\r\n 'use strict';\r\n}" }, -{ input: "var x = function() {\n//comment\nreturn 1;\n}", operations: [ { operation: "Document" } ], expected: "var x = function () {\n //comment\n return 1;\n}" }, -{ input: " function foo4() {\r\n function foo5() {\r\n function foo6() {\r\n test1\r\n }\r\n test2\r\n }\r\n }", operations: [ { operation: "Selection", span: { start: 62, length: 120 } } ], expected: " function foo4() {\r\n function foo5() {\r\n function foo6() {\r\n test1\r\n }\r\n test2\r\n }\r\n }" }, -{ input: "do{\r\ndo{\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "CloseBrace", point: { position: 46 } } ], expected: "do {\r\n do {\r\n do {\r\n } while (a !== b)\r\n } while (a !== b)\r\n} while (a !== b)" }, -{ input: "if (true)\n// test\n test;", operations: [ { operation: "Document" } ], expected: "if (true)\n // test\n test;" }, -{ input: "function test() {\r\n return (\r\n function test() {\r\n test;\r\n }\r\n );\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n return (\r\n function test() {\r\n test;\r\n }\r\n );\r\n}" }, -{ input: "for(var i=0;i<10;i++){\r\nfor(var j=0;j<10;j++){\r\nj-=i\r\n}}", operations: [ { operation: "CloseBrace", point: { position: 56 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n }\n}" }, -{ input: " var a = 0 ;", operations: [ { operation: "Semicolon", point: { position: 14 } } ], expected: "var a = 0;" }, -{ input: "var obj={a:{b:2,c:{d:\r\n{e:{}}}}}", operations: [ { operation: "Enter", point: { position: 23 } } ], expected: "var obj = {\n a: {\n b: 2, c: {\n d:\r\n { e: {} }\n }\n }\n}" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 74 } } ], expected: "function foo() {\r\n try {\r\n x += 2\r\n }\r\n catch (e) {\r\n x += 2\r\n } finally {\r\n x += 2\r\n }\r\n}" }, -{ input: "var obj = {\r\na: {\r\nb: 2, c: {\r\nd: {\r\ne: function f() {\r\nreturn obj.a.c.d.e() + f();\r\n}\r\n}\r\n}\r\n}}", operations: [ { operation: "CloseBrace", point: { position: 96 } } ], expected: "var obj = {\r\n a: {\r\n b: 2, c: {\r\n d: {\r\n e: function f() {\r\n return obj.a.c.d.e() + f();\r\n }\r\n }\r\n }\r\n }\n}" }, -{ input: "if (x!=1^y===2){ x+=2}", operations: [ { operation: "CloseBrace", point: { position: 24 } } ], expected: "if (x != 1 ^ y === 2) { x += 2 }" }, -{ input: "function test() {\r\n var a;\r\n label:\r\n for (; ;)\r\n\r\n", operations: [ { operation: "Enter", point: { position: 58 } } ], expected: "function test() {\r\n var a;\r\n label:\r\n for (; ;)\r\n\r\n" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++){\r\nj-=i}}", operations: [ { operation: "Enter", point: { position: 46 } } ], expected: "for (var i = 0; i < 10; i++) {\n for (var j = 0; j < 10; j++) {\r\n j -= i\n }\n}" }, -{ input: "do {\r\n for (var i = 0; i < 10; i++)\r\n i -= 2\r\n }\r\nwhile (1 !== 1)", operations: [ { operation: "Enter", point: { position: 67 } } ], expected: "do {\r\n for (var i = 0; i < 10; i++)\r\n i -= 2\r\n}\r\nwhile (1 !== 1)" }, -{ input: "{\r\n try {\r\n } catch (e) {\r\n }\r\n}", operations: [ { operation: "Document" } ], expected: "{\r\n try {\r\n } catch (e) {\r\n }\r\n}" }, -{ input: "{ { {\r\n{\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 7, length: 13 } } ], expected: "{ { {\r\n {\r\n }\r\n}\r\n}\r\n}" }, -{ input: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\nj -= i}}\r\n", operations: [ { operation: "Enter", point: { position: 78 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\n }\n}\r\n" }, -{ input: "var a = {\r\n}", operations: [ { operation: "Document" } ], expected: "var a = {\r\n}" }, -{ input: "\r\n switch ( a ) {\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 2 } } ], expected: "\r\nswitch (a) {\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "function a() {\r\nvar b = 0;//;\r\n}", operations: [ { operation: "Semicolon", point: { position: 31 } } ], expected: "function a() {\r\nvar b = 0;//;\r\n}" }, -{ input: "for (a in b) { }", operations: [ { operation: "Document" } ], expected: "for (a in b) { }" }, -{ input: "\r\n{\r\nfunction test(/* test */ a,\r\n /* test */ b\r\n /* test */) {\r\n// test\r\n}\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n{\r\n function test(/* test */ a,\r\n /* test */ b\r\n /* test */) {\r\n // test\r\n }\r\n}\r\n" }, -{ input: " //\r\n", operations: [ { operation: "Enter", point: { position: 8 } } ], expected: "//\r\n" }, -{ input: " if ( a[\"}\"])\r\nb++;", operations: [ { operation: "CloseBrace", point: { position: 10 } } ], expected: " if ( a[\"}\"])\r\nb++;" }, -{ input: "$ ( document ) . ready ( function ( ) { \n alert ( \"i am ready\" ) ;\n } );", operations: [ { operation: "Semicolon", point: { position: 138 } } ], expected: "$(document).ready(function () {\n alert(\"i am ready\");\n});" }, -{ input: "function f() {\r\nvar s=\"string\";\r\n}", operations: [ { operation: "Semicolon", point: { position: 31 } } ], expected: "function f() {\r\n var s = \"string\";\r\n}" }, -{ input: "do{for(var i=0;i<10;i++)i-=2\r\n}while(1!==1)", operations: [ { operation: "Enter", point: { position: 30 } } ], expected: "do {\n for (var i = 0; i < 10; i++) i -= 2\r\n} while (1 !== 1)" }, -{ input: "do{\r\ndo{\r\n\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "Enter", point: { position: 12 } } ], expected: "do{\r\ndo{\r\n\r\n do {\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "CloseBrace", point: { position: 49 } } ], expected: "for (var i = 0; i < 10; i++) { for (var j = 0; j < 10; j++) { j -= i }}" }, -{ input: "var obj = {\r\na: {\r\nb: 2, c: {\r\nd: {\r\ne: function f() {\r\nreturn obj.a.c.d.e() + f();\r\n}\r\n}\r\n } \r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 99 } } ], expected: "var obj = {\r\na: {\r\n b: 2, c: {\r\n d: {\r\n e: function f() {\r\n return obj.a.c.d.e() + f();\r\n }\r\n }\r\n }\r\n}\r\n}" }, -{ input: "var a = 0 ;var b=0;var c = 0 ;", operations: [ { operation: "Paste", span: { start: 13, length: 7 } } ], expected: "var a = 0; var b = 0; var c = 0;" }, -{ input: "function a()\r\n{\r\n}", operations: [ { operation: "Enter", point: { position: 14 } } ], expected: "function a()\r\n{\r\n}" }, -{ input: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n{\r\ntest\r\n}\r\n}\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 110, length: 25 } } ], expected: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n {\r\n test\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }" }, -{ input: " \r\nfunction a() { \r\n return; \r\n} \r\n ", operations: [ { operation: "Document" } ], expected: "\r\nfunction a() {\r\n return;\r\n}\r\n" }, -{ input: "foo(\r\n1, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo(\r\n1, 2, 3)" }, -{ input: "function Init() {\r\n var a = [[1, 2],\r\n [3, 4],\r\n\r\n ];\r\n}", operations: [ { operation: "Enter", point: { position: 63 } } ], expected: "function Init() {\r\n var a = [[1, 2],\r\n [3, 4],\r\n\r\n ];\r\n}" }, -{ input: "\r\n //function start\r\n function abc() { }\r\n //function end\r\n", operations: [ { operation: "Document" } ], expected: "\r\n//function start\r\nfunction abc() { }\r\n//function end\r\n" }, -{ input: "for(var i=0;i<10;i++){\r\n for (var j = 0; j < 10; j++) {\r\nj-=i\r\n\r\n}\r\n}", operations: [ { operation: "Enter", point: { position: 66 } } ], expected: "for(var i=0;i<10;i++){\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n\r\n}\r\n}" }, -{ input: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 94 } } ], expected: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n" }, -{ input: "x = {\r\n a: function() {\r\n},\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "x = {\r\n a: function() {\r\n },\r\n\r\n}" }, -{ input: "if(1)\r\n if(1)\r\n x++\r\n else\r\n if(1)\r\n x+=2\r\n else\r\nx+=2\r\n", operations: [ { operation: "Enter", point: { position: 94 } } ], expected: "if(1)\r\n if(1)\r\n x++\r\n else\r\n if(1)\r\n x+=2\r\n else\r\n x += 2\r\n" }, -{ input: "for (a in b) {\nx++;}\n", operations: [ { operation: "Enter", point: { position: 21 } } ], expected: "for (a in b) {\n x++;\n}\n" }, -{ input: "if(1)if(1)if(1)if(1){x+=2}", operations: [ { operation: "CloseBrace", point: { position: 26 } } ], expected: "if (1) if (1) if (1) if (1) { x += 2 }" }, -{ input: "if (x!=1^y===2){ x+=2\r\n}", operations: [ { operation: "CloseBrace", point: { position: 26 } } ], expected: "if (x != 1 ^ y === 2) {\n x += 2\r\n}" }, -{ input: "var d = new Date ()", operations: [ { operation: "Document" } ], expected: "var d = new Date()" }, -{ input: "do {\r\n} while (1 == 10);", operations: [ { operation: "Document" } ], expected: "do {\r\n} while (1 == 10);" }, -{ input: "string='string+=2';", operations: [ { operation: "Semicolon", point: { position: 19 } } ], expected: "string = 'string+=2';" }, -{ input: "function foo() {\r\n try {\r\n }\r\ncatch(e){\r\n } finally {\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 48 } } ], expected: "function foo() {\r\n try {\r\n }\r\n catch (e) {\r\n } finally {\r\n }\r\n}" }, -{ input: "try // comment\r\n{\r\n}\r\ncatch (e) // comment\r\n{\r\n}\r\nfinally // comment\r\n{\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "try // comment\r\n{\r\n}\r\ncatch (e) // comment\r\n{\r\n}\r\nfinally // comment\r\n{\r\n}\r\n" }, -{ input: "function f() {\r\n /**/ var x;\r\n}", operations: [ { operation: "Semicolon", point: { position: 39 } } ], expected: "function f() {\r\n /**/ var x;\r\n}" }, -{ input: "if (a)\r\ntest;\r\nelse if (b)\r\ntest;", operations: [ { operation: "Document" } ], expected: "if (a)\r\n test;\r\nelse if (b)\r\n test;" }, -{ input: "foo(1, 2, 3\r\n)", operations: [ { operation: "Document" } ], expected: "foo(1, 2, 3\r\n)" }, -{ input: "\r\nswitch (a){\r\n case 1: x++;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\nswitch (a) {\r\n case 1: x++;\r\n}\r\n" }, -{ input: "x = {\r\n a: function () {\r\n\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 39 } } ], expected: "x = {\r\n a: function () {\r\n\r\n }\r\n}" }, -{ input: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}", operations: [ { operation: "Enter", point: { position: 45 } } ], expected: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}" }, -{ input: "string='string+=2;'", operations: [ { operation: "Semicolon", point: { position: 18 } } ], expected: "string='string+=2;'" }, -{ input: "function test() {\r\n function foo() {\r\n var a;\r\n// some\r\ncomment\r\n", operations: [ { operation: "Enter", point: { position: 66 } } ], expected: "function test() {\r\n function foo() {\r\n var a;\r\n // some\r\n comment\r\n" }, -{ input: "switch ( a ) {\r\n case 1: x+=2;\r\n case 2:{for(var i=0;i<10;i++){ \r\nx+=2;}\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 89 } } ], expected: "switch (a) {\r\n case 1: x += 2;\r\n case 2: {\n for (var i = 0; i < 10; i++) {\r\n x += 2;\n }\r\n }\r\n}" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2;\r\n}while(1!==1)", operations: [ { operation: "Semicolon", point: { position: 33 } } ], expected: "do{\r\n for (var i = 0; i < 10; i++)\r\n i -= 2;\r\n}while(1!==1)" }, -{ input: "\r\nfunction foo() {\r\n try{ } catch (e) { } finally { }\r\n\r\n\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 63 } } ], expected: "\r\nfunction foo() {\r\n try { } catch (e) { } finally { }\r\n\r\n\r\n}\r\n" }, -{ input: "do{for(var i=0;i<10;i++)\r\ni-=2}while(1!==1)", operations: [ { operation: "Enter", point: { position: 26 } } ], expected: "do {\n for (var i = 0; i < 10; i++)\r\n i -= 2\n} while (1 !== 1)" }, -{ input: "\r\n fun(\r\n {\r\n a: 1\r\n });\r\n", operations: [ { operation: "Document" } ], expected: "\r\nfun(\r\n {\r\n a: 1\r\n });\r\n" }, -{ input: "function f () //comment\r\n{\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "function f() //comment\r\n{\r\n}\r\n" }, -{ input: "function a(b) {\r\n var c = 0;\r\n if (b != null) {\r\n for (d in b) {\r\n }\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 94 } } ], expected: "function a(b) {\r\n var c = 0;\r\n if (b != null) {\r\n for (d in b) {\r\n }\r\n }\r\n}" }, -{ input: "switch (a) {\r\n case 1:\r\n\r\n break;\r\n}", operations: [ { operation: "Enter", point: { position: 34 } } ], expected: "switch (a) {\r\n case 1:\r\n\r\n break;\r\n}" }, -{ input: " \r\n do{\r\n for(var i=0;i<10;i++)\r\n i -= 2\r\n}\r\nwhile (1 !== 1)", operations: [ { operation: "Enter", point: { position: 5 } } ], expected: "\r\ndo {\r\n for(var i=0;i<10;i++)\r\n i -= 2\r\n}\r\nwhile (1 !== 1)" }, -{ input: "function test() {\r\n label1:\r\nvar a\r\n\r\n var b;\r\n}", operations: [ { operation: "Enter", point: { position: 39 } } ], expected: "function test() {\r\n label1:\r\n var a\r\n\r\n var b;\r\n}" }, -{ input: "var x = {\n//comment\na: 1\n}", operations: [ { operation: "Document" } ], expected: "var x = {\n //comment\n a: 1\n}" }, -{ input: "for(var i=0;i<10;i++){\r\n\r\nfor(var j=0;j<10;j++){\r\nj-=i\r\n}\r\n}", operations: [ { operation: "Enter", point: { position: 26 } } ], expected: "for(var i=0;i<10;i++){\r\n\r\n for (var j = 0; j < 10; j++) {\r\nj-=i\r\n}\r\n}" }, -{ input: "if (true) {\r\n//\r\n} else if (false) {\r\n//\r\n} else\r\n if (true)\r\n//", operations: [ { operation: "Document" } ], expected: "if (true) {\r\n //\r\n} else if (false) {\r\n //\r\n} else\r\n if (true)\r\n //" }, -{ input: "x = [\n 1,\n 1\n +\n // test\n 2\n]", operations: [ { operation: "Document" } ], expected: "x = [\n 1,\n 1\n +\n // test\n 2\n]" }, -{ input: "var x =\n function() {\nreturn 1;\n}", operations: [ { operation: "Document" } ], expected: "var x =\n function () {\n return 1;\n }" }, -{ input: "function f() {\n var x }", operations: [ { operation: "Document" } ], expected: "function f() {\n var x\n}" }, -{ input: "switch (a) {\r\n case 1: b++;\r\n break ;\r\n\r\n default: a++;\r\n break;\r\n}", operations: [ { operation: "Enter", point: { position: 46 } } ], expected: "switch (a) {\r\n case 1: b++;\r\n break;\r\n\r\n default: a++;\r\n break;\r\n}" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n} finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 32 } } ], expected: "function foo() {\r\n try {\r\n x += 2\r\n }\r\ncatch( e){\r\nx+=2\r\n} finally {\r\nx+=2\r\n}\r\n}" }, -{ input: "function f(a, b\n , c){\n}", operations: [ { operation: "CloseBrace", point: { position: 39 } } ], expected: "function f(a, b\n , c) {\n}" }, -{ input: "function add(a, b) { return a + b}", operations: [ { operation: "Document" } ], expected: "function add(a, b) { return a + b }" }, -{ input: "var a = 0 ;\r\n", operations: [ { operation: "Enter", point: { position: 15 } } ], expected: "var a = 0;\r\n" }, -{ input: "var a = function (b) {\r\nb = 0;\r\n}", operations: [ { operation: "CloseBrace", point: { position: 33 } } ], expected: "var a = function (b) {\r\n b = 0;\r\n}" }, -{ input: "\r\nif (\r\n test) {\r\n a;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\nif (\r\n test) {\r\n a;\r\n}\r\n" }, -{ input: " var a = 0 ;\r\n var b = { } ;\r\n var c = false ;", operations: [ { operation: "Selection", span: { start: 18, length: 34 } } ], expected: " var a = 0 ;\r\n var b = {};\r\n var c = false ;" }, -{ input: "function a() {\r\n return (\r\n function () {\r\n return 0;\r\n }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 93 } } ], expected: "function a() {\r\n return (\r\n function () {\r\n return 0;\r\n }\r\n}" }, -{ input: "function test() {\r\n label1:\r\n a();\r\n b()\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 59 } } ], expected: "function test() {\r\n label1:\r\n a();\r\n b()\r\n\r\n}" }, -{ input: "(function () {\r\n a({\r\n b: 0\r\n });\r\n})();", operations: [ { operation: "Document" } ], expected: "(function () {\r\n a({\r\n b: 0\r\n });\r\n})();" }, -{ input: "function a() {\r\n /**/ }", operations: [ { operation: "Document" } ], expected: "function a() {\r\n /**/\n}" }, -{ input: "for (var i = 0; i < 10; i++) {\r\n for (var j=0;j<10;j++) {\r\nj=i;\r\n }\r\n}", operations: [ { operation: "Semicolon", point: { position: 64 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j=0;j<10;j++) {\r\n j = i;\r\n }\r\n}" }, -{ input: "function f() {\r\n var x; /*\r\n */ var y = 2;\r\n}", operations: [ { operation: "Document" } ], expected: "function f() {\r\n var x; /*\r\n */ var y = 2;\r\n}" }, -{ input: "foo (1, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo(1, 2, 3)" }, -{ input: "if (typeof a == null);", operations: [ { operation: "Document" } ], expected: "if (typeof a == null);" }, -{ input: "function f() {\r\n var x = \"\\r\n \"; var y = 2;\r\n}", operations: [ { operation: "Document" } ], expected: "function f() {\r\n var x = \"\\r\n \"; var y = 2;\r\n}" }, -{ input: "void x;", operations: [ { operation: "Document" } ], expected: "void x;" }, -{ input: "function f() {\r\n string='string'\r\n }\r\n", operations: [ { operation: "Enter", point: { position: 44 } } ], expected: "function f() {\r\n string='string'\r\n}\r\n" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2\r\n}while(1!==1);", operations: [ { operation: "Semicolon", point: { position: 48 } } ], expected: "do {\r\n for (var i = 0; i < 10; i++)\r\n i -= 2\r\n} while (1 !== 1);" }, -{ input: "function test() {\r\n return (\r\n {\r\n a: 1\r\n }\r\n );\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n return (\r\n {\r\n a: 1\r\n }\r\n );\r\n}" }, -{ input: "for(var i=0;i<10;i++)\r\n{for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "Enter", point: { position: 23 } } ], expected: "for (var i = 0; i < 10; i++)\r\n{ for (var j = 0; j < 10; j++) { j -= i } }" }, -{ input: "for(var i=0;i<10;i++){\r\nfor(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "Enter", point: { position: 24 } } ], expected: "for (var i = 0; i < 10; i++) {\r\n for (var j = 0; j < 10; j++) { j -= i }\n}" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2\r\n}while(1!==1)\r\n", operations: [ { operation: "Enter", point: { position: 49 } } ], expected: "do{\r\nfor(var i=0;i<10;i++)\r\ni-=2\r\n} while (1 !== 1)\r\n" }, -{ input: "if(1===1\r\n&& 2===2)x+=2", operations: [ { operation: "Enter", point: { position: 10 } } ], expected: "if (1 === 1\r\n&& 2 === 2) x += 2" }, -{ input: "\r\n{\r\n\r\n/* test\r\n test2\r\n test3 */\r\nvar a,\r\n // test\r\n // test\r\n b;\r\n\r\nx = {\r\na: 1 +\r\n // test\r\n /* test\r\n test2 */\r\n 2\r\n}\r\n\r\na(1,\r\n 2). // test\r\n test(); /* test */\r\n\r\n/* test\r\n test2\r\n test3 */\r\nfunction foo(a, b,\r\n /* test\r\n test2\r\n test3 */\r\n c) {\r\n}\r\n\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n{\r\n\r\n /* test\r\n test2\r\n test3 */\r\n var a,\r\n // test\r\n // test\r\n b;\r\n\r\n x = {\r\n a: 1 +\r\n // test\r\n /* test\r\n test2 */\r\n 2\r\n }\r\n\r\n a(1,\r\n 2). // test\r\n test(); /* test */\r\n\r\n /* test\r\n test2\r\n test3 */\r\n function foo(a, b,\r\n /* test\r\n test2\r\n test3 */\r\n c) {\r\n }\r\n\r\n}\r\n" }, -{ input: "\r\n for (var i = 0; i < 10\r\n ; i--) {\r\n test\r\n ;\r\n }\r\n", operations: [ { operation: "Document" } ], expected: "\r\nfor (var i = 0; i < 10\r\n ; i--) {\r\n test\r\n ;\r\n}\r\n" }, -{ input: "if (1)\r\n x++;\r\nelse if (1)\r\n x--;", operations: [ { operation: "Document" } ], expected: "if (1)\r\n x++;\r\nelse if (1)\r\n x--;" }, -{ input: "x = {\n get foo () {\n },\n set foo (val) {\n }\n};", operations: [ { operation: "Document" } ], expected: "x = {\n get foo() {\n },\n set foo(val) {\n }\n};" }, -{ input: "function foo\r\n(a, b, c) {\r\n}", operations: [ { operation: "Document" } ], expected: "function foo\r\n(a, b, c) {\r\n}" }, -{ input: "switch ( a ) {\r\n case 1: x+=2;\r\n case 2:{for(var i=0;i<10;i++){ \r\nx+=2;\r\n }}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 80 } } ], expected: "switch ( a ) {\r\n case 1: x+=2;\r\n case 2: {\n for (var i = 0; i < 10; i++) {\r\n x += 2;\r\n }\n }\r\n}" }, -{ input: "function f() {\r\n'use strict'}", operations: [ { operation: "CloseBrace", point: { position: 29 } } ], expected: "function f() {\r\n 'use strict'\n}" }, -{ input: "foo(1\r\n, 2, 3)", operations: [ { operation: "Document" } ], expected: "foo(1\r\n, 2, 3)" }, -{ input: "do{\r\ndo\r\n{\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)", operations: [ { operation: "Enter", point: { position: 9 } } ], expected: "do{\r\n do\r\n {\r\ndo{\r\n}while(a!==b)\r\n}while(a!==b)\r\n}while(a!==b)" }, -{ input: "function Sum(a,b,c) {\r\n for(i=0,j=1,k=0,fib=1;i<5;i++,fib=j+k,k=j,j=fib) {\r\n var sparseArray = [1,,,,5]\r\n }\r\n}", operations: [ { operation: "Selection", span: { start: 49, length: 3 } } ], expected: "function Sum(a,b,c) {\r\n for (i = 0, j = 1, k = 0, fib = 1; i < 5; i++, fib = j + k, k = j, j = fib) {\r\n var sparseArray = [1,,,,5]\r\n }\r\n}" }, -{ input: "function a() {\r\n function b() {\r\n\r\n }\r\n}", operations: [ { operation: "Document" } ], expected: "function a() {\r\n function b() {\r\n\r\n }\r\n}" }, -{ input: "", operations: [ { operation: "Document" } ], expected: "" }, -{ input: "function a() {\r\nvar b=\"c\"\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 27 } } ], expected: "function a() {\r\n var b = \"c\"\r\n\r\n}" }, -{ input: " if ( a[\"\r\n\"])\r\nb++;", operations: [ { operation: "Enter", point: { position: 11 } } ], expected: "if ( a[\"\r\n\"])\r\nb++;" }, -{ input: "/* \r\n \r\n*/ ", operations: [ { operation: "Document" } ], expected: "/* \r\n \r\n*/" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n};", operations: [ { operation: "Semicolon", point: { position: 75 } } ], expected: "function foo() {\r\n try {\r\n x += 2\r\n }\r\n catch (e) {\r\n x += 2\r\n } finally {\r\n x += 2\r\n }\r\n};" }, -{ input: "if (1) if (1) a++;", operations: [ { operation: "Document" } ], expected: "if (1) if (1) a++;" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 53 } } ], expected: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\n catch (e) {\r\n x += 2\r\n }finally {\r\nx+=2\r\n}\r\n}" }, -{ input: "function f() {\r\n'use strict'\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 30 } } ], expected: "function f() {\r\n 'use strict'\r\n\r\n}" }, -{ input: " \r\n ", operations: [ { operation: "Document" } ], expected: " \r\n " }, -{ input: "{ var b; }", operations: [ { operation: "Document" } ], expected: "{ var b; }" }, -{ input: "var z = {a: 1};", operations: [ { operation: "Document" } ], expected: "var z = { a: 1 };" }, -{ input: "var z =\n {a: 1};", operations: [ { operation: "Document" } ], expected: "var z =\n { a: 1 };" }, -{ input: "for (var i = 0; i < 10; i++) { var a }", operations: [ { operation: "Document" } ], expected: "for (var i = 0; i < 10; i++) { var a }" }, -{ input: "for (var i = 0; i < 10; i++)\n { var a }", operations: [ { operation: "Document" } ], expected: "for (var i = 0; i < 10; i++)\n{ var a }" }, -{ input: "if (1) { var a }", operations: [ { operation: "Document" } ], expected: "if (1) { var a }" }, -{ input: "if (1)\n { var a }", operations: [ { operation: "Document" } ], expected: "if (1)\n{ var a }" }, -{ input: "while (1) { var a }", operations: [ { operation: "Document" } ], expected: "while (1) { var a }" }, -{ input: "while (1)\n { var a }", operations: [ { operation: "Document" } ], expected: "while (1)\n{ var a }" }, -{ input: "do { var a } while (1)", operations: [ { operation: "Document" } ], expected: "do { var a } while (1)" }, -{ input: "do\n { var a }\n while (1)", operations: [ { operation: "Document" } ], expected: "do\n{ var a }\nwhile (1)" }, -{ input: "for (var a in b) { var a }", operations: [ { operation: "Document" } ], expected: "for (var a in b) { var a }" }, -{ input: "for (var a in b)\n { var a }", operations: [ { operation: "Document" } ], expected: "for (var a in b)\n{ var a }" }, -{ input: "with (x) { var a }", operations: [ { operation: "Document" } ], expected: "with (x) { var a }" }, -{ input: "with (x)\n { var a }", operations: [ { operation: "Document" } ], expected: "with (x)\n{ var a }" }, -{ input: "try { var a } \ncatch (e) { var a } \nfinally { }", operations: [ { operation: "Document" } ], expected: "try { var a }\ncatch (e) { var a }\nfinally { }" }, -{ input: "try\n { var a } \ncatch (e)\n { var a } \nfinally\n { }", operations: [ { operation: "Document" } ], expected: "try\n{ var a }\ncatch (e)\n{ var a }\nfinally\n{ }" }, -{ input: "switch (x) { case 1: { var a } }", operations: [ { operation: "Document" } ], expected: "switch (x) { case 1: { var a } }" }, -{ input: "switch (x)\n { case 1: { var a } }", operations: [ { operation: "Document" } ], expected: "switch (x)\n{ case 1: { var a } }" }, -{ input: "function f() { var x }", operations: [ { operation: "Document" } ], expected: "function f() { var x }" }, -{ input: "function f()\n\n { var x }", operations: [ { operation: "Document" } ], expected: "function f()\n\n{ var x }" }, -{ input: "function test() {\r\nlabel1:\r\nvar a;\r\nvar b;\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n label1:\r\n var a;\r\n var b;\r\n}" }, -{ input: "{\n x =\nfunction () {\n };\n}", operations: [ { operation: "Document" } ], expected: "{\n x =\nfunction () {\n};\n}" }, -{ input: "switch (a){\r\n case 1: x+=2;\r\ncase 2 : { \r\nx+=2}\r\n}", operations: [ { operation: "Enter", point: { position: 49 } } ], expected: "switch (a){\r\n case 1: x+=2;\r\n case 2: {\r\n x += 2\n }\r\n}" }, -{ input: " // ;", operations: [ { operation: "Semicolon", point: { position: 7 } } ], expected: " // ;" }, -{ input: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 115 } } ], expected: "// JScript source code\r\nfunction adder(a, b) {\r\n ///Adds two numbers \r\n return a + b;\r\n}\r\n" }, -{ input: "function foo4() {\r\n test;\r\n for (; ;) {\r\n test\r\n }\r\n}", operations: [ { operation: "Selection", span: { start: 46, length: 33 } } ], expected: "function foo4() {\r\n test;\r\n for (; ;) {\r\n test\r\n }\r\n}" }, -{ input: "if (a in b) { }", operations: [ { operation: "Document" } ], expected: "if (a in b) { }" }, -{ input: "\r\nfunction f() {\r\nlabel0:\r\nfor (var i = 0; i < 10; i++) {\r\nlabel1: {\r\nfor (var i = 0; i < 10; i++)\r\nx = 2;\r\nlabel2:\r\nfor (var i = 0; i < 10; i++) {\r\nbreak label2\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Document" } ], expected: "\r\nfunction f() {\r\n label0:\r\n for (var i = 0; i < 10; i++) {\r\n label1: {\r\n for (var i = 0; i < 10; i++)\r\n x = 2;\r\n label2:\r\n for (var i = 0; i < 10; i++) {\r\n break label2\r\n }\r\n }\r\n }\r\n}" }, -{ input: "function f() {\r\nstring='string'}", operations: [ { operation: "CloseBrace", point: { position: 32 } } ], expected: "function f() {\r\n string = 'string'\n}" }, -{ input: "\r\nfunction a() {\r\nfunction test() /* test */\r\n{\r\nif (test) /* test */\r\n{\r\n}\r\n}\r\n}", operations: [ { operation: "Document" } ], expected: "\r\nfunction a() {\r\n function test() /* test */ {\r\n if (test) /* test */ {\r\n }\r\n }\r\n}" }, -{ input: "that = {\r\n method: function () {\r\n return this.datum;\r\n } , \r\n\r\n datum: 0\r\n};", operations: [ { operation: "Enter", point: { position: 98 } } ], expected: "that = {\r\n method: function () {\r\n return this.datum;\r\n },\r\n\r\n datum: 0\r\n};" }, -{ input: "for (; ;)\n// test\n test;", operations: [ { operation: "Document" } ], expected: "for (; ;)\n // test\n test;" }, -{ input: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "(function () {\r\n a({\r\n b: 0\r\n });\r\n\r\n})();" }, -{ input: "var f = function () {\n mycanvas.onmousedown = function () {\n };\n\n}", operations: [ { operation: "Enter", point: { position: 70 } } ], expected: "var f = function () {\n mycanvas.onmousedown = function () {\n };\n\n}" }, -{ input: "var obj={a:{b:2,c:{d:{e:{}}}}};", operations: [ { operation: "Semicolon", point: { position: 31 } } ], expected: "var obj = { a: { b: 2, c: { d: { e: {} } } } };" }, -{ input: "if (1)\r\n x++;\r\nelse x--;", operations: [ { operation: "Document" } ], expected: "if (1)\r\n x++;\r\nelse x--;" }, -{ input: "do{\r\nfor(var i=0;i<10;i++)i-=2}while(1!==1)", operations: [ { operation: "Enter", point: { position: 5 } } ], expected: "do {\r\n for (var i = 0; i < 10; i++) i -= 2\n} while (1 !== 1)" }, -{ input: "switch (a){\r\n case 1,2,3:\r\n break;\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "switch (a) {\r\n case 1, 2, 3:\r\n break;\r\n}\r\n" }, -{ input: " foo(function (file) {\r\n return 0\r\n })\r\n .then(function (doc) {\r\n return 1\r\n });", operations: [ { operation: "Document" } ], expected: "foo(function (file) {\r\n return 0\r\n})\r\n .then(function (doc) {\r\n return 1\r\n });" }, -{ input: "var a = 1;\nvar f = function () {\n var b = 2;\n}\n", operations: [ { operation: "Enter", point: { position: 50 } } ], expected: "var a = 1;\nvar f = function () {\n var b = 2;\n}\n" }, -{ input: "do{for(var i=0;i<10;i++)i-=2}\r\nwhile(1!==1)", operations: [ { operation: "Enter", point: { position: 31 } } ], expected: "do { for (var i = 0; i < 10; i++) i -= 2 }\r\nwhile (1 !== 1)" }, -{ input: " function a( b,c ) \r\n {\r\n var d=0 ;\r\n }", operations: [ { operation: "Document" } ], expected: "function a(b, c) {\r\n var d = 0;\r\n}" }, -{ input: "function f() {\r\n /*\r\n */ var x\r\n\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 59 } } ], expected: "function f() {\r\n /*\r\n */ var x\r\n\r\n\r\n}" }, -{ input: "if (x!=1^y===2) x+=2\r\n", operations: [ { operation: "Enter", point: { position: 24 } } ], expected: "if (x != 1 ^ y === 2) x += 2\r\n" }, -{ input: "function f() {\n }", operations: [ { operation: "Enter", point: { position: 15 } } ], expected: "function f() {\n}" }, -{ input: "function test() {\r\n try { }\r\n catch (e) { }\r\n finally\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n try { }\r\n catch (e) { }\r\n finally\r\n }" }, -{ input: "a = [\n // test\n foo(\n // test\n 1),\n 2\n];", operations: [ { operation: "Document" } ], expected: "a = [\n // test\n foo(\n // test\n 1),\n 2\n];" }, -{ input: "if (x!=1^y===2) x+=2;", operations: [ { operation: "Semicolon", point: { position: 23 } } ], expected: "if (x != 1 ^ y === 2) x += 2;" }, -{ input: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n}finally {\r\nx+=2\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 71 } } ], expected: "function foo() {\r\ntry {\r\nx+=2\r\n}\r\ncatch( e){\r\nx+=2\r\n} finally {\r\n x += 2\r\n}\r\n}" }, -{ input: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}", operations: [ { operation: "Enter", point: { position: 46 } } ], expected: "switch (a) {\n case 1: b++;\n break;\n\n default: a++;\n break;\n}" }, -{ input: "function test() { }\r\n", operations: [ { operation: "Enter", point: { position: 27 } } ], expected: "function test() { }\r\n" }, -{ input: "delete x;", operations: [ { operation: "Document" } ], expected: "delete x;" }, -{ input: "\r\n{\r\n\r\nvar a,\r\n b;\r\n\r\nx = {\r\na: 1 +\r\n 2\r\n}\r\n\r\na(1,\r\n 2).\r\n test();\r\n\r\nfunction foo(a, b,\r\n c) {\r\n}\r\n\r\nfor (i = 0;\r\n i < 1;\r\n i++) {\r\n}\r\n\r\nfor (a\r\n in b) {\r\n}\r\n\r\nwhile (i +\r\n 2) {\r\n}\r\n\r\nswitch (i +\r\n 2) {\r\n\r\n case 1 +\r\n 3:\r\n break;\r\n}\r\n\r\ntry {\r\n}\r\ncatch (\r\n e) {\r\n}\r\n\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n{\r\n\r\n var a,\r\n b;\r\n\r\n x = {\r\n a: 1 +\r\n 2\r\n }\r\n\r\n a(1,\r\n 2).\r\n test();\r\n\r\n function foo(a, b,\r\n c) {\r\n }\r\n\r\n for (i = 0;\r\n i < 1;\r\n i++) {\r\n }\r\n\r\n for (a\r\n in b) {\r\n }\r\n\r\n while (i +\r\n 2) {\r\n }\r\n\r\n switch (i +\r\n 2) {\r\n\r\n case 1 +\r\n 3:\r\n break;\r\n }\r\n\r\n try {\r\n }\r\n catch (\r\n e) {\r\n }\r\n\r\n}\r\n" }, -{ input: "function f() {\r\n do{\r\nx++ }\r\n}", operations: [ { operation: "CloseBrace", point: { position: 30 } } ], expected: "function f() {\r\n do {\r\n x++\n }\r\n}" }, -{ input: "do\r\n{for(var i=0;i<10;i++)i-=2}while(1!==1)", operations: [ { operation: "Enter", point: { position: 4 } } ], expected: "do\r\n{ for (var i = 0; i < 10; i++) i -= 2 } while (1 !== 1)" }, -{ input: "switch (a){\r\n case 1 :\r\n x+=2\r\n case 2:{\r\n }\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 28 } } ], expected: "switch (a){\r\n case 1:\r\n x += 2\r\n case 2:{\r\n }\r\n}\r\n" }, -{ input: "var x = [\n //comment\n 1,\n 2,\n 3\n]", operations: [ { operation: "Document" } ], expected: "var x = [\n //comment\n 1,\n 2,\n 3\n]" }, -{ input: "switch (a){\r\n case 1: x += 2;\r\n\r\ncase 1 : x+=2;\r\n}\r\n", operations: [ { operation: "Enter", point: { position: 36 } } ], expected: "switch (a){\r\n case 1: x += 2;\r\n\r\n case 1: x += 2;\r\n}\r\n" }, -{ input: " foo(function (file) {\r\n return 0\r\n }).then(function (doc) {\r\n return 1\r\n });", operations: [ { operation: "Document" } ], expected: "foo(function (file) {\r\n return 0\r\n}).then(function (doc) {\r\n return 1\r\n});" }, -{ input: "function f() {\r\nvar s=1 /**/;\r\n}", operations: [ { operation: "Semicolon", point: { position: 30 } } ], expected: "function f() {\r\n var s = 1 /**/;\r\n}" }, -{ input: "switch (a){\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n \r\n}", operations: [ { operation: "Enter", point: { position: 61 } } ], expected: "switch (a){\r\n case 1: x+=2;\r\n case 2:{\r\n }\r\n\r\n}" }, -{ input: "if(1)\r\nif(1)\r\nx++\r\nelse\r\nif(1)\r\nx+=2\r\nelse\r\nx+=2\r\n\r\n\r\n\r\n;", operations: [ { operation: "Semicolon", point: { position: 57 } } ], expected: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x += 2\r\n else\r\n x += 2\r\n\r\n\r\n\r\n;" }, -{ input: "function a() {\r\nvar b = 0;//\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "function a() {\r\n var b = 0;//\r\n\r\n}" }, -{ input: "if (a)\r\ntest;\r\nelse\r\nif (b)\r\ntest;", operations: [ { operation: "Document" } ], expected: "if (a)\r\n test;\r\nelse\r\n if (b)\r\n test;" }, -{ input: "for(var j=0;j<10;j++)j-=i;", operations: [ { operation: "Semicolon", point: { position: 26 } } ], expected: "for (var j = 0; j < 10; j++) j -= i;" }, -{ input: "if(1)\r\nif(1)\r\nx++\r\nelse\r\nif(1)\r\nx+=2\r\nelse\r\nx+=2;", operations: [ { operation: "Semicolon", point: { position: 49 } } ], expected: "if (1)\r\n if (1)\r\n x++\r\n else\r\n if (1)\r\n x += 2\r\n else\r\n x += 2;" }, -{ input: "function test() {\r\n var a\r\n }", operations: [ { operation: "Document" } ], expected: "function test() {\r\n var a\r\n}" }, -{ input: "if (1) {\r\n} else { }", operations: [ { operation: "Document" } ], expected: "if (1) {\r\n} else { }" }, -{ input: "function f() {\r\n /*\r\n\r\n */\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "function f() {\r\n /*\r\n\r\n */\r\n}" }, -{ input: "if (x!=1^y===2) \r\n x+=2", operations: [ { operation: "Enter", point: { position: 18 } } ], expected: "if (x != 1 ^ y === 2)\r\n x += 2" }, -{ input: "for (a in b) {\n for (c in d) {\n for (e in f) {\n for (q in w) {}}}}\n", operations: [ { operation: "Enter", point: { position: 88 } } ], expected: "for (a in b) {\n for (c in d) {\n for (e in f) {\n for (q in w) { }\n }\n }\n}\n" }, -{ input: "a=a+\nb+\n c+\n d +\ne +\nm+f;", operations: [ { operation: "Semicolon", point: { position: 100 } } ], expected: "a = a +\nb +\n c +\n d +\ne +\nm + f;" }, -{ input: "x = {\r\n get a() {\r\n\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "x = {\r\n get a() {\r\n\r\n }\r\n}" }, -{ input: "if(1)\r\n;", operations: [ { operation: "Enter", point: { position: 7 } } ], expected: "if (1)\r\n ;" }, -{ input: "function test() {\r\n return (\r\n [\r\n 1\r\n ]\r\n );\r\n}", operations: [ { operation: "Document" } ], expected: "function test() {\r\n return (\r\n [\r\n 1\r\n ]\r\n );\r\n}" }, -{ input: "string='string+=2\\r\n'", operations: [ { operation: "Enter", point: { position: 20 } } ], expected: "string = 'string+=2\\r\n'" }, -{ input: "if(1)\r\nif(1)\r\nx++\r\nelse\r\n{if(1)\r\nx+=2\r\nelse\r\nx+=2}", operations: [ { operation: "CloseBrace", point: { position: 50 } } ], expected: "if(1)\r\n if (1)\r\n x++\r\n else {\n if (1)\r\n x += 2\r\n else\r\n x += 2\n }" }, -{ input: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n{\r\n}\r\n}\r\n}\r\n}\r\n}\r\n}", operations: [ { operation: "Selection", span: { start: 110, length: 19 } } ], expected: " function test() { function foo() { function foo3() { function foo4() { function foo5() { function foo6()\r\n {\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }" }, -{ input: "switch (a){\r\n case 1: x+=2;\r\n case 2 : { x+=2;}\r\n}\r\n", operations: [ { operation: "Semicolon", point: { position: 53 } } ], expected: "switch (a){\r\n case 1: x+=2;\r\n case 2: { x += 2;}\r\n}\r\n" }, -{ input: "// ", operations: [ { operation: "Document" } ], expected: "// " }, -{ input: "for(var i=0;\r\ni<10;i++){for(var j=0;j<10;j++){j-=i}}", operations: [ { operation: "Enter", point: { position: 14 } } ], expected: "for (var i = 0;\r\ni < 10; i++) { for (var j = 0; j < 10; j++) { j -= i } }" }, -{ input: "if (a) if (b) if (c) if (d)\r\ntest;", operations: [ { operation: "Document" } ], expected: "if (a) if (b) if (c) if (d)\r\n test;" }, -{ input: "do{for(var i=0;i<10;i++)i-=2}while(1!==1)", operations: [ { operation: "Semicolon", point: { position: 15 } } ], expected: "do { for (var i = 0;i<10;i++)i-=2}while(1!==1)" }, -{ input: "$ ( '#TextBox1' ) . unbind ( ) ;", operations: [ { operation: "Document" } ], expected: "$('#TextBox1').unbind();" }, -{ input: "do{do{do{}while(a!==b)}while(a!==b)}while(a!==b);", operations: [ { operation: "Semicolon", point: { position: 49 } } ], expected: "do { do { do { } while (a !== b) } while (a !== b) } while (a !== b);" }, -{ input: "do{for(var i=0;i<10;i++)i-=2;}while(1!==1)", operations: [ { operation: "Semicolon", point: { position: 29 } } ], expected: "do { for (var i = 0; i < 10; i++) i -= 2;}while(1!==1)" }, -{ input: "for(var i=0;i<10;i++){\r\nfor(var j=0;j<10;j++){\r\nj-=i\r\n}\r\n}", operations: [ { operation: "CloseBrace", point: { position: 55 } } ], expected: "for(var i=0;i<10;i++){\r\n for (var j = 0; j < 10; j++) {\r\n j -= i\r\n }\r\n}" }, -{ input: "function a() {\r\nfunction b() {\r\nfunction c() {\r\n}}}", operations: [ { operation: "CloseBrace", point: { position: 51 } } ], expected: "function a() {\r\n function b() {\r\n function c() {\r\n }\n }\n}" }, -{ input: " do do do do\r\n test;\r\n while (0)\r\n while (0)\r\n while (0)\r\n while (0)", operations: [ { operation: "Document" } ], expected: "do do do do\r\n test;\r\nwhile (0)\r\nwhile (0)\r\nwhile (0)\r\nwhile (0)" }, -{ input: "/**/ ", operations: [ { operation: "Document" } ], expected: "/**/" }, -{ input: "function a()\n{ var a\n}", operations: [ { operation: "Enter", point: { position: 21 } } ], expected: "function a()\n{\n var a\n}" }, -{ input: "for(var i=0;i<10;i++){for(var j=0;j<10;\r\nj++){j-=i}}", operations: [ { operation: "Enter", point: { position: 41 } } ], expected: "for (var i = 0; i < 10; i++) {\n for (var j = 0; j < 10;\r\n j++) { j -= i }\n}" }, -{ input: "function a() {\r\n if (true) {\r\n }\r\n\r\n}", operations: [ { operation: "Enter", point: { position: 40 } } ], expected: "function a() {\r\n if (true) {\r\n }\r\n\r\n}" }, -{ input: "string='string+=2'\r\n", operations: [ { operation: "Enter", point: { position: 20 } } ], expected: "string = 'string+=2'\r\n" }, -{ input: "for (a in b) {\r\nx++;}\r\n", operations: [ { operation: "Enter", point: { position: 23 } } ], expected: "for (a in b) {\r\n x++;\n}\r\n" }, -{ input: "var obj={a:{b:2,c:{\r\nd:{e:{}}}}}", operations: [ { operation: "Enter", point: { position: 21 } } ], expected: "var obj = {\n a: {\n b: 2, c: {\r\n d: { e: {} }\n }\n }\n}" }, -{ input: "\r\n// test\r\n\r\n{\r\n// test\r\n}\r\n\r\nfunction foo() {\r\n// test\r\n\r\nswitch (a) {\r\n// test\r\ncase 1:\r\n// test\r\ndefault:\r\n// test\r\n}\r\n\r\nif (false)\r\n// test\r\nifblock;\r\n\r\nif (false) {\r\n//test\r\n}\r\n\r\nif (false) test;\r\nelse\r\n// test\r\ntest;\r\n\r\nif (false) test;\r\nelse {\r\n// test\r\ntest;\r\n}\r\n\r\nfor (; ;)\r\n// test\r\ntest;\r\n\r\nfor (; ;) {\r\n// test\r\nforblock;\r\n}\r\n\r\nfor (a in b)\r\n// test\r\ntest;\r\n\r\nfor (a in b) {\r\n// test\r\ntest\r\n}\r\n\r\nwhile (false)\r\n// test\r\ntest;\r\n\r\nwhile (false) {\r\n// test\r\ntest;\r\n}\r\n\r\nwith (a) {\r\n// test\r\n}\r\n\r\ndo\r\n// test\r\ntestl\r\nwhile (false)\r\n\r\ndo {\r\n// test\r\ntest;\r\n} while (false)\r\n\r\ntry {\r\n// test\r\n} catch (e) {\r\n// test\r\n} finally {\r\n// test\r\n}\r\n\r\n(function () {\r\nvar a = function () {\r\nreturn 1;\r\n},\r\n// This is a comment inline with a multiline statement\r\nb = 2,\r\nc = 3;\r\n})();\r\n\r\n\r\nvar a = {\r\n// test\r\nx: 1,\r\ny: 2 +\r\n// test\r\n3 +\r\n4,\r\n}\r\n\r\n\r\nvar a,\r\n// test\r\nb;\r\n\r\nvar a = [\r\n// test\r\n1,\r\n2,\r\n3\r\n];\r\n\r\na = 1 +\r\n// test\r\n2;\r\n\r\n}\r\n", operations: [ { operation: "Document" } ], expected: "\r\n// test\r\n\r\n{\r\n // test\r\n}\r\n\r\nfunction foo() {\r\n // test\r\n\r\n switch (a) {\r\n // test\r\n case 1:\r\n // test\r\n default:\r\n // test\r\n }\r\n\r\n if (false)\r\n // test\r\n ifblock;\r\n\r\n if (false) {\r\n //test\r\n }\r\n\r\n if (false) test;\r\n else\r\n // test\r\n test;\r\n\r\n if (false) test;\r\n else {\r\n // test\r\n test;\r\n }\r\n\r\n for (; ;)\r\n // test\r\n test;\r\n\r\n for (; ;) {\r\n // test\r\n forblock;\r\n }\r\n\r\n for (a in b)\r\n // test\r\n test;\r\n\r\n for (a in b) {\r\n // test\r\n test\r\n }\r\n\r\n while (false)\r\n // test\r\n test;\r\n\r\n while (false) {\r\n // test\r\n test;\r\n }\r\n\r\n with (a) {\r\n // test\r\n }\r\n\r\n do\r\n // test\r\n testl\r\n while (false)\r\n\r\n do {\r\n // test\r\n test;\r\n } while (false)\r\n\r\n try {\r\n // test\r\n } catch (e) {\r\n // test\r\n } finally {\r\n // test\r\n }\r\n\r\n (function () {\r\n var a = function () {\r\n return 1;\r\n },\r\n // This is a comment inline with a multiline statement\r\n b = 2,\r\n c = 3;\r\n })();\r\n\r\n\r\n var a = {\r\n // test\r\n x: 1,\r\n y: 2 +\r\n // test\r\n 3 +\r\n 4,\r\n }\r\n\r\n\r\n var a,\r\n // test\r\n b;\r\n\r\n var a = [\r\n // test\r\n 1,\r\n 2,\r\n 3\r\n ];\r\n\r\n a = 1 +\r\n // test\r\n 2;\r\n\r\n}\r\n" }, -{ input: " \r\n /* \r\n\r\n a \r\n a\r\n a \r\n a \r\na \r\n \r\n\r\n */ \r\n ", operations: [ { operation: "Document" } ], expected: "\r\n/* \r\n\r\n a \r\n a\r\n a \r\na \r\na \r\n\r\n\r\n*/\r\n" }, -{ input: "string='{string +=2}'", operations: [ { operation: "CloseBrace", point: { position: 20 } } ], expected: "string='{string +=2}'" }, -{ input: "var obj={a:{b:2,c:{d:{e:{}}}}}\r\n", operations: [ { operation: "Enter", point: { position: 32 } } ], expected: "var obj = { a: { b: 2, c: { d: { e: {} } } } }\r\n" }, -{ input: "string='string\\r\n line2'+'other part'\r\n", operations: [ { operation: "Enter", point: { position: 47 } } ], expected: "string='string\\r\n line2' + 'other part'\r\n" }, -{ input: " switch( a)\r\n{case 1 :x+=2 ;break\r\n case 2:{\r\n }\r\n}", operations: [ { operation: "Enter", point: { position: 13 } } ], expected: "switch (a)\r\n{\n case 1: x += 2; break\r\n case 2:{\r\n }\r\n}" } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/classes.ts b/src/harness/unittests/services/formatting/testCode/formatting/classes.ts deleted file mode 100644 index e779f69810f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/classes.ts +++ /dev/null @@ -1,79 +0,0 @@ - class a { - constructor ( n : number ) ; - constructor ( s : string ) ; - constructor ( ns : any ) { - - } - - public pgF ( ) { } ; - - public pv ; - public get d ( ) { - return 30 ; - } - public set d ( ) { - } - - public static get p2 ( ) { - return { x : 30 , y : 40 } ; - } - - private static d2 ( ) { - } - private static get p3 ( ) { - return "string" ; - } - private pv3 ; - - private foo ( n : number ) : string ; - private foo ( s : string ) : string ; - private foo ( ns : any ) { - return ns.toString ( ) ; - } -} - - class b extends a { -} - - class m1b { - -} - - interface m1ib { - - } - class c extends m1b { -} - - class ib2 implements m1ib { -} - - declare class aAmbient { - constructor ( n : number ) ; - constructor ( s : string ) ; - public pgF ( ) : void ; - public pv ; - public d : number ; - static p2 : { x : number ; y : number ; } ; - static d2 ( ) ; - static p3 ; - private pv3 ; - private foo ( s ) ; -} - - class d { - private foo ( n : number ) : string ; - private foo ( ns : any ) { - return ns.toString ( ) ; - } - private foo ( s : string ) : string ; -} - - class e { - private foo ( ns : any ) { - return ns.toString ( ) ; - } - private foo ( s : string ) : string ; - private foo ( n : number ) : string ; -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/classesBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/classesBaseline.ts deleted file mode 100644 index e7e69b44125..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/classesBaseline.ts +++ /dev/null @@ -1,79 +0,0 @@ -class a { - constructor(n: number); - constructor(s: string); - constructor(ns: any) { - - } - - public pgF() { }; - - public pv; - public get d() { - return 30; - } - public set d() { - } - - public static get p2() { - return { x: 30, y: 40 }; - } - - private static d2() { - } - private static get p3() { - return "string"; - } - private pv3; - - private foo(n: number): string; - private foo(s: string): string; - private foo(ns: any) { - return ns.toString(); - } -} - -class b extends a { -} - -class m1b { - -} - -interface m1ib { - -} -class c extends m1b { -} - -class ib2 implements m1ib { -} - -declare class aAmbient { - constructor(n: number); - constructor(s: string); - public pgF(): void; - public pv; - public d: number; - static p2: { x: number; y: number; }; - static d2(); - static p3; - private pv3; - private foo(s); -} - -class d { - private foo(n: number): string; - private foo(ns: any) { - return ns.toString(); - } - private foo(s: string): string; -} - -class e { - private foo(ns: any) { - return ns.toString(); - } - private foo(s: string): string; - private foo(n: number): string; -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMark.ts b/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMark.ts deleted file mode 100644 index 5562e142046..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMark.ts +++ /dev/null @@ -1,4 +0,0 @@ -class foo { - constructor (n?: number, m? = 5, o?: string = "") { } - x:number = 1?2:3; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMarkBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMarkBaseline.ts deleted file mode 100644 index 52bbe56251d..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/colonAndQMarkBaseline.ts +++ /dev/null @@ -1,4 +0,0 @@ -class foo { - constructor(n?: number, m? = 5, o?: string = "") { } - x: number = 1 ? 2 : 3; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunction.ts b/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunction.ts deleted file mode 100644 index 35daa4d895c..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunction.ts +++ /dev/null @@ -1,3 +0,0 @@ -$ ( document ) . ready ( function ( ) { - alert ( 'i am ready' ) ; - } ); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunctionBaseLine.ts b/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunctionBaseLine.ts deleted file mode 100644 index 838ef682207..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/documentReadyFunctionBaseLine.ts +++ /dev/null @@ -1,3 +0,0 @@ -$(document).ready(function() { - alert('i am ready'); -}); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlock.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyBlock.ts deleted file mode 100644 index 9e26dfeeb6e..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlock.ts +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlockBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyBlockBaseline.ts deleted file mode 100644 index 6f31cf5a2e6..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyBlockBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -{ } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteral.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteral.ts deleted file mode 100644 index 1feec453d03..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteral.ts +++ /dev/null @@ -1,10 +0,0 @@ - function foo ( x : { } ) { } - -foo ( { } ) ; - - - - interface bar { - x : { } ; - y : ( ) => { } ; - } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteralBaseLine.ts b/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteralBaseLine.ts deleted file mode 100644 index 04f3c0bc9b9..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/emptyInterfaceLiteralBaseLine.ts +++ /dev/null @@ -1,10 +0,0 @@ -function foo(x: {}) { } - -foo({}); - - - -interface bar { - x: {}; - y: () => {}; -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctions.ts b/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctions.ts deleted file mode 100644 index ebbf54557fa..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctions.ts +++ /dev/null @@ -1,112 +0,0 @@ -// valid - ( ) => 1 ; - ( arg ) => 2 ; - arg => 2 ; - ( arg = 1 ) => 3 ; - ( arg ? ) => 4 ; - ( arg : number ) => 5 ; - ( arg : number = 0 ) => 6 ; - ( arg ? : number ) => 7 ; - ( ... arg : number [ ] ) => 8 ; - ( arg1 , arg2 ) => 12 ; - ( arg1 = 1 , arg2 =3 ) => 13 ; - ( arg1 ? , arg2 ? ) => 14 ; - ( arg1 : number , arg2 : number ) => 15 ; - ( arg1 : number = 0 , arg2 : number = 1 ) => 16 ; - ( arg1 ? : number , arg2 ? : number ) => 17 ; - ( arg1 , ... arg2 : number [ ] ) => 18 ; - ( arg1 , arg2 ? : number ) => 19 ; - -// in paren - ( ( ) => 21 ) ; - ( ( arg ) => 22 ) ; - ( ( arg = 1 ) => 23 ) ; - ( ( arg ? ) => 24 ) ; - ( ( arg : number ) => 25 ) ; - ( ( arg : number = 0 ) => 26 ) ; - ( ( arg ? : number ) => 27 ) ; - ( ( ... arg : number [ ] ) => 28 ) ; - -// in multiple paren - ( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ; - -// in ternary exression - false ? ( ) => 41 : null ; - false ? ( arg ) => 42 : null ; - false ? ( arg = 1 ) => 43 : null ; - false ? ( arg ? ) => 44 : null ; - false ? ( arg : number ) => 45 : null ; - false ? ( arg ? : number ) => 46 : null ; - false ? ( arg ? : number = 0 ) => 47 : null ; - false ? ( ... arg : number [ ] ) => 48 : null ; - -// in ternary exression within paren - false ? ( ( ) => 51 ) : null ; - false ? ( ( arg ) => 52 ) : null ; - false ? ( ( arg = 1 ) => 53 ) : null ; - false ? ( ( arg ? ) => 54 ) : null ; - false ? ( ( arg : number ) => 55 ) : null ; - false ? ( ( arg ? : number ) => 56 ) : null ; - false ? ( ( arg ? : number = 0 ) => 57 ) : null ; - false ? ( ( ... arg : number [ ] ) => 58 ) : null ; - -// ternary exression's else clause - false ? null : ( ) => 61 ; - false ? null : ( arg ) => 62 ; - false ? null : ( arg = 1 ) => 63 ; - false ? null : ( arg ? ) => 64 ; - false ? null : ( arg : number ) => 65 ; - false ? null : ( arg ? : number ) => 66 ; - false ? null : ( arg ? : number = 0 ) => 67 ; - false ? null : ( ... arg : number [ ] ) => 68 ; - - -// nested ternary expressions - ( a ? ) => { return a ; } ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ; - -//multiple levels - ( a ? ) => { return a ; } ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ; - - -// In Expressions - ( ( arg ) => 90 ) instanceof Function ; - ( ( arg = 1 ) => 91 ) instanceof Function ; - ( ( arg ? ) => 92 ) instanceof Function ; - ( ( arg : number ) => 93 ) instanceof Function ; - ( ( arg : number = 1 ) => 94 ) instanceof Function ; - ( ( arg ? : number ) => 95 ) instanceof Function ; - ( ( ... arg : number [ ] ) => 96 ) instanceof Function ; - -'' + ( arg ) => 100 ; - ( ( arg ) => 0 ) + '' + ( arg ) => 101 ; - ( ( arg = 1 ) => 0 ) + '' + ( arg = 2 ) => 102 ; - ( ( arg ? ) => 0 ) + '' + ( arg ? ) => 103 ; - ( ( arg : number ) => 0 ) + '' + ( arg : number ) => 104 ; - ( ( arg : number = 1 ) => 0 ) + '' + ( arg : number = 2 ) => 105 ; - ( ( arg ? : number = 1 ) => 0 ) + '' + ( arg ? : number = 2 ) => 106 ; - ( ( ... arg : number [ ] ) => 0 ) + '' + ( ... arg : number [ ] ) => 107 ; - ( ( arg1 , arg2 ? ) => 0 ) + '' + ( arg1 , arg2 ? ) => 108 ; - ( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + ( arg1 , ... arg2 : number [ ] ) => 108 ; - - -// Function Parameters -function foo ( ... arg : any [ ] ) { } - -foo ( - ( a ) => 110 , - ( ( a ) => 111 ) , - ( a ) => { - return 112 ; - } , - ( a ? ) => 113 , - ( a , b ? ) => 114 , - ( a : number ) => 115 , - ( a : number = 0 ) => 116 , - ( a = 0 ) => 117 , - ( a ? : number = 0 ) => 118 , - ( a ? , b ? : number = 0 ) => 118 , - ( ... a : number [ ] ) => 119 , - ( a , b ? = 0 , ... c : number [ ] ) => 120 , - ( a ) => ( b ) => ( c ) => 121 , - false ? ( a ) => 0 : ( b ) => 122 - ) ; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctionsBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctionsBaseline.ts deleted file mode 100644 index 7a1ef86f5af..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/fatArrowFunctionsBaseline.ts +++ /dev/null @@ -1,112 +0,0 @@ -// valid -() => 1; -(arg) => 2; -arg => 2; -(arg = 1) => 3; -(arg?) => 4; -(arg: number) => 5; -(arg: number = 0) => 6; -(arg?: number) => 7; -(...arg: number[]) => 8; -(arg1, arg2) => 12; -(arg1 = 1, arg2 = 3) => 13; -(arg1?, arg2?) => 14; -(arg1: number, arg2: number) => 15; -(arg1: number = 0, arg2: number = 1) => 16; -(arg1?: number, arg2?: number) => 17; -(arg1, ...arg2: number[]) => 18; -(arg1, arg2?: number) => 19; - -// in paren -(() => 21); -((arg) => 22); -((arg = 1) => 23); -((arg?) => 24); -((arg: number) => 25); -((arg: number = 0) => 26); -((arg?: number) => 27); -((...arg: number[]) => 28); - -// in multiple paren -(((((arg) => { return 32; })))); - -// in ternary exression -false ? () => 41 : null; -false ? (arg) => 42 : null; -false ? (arg = 1) => 43 : null; -false ? (arg?) => 44 : null; -false ? (arg: number) => 45 : null; -false ? (arg?: number) => 46 : null; -false ? (arg?: number = 0) => 47 : null; -false ? (...arg: number[]) => 48 : null; - -// in ternary exression within paren -false ? (() => 51) : null; -false ? ((arg) => 52) : null; -false ? ((arg = 1) => 53) : null; -false ? ((arg?) => 54) : null; -false ? ((arg: number) => 55) : null; -false ? ((arg?: number) => 56) : null; -false ? ((arg?: number = 0) => 57) : null; -false ? ((...arg: number[]) => 58) : null; - -// ternary exression's else clause -false ? null : () => 61; -false ? null : (arg) => 62; -false ? null : (arg = 1) => 63; -false ? null : (arg?) => 64; -false ? null : (arg: number) => 65; -false ? null : (arg?: number) => 66; -false ? null : (arg?: number = 0) => 67; -false ? null : (...arg: number[]) => 68; - - -// nested ternary expressions -(a?) => { return a; } ? (b?) => { return b; } : (c?) => { return c; }; - -//multiple levels -(a?) => { return a; } ? (b) => (c) => 81 : (c) => (d) => 82; - - -// In Expressions -((arg) => 90) instanceof Function; -((arg = 1) => 91) instanceof Function; -((arg?) => 92) instanceof Function; -((arg: number) => 93) instanceof Function; -((arg: number = 1) => 94) instanceof Function; -((arg?: number) => 95) instanceof Function; -((...arg: number[]) => 96) instanceof Function; - -'' + (arg) => 100; -((arg) => 0) + '' + (arg) => 101; -((arg = 1) => 0) + '' + (arg = 2) => 102; -((arg?) => 0) + '' + (arg?) => 103; -((arg: number) => 0) + '' + (arg: number) => 104; -((arg: number = 1) => 0) + '' + (arg: number = 2) => 105; -((arg?: number = 1) => 0) + '' + (arg?: number = 2) => 106; -((...arg: number[]) => 0) + '' + (...arg: number[]) => 107; -((arg1, arg2?) => 0) + '' + (arg1, arg2?) => 108; -((arg1, ...arg2: number[]) => 0) + '' + (arg1, ...arg2: number[]) => 108; - - -// Function Parameters -function foo(...arg: any[]) { } - -foo( - (a) => 110, - ((a) => 111), - (a) => { - return 112; - }, - (a?) => 113, - (a, b?) => 114, - (a: number) => 115, - (a: number = 0) => 116, - (a = 0) => 117, - (a?: number = 0) => 118, - (a?, b?: number = 0) => 118, - (...a: number[]) => 119, - (a, b? = 0, ...c: number[]) => 120, - (a) => (b) => (c) => 121, - false ? (a) => 0 : (b) => 122 - ); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatement.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatement.ts deleted file mode 100644 index 314cd416a81..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatement.ts +++ /dev/null @@ -1,2 +0,0 @@ -if(false){debugger;} - if ( false ) { debugger ; } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatementBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatementBaseline.ts deleted file mode 100644 index c03acf91ecf..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatDebuggerStatementBaseline.ts +++ /dev/null @@ -1,2 +0,0 @@ -if (false) { debugger; } -if (false) { debugger; } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationList.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationList.ts deleted file mode 100644 index 956309d2c4d..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationList.ts +++ /dev/null @@ -1,13 +0,0 @@ -var fun1 = function ( ) { - var x = 'foo' , - z = 'bar' ; - return x ; -}, - -fun2 = ( function ( f ) { - var fun = function ( ) { - console . log ( f ( ) ) ; - }, - x = 'Foo' ; - return fun ; -} ( fun1 ) ) ; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationListBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationListBaseline.ts deleted file mode 100644 index f1d32283fd7..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/formatvariableDeclarationListBaseline.ts +++ /dev/null @@ -1,13 +0,0 @@ -var fun1 = function() { - var x = 'foo', - z = 'bar'; - return x; -}, - -fun2 = (function(f) { - var fun = function() { - console.log(f()); - }, - x = 'Foo'; - return fun; -} (fun1)); diff --git a/src/harness/unittests/services/formatting/testCode/formatting/implicitModule.ts b/src/harness/unittests/services/formatting/testCode/formatting/implicitModule.ts deleted file mode 100644 index 352a252593b..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/implicitModule.ts +++ /dev/null @@ -1,3 +0,0 @@ - export class A { - - } diff --git a/src/harness/unittests/services/formatting/testCode/formatting/implicitModuleBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/implicitModuleBaseline.ts deleted file mode 100644 index df93540466f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/implicitModuleBaseline.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class A { - -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/importDeclaration.ts b/src/harness/unittests/services/formatting/testCode/formatting/importDeclaration.ts deleted file mode 100644 index afd010fe8b7..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/importDeclaration.ts +++ /dev/null @@ -1,6 +0,0 @@ -module Foo { -} - -import bar = Foo; - -import bar2=Foo; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/importDeclarationBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/importDeclarationBaseline.ts deleted file mode 100644 index d0a4e190d95..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/importDeclarationBaseline.ts +++ /dev/null @@ -1,6 +0,0 @@ -module Foo { -} - -import bar = Foo; - -import bar2 = Foo; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/main.ts b/src/harness/unittests/services/formatting/testCode/formatting/main.ts deleted file mode 100644 index 7640013af8b..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/main.ts +++ /dev/null @@ -1,95 +0,0 @@ - -var a;var c , b;var $d -var $e -var f -a++;b++; - -function f ( ) { - for (i = 0; i < 10; i++) { - k = abc + 123 ^ d; - a = XYZ[m (a[b[c][d]])]; - break; - - switch ( variable){ - case 1: abc += 425; -break; -case 404 : a [x--/2]%=3 ; - break ; - case vari : v[--x ] *=++y*( m + n / k[z]); - for (a in b){ - for (a = 0; a < 10; ++a) { - a++;--a; - if (a == b) { - a++;b--; - } -else -if (a == c){ -++a; -(--c)+=d; -$c = $a + --$b; -} -if (a == b) -if (a != b) { - if (a !== b) - if (a === b) - --a; - else - --a; - else { - a--;++b; -a++ - } - } - } - for (x in y) { -m-=m; -k=1+2+3+4; -} -} - break; - - } - } - var a ={b:function(){}}; - return {a:1,b:2} -} - -var z = 1; - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) -for (k = 0; k < 10; ++k) { -z++; -} - -for (k = 0; k < 10; k += 2) { -z++; -} - - $(document).ready (); - - - function pageLoad() { - $('#TextBox1' ) . unbind ( ) ; -$('#TextBox1' ) . datepicker ( ) ; -} - - function pageLoad ( ) { - var webclass=[ - { 'student' : - { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } - } , -{ 'student': -{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'} -} , - { 'student': -{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'} -} - ]; - -$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList')); - -} - -$( document ).ready(function(){ -alert('hello'); - } ) ; diff --git a/src/harness/unittests/services/formatting/testCode/formatting/mainBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/mainBaseline.ts deleted file mode 100644 index 30756f547ca..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/mainBaseline.ts +++ /dev/null @@ -1,98 +0,0 @@ - -var a; var c, b; var $d -var $e -var f -a++; b++; - -function f() { - for (i = 0; i < 10; i++) { - k = abc + 123 ^ d; - a = XYZ[m(a[b[c][d]])]; - break; - - switch (variable) { - case 1: abc += 425; - break; - case 404: a[x-- / 2] %= 3; - break; - case vari: v[--x] *= ++y * (m + n / k[z]); - for (a in b) { - for (a = 0; a < 10; ++a) { - a++; --a; - if (a == b) { - a++; b--; - } - else - if (a == c) { - ++a; - (--c) += d; - $c = $a + --$b; - } - if (a == b) - if (a != b) { - if (a !== b) - if (a === b) - --a; - else - --a; - else { - a--; ++b; - a++ - } - } - } - for (x in y) { - m -= m; - k = 1 + 2 + 3 + 4; - } - } - break; - - } - } - var a = { b: function() { } }; - return { a: 1, b: 2 } -} - -var z = 1; -for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; ++k) { - z++; - } - -for (k = 0; k < 10; k += 2) { - z++; -} - -$(document).ready(); - - -function pageLoad() { - $('#TextBox1').unbind(); - $('#TextBox1').datepicker(); -} - -function pageLoad() { - var webclass = [ - { - 'student': - { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } - }, -{ - 'student': - { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' } -}, - { - 'student': - { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' } - } - ]; - - $create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList')); - -} - -$(document).ready(function() { - alert('hello'); -}); diff --git a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentation.ts b/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentation.ts deleted file mode 100644 index 3030a36630a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentation.ts +++ /dev/null @@ -1,3 +0,0 @@ - module Foo { - export module A . B . C { } - } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentationBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentationBaseline.ts deleted file mode 100644 index 0013b367dcf..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/moduleIndentationBaseline.ts +++ /dev/null @@ -1,3 +0,0 @@ -module Foo { - export module A.B.C { } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/modules.ts b/src/harness/unittests/services/formatting/testCode/formatting/modules.ts deleted file mode 100644 index 5ce0d19b632..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/modules.ts +++ /dev/null @@ -1,76 +0,0 @@ - module mod1 { - export class b { - } - class d { - } - - - export interface ib { - } -} - - module m2 { - - export module m3 { - export class c extends mod1.b { - } - export class ib2 implements mod1.ib { - } - } -} - - class c extends mod1.b { -} - - class ib2 implements mod1.ib { -} - - declare export module "m4" { - export class d { - } ; - var x : d ; - export function foo ( ) : d ; -} - - import m4 = module ( "m4" ) ; - export var x4 = m4.x ; - export var d4 = m4.d ; - export var f4 = m4.foo ( ) ; - - export module m1 { - declare export module "m2" { - export class d { - } ; - var x: d ; - export function foo ( ) : d ; - } - import m2 = module ( "m2" ) ; - import m3 = module ( "m4" ) ; - - export var x2 = m2.x ; - export var d2 = m2.d ; - export var f2 = m2.foo ( ) ; - - export var x3 = m3.x ; - export var d3 = m3.d ; - export var f3 = m3.foo ( ) ; -} - - export var x2 = m1.m2.x ; - export var d2 = m1.m2.d ; - export var f2 = m1.m2.foo ( ) ; - - export var x3 = m1.m3.x ; - export var d3 = m1.m3.d ; - export var f3 = m1.m3.foo ( ) ; - - export module m5 { - export var x2 = m1.m2.x ; - export var d2 = m1.m2.d ; - export var f2 = m1.m2.foo ( ) ; - - export var x3 = m1.m3.x ; - export var d3 = m1.m3.d ; - export var f3 = m1.m3.foo ( ) ; -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/modulesBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/modulesBaseline.ts deleted file mode 100644 index e6f62024fe6..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/modulesBaseline.ts +++ /dev/null @@ -1,76 +0,0 @@ -module mod1 { - export class b { - } - class d { - } - - - export interface ib { - } -} - -module m2 { - - export module m3 { - export class c extends mod1.b { - } - export class ib2 implements mod1.ib { - } - } -} - -class c extends mod1.b { -} - -class ib2 implements mod1.ib { -} - -declare export module "m4" { - export class d { - }; - var x: d; - export function foo(): d; -} - -import m4 = module("m4"); -export var x4 = m4.x; -export var d4 = m4.d; -export var f4 = m4.foo(); - -export module m1 { - declare export module "m2" { - export class d { - }; - var x: d; - export function foo(): d; - } - import m2 = module("m2"); - import m3 = module("m4"); - - export var x2 = m2.x; - export var d2 = m2.d; - export var f2 = m2.foo(); - - export var x3 = m3.x; - export var d3 = m3.d; - export var f3 = m3.foo(); -} - -export var x2 = m1.m2.x; -export var d2 = m1.m2.d; -export var f2 = m1.m2.foo(); - -export var x3 = m1.m3.x; -export var d3 = m1.m3.d; -export var f3 = m1.m3.foo(); - -export module m5 { - export var x2 = m1.m2.x; - export var d2 = m1.m2.d; - export var f2 = m1.m2.foo(); - - export var x3 = m1.m3.x; - export var d3 = m1.m3.d; - export var f3 = m1.m3.foo(); -} - diff --git a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteral.ts b/src/harness/unittests/services/formatting/testCode/formatting/objectLiteral.ts deleted file mode 100644 index dbecc4d4fec..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteral.ts +++ /dev/null @@ -1,27 +0,0 @@ -var x = {foo: 1, -bar: "tt", -boo: 1 + 5}; - -var x2 = {foo: 1, -bar: "tt",boo:1+5}; - -function Foo() { -var typeICalc = { -clear: { -"()": [1, 2, 3] -} -} -} - -// Rule for object literal members for the "value" of the memebr to follow the indent -// of the member, i.e. the relative position of the value is maintained when the member -// is indented. -var x2 = { - foo: -3, - 'bar': - { a: 1, b : 2} -}; - -var x={ }; -var y = {}; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteralBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/objectLiteralBaseline.ts deleted file mode 100644 index 3a7fa63d927..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/objectLiteralBaseline.ts +++ /dev/null @@ -1,31 +0,0 @@ -var x = { - foo: 1, - bar: "tt", - boo: 1 + 5 -}; - -var x2 = { - foo: 1, - bar: "tt", boo: 1 + 5 -}; - -function Foo() { - var typeICalc = { - clear: { - "()": [1, 2, 3] - } - } -} - -// Rule for object literal members for the "value" of the memebr to follow the indent -// of the member, i.e. the relative position of the value is maintained when the member -// is indented. -var x2 = { - foo: - 3, - 'bar': - { a: 1, b: 2 } -}; - -var x = {}; -var y = {}; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracket.ts b/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracket.ts deleted file mode 100644 index 0161f04308d..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracket.ts +++ /dev/null @@ -1,32 +0,0 @@ -function f( ) { -var x = 3; - var z = 2 ; - a = z ++ - 2 * x ; - for ( ; ; ) { - a+=(g +g)*a%t; - b -- ; -} - - switch ( a ) - { - case 1 : { - a ++ ; - b--; - if(a===a) - return; - else - { - for(a in b) - if(a!=a) - { - for(a in b) - { -a++; - } - } - } - } - default: - break; - } -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracketBaseLine.ts b/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracketBaseLine.ts deleted file mode 100644 index 051a4ebd13a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onClosingBracketBaseLine.ts +++ /dev/null @@ -1,28 +0,0 @@ -function f() { - var x = 3; - var z = 2; - a = z++ - 2 * x; - for (; ;) { - a += (g + g) * a % t; - b--; - } - - switch (a) { - case 1: { - a++; - b--; - if (a === a) - return; - else { - for (a in b) - if (a != a) { - for (a in b) { - a++; - } - } - } - } - default: - break; - } -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColon.ts b/src/harness/unittests/services/formatting/testCode/formatting/onSemiColon.ts deleted file mode 100644 index 3b5b5456a6f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColon.ts +++ /dev/null @@ -1 +0,0 @@ -var a=b+c^d-e*++f; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColonBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/onSemiColonBaseline.ts deleted file mode 100644 index 2ba96e4f88a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/onSemiColonBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -var a = b + c ^ d - e * ++f; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructor.ts b/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructor.ts deleted file mode 100644 index 7d98d5a8f43..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructor.ts +++ /dev/null @@ -1 +0,0 @@ -class test { constructor () { } } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructorBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructorBaseline.ts deleted file mode 100644 index bc124d41baf..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/spaceAfterConstructorBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -class test { constructor() { } } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurly.ts b/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurly.ts deleted file mode 100644 index ec093e0e376..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurly.ts +++ /dev/null @@ -1,10 +0,0 @@ -module Tools { - export enum NodeType { - Error, - Comment, - } - export enum foob - { - Blah=1, Bleah=2 - } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurlyBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurlyBaseline.ts deleted file mode 100644 index d0a3db2d51a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/tabAfterCloseCurlyBaseline.ts +++ /dev/null @@ -1,9 +0,0 @@ -module Tools { - export enum NodeType { - Error, - Comment, - } - export enum foob { - Blah = 1, Bleah = 2 - } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructs.ts b/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructs.ts deleted file mode 100644 index 43ef3710ef1..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructs.ts +++ /dev/null @@ -1,65 +0,0 @@ - module MyModule - { - module A.B.C { -module F { -} - } -interface Blah -{ -boo: string; -} - - class Foo - { - -} - -class Foo2 { -public foo():number { -return 5 * 6; -} -public foo2() { -if (1 === 2) - - -{ -var y : number= 76; -return y; -} - - while (2 == 3) { - if ( y == null ) { - -} - } -} - -public foo3() { -if (1 === 2) - -//comment preventing line merging -{ -var y = 76; -return y; -} - -} - } - } - -function foo(a:number, b:number):number -{ -return 0; -} - -function bar(a:number, b:number) :number[] { -return []; -} - -module BugFix3 { -declare var f: { - (): any; - (x: number): string; - foo: number; -}; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructsBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructsBaseline.ts deleted file mode 100644 index 929334e4730..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/typescriptConstructsBaseline.ts +++ /dev/null @@ -1,58 +0,0 @@ -module MyModule { - module A.B.C { - module F { - } - } - interface Blah { - boo: string; - } - - class Foo { - - } - - class Foo2 { - public foo(): number { - return 5 * 6; - } - public foo2() { - if (1 === 2) { - var y: number = 76; - return y; - } - - while (2 == 3) { - if (y == null) { - - } - } - } - - public foo3() { - if (1 === 2) - - //comment preventing line merging - { - var y = 76; - return y; - } - - } - } -} - -function foo(a: number, b: number): number { - return 0; -} - -function bar(a: number, b: number): number[] { - return []; -} - -module BugFix3 { - declare var f: { - (): any; - (x: number): string; - foo: number; - }; -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/various.ts b/src/harness/unittests/services/formatting/testCode/formatting/various.ts deleted file mode 100644 index bd814c2348e..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/various.ts +++ /dev/null @@ -1,17 +0,0 @@ -function f(a,b,c,d){ -for(var i=0;i<10;i++){ -var a=0; -var b=a+a+a*a%a/2-1; -b+=a; -++b; -f(a,b,c,d); -if(1===1){ -var m=function(e,f){ -return e^f; -} -} -} -} - -for (var i = 0 ; i < this.foo(); i++) { -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/variousBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/variousBaseline.ts deleted file mode 100644 index a4b5ceeb1c2..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/variousBaseline.ts +++ /dev/null @@ -1,17 +0,0 @@ -function f(a, b, c, d) { - for (var i = 0; i < 10; i++) { - var a = 0; - var b = a + a + a * a % a / 2 - 1; - b += a; - ++b; - f(a, b, c, d); - if (1 === 1) { - var m = function(e, f) { - return e ^ f; - } - } - } -} - -for (var i = 0 ; i < this.foo(); i++) { -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/formatting/withStatement.ts b/src/harness/unittests/services/formatting/testCode/formatting/withStatement.ts deleted file mode 100644 index 66ec4bf546f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/withStatement.ts +++ /dev/null @@ -1,9 +0,0 @@ -with (foo.bar) - - { - - } - -with (bar.blah) -{ -} diff --git a/src/harness/unittests/services/formatting/testCode/formatting/withStatementBaseline.ts b/src/harness/unittests/services/formatting/testCode/formatting/withStatementBaseline.ts deleted file mode 100644 index f81378d7f82..00000000000 --- a/src/harness/unittests/services/formatting/testCode/formatting/withStatementBaseline.ts +++ /dev/null @@ -1,6 +0,0 @@ -with (foo.bar) { - -} - -with (bar.blah) { -} diff --git a/tests/cases/fourslash_old/callOrderDependence.ts b/tests/cases/fourslash_old/callOrderDependence.ts deleted file mode 100644 index 3e7100068f2..00000000000 --- a/tests/cases/fourslash_old/callOrderDependence.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -/////**/ - -diagnostics.setEditValidation(IncrementalEditValidation.None); -edit.replace(0, 0, "function foo(bar) {\n b\n}\n"); -goTo.position(27); -FourSlash.currentTestState.getCompletionListAtCaret().entries - .forEach(entry => FourSlash.currentTestState.getCompletionEntryDetails(entry.name)); diff --git a/tests/cases/fourslash_old/chainedFunctionCallsErrorSpan.ts b/tests/cases/fourslash_old/chainedFunctionCallsErrorSpan.ts deleted file mode 100644 index e4a56c546b5..00000000000 --- a/tests/cases/fourslash_old/chainedFunctionCallsErrorSpan.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// - -////'foo'.replace('o', '3')./*1*/replace/*2*/('f', 5); - -verify.errorExistsBetweenMarkers('1', '2'); diff --git a/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts b/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts deleted file mode 100644 index 92d288dcb2a..00000000000 --- a/tests/cases/fourslash_old/completionListGenericConstraintsNames.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// - -////interface IBar { -////} -//// -////class BarWrapper { -//// private value: /*1*/; -//// public getValue(v: /*2*/T): /*3*/ { -//// } -////} -////function foo(p1: T, p2: /*21*/U) : /*22*/ { -//// var x : /*23*/ -////} -////class MethodTest { -//// public method(p1: T, p2: U, p3:/*31*/ M): Array { -//// return null; -//// } -////} - -goTo.eachMarker(() => { - verify.memberListContains("T"); - verify.memberListContains("U"); - verify.memberListContains("M"); - }); diff --git a/tests/cases/fourslash_old/completionListInTypedObjectLiterals.ts b/tests/cases/fourslash_old/completionListInTypedObjectLiterals.ts deleted file mode 100644 index ce9c34df645..00000000000 --- a/tests/cases/fourslash_old/completionListInTypedObjectLiterals.ts +++ /dev/null @@ -1,142 +0,0 @@ -/// - -////interface MyPoint { -//// x1: number; -//// y1: number; -////} -////var p1: MyPoint = { -//// /*1*/ -////}; -////var p2: MyPoint = { -//// /*2*/x1: 5, -//// /*3*/ -////}; -////var p3: MyPoint = { -//// x1: /*4*/ -////}; -////var p4: any = { -//// /*5*/ -////} -/////// Cast expressions -////var x = ({ -//// /*6*/x1: 0, -////}); -////// Call expression -////function bar(e: MyPoint) { } -////bar({ -//// /*7*/ -////}); -////// New Expression -////class bar2 { -//// constructor(e: MyPoint) { } -////} -//// -////new bar2({ -//// x1: 0, -//// /*8*/ -////}); -////interface Foo { -//// x: { a: number }; -////} -////var aaa: Foo; -////aaa = {/*9*/ -////aaa.x = { /*10*/ -////var bbb = { /*11*/ -////var bbb = { x: { /*12*/ -////var ccc: Foo = { func: () => ({ /*13*/ }) -////var ddd: Foo = { -//// -//// /*14*/ -////var p15: MyPoint = { -//// "x1": 5, -//// /*15*/ -////}; -////// return statements -////function foo(): MyPoint { -//// return { -//// /*16*/ }; -////} -////interface MyPointCreator { -//// create(): MyPoint; -////} -//// -////function getMyPointCreator(): MyPointCreator { -//// return { -//// create: () => { -//// return { -//// x1: 5, -//// /*17*/ -//// }; -//// }, -//// } -////} -//// var eee:Foo = { /*18*/ - -////interface Foo { -//// x: { a: number }; -////} -//// var fff:Foo = { x: { /*19*/ - -goTo.marker("1"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("2"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("3"); -verify.not.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("4"); -verify.not.memberListContains("x1"); -verify.not.memberListContains("y1"); - -goTo.marker("5"); -verify.completionListIsEmpty(); - -goTo.marker("6"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("7"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("8"); -verify.not.memberListContains("x1"); -verify.memberListContains("y1"); - -goTo.marker("11"); -verify.memberListContains("x"); -verify.memberListCount(1); - -goTo.marker("12"); -verify.memberListContains("a"); -verify.memberListCount(1); - -goTo.marker("13"); -verify.memberListCount(0); - -goTo.marker("14"); -verify.memberListContains("x"); -verify.memberListCount(1); - -goTo.marker("16"); -verify.memberListContains("x1"); -verify.memberListContains("y1"); -verify.memberListCount(2); - -goTo.marker("17"); -verify.not.memberListContains("x1"); -verify.memberListContains("y1"); -verify.memberListCount(1); - -goTo.marker("18"); -verify.memberListContains("x"); -verify.memberListCount(1); - -goTo.marker("19"); -verify.memberListContains("a"); -verify.memberListCount(1); \ No newline at end of file diff --git a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation.ts b/tests/cases/fourslash_old/constructorOverloadWithoutImplementation.ts deleted file mode 100644 index 79af7af77b4..00000000000 --- a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -////class C { -//// constructor(); -//// constructor(x); -//// /*1*/constructor/*2*/(x, y); -////} - -verify.errorExistsBetweenMarkers('1', '2'); \ No newline at end of file diff --git a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation2.ts b/tests/cases/fourslash_old/constructorOverloadWithoutImplementation2.ts deleted file mode 100644 index 22ec5dd79c9..00000000000 --- a/tests/cases/fourslash_old/constructorOverloadWithoutImplementation2.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -////class C { -//// constructor(); -//// constructor(x); -//// /*1*/foo/*2*/(x, y) { } -////} - -verify.errorExistsBetweenMarkers('1', '2'); \ No newline at end of file diff --git a/tests/cases/fourslash_old/exportEqualIncremental.ts b/tests/cases/fourslash_old/exportEqualIncremental.ts deleted file mode 100644 index ee6ed886a4f..00000000000 --- a/tests/cases/fourslash_old/exportEqualIncremental.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -////interface IPoint { -//// getDist(): number; -////} -////module Shapes { -//// export class Point implements /*1*/IPoint/*2*/ { -//// constructor (public x: number, public y: number) { } -//// getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } -//// static origin = new Point(0, 0); -//// } -////} -////var p: IPoint = new Shapes.Point(3, 4); -////var dist = p.getDist(); - -verify.numberOfErrorsInCurrentFile(0); -goTo.eof(); -edit.insertLine("export = Shapes"); -verify.numberOfErrorsInCurrentFile(1); -verify.errorExistsBetweenMarkers("1", "2"); diff --git a/tests/cases/fourslash_old/findReferences.ts b/tests/cases/fourslash_old/findReferences.ts deleted file mode 100644 index 71efcf1d145..00000000000 --- a/tests/cases/fourslash_old/findReferences.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -////class [|{| "name" : "className" |}foo|] { -//// constructor() { -//// } -//// public get [|{| "name" : "barMethodName" |}bar|]() { -//// return 0; -//// } -//// static [|{| "name" : "staticMethodName" |}method|]() { } -////} -////var n: [|{| "name" : "varTypeName" |}foo|] = new [|{| "name" : "ctorInvocation" |}foo|](); -////var x = n.[|{| "name" : "barMethodInvocation" |}bar|](); -////[|{| "name" : "classNameMethodInvocation" |}foo|].[|{| "name" : "staticMethodInvocation" |}method|](); - -var foo1: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "className")[0]; -var bar1: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "barMethodName")[0]; -var method1: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "staticMethodName")[0]; -var foo2: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "varTypeName")[0]; -var foo3: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "ctorInvocation")[0]; -var bar2: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "barMethodInvocation")[0]; -var foo4: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "classNameMethodInvocation")[0]; -var method2: FourSlashInterface.Range = test.ranges().filter((range)=> range.marker.data.name === "staticMethodInvocation")[0]; - -goTo.marker('className'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('barMethodName'); -verify.occurrencesAtPositionContains(bar1); -verify.occurrencesAtPositionContains(bar2); - -goTo.marker('staticMethodName'); -verify.occurrencesAtPositionContains(method1); -verify.occurrencesAtPositionContains(method2); - -goTo.marker('varTypeName'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('ctorInvocation'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('barMethodInvocation'); -verify.occurrencesAtPositionContains(bar1); -verify.occurrencesAtPositionContains(bar2); - -goTo.marker('classNameMethodInvocation'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); -verify.occurrencesAtPositionContains(foo4); - -goTo.marker('staticMethodInvocation'); -verify.occurrencesAtPositionContains(method1); -verify.occurrencesAtPositionContains(method2); \ No newline at end of file diff --git a/tests/cases/fourslash_old/findReferences1.ts b/tests/cases/fourslash_old/findReferences1.ts deleted file mode 100644 index 3d06cacee23..00000000000 --- a/tests/cases/fourslash_old/findReferences1.ts +++ /dev/null @@ -1,28 +0,0 @@ -/// - -//// interface I { -//// (): void; -//// } -//// -//// var i: I; -//// var [|{| "name" : "varName" |}o|]: Object; -//// [|{| "name" : "varName1" |}o|] = i; -//// i = [|{| "name" : "varName2" |}o|]; -//// -//// var a: { -//// (): void -//// } -//// [|{| "name" : "varName3" |}o|] = a; -//// a = [|{| "name" : "varName4" |}o|]; - -var varName: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName")[0]; -var varName1: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName1")[0]; -var varName2: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName2")[0]; -var varName3: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName3")[0]; -var varName4: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "varName4")[0]; - -goTo.marker('varName'); -verify.occurrencesAtPositionContains(varName1); -verify.occurrencesAtPositionContains(varName2); -verify.occurrencesAtPositionContains(varName3); -verify.occurrencesAtPositionContains(varName4); diff --git a/tests/cases/fourslash_old/findReferencesAliases1.ts b/tests/cases/fourslash_old/findReferencesAliases1.ts deleted file mode 100644 index 0bee382e2b3..00000000000 --- a/tests/cases/fourslash_old/findReferencesAliases1.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -////declare module mod { -//// class Customer { -//// constructor(name: string); -//// } -////} -////import [|{| "name" : "aliasName1" |}c|] = mod.Customer; -////[|{| "name" : "aliasName2" |}c|].prototype; - -var name1: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "aliasName1")[0]; -var name2: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "aliasName2")[0]; - -goTo.marker('aliasName1'); -verify.occurrencesAtPositionContains(name1); -verify.occurrencesAtPositionContains(name2); - -goTo.marker('aliasName2'); -verify.occurrencesAtPositionContains(name1); -verify.occurrencesAtPositionContains(name2); \ No newline at end of file diff --git a/tests/cases/fourslash_old/findReferencesModules1.ts b/tests/cases/fourslash_old/findReferencesModules1.ts deleted file mode 100644 index 5956bd36936..00000000000 --- a/tests/cases/fourslash_old/findReferencesModules1.ts +++ /dev/null @@ -1,27 +0,0 @@ -/// - -////module [|{| "name" : "moduleName1" |}foo|] { -//// export class Point { -//// constructor(public x: number, public y: number) { } -//// } -////} -////var p: [|{| "name" : "moduleName2" |}foo|].Point = new [|{| "name" : "moduleName3" |}foo|].Point(1, 1); - -var foo1: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "moduleName1")[0]; -var foo2: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "moduleName2")[0]; -var foo3: FourSlashInterface.Range = test.ranges().filter(range => range.marker.data.name === "moduleName3")[0]; - -goTo.marker('moduleName1'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); - -goTo.marker('moduleName2'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); - -goTo.marker('moduleName3'); -verify.occurrencesAtPositionContains(foo1); -verify.occurrencesAtPositionContains(foo2); -verify.occurrencesAtPositionContains(foo3); \ No newline at end of file diff --git a/tests/cases/fourslash_old/funduleDefinedInADifferentFile.ts b/tests/cases/fourslash_old/funduleDefinedInADifferentFile.ts deleted file mode 100644 index c605ca0077a..00000000000 --- a/tests/cases/fourslash_old/funduleDefinedInADifferentFile.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -////function E() { } -////module E { -//// export interface I {} -//// export var value = 1; -////} - -////var x: E.I; -////var y/**/ = E.value; -goTo.marker(); -verify.numberOfErrorsInCurrentFile(0); \ No newline at end of file diff --git a/tests/cases/fourslash_old/funduleDefinedInADifferentFile2.ts b/tests/cases/fourslash_old/funduleDefinedInADifferentFile2.ts deleted file mode 100644 index 5c7aff2bfcf..00000000000 --- a/tests/cases/fourslash_old/funduleDefinedInADifferentFile2.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// - -// @Filename: f1.ts -////declare module "q" { -//// export = Q; -////} -////declare function Q(value: T): void; -////declare module Q { -//// -//// interface Deferred { -//// // promise: Promise; -//// resolve(value: T): void; -//// reject(reason: any): void; -//// notify(value: any): void; -//// makeNodeResolver(): (reason: any, value: T) => void; -//// } -//// -////export function defer(): Deferred; -////} - -// @Filename: f2.ts -/////// -////import q = require('q'); -////Q.defer/**/(); - - -goTo.marker(); -verify.completionListContains('defer'); -verify.numberOfErrorsInCurrentFile(0); diff --git a/tests/cases/fourslash_old/genericIncrementalParse.ts b/tests/cases/fourslash_old/genericIncrementalParse.ts deleted file mode 100644 index 73c4c888b1a..00000000000 --- a/tests/cases/fourslash_old/genericIncrementalParse.ts +++ /dev/null @@ -1,30 +0,0 @@ -/// - - -//// class C { // it is error to reference T in constraint -//// constructor() { } -//// foo(a: T) { -//// } -//// } -//// -//// interface I1 { -//// a: number; -//// }; -//// -//// interface I2 { -//// a: number; -//// b: string; -//// } -//// -//// var x = new C< { a: number; }, { a: number; b: string; }>(); -//// var y = new C(); -//// /*1*/ - -verify.numberOfErrorsInCurrentFile(1); - -goTo.marker("1"); -edit.insert("var z = new C < I2"); -verify.numberOfErrorsInCurrentFile(2); - -edit.insert(",I1>()"); -verify.numberOfErrorsInCurrentFile(2); diff --git a/tests/cases/fourslash_old/genericStructuralTypeConstraint.ts b/tests/cases/fourslash_old/genericStructuralTypeConstraint.ts deleted file mode 100644 index 458aaaa580c..00000000000 --- a/tests/cases/fourslash_old/genericStructuralTypeConstraint.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// - - -//// class C { // it is error to reference T in constraint -//// constructor() { } -//// foo(a: T) { -//// } -//// } -//// -//// interface I1 { -//// a: string;/*1*/ -//// }; -//// -//// interface I2 { -//// a: number; -//// b: string; -//// } -//// -//// var x = new C< { a: number; }, { a: number; b: string; }>(); -//// var y = new C(); -//// var z = new C() -//// /*2*/ - -goTo.marker("2"); -edit.insertLine(""); -// y fails due to a: string in I1, z fails due to I1 not being assignment compatible to I2 -verify.numberOfErrorsInCurrentFile(3); - -goTo.marker("1"); -edit.backspace(10); -edit.insertLine(""); -verify.numberOfErrorsInCurrentFile(2); -// y should be OK now member a is gone, z fails due to I1 not being assignment compatible to I2 - -edit.insert("a: number;"); -// y should be OK with member a the correct type, z still fails due to I1 not being assignment compatible to I2 -verify.numberOfErrorsInCurrentFile(2); diff --git a/tests/cases/fourslash_old/getTypeOfUnresolvedGenericExtension.ts b/tests/cases/fourslash_old/getTypeOfUnresolvedGenericExtension.ts deleted file mode 100644 index 0faf4cbb959..00000000000 --- a/tests/cases/fourslash_old/getTypeOfUnresolvedGenericExtension.ts +++ /dev/null @@ -1,10 +0,0 @@ -/// - -//// class S18 extends S18< A[], { }[] > -//// { -//// } -//// (new S18(123))./**/S18 ; -//// - -goTo.marker(); -diagnostics.validateTypeAtCurrentPosition(); diff --git a/tests/cases/fourslash_old/overloadResolutionErrors.ts b/tests/cases/fourslash_old/overloadResolutionErrors.ts deleted file mode 100644 index ac3a4def8cf..00000000000 --- a/tests/cases/fourslash_old/overloadResolutionErrors.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// - -// Tests that the error spans are correct for a signature mismatch - -/////*1*/'foo'.replace('o', '3')./*2*/replace/*3*/('f', 5)/*4*/; -//// -/////*5*/('foo'.replace('o', '3')./*55*/replace/*6*/)/*65*/('f', 5); -////var foo = { -//// fun: () => false, -//// fun2: function () { return true; } -////}; -/////*7*/foo./*8*/fun/*9*/(1); -/////*10*/foo./*11*/fun2/*12*/(1); -//// -////module M { -//// export class C { -//// constructor(x: number) { } -//// public method(x: string); -//// public method(x: number); -//// public method(x) { } -//// } -////} -////var c: M.C = new /*13*/M./*14*/C/*15*/(""); -/////*16*/c./*17*/method/*18*/(c); -/////*19*/(c./*195*/method/*20*/)/*21*/(c); - - -verify.errorExistsBetweenMarkers('2', '3'); -verify.errorExistsBetweenMarkers('8', '9'); -verify.errorExistsBetweenMarkers('11', '12'); -verify.errorExistsBetweenMarkers('14', '15'); -verify.errorExistsBetweenMarkers('17', '18'); -verify.not.errorExistsBetweenMarkers('1', '2'); -verify.not.errorExistsBetweenMarkers('3', '4'); -verify.not.errorExistsBetweenMarkers('7', '8'); -verify.not.errorExistsBetweenMarkers('10', '11'); -verify.not.errorExistsBetweenMarkers('13', '14'); -verify.not.errorExistsBetweenMarkers('16', '17'); diff --git a/tests/cases/fourslash_old/thisRefGotoDef.ts b/tests/cases/fourslash_old/thisRefGotoDef.ts deleted file mode 100644 index ba16a6aa31c..00000000000 --- a/tests/cases/fourslash_old/thisRefGotoDef.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// class Greeter { -//// /*def*/element: HTMLElement; -//// span: HTMLElement; -//// timerToken: number; -//// constructor(element: HTMLElement) { -//// this.element/*ref*/ = element; -//// } -//// } - -verify.goToDefinition("ref", "def"); From 747a6fd4f55f4a13adfa321c161dd8632e0c2ac1 Mon Sep 17 00:00:00 2001 From: Soo Jae Hwang Date: Wed, 22 Mar 2017 09:17:00 +0900 Subject: [PATCH 153/207] Replace "tsc @args.txt" to "tsc --project tsconfig.json" --- lib/tsc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tsc.js b/lib/tsc.js index be8abfb4a0d..f7231fcafd8 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -53977,7 +53977,7 @@ var ts; var padding = makePadding(marginLength); output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); + output.push(padding + "tsc --project tsconfig.json" + ts.sys.newLine); output.push(ts.sys.newLine); output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); var optsList = ts.filter(ts.optionDeclarations.slice(), function (v) { return !v.experimental; }); From 5b739cf78ce901ae556c725221873801b45cd1a4 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Tue, 21 Mar 2017 22:54:06 -0700 Subject: [PATCH 154/207] respond to comments --- src/compiler/checker.ts | 118 +++++++++++++----- src/compiler/core.ts | 3 - src/compiler/transformers/es2017.ts | 2 +- src/compiler/transformers/esnext.ts | 4 +- src/compiler/transformers/ts.ts | 2 +- src/compiler/types.ts | 6 +- src/compiler/utilities.ts | 6 +- src/services/codefixes/fixAddMissingMember.ts | 2 +- .../fixClassIncorrectlyImplementsInterface.ts | 2 +- src/services/codefixes/helpers.ts | 40 +++--- ...assExtendAbstractMethodAnonymousClass.1.ts | 33 +++++ ...ClassImplementClassMemberAnonymousClass.ts | 20 +++ ...FixClassImplementClassPropertyTypeQuery.ts | 10 ++ 13 files changed, 180 insertions(+), 68 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bb5046a8d66..dabc5407e13 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -106,9 +106,9 @@ namespace ts { getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, - createTypeNode, - createIndexSignatureFromIndexInfo, - createSignatureParts, + typeToTypeNode, + indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2196,8 +2196,8 @@ namespace ts { return undefined; } - const constraint = createTypeNode(getConstraintFromTypeParameter(type), enclosingDeclaration); - const defaultParameter = createTypeNode(getDefaultFromTypeParameter(type), enclosingDeclaration); + const constraint = typeToTypeNode(getConstraintFromTypeParameter(type), enclosingDeclaration); + const defaultParameter = typeToTypeNode(getDefaultFromTypeParameter(type), enclosingDeclaration); const name = symbolToString(type.symbol); return createTypeParameterDeclaration(name, constraint, defaultParameter); @@ -2206,7 +2206,7 @@ namespace ts { function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: Node): ParameterDeclaration { const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; const parameterType = getTypeOfSymbol(parameterSymbol); - const parameterTypeNode = createTypeNode(parameterType, enclosingDeclaration); + const parameterTypeNode = typeToTypeNode(parameterType, enclosingDeclaration); // TODO: how should we clone members/modifiers? // TODO: check initializer accessibility correctly. const parameterNode = createParameter( @@ -2220,32 +2220,35 @@ namespace ts { return parameterNode; } - function createSignatureParts(signature: Signature, enclosingDeclaration: Node): SignatureParts { - return { - typeParameters: signature.typeParameters && signature.typeParameters.map(parameter => createTypeParameterDeclarationFromType(parameter,enclosingDeclaration)), - parameters: signature.parameters.map(parameter => createParameterDeclarationFromSymbol(parameter,enclosingDeclaration)), - type: createTypeNodeExceptAny(getReturnTypeOfSignature(signature)) - } + function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node): SignatureDeclaration { + const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => createTypeParameterDeclarationFromType(parameter, enclosingDeclaration)); + const parameters = signature.parameters.map(parameter => createParameterDeclarationFromSymbol(parameter, enclosingDeclaration)); + const type = createTypeNodeExceptAny(getReturnTypeOfSignature(signature)); + + return createSignatureDeclaration(kind, typeParameters, parameters, type); function createTypeNodeExceptAny(type: Type): TypeNode | undefined { - const typeNode = createTypeNode(type, enclosingDeclaration); + const typeNode = typeToTypeNode(type, enclosingDeclaration); return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; } } - function createTypeNode(type: Type, enclosingDeclaration: Node): TypeNode { - let undefinedArgumentIsError = true; + + // function typeToDisplayParts + + function typeToTypeNode(type: Type, enclosingDeclaration: Node, returnNodeOnError?: boolean): TypeNode { let encounteredError = false; let inObjectTypeLiteral = false; let checkAlias = true; let symbolStack: Symbol[] = undefined; const result = createTypeNodeWorker(type); - return encounteredError ? undefined: result; + // returnNodeOnError = true; // TODO: unset. + return encounteredError && !returnNodeOnError ? undefined: result; function createTypeNodeWorker(type: Type): TypeNode { if (!type) { - if (undefinedArgumentIsError) { encounteredError = true; } + encounteredError = true; return undefined; } @@ -2364,7 +2367,7 @@ namespace ts { const typeParameter = getTypeParameterFromMappedType(type); const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter, enclosingDeclaration); - const templateTypeNode = createTypeNode(getTemplateTypeFromMappedType(type), enclosingDeclaration); + const templateTypeNode = typeToTypeNode(getTemplateTypeFromMappedType(type), enclosingDeclaration); const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -2438,13 +2441,11 @@ namespace ts { if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { const signature = resolved.callSignatures[0]; - const signatureParts = createSignatureParts(signature, enclosingDeclaration); - return createSignatureDeclaration(SyntaxKind.FunctionType, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); + return signatureToSignatureDeclaration(signature, SyntaxKind.FunctionType, enclosingDeclaration); } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { const signature = resolved.constructSignatures[0]; - const signatureParts = createSignatureParts(signature, enclosingDeclaration); - return createSignatureDeclaration(SyntaxKind.ConstructorType, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); + return signatureToSignatureDeclaration(signature, SyntaxKind.ConstructorType, enclosingDeclaration); } } @@ -2520,18 +2521,16 @@ namespace ts { function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { const typeElements: TypeElement[] = []; for (const signature of resolvedType.callSignatures) { - const signatureParts = createSignatureParts(signature, enclosingDeclaration); - typeElements.push(createSignatureDeclaration(SyntaxKind.CallSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); + typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.CallSignature, enclosingDeclaration)); } for (const signature of resolvedType.constructSignatures) { - const signatureParts = createSignatureParts(signature, enclosingDeclaration); - typeElements.push(createSignatureDeclaration(SyntaxKind.ConstructSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); + typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.ConstructSignature, enclosingDeclaration)); } if (resolvedType.stringIndexInfo) { - typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration)); + typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration)); } if (resolvedType.numberIndexInfo) { - typeElements.push(createIndexSignatureFromIndexInfo(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration)); + typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration)); } const properties = resolvedType.properties; @@ -2550,8 +2549,8 @@ namespace ts { if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); for (const signature of signatures) { - const signatureParts = createSignatureParts(signature, enclosingDeclaration); - const methodDeclaration = createSignatureDeclaration(SyntaxKind.MethodSignature, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type, propertyName, optionalToken); + const methodDeclaration = signatureToSignatureDeclaration(signature, SyntaxKind.MethodSignature, enclosingDeclaration); + methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; typeElements.push(methodDeclaration); } @@ -2571,7 +2570,6 @@ namespace ts { function createNameFromSymbol(symbol: Symbol): EntityName; function createNameFromSymbol(symbol: Symbol): EntityName { let parentSymbol: Symbol; - symbol; enclosingDeclaration; let meaning: SymbolFlags; // Get qualified name if the symbol is not a type parameter @@ -2580,18 +2578,49 @@ namespace ts { const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; if (!isTypeParameter && enclosingDeclaration) { chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); + // TODO: check whether type pointed to by symbol requires type arguments to be printed. Debug.assert(chain && chain.length > 0); } else { chain = [symbol]; } + parentSymbol = undefined; const result = createEntityNameFromSymbolChain(chain, chain.length - 1); return result; function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { Debug.assert(chain && 0 <= index && index < chain.length); - const identifier = createIdentifier(getNameOfSymbol(chain[index])); + // const parentIndex = index - 1; + const symbol = chain[index]; + let typeParameterString = ""; + if(index > 0) { + // TODO: is the parentSymbol wrong? + const parentSymbol = chain[index - 1]; + let typeParameters: TypeParameter[]; + if(getCheckFlags(symbol) & CheckFlags.Instantiated) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); + } + else { + const targetSymbol = getTargetSymbol(parentSymbol); + if(targetSymbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeAlias)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + } + } + if(typeParameters && typeParameters.length > 0) { + encounteredError = true; + const writer = getSingleLineStringWriter(); + const displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, 0); + typeParameterString = writer.string(); + releaseStringWriter(writer); + + } + } + const symbolName = getNameOfSymbol(symbol); + const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName; + let identifier = createIdentifier(symbolNameWithTypeParameters); + return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -2628,10 +2657,31 @@ namespace ts { } } } + + function getNameOfSymbol(symbol: Symbol): string { + if (symbol.declarations && symbol.declarations.length) { + const declaration = symbol.declarations[0]; + if (declaration.name) { + return declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { + return declarationNameToString((declaration.parent).name); + } + encounteredError = true; + switch (declaration.kind) { + case SyntaxKind.ClassExpression: + return "(Anonymous class)"; + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return "(Anonymous function)"; + } + } + return symbol.name; + } } } - function createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration { + function indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration { const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); const name = getNameFromIndexInfo(indexInfo); @@ -2643,7 +2693,7 @@ namespace ts { /*questionToken*/ undefined, indexerTypeNode, /*initializer*/ undefined); - const typeNode = createTypeNode(indexInfo.type, enclosingDeclaration); + const typeNode = typeToTypeNode(indexInfo.type, enclosingDeclaration); return createIndexSignatureDeclaration( [indexingParameter], typeNode, diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 3f466e726dc..c380a39611d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1067,9 +1067,6 @@ namespace ts { /** Does nothing. */ export function noop(): void {} - /** Returns its first argument. */ - export function identity(x: X): X { return x; } - /** Throws an error because a function is not implemented. */ export function notImplemented(): never { throw new Error("Not implemented"); diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 9c7bcf5b2ae..088c57866d0 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -125,7 +125,7 @@ namespace ts { visitNodes(node.modifiers, visitor, isModifier), node.asteriskToken, node.name, - node.questionToken, + /*questionToken*/ undefined, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 2475e511196..83e84e6eab5 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -475,7 +475,7 @@ namespace ts { /*modifiers*/ undefined, node.dotDotDotToken, getGeneratedNameForNode(node), - node.questionToken, + /*questionToken*/ undefined, /*type*/ undefined, visitNode(node.initializer, visitor, isExpression) ); @@ -541,7 +541,7 @@ namespace ts { ? undefined : node.asteriskToken, visitNode(node.name, visitor, isPropertyName), - visitNode(node.questionToken, visitor, isToken), + visitNode(/*questionToken*/ undefined, visitor, isToken), /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index bbc588ee9fe..6dc643b9543 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2049,7 +2049,7 @@ namespace ts { visitNodes(node.modifiers, modifierVisitor, isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), - node.questionToken, + /*questionToken*/ undefined, /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2579ee2eaf3..5ccdd79f199 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2473,11 +2473,11 @@ namespace ts { getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - createTypeNode(type: Type, enclosingDeclaration: Node): TypeNode; + typeToTypeNode(type: Type, enclosingDeclaration: Node): TypeNode; /** Note that the resulting nodes cannot be checked. */ - createIndexSignatureFromIndexInfo(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration; /** Note that the resulting nodes cannot be checked. */ - createSignatureParts(signature: Signature, enclosingDeclaration: Node): SignatureParts; + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node): SignatureDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 47642291c2c..656b3c5db44 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -744,8 +744,8 @@ namespace ts { // // let a: A.B.C; // - // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or - // A.B.C is a type node. + // Calling isPartOfTypeNode would consider the qualified name A.B a type node. + // Only C and A.B.C are type nodes. if (SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= SyntaxKind.LastTypeNode) { return true; } @@ -3735,7 +3735,7 @@ namespace ts { * of a TypeNode. */ export function isTypeNode(node: Node): node is TypeNode { - return isTypeNodeKind(node.kind); + return node && isTypeNodeKind(node.kind) && (!node.parent || isPartOfTypeNode(node)); } // Binding patterns diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index a67c6791ba3..bf706e7deda 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -38,7 +38,7 @@ namespace ts.codefix { const checker = context.program.getTypeChecker(); const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); - typeNode = checker.createTypeNode(widenedType, classDeclaration) || typeNode; + typeNode = checker.typeToTypeNode(widenedType, classDeclaration) || typeNode; } const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); diff --git a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts index 365fd358011..3b1b99febb0 100644 --- a/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts +++ b/src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts @@ -53,7 +53,7 @@ namespace ts.codefix { if (!indexInfoOfKind) { return; } - const newIndexSignatureDeclaration = checker.createIndexSignatureFromIndexInfo(indexInfoOfKind, kind, classDeclaration); + const newIndexSignatureDeclaration = checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration); newNodes.push(newIndexSignatureDeclaration); } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 4a9ee25228f..3b4a75caa79 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -64,7 +64,7 @@ namespace ts.codefix { const declaration = declarations[0] as Declaration; const name = declaration.name ? getSynthesizedDeepClone(declaration.name) as PropertyName : undefined; const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); - const modifiers = visibilityModifier ? [visibilityModifier] : undefined; + const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined; const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); switch (declaration.kind) { @@ -72,7 +72,7 @@ namespace ts.codefix { case SyntaxKind.SetAccessor: case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: - const typeNode = checker.createTypeNode(type, enclosingDeclaration); + const typeNode = checker.typeToTypeNode(type, enclosingDeclaration); const property = createProperty( /*decorators*/undefined, modifiers, @@ -99,30 +99,32 @@ namespace ts.codefix { if (declarations.length === 1) { Debug.assert(signatures.length === 1); const signature = signatures[0]; - const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); - return createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type); + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration) as MethodDeclaration; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; + signatureDeclaration.body = createStubbedMethodBody(); + return signatureDeclaration; } let signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { const signature = signatures[i]; - const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); - signatureDeclarations.push(createMethod( - /*decorators*/ undefined, - modifiers, - /*asteriskToken*/ undefined, - name, - optional ? createToken(SyntaxKind.QuestionToken) : undefined, - signatureParts.typeParameters, - signatureParts.parameters, - signatureParts.type, - /*body*/undefined)); + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration) as MethodDeclaration; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; + signatureDeclarations.push(signatureDeclaration); } if (declarations.length > signatures.length) { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); - const signatureParts = checker.createSignatureParts(signature, enclosingDeclaration); - signatureDeclarations.push(createStubbedMethod(modifiers, name, optional, signatureParts.typeParameters, signatureParts.parameters, signatureParts.type)); + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration) as MethodDeclaration; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; + signatureDeclaration.body = createStubbedMethodBody(); + signatureDeclarations.push(signatureDeclaration); } else { Debug.assert(declarations.length === signatures.length); @@ -195,9 +197,9 @@ namespace ts.codefix { export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { return createMethod( - /*decorators*/undefined, + /*decorators*/ undefined, modifiers, - /*asteriskToken*/undefined, + /*asteriskToken*/ undefined, name, optional ? createToken(SyntaxKind.QuestionToken) : undefined, typeParameters, diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts new file mode 100644 index 00000000000..134ce173763 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts @@ -0,0 +1,33 @@ +/// + +class A { + foo() { + return class { x: number; } + } + bar() { + return new class { x: number; } + } +} +class B { + foo() { + return class { + x: X; + } + } +} + + +class D extends A { } + +verify.rangeAfterCodeFix(` + f(a: number, b: string): boolean; + f(a: number, b: string): this; + f(a: string, b: number): Function; + f(a: string): Function; + f(a: any, b?: any) { + throw new Error("Method not implemented."); + } + foo(): number { + throw new Error("Method not implemented."); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts b/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts new file mode 100644 index 00000000000..a8a024d194b --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts @@ -0,0 +1,20 @@ +/// + +//// class A { +//// foo() { +//// return class { x: number; } +//// } +//// bar() { +//// return new class { x: number; } +//// } +//// } +//// class C implements A {[| |]} + +verify.rangeAfterCodeFix(` + foo() { + throw new Error("Method not implemented."); + } + bar() { + throw new Error("Method not implemented."); + } +`); diff --git a/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts new file mode 100644 index 00000000000..4a5663a8ba8 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementClassPropertyTypeQuery.ts @@ -0,0 +1,10 @@ +/// + +//// class A { +//// A: typeof A; +//// } +//// class D implements A {[| |]} + +verify.rangeAfterCodeFix(` + A: typeof A; +`); From 1511dd9c241cf4f0f85fddaa2ebb5840ee27f16e Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 2 Mar 2017 17:43:02 +0100 Subject: [PATCH 155/207] Fix parent type of JsxAttributes --- src/compiler/types.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 759d3cd41eb..42b8a140e4b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1504,6 +1504,7 @@ namespace ts { export type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; export interface JsxAttributes extends ObjectLiteralExpressionBase { + parent?: JsxOpeningLikeElement; } /// The opening element of a ... JsxElement @@ -1523,7 +1524,7 @@ namespace ts { export interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; - parent?: JsxOpeningLikeElement; + parent?: JsxAttributes; name: Identifier; /// JSX attribute initializers are optional; is sugar for initializer?: StringLiteral | JsxExpression; @@ -1531,7 +1532,7 @@ namespace ts { export interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; - parent?: JsxOpeningLikeElement; + parent?: JsxAttributes; expression: Expression; } From 6e086980a4955d2b539d61ba00ddd40afa0e0413 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Mon, 20 Mar 2017 22:07:15 +0100 Subject: [PATCH 156/207] Also fix type of NewExpression#arguments --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 42b8a140e4b..6a42c57cd64 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1450,7 +1450,7 @@ namespace ts { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; - arguments: NodeArray; + arguments?: NodeArray; } export interface TaggedTemplateExpression extends MemberExpression { From fcca27c03eb11d45691433b9fcaf60d94e118f13 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Tue, 21 Mar 2017 20:21:43 +0100 Subject: [PATCH 157/207] Fix type of HeritageClause#types --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6a42c57cd64..ba383ed1bce 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1778,7 +1778,7 @@ namespace ts { kind: SyntaxKind.HeritageClause; parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; - types?: NodeArray; + types: NodeArray; } export interface TypeAliasDeclaration extends DeclarationStatement { From eb8972d5ff9eec8dc3ad9c29a8d4b57fb6d0533b Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Wed, 22 Mar 2017 15:28:51 +0100 Subject: [PATCH 158/207] Add parent types to class elements --- src/compiler/types.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ba383ed1bce..78425c9eac5 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -815,18 +815,21 @@ namespace ts { export interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { kind: SyntaxKind.Constructor; + parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; } // For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. export interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; + parent?: ClassDeclaration | ClassExpression; } // See the comment on MethodDeclaration for the intuition behind GetAccessorDeclaration being a // ClassElement and an ObjectLiteralElement. export interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.GetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } @@ -835,6 +838,7 @@ namespace ts { // ClassElement and an ObjectLiteralElement. export interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.SetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } @@ -843,6 +847,7 @@ namespace ts { export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; + parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } export interface TypeNode extends Node { @@ -937,6 +942,7 @@ namespace ts { export interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; + parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; From d906e91236c6363e22154ae5fa18f5b179b1f036 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 22 Mar 2017 12:01:08 -0700 Subject: [PATCH 159/207] Code review comments --- src/compiler/commandLineParser.ts | 58 +++++++++---------- src/compiler/diagnosticMessages.json | 30 +++++----- .../tsconfig.json | 14 ++--- .../tsconfig.json | 14 ++--- .../tsconfig.json | 14 ++--- .../tsconfig.json | 14 ++--- .../tsconfig.json | 14 ++--- .../tsconfig.json | 14 ++--- .../tsconfig.json | 14 ++--- .../tsconfig.json | 14 ++--- 10 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index bc9d090edd9..598906cb057 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -15,7 +15,7 @@ namespace ts { shortName: "h", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.CommandLine_Options, + category: Diagnostics.Command_line_Options, description: Diagnostics.Print_this_message, }, { @@ -27,7 +27,7 @@ namespace ts { name: "all", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.CommandLine_Options, + category: Diagnostics.Command_line_Options, description: Diagnostics.Show_all_compiler_options, }, { @@ -35,14 +35,14 @@ namespace ts { shortName: "v", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.CommandLine_Options, + category: Diagnostics.Command_line_Options, description: Diagnostics.Print_the_compiler_s_version, }, { name: "init", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.CommandLine_Options, + category: Diagnostics.Command_line_Options, description: Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { @@ -51,7 +51,7 @@ namespace ts { type: "string", isFilePath: true, showInSimplifiedHelpView: true, - category: Diagnostics.CommandLine_Options, + category: Diagnostics.Command_line_Options, paramType: Diagnostics.FILE_OR_DIRECTORY, description: Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, }, @@ -59,7 +59,7 @@ namespace ts { name: "pretty", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.CommandLine_Options, + category: Diagnostics.Command_line_Options, description: Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { @@ -67,7 +67,7 @@ namespace ts { shortName: "w", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.CommandLine_Options, + category: Diagnostics.Command_line_Options, description: Diagnostics.Watch_input_files, }, @@ -230,13 +230,13 @@ namespace ts { name: "downlevelIteration", type: "boolean", category: Diagnostics.Basic_Options, - description: Diagnostics.Use_full_down_level_iteration_for_iterables_and_arrays_for_for_of_spread_and_destructuring_in_ES5_Slash3 + description: Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, { name: "isolatedModules", type: "boolean", category: Diagnostics.Basic_Options, - description: Diagnostics.Unconditionally_emit_imports_for_unresolved_files + description: Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule }, // Strict Type Checks @@ -244,35 +244,35 @@ namespace ts { name: "strict", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Type_Checks, - description: Diagnostics.Enable_all_strict_type_checks + category: Diagnostics.Strict_Type_Checking_Options, + description: Diagnostics.Enable_all_strict_type_checking_options }, { name: "noImplicitAny", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Type_Checks, + category: Diagnostics.Strict_Type_Checking_Options, description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, }, { name: "strictNullChecks", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Type_Checks, + category: Diagnostics.Strict_Type_Checking_Options, description: Diagnostics.Enable_strict_null_checks }, { name: "noImplicitThis", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Type_Checks, + category: Diagnostics.Strict_Type_Checking_Options, description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, { name: "alwaysStrict", type: "boolean", showInSimplifiedHelpView: true, - category: Diagnostics.Strict_Type_Checks, + category: Diagnostics.Strict_Type_Checking_Options, description: Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, @@ -331,7 +331,7 @@ namespace ts { type: "object", isTSConfigOnly: true, category: Diagnostics.Module_Resolution_Options, - description: Diagnostics.List_of_path_mapping_entries_for_module_names_to_locations_relative_to_the_baseUrl + description: Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl }, { @@ -346,7 +346,7 @@ namespace ts { isFilePath: true }, category: Diagnostics.Module_Resolution_Options, - description: Diagnostics.List_of_root_folders_whose_combined_content_represent_the_structure_of_the_project_at_runtime + description: Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime }, { name: "typeRoots", @@ -383,7 +383,7 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.LOCATION, - category: Diagnostics.SourceMap_Options, + category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, }, { @@ -391,19 +391,19 @@ namespace ts { type: "string", isFilePath: true, paramType: Diagnostics.LOCATION, - category: Diagnostics.SourceMap_Options, + category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, }, { name: "inlineSourceMap", type: "boolean", - category: Diagnostics.SourceMap_Options, + category: Diagnostics.Source_Map_Options, description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", - category: Diagnostics.SourceMap_Options, + category: Diagnostics.Source_Map_Options, description: Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, @@ -438,7 +438,7 @@ namespace ts { name: "extendedDiagnostics", type: "boolean", category: Diagnostics.Advanced_Options, - description: Diagnostics.Show_extended_diagnostic_information + description: Diagnostics.Show_verbose_diagnostic_information }, { name: "traceResolution", @@ -496,7 +496,7 @@ namespace ts { name: "locale", type: "string", category: Diagnostics.Advanced_Options, - description: Diagnostics.The_locale_to_use_to_show_error_messages_e_g_en_us + description: Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us }, { name: "newLine", @@ -512,7 +512,7 @@ namespace ts { name: "noErrorTruncation", type: "boolean", category: Diagnostics.Advanced_Options, - description: Diagnostics.Do_not_truncation_error_messages + description: Diagnostics.Do_not_truncate_error_messages }, { name: "noLib", @@ -524,7 +524,7 @@ namespace ts { name: "noResolve", type: "boolean", category: Diagnostics.Advanced_Options, - description: Diagnostics.Do_not_add_triple_slash_references_or_module_import_targets_to_the_list_of_compiled_files + description: Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files }, { name: "stripInternal", @@ -536,7 +536,7 @@ namespace ts { name: "disableSizeLimit", type: "boolean", category: Diagnostics.Advanced_Options, - description: Diagnostics.Disable_size_limitation_on_JavaScript_project + description: Diagnostics.Disable_size_limitations_on_JavaScript_projects }, { name: "noImplicitUseStrict", @@ -621,7 +621,7 @@ namespace ts { name: "plugin", type: "object" }, - description: Diagnostics.List_of_Language_Service_plugins + description: Diagnostics.List_of_language_service_plugins } ]; @@ -932,7 +932,7 @@ namespace ts { if (hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - if (optionsNameMap.has(name) && optionsNameMap.get(name).category === Diagnostics.CommandLine_Options) { + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === Diagnostics.Command_line_Options) { continue; } const value = options[name]; @@ -987,7 +987,7 @@ namespace ts { function writeConfigurations() { // Filter applicable options to place in the file const categorizedOptions = reduceLeft( - filter(optionDeclarations, o => o.category !== Diagnostics.CommandLine_Options && o.category !== Diagnostics.Advanced_Options), + filter(optionDeclarations, o => o.category !== Diagnostics.Command_line_Options && o.category !== Diagnostics.Advanced_Options), (memo, value) => { if (value.category) { const name = getLocaleSpecificMessage(value.category); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b60f49076ef..92812604b8a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3045,7 +3045,7 @@ "category": "Message", "code": 6149 }, - "Show extended diagnostic information.": { + "Show verbose diagnostic information.": { "category": "Message", "code": 6150 }, @@ -3057,7 +3057,7 @@ "category": "Message", "code": 6152 }, - "Unconditionally emit imports for unresolved files.": { + "Transpile each file as a separate module (similar to 'ts.transpileModule').": { "category": "Message", "code": 6153 }, @@ -3069,11 +3069,11 @@ "category": "Message", "code": 6155 }, - "The locale to use to show error messages, e.g. 'en-us'.": { + "The locale used when displaying messages to the user (e.g. 'en-us')": { "category": "Message", "code": 6156 }, - "Do not generate custom helper functions like __extends in compiled output.": { + "Do not generate custom helper functions like '__extends' in compiled output.": { "category": "Message", "code": 6157 }, @@ -3081,7 +3081,7 @@ "category": "Message", "code": 6158 }, - "Do not add triple-slash references or module import targets to the list of compiled files.": { + "Do not add triple-slash references or imported modules to the list of compiled files.": { "category": "Message", "code": 6159 }, @@ -3093,7 +3093,7 @@ "category": "Message", "code": 6161 }, - "Disable size limitation on JavaScript project.": { + "Disable size limitations on JavaScript projects.": { "category": "Message", "code": 6162 }, @@ -3105,7 +3105,7 @@ "category": "Message", "code": 6164 }, - "Do not truncation error messages.": { + "Do not truncate error messages.": { "category": "Message", "code": 6165 }, @@ -3113,11 +3113,11 @@ "category": "Message", "code": 6166 }, - "List of path mapping entries for module names to locations relative to the 'baseUrl'.": { + "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'.": { "category": "Message", "code": 6167 }, - "List of root folders whose combined content represent the structure of the project at runtime.": { + "List of root folders whose combined content represents the structure of the project at runtime.": { "category": "Message", "code": 6168 }, @@ -3129,7 +3129,7 @@ "category": "Message", "code": 6170 }, - "CommandLine Options": { + "Command-line Options": { "category": "Message", "code": 6171 }, @@ -3137,7 +3137,7 @@ "category": "Message", "code": 6172 }, - "Strict Type Checks": { + "Strict Type-Checking Options": { "category": "Message", "code": 6173 }, @@ -3145,7 +3145,7 @@ "category": "Message", "code": 6174 }, - "SourceMap Options": { + "Source Map Options": { "category": "Message", "code": 6175 }, @@ -3161,15 +3161,15 @@ "category": "Message", "code": 6178 }, - "Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3.": { + "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'.": { "category": "Message", "code": 6179 }, - "Enable all strict type checks.": { + "Enable all strict type-checking options.": { "category": "Message", "code": 6180 }, - "List of Language Service plugins.": { + "List of language service plugins.": { "category": "Message", "code": 6181 }, diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index f26b471d2cb..5918c273ce5 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 2dc7f0564bf..38c4542b407 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true, /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 48a7fd7784e..d948b648153 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index a2f4e6bd992..70870f296e1 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 62bfc7ca265..3eabb0894f1 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index f26b471d2cb..5918c273ce5 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 02a1724add3..b88ac604c14 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index b1e048551d3..db838e21d2f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -14,11 +14,11 @@ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Use full down-level iteration for iterables and arrays for 'for-of', spread, and destructuring in ES5/3. */ - // "isolatedModules": true, /* Unconditionally emit imports for unresolved files. */ + // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ + // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type Checks */ - "strict": true, /* Enable all strict type checks. */ + /* Strict Type-Checking Options */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ @@ -33,13 +33,13 @@ /* Module Resolution Options */ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* List of path mapping entries for module names to locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represent the structure of the project at runtime. */ + // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - /* SourceMap Options */ + /* Source Map Options */ // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ From 88b88e10551be40c78b083b84f422f71ae125124 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 22 Mar 2017 12:41:11 -0700 Subject: [PATCH 160/207] Remove BOM --- src/compiler/commandLineParser.ts | 2 +- src/harness/unittests/initializeTSConfig.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 598906cb057..41d71c79ac3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1,4 +1,4 @@ -/// +/// /// /// /// diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts index 4f193d358f2..d0bc72d4307 100644 --- a/src/harness/unittests/initializeTSConfig.ts +++ b/src/harness/unittests/initializeTSConfig.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { From ae1983bce1a65ecb736c3ce752eb228a4e3227b9 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 22 Mar 2017 12:45:36 -0700 Subject: [PATCH 161/207] Show help if `--all` is specifided without `--help` --- src/compiler/tsc.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a62bad393ab..4fd3ecb02bb 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -225,7 +225,7 @@ namespace ts { return sys.exit(ExitStatus.Success); } - if (commandLine.options.help) { + if (commandLine.options.help || commandLine.options.all) { printVersion(); printHelp(commandLine.options.all); return sys.exit(ExitStatus.Success); From c4ddc5bffad8ab3609270a17ac6be40aaaa1ab7b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 22 Mar 2017 12:54:51 -0700 Subject: [PATCH 162/207] Respond to more comments --- src/compiler/checker.ts | 72 ++++++++++--------- src/compiler/factory.ts | 20 ++---- src/services/codefixes/fixAddMissingMember.ts | 4 +- src/services/codefixes/helpers.ts | 2 +- src/services/textChanges.ts | 6 +- 5 files changed, 50 insertions(+), 54 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dabc5407e13..c4eaed3fdef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2191,7 +2191,7 @@ namespace ts { return result; } - function createTypeParameterDeclarationFromType(type: TypeParameter, enclosingDeclaration: Node): TypeParameterDeclaration { + function typeParameterToDeclaration(type: TypeParameter, enclosingDeclaration?: Node): TypeParameterDeclaration { if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { return undefined; } @@ -2199,35 +2199,36 @@ namespace ts { const constraint = typeToTypeNode(getConstraintFromTypeParameter(type), enclosingDeclaration); const defaultParameter = typeToTypeNode(getDefaultFromTypeParameter(type), enclosingDeclaration); + // TODO: use method internal to typeToTypeNode. const name = symbolToString(type.symbol); return createTypeParameterDeclaration(name, constraint, defaultParameter); } - function createParameterDeclarationFromSymbol(parameterSymbol: Symbol, enclosingDeclaration: Node): ParameterDeclaration { + function symbolToParameterDeclaration(parameterSymbol: Symbol, enclosingDeclaration?: Node): ParameterDeclaration { const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; const parameterType = getTypeOfSymbol(parameterSymbol); const parameterTypeNode = typeToTypeNode(parameterType, enclosingDeclaration); // TODO: how should we clone members/modifiers? // TODO: check initializer accessibility correctly. const parameterNode = createParameter( - parameterDeclaration.decorators && parameterDeclaration.decorators.map(getSynthesizedDeepClone), - parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedDeepClone), + parameterDeclaration.decorators, + parameterDeclaration.modifiers, parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), - getSynthesizedDeepClone(parameterDeclaration.name), + parameterDeclaration.name, parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), parameterTypeNode, - parameterDeclaration.initializer && getSynthesizedDeepClone(parameterDeclaration.initializer)); + parameterDeclaration.initializer); return parameterNode; } - function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node): SignatureDeclaration { - const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => createTypeParameterDeclarationFromType(parameter, enclosingDeclaration)); - const parameters = signature.parameters.map(parameter => createParameterDeclarationFromSymbol(parameter, enclosingDeclaration)); - const type = createTypeNodeExceptAny(getReturnTypeOfSignature(signature)); + function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node): SignatureDeclaration { + const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, enclosingDeclaration)); + const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, enclosingDeclaration)); + const type = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); return createSignatureDeclaration(kind, typeParameters, parameters, type); - function createTypeNodeExceptAny(type: Type): TypeNode | undefined { + function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { const typeNode = typeToTypeNode(type, enclosingDeclaration); return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; } @@ -2236,17 +2237,17 @@ namespace ts { // function typeToDisplayParts - function typeToTypeNode(type: Type, enclosingDeclaration: Node, returnNodeOnError?: boolean): TypeNode { + function typeToTypeNode(type: Type, enclosingDeclaration?: Node, returnNodeOnError?: boolean): TypeNode { let encounteredError = false; let inObjectTypeLiteral = false; let checkAlias = true; let symbolStack: Symbol[] = undefined; - const result = createTypeNodeWorker(type); + const result = typeToTypeNodeWorker(type); // returnNodeOnError = true; // TODO: unset. return encounteredError && !returnNodeOnError ? undefined: result; - function createTypeNodeWorker(type: Type): TypeNode { + function typeToTypeNodeWorker(type: Type): TypeNode { if (!type) { encounteredError = true; return undefined; @@ -2308,7 +2309,7 @@ namespace ts { if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); - return createTypeReferenceNodeFromType(type); + return typeReferenceToTypeReferenceNode(type); } if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); @@ -2347,25 +2348,25 @@ namespace ts { if (type.flags & TypeFlags.Index) { const indexedType = (type).type; - const indexTypeNode = createTypeNodeWorker(indexedType); + const indexTypeNode = typeToTypeNodeWorker(indexedType); return createTypeOperatorNode(indexTypeNode); } if (type.flags & TypeFlags.IndexedAccess) { - const objectTypeNode = createTypeNodeWorker((type).objectType); - const indexTypeNode = createTypeNodeWorker((type).indexType); + const objectTypeNode = typeToTypeNodeWorker((type).objectType); + const indexTypeNode = typeToTypeNodeWorker((type).indexType); return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } Debug.fail("Should be unreachable."); function mapToTypeNodeArray(types: Type[]): NodeArray { - return types && asNodeArray(types.map(createTypeNodeWorker) as TypeNode[]); + return types && asNodeArray(types.map(typeToTypeNodeWorker) as TypeNode[]); } function createMappedTypeNodeFromType(type: MappedType) { Debug.assert(!!(type.flags & TypeFlags.Object)); const typeParameter = getTypeParameterFromMappedType(type); - const typeParameterNode = createTypeParameterDeclarationFromType(typeParameter, enclosingDeclaration); + const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration); const templateTypeNode = typeToTypeNode(getTemplateTypeFromMappedType(type), enclosingDeclaration); const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; @@ -2464,10 +2465,10 @@ namespace ts { } } - function createTypeReferenceNodeFromType(type: TypeReference) { + function typeReferenceToTypeReferenceNode(type: TypeReference) { const typeArguments: Type[] = type.typeArguments || emptyArray; if (type.target === globalArrayType) { - const elementType = createTypeNodeWorker(typeArguments[0]); + const elementType = typeToTypeNodeWorker(typeArguments[0]); return createArrayTypeNode(elementType); } else if (type.target.objectFlags & ObjectFlags.Tuple) { @@ -2489,21 +2490,20 @@ namespace ts { // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const name = createNameFromSymbol(parent); - const qualifiedNamePart = name; + const qualifiedNamePart = createNameFromSymbol(parent, /*mustBeIdentifier*/ true); if (!qualifiedName) { - qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/undefined); + qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); } else { Debug.assert(!qualifiedName.right); qualifiedName.right = qualifiedNamePart; - qualifiedName = createQualifiedName(qualifiedName, /*right*/undefined); + qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); } } } } let entityName: EntityName = undefined; - const nameIdentifier = createNameFromSymbol(type.symbol); + const nameIdentifier = createNameFromSymbol(type.symbol, /*mustBeIdentifier*/ true); if (qualifiedName) { Debug.assert(!qualifiedName.right); qualifiedName.right = nameIdentifier; @@ -2544,7 +2544,7 @@ namespace ts { if (!oldDeclaration) { return; } - const propertyName = getSynthesizedDeepClone(oldDeclaration.name); + const propertyName = oldDeclaration.name; const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;; if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); @@ -2559,16 +2559,16 @@ namespace ts { typeElements.push(createPropertySignature( propertyName, optionalToken, - createTypeNodeWorker(propertyType), + typeToTypeNodeWorker(propertyType), /*initializer*/undefined)); } } return typeElements.length ? typeElements : undefined; } - function createNameFromSymbol(symbol: Symbol): Identifier; - function createNameFromSymbol(symbol: Symbol): EntityName; - function createNameFromSymbol(symbol: Symbol): EntityName { + function createNameFromSymbol(symbol: Symbol, mustBeIdentifier: true): Identifier; + function createNameFromSymbol(symbol: Symbol, mustBeIdentifier?: false): EntityName; + function createNameFromSymbol(symbol: Symbol, mustBeIdentifier: boolean | undefined): EntityName { let parentSymbol: Symbol; let meaning: SymbolFlags; @@ -2586,8 +2586,12 @@ namespace ts { } parentSymbol = undefined; - const result = createEntityNameFromSymbolChain(chain, chain.length - 1); - return result; + if(mustBeIdentifier && chain.length !== 1) { + encounteredError = true; + // TODO: failing to get an identifier when we expect one generates an unprintable node. + // Should error handling be more severe? + } + return createEntityNameFromSymbolChain(chain, chain.length - 1); function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { Debug.assert(chain && 0 <= index && index < chain.length); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index e60ed0009e5..0ae42459709 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -67,15 +67,6 @@ namespace ts { return clone; } - /* @internal */ - export function getSynthesizedDeepClone(node: T | undefined): T { - if (node === undefined) { - return undefined; - } - const clone = visitEachChild(node, getSynthesizedDeepClone, nullTransformationContext); - return clone === node ? getSynthesizedClone(node) : clone; - } - // Literals export function createLiteral(value: string): StringLiteral; @@ -227,9 +218,7 @@ namespace ts { // Type Elements - export function createConstructSignature() { - throw new Error("not implemented."); - } + // TODO: add signatures // Types @@ -251,7 +240,7 @@ namespace ts { export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: NodeArray | undefined) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; - typeReference.typeName = isQualifiedName(typeName) ? typeName : asName(typeName); + typeReference.typeName = asName(typeName); typeReference.typeArguments = typeArguments; return typeReference; } @@ -388,7 +377,7 @@ namespace ts { : node; } - // TODO: ask if we should have multiple implementations. Some T's can't have question token. + // TODO: Split according to AST nodes. export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): T; export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): T; export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name?: string | PropertyName, questionToken?: QuestionToken): T { @@ -2030,7 +2019,8 @@ namespace ts { function asName(name: string | Identifier): Identifier; function asName(name: string | BindingName): BindingName; function asName(name: string | PropertyName): PropertyName; - function asName(name: string | Identifier | BindingName | PropertyName) { + function asName(name: string | EntityName): EntityName; + function asName(name: string | Identifier | BindingName | PropertyName | QualifiedName) { return typeof name === "string" ? createIdentifier(name) : name; } diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index bf706e7deda..4ef9fce0672 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -31,7 +31,7 @@ namespace ts.codefix { return undefined; } - let typeNode: TypeNode = createKeywordTypeNode(SyntaxKind.AnyKeyword); + let typeNode: TypeNode; if (token.parent.parent.kind === SyntaxKind.BinaryExpression) { const binaryExpression = token.parent.parent as BinaryExpression; @@ -41,6 +41,8 @@ namespace ts.codefix { typeNode = checker.typeToTypeNode(widenedType, classDeclaration) || typeNode; } + typeNode = typeNode ? typeNode : createKeywordTypeNode(SyntaxKind.AnyKeyword); + const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile); const property = createProperty( diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 3b4a75caa79..b3635f89f6a 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -62,7 +62,7 @@ namespace ts.codefix { } const declaration = declarations[0] as Declaration; - const name = declaration.name ? getSynthesizedDeepClone(declaration.name) as PropertyName : undefined; + const name = declaration.name; const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined; const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index ddcbf2fa2f5..cc304c0751a 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -275,8 +275,8 @@ namespace ts.textChanges { /** * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, - * i.e. arguments in arguments lists, parameters in parameter lists etc. Statements or class elements are different in sense that - * for them separators are treated as the part of the node. + * i.e. arguments in arguments lists, parameters in parameter lists etc. + * Separators are treated as part of the node for statements and class elements. */ public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); @@ -484,7 +484,7 @@ namespace ts.textChanges { private static normalize(changes: Change[]) { // order changes by start position const normalized = stableSort(changes, (a, b) => a.range.pos - b.range.pos); - // verify that end position of the change is less than start position of the next change + // verify that change intervals to not overlap, except possible at end points. for (let i = 0; i < normalized.length - 2; i++) { Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); } From 11d1409f5fd07bd90e64e6128ef90171d2a5b099 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 22 Mar 2017 13:01:53 -0700 Subject: [PATCH 163/207] Format else clauses --- Jakefile.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index fa5aa141d60..fa4869c1921 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -29,7 +29,8 @@ var thirdParty = "ThirdPartyNoticeText.txt"; var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; if (process.env.path !== undefined) { process.env.path = nodeModulesPathPrefix + process.env.path; -} else if (process.env.PATH !== undefined) { +} +else if (process.env.PATH !== undefined) { process.env.PATH = nodeModulesPathPrefix + process.env.PATH; } @@ -312,13 +313,15 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts if (useDebugMode) { if (opts.inlineSourceMap) { options += " --inlineSourceMap --inlineSources"; - } else { + } + else { options += " -sourcemap"; if (!opts.noMapRoot) { options += " -mapRoot file:///" + path.resolve(path.dirname(outFile)); } } - } else { + } + else { options += " --newLine LF"; } @@ -748,7 +751,8 @@ function exec(cmd, completeHandler, errorHandler) { ex.addListener("error", function (e, status) { if (errorHandler) { errorHandler(e, status); - } else { + } + else { fail("Process exited with code " + status); } }); @@ -1021,7 +1025,8 @@ function acceptBaseline(sourceFolder, targetFolder) { if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { filename = filename.substr(0, filename.length - deleteEnding.length); fs.unlinkSync(path.join(targetFolder, filename)); - } else { + } + else { var target = path.join(targetFolder, filename); if (fs.existsSync(target)) { fs.unlinkSync(target); From 2958649a9594641fe6d59f8342888372871405fa Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 22 Mar 2017 14:33:49 -0700 Subject: [PATCH 164/207] Enum and enum literal --- src/compiler/checker.ts | 6 ++++-- .../codeFixClassImplementInterfacePropertyEnum.ts | 13 +++++++++++++ ...FixClassImplementInterfacePropertyEnumLiteral.ts | 13 +++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnum.ts create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c4eaed3fdef..2790d03934d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2266,7 +2266,8 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.BooleanKeyword); } if (type.flags & TypeFlags.Enum) { - throw new Error ("enums not implemented") + const name = createNameFromSymbol(type.symbol); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (type.flags & (TypeFlags.StringLiteral)) { return createLiteralTypeNode((createLiteral((type).text))); @@ -2278,7 +2279,8 @@ namespace ts { return (type).intrinsicName === "true" ? createTrue() : createFalse(); } if (type.flags & TypeFlags.EnumLiteral) { - throw new Error("enum literal not implemented"); + const name = createNameFromSymbol(type.symbol); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (type.flags & TypeFlags.Void) { return createKeywordTypeNode(SyntaxKind.VoidKeyword); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnum.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnum.ts new file mode 100644 index 00000000000..8b04e4a4b45 --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnum.ts @@ -0,0 +1,13 @@ +/// + +// @lib: es2017 + +//// enum E { a,b,c } +//// interface I { +//// a: E; +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + a: E; +`); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts new file mode 100644 index 00000000000..720acc1cccf --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts @@ -0,0 +1,13 @@ +/// + +// @lib: es2017 + +//// enum E { a,b,c } +//// interface I { +//// a: E.a +//// } +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` + a: E.a; +`); \ No newline at end of file From 43e01f282b5172152a9b9c3cac2c5b058fa94a8e Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 22 Mar 2017 14:50:01 -0700 Subject: [PATCH 165/207] remove trivia --- src/compiler/checker.ts | 4 +-- src/services/codefixes/helpers.ts | 11 ++++++- ...assExtendAbstractMethodAnonymousClass.1.ts | 33 ------------------- .../codeFixClassImplementInterfaceComments.ts | 25 ++++++++++---- 4 files changed, 31 insertions(+), 42 deletions(-) delete mode 100644 tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2790d03934d..b681d1298d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2208,13 +2208,13 @@ namespace ts { const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; const parameterType = getTypeOfSymbol(parameterSymbol); const parameterTypeNode = typeToTypeNode(parameterType, enclosingDeclaration); - // TODO: how should we clone members/modifiers? // TODO: check initializer accessibility correctly. const parameterNode = createParameter( parameterDeclaration.decorators, parameterDeclaration.modifiers, parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), - parameterDeclaration.name, + // Clone name to remove trivia. + getSynthesizedClone(parameterDeclaration.name), parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), parameterTypeNode, parameterDeclaration.initializer); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index b3635f89f6a..da729215087 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -62,7 +62,8 @@ namespace ts.codefix { } const declaration = declarations[0] as Declaration; - const name = declaration.name; + // Clone name to remove leading trivia. + const name = getSynthesizedClone(declaration.name); const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined; const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); @@ -227,4 +228,12 @@ namespace ts.codefix { } return undefined; } + + function stripComments(node: Node): Node { + if(node === undefined) { + return node; + } + const strippedChildren = visitEachChild(node, stripComments, nullTransformationContext); + return strippedChildren === node ? getSynthesizedClone(strippedChildren) : strippedChildren; + } } \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts b/tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts deleted file mode 100644 index 134ce173763..00000000000 --- a/tests/cases/fourslash/codeFixClassExtendAbstractMethodAnonymousClass.1.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// - -class A { - foo() { - return class { x: number; } - } - bar() { - return new class { x: number; } - } -} -class B { - foo() { - return class { - x: X; - } - } -} - - -class D extends A { } - -verify.rangeAfterCodeFix(` - f(a: number, b: string): boolean; - f(a: number, b: string): this; - f(a: string, b: number): Function; - f(a: string): Function; - f(a: any, b?: any) { - throw new Error("Method not implemented."); - } - foo(): number { - throw new Error("Method not implemented."); - } -`); diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts index 56d56a5a504..f082074f16c 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceComments.ts @@ -2,13 +2,26 @@ // @lib: es2017 -//// /** interface prefix */ -//// interface /**interface name prefix */ I /**open-brace prefix*/{ -//// /** property prefix*/ x /**colon prefix*/: /**number prefix*/ number; -//// +//// namespace N { +//// /**enum prefix */ +//// export enum /**enum identifier prefix */ E /**open-brace prefix*/ { +//// /* literal prefix */ a /** comma prefix */, +//// /* literal prefix */ b /** comma prefix */, +//// /* literal prefix */ c +//// /** close brace prefix */ } +//// /** interface prefix */ +//// export interface /**interface name prefix */ I /**open-brace prefix*/ { +//// /** property prefix */ a /** colon prefix */: /** enum literal prefix 1*/ E /** dot prefix */. /** enum literal prefix 2*/a; +//// /** property prefix */ b /** colon prefix */: /** enum prefix */ E; +//// /**method signature prefix */foo /**open angle prefix */< /**type parameter name prefix */ X /** closing angle prefix */> /**open paren prefix */(/** parameter prefix */ a/** colon prefix */: /** parameter type prefix */ X /** close paren prefix */) /** colon prefix */: /** return type prefix */ string /** semicolon prefix */; +//// /**close-brace prefix*/ } //// /**close-brace prefix*/ } -//// class C implements I {[| |]} +//// class C implements N.I {[| |]} verify.rangeAfterCodeFix(` - x: number; + a: N.E.a; + b: N.E; + foo(a: X): string { + throw new Error("Method not implemented."); + } `); From db6c96967cb856c6eeadae5b87ca34178664aca2 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Wed, 22 Mar 2017 16:23:21 -0700 Subject: [PATCH 166/207] Change ingore diagonstic comment to `// @ts-ignore` --- src/compiler/core.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/program.ts | 10 +++++----- src/harness/fourslash.ts | 2 +- src/services/codefixes/disableJsDiagnostics.ts | 16 ++++++++-------- src/services/codefixes/fixAddMissingMember.ts | 2 +- .../checkJsFiles_skipDiagnostics.symbols | 10 +++++----- .../reference/checkJsFiles_skipDiagnostics.types | 10 +++++----- .../Default initialized TSConfig/tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../compiler/checkJsFiles_skipDiagnostics.ts | 10 +++++----- .../codeFixDisableJsDiagnosticsInFile3.ts | 2 +- .../codeFixDisableJsDiagnosticsInFile4.ts | 2 +- .../codeFixDisableJsDiagnosticsInFile5.ts | 2 +- .../codeFixDisableJsDiagnosticsInFile6.ts | 2 +- .../codeFixDisableJsDiagnosticsInFile7.ts | 2 +- .../codeFixDisableJsDiagnosticsInFile8.ts | 2 +- 23 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 14aeb35dc89..a56f1004d28 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1,4 +1,4 @@ -/// +/// /// namespace ts { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 0aed8bf2be1..983e128ec7f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3484,7 +3484,7 @@ "category": "Message", "code": 90018 }, - "Suppress this error message.": { + "Ignore this error message.": { "category": "Message", "code": 90019 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b4b93c0d21b..31fc665649a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1,10 +1,10 @@ -/// +/// /// /// namespace ts { const emptyArray: any[] = []; - const suppressDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-suppress)?)/; + const ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string { while (true) { @@ -926,7 +926,7 @@ namespace ts { } /** - * Skip errors if previous line start with '// @ts-suppress' comment, not counting non-empty non-comment lines + * Skip errors if previous line start with '// @ts-ignore' comment, not counting non-empty non-comment lines */ function shouldReportDiagnostic(diagnostic: Diagnostic) { const { file, start } = diagnostic; @@ -934,13 +934,13 @@ namespace ts { let { line } = computeLineAndCharacterOfPosition(lineStarts, start); while (line > 0) { const previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); - const result = suppressDiagnosticCommentRegEx.exec(previousLineText); + const result = ignoreDiagnosticCommentRegEx.exec(previousLineText); if (!result) { // non-empty line return true; } if (result[3]) { - // @ts-suppress + // @ts-ignore return false; } line--; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 0285cdc51fe..aa07407b0f2 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1,4 +1,4 @@ -// +// // Copyright (c) Microsoft Corporation. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/services/codefixes/disableJsDiagnostics.ts b/src/services/codefixes/disableJsDiagnostics.ts index 621555cf84b..7fa5c5bf23f 100644 --- a/src/services/codefixes/disableJsDiagnostics.ts +++ b/src/services/codefixes/disableJsDiagnostics.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { registerCodeFix({ errorCodes: getApplicableDiagnosticCodes(), @@ -12,12 +12,12 @@ namespace ts.codefix { .map(d => allDiagnostcs[d].code); } - function getSuppressCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) { - let { line } = getLineAndCharacterOfPosition(sourceFile, position); + function getIgnoreCommentLocationForLocation(sourceFile: SourceFile, position: number, newLineCharacter: string) { + const { line } = getLineAndCharacterOfPosition(sourceFile, position); const lineStartPosition = getStartPositionOfLine(line, sourceFile); const startPosition = getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); - // First try to see if we can put the '// @ts-suppress' on the previous line. + // First try to see if we can put the '// @ts-ignore' on the previous line. // We need to make sure that we are not in the middle of a string literal or a comment. // We also want to check if the previous line holds a comment for a node on the next line // if so, we do not want to separate the node from its comment if we can. @@ -27,7 +27,7 @@ namespace ts.codefix { if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { return { span: { start: startPosition, length: 0 }, - newText: `// @ts-suppress${newLineCharacter}` + newText: `// @ts-ignore${newLineCharacter}` }; } } @@ -35,7 +35,7 @@ namespace ts.codefix { // If all fails, add an extra new line immediatlly before the error span. return { span: { start: position, length: 0 }, - newText: `${position === startPosition ? "" : newLineCharacter}// @ts-suppress${newLineCharacter}` + newText: `${position === startPosition ? "" : newLineCharacter}// @ts-ignore${newLineCharacter}` }; } @@ -47,10 +47,10 @@ namespace ts.codefix { } return [{ - description: getLocaleSpecificMessage(Diagnostics.Suppress_this_error_message), + description: getLocaleSpecificMessage(Diagnostics.Ignore_this_error_message), changes: [{ fileName: sourceFile.fileName, - textChanges: [getSuppressCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] + textChanges: [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] }] }, { diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 765ffa818b6..1934de11f35 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ namespace ts.codefix { registerCodeFix({ errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code], diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols index a0f2200048f..eb2afaf4361 100644 --- a/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.symbols @@ -4,15 +4,15 @@ var x = 0; >x : Symbol(x, Decl(a.js, 1, 3)) -/// @ts-suppress +/// @ts-ignore x(); >x : Symbol(x, Decl(a.js, 1, 3)) -/// @ts-suppress +/// @ts-ignore x(); >x : Symbol(x, Decl(a.js, 1, 3)) -/// @ts-suppress +/// @ts-ignore x( >x : Symbol(x, Decl(a.js, 1, 3)) @@ -21,7 +21,7 @@ x( -// @ts-suppress +// @ts-ignore // come comment // some other comment @@ -32,7 +32,7 @@ x(); -// @ts-suppress: no call signature +// @ts-ignore: no call signature x(); >x : Symbol(x, Decl(a.js, 1, 3)) diff --git a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types index 69105a3112a..aa24f1f0541 100644 --- a/tests/baselines/reference/checkJsFiles_skipDiagnostics.types +++ b/tests/baselines/reference/checkJsFiles_skipDiagnostics.types @@ -5,17 +5,17 @@ var x = 0; >0 : 0 -/// @ts-suppress +/// @ts-ignore x(); >x() : any >x : number -/// @ts-suppress +/// @ts-ignore x(); >x() : any >x : number -/// @ts-suppress +/// @ts-ignore x( >x( 2, 3) : any >x : number @@ -28,7 +28,7 @@ x( -// @ts-suppress +// @ts-ignore // come comment // some other comment @@ -40,7 +40,7 @@ x(); -// @ts-suppress: no call signature +// @ts-ignore: no call signature x(); >x() : any >x : number diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 5918c273ce5..97f59dea8ea 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 38c4542b407..b90e3fc6c58 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index d948b648153..482cfa6a9d5 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ "jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 70870f296e1..c6a26629dab 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 3eabb0894f1..72289dd1787 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 5918c273ce5..97f59dea8ea 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index b88ac604c14..1ac7c8c54da 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index db838e21d2f..33a9ecc5cd4 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", /* Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'. */ // "lib": [], /* Specify library files to be included in the compilation: */ // "allowJs": true, /* Allow javascript files to be compiled. */ + // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "declaration": true, /* Generates corresponding '.d.ts' file. */ // "sourceMap": true, /* Generates corresponding '.map' file. */ diff --git a/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts index bcbcc815e7c..48364c6a592 100644 --- a/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts +++ b/tests/cases/compiler/checkJsFiles_skipDiagnostics.ts @@ -6,20 +6,20 @@ var x = 0; -/// @ts-suppress +/// @ts-ignore x(); -/// @ts-suppress +/// @ts-ignore x(); -/// @ts-suppress +/// @ts-ignore x( 2, 3); -// @ts-suppress +// @ts-ignore // come comment // some other comment @@ -29,5 +29,5 @@ x(); -// @ts-suppress: no call signature +// @ts-ignore: no call signature x(); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts index f486a7e171b..5cace444859 100644 --- a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile3.ts @@ -10,5 +10,5 @@ // Disable checking for next line verify.rangeAfterCodeFix(`var x = ""; -// @ts-suppress +// @ts-ignore x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts index cadbda2c273..1319325a3d2 100644 --- a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile4.ts @@ -13,6 +13,6 @@ // Disable checking for next line verify.rangeAfterCodeFix(`"test \\ "; -// @ts-suppress +// @ts-ignore x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts index 56b9fbf20d9..3a4b619a7fa 100644 --- a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile5.ts @@ -12,6 +12,6 @@ // Disable checking for next line verify.rangeAfterCodeFix(`/** comment */ -// @ts-suppress +// @ts-ignore x = 1;`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts index a0497b4deb9..5b93f4953d1 100644 --- a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile6.ts @@ -12,6 +12,6 @@ ////} // Disable checking for next line -verify.rangeAfterCodeFix(`// @ts-suppress +verify.rangeAfterCodeFix(`// @ts-ignore f(x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts index ad8377e129d..767fa984304 100644 --- a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile7.ts @@ -12,6 +12,6 @@ ////} // Disable checking for next line -verify.rangeAfterCodeFix(`// @ts-suppress +verify.rangeAfterCodeFix(`// @ts-ignore x();`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); diff --git a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts index 8ec350479af..3df5864f198 100644 --- a/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts +++ b/tests/cases/fourslash/codeFixDisableJsDiagnosticsInFile8.ts @@ -14,6 +14,6 @@ // Disable checking for next line verify.rangeAfterCodeFix(`f( - // @ts-suppress + // @ts-ignore x());`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); From abd14ef18586c91c1d08c7fd87e0a82b4746e9fc Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Wed, 22 Mar 2017 19:10:56 -0700 Subject: [PATCH 167/207] temp --- src/compiler/checker.ts | 955 +++++++++++++++++++++------------------- src/compiler/types.ts | 20 +- 2 files changed, 510 insertions(+), 465 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b681d1298d2..e004a0ca390 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -61,6 +61,7 @@ namespace ts { const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; const emitResolver = createResolver(); + let nodeBuilderCache: NodeBuilder | undefined; const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined"); undefinedSymbol.declarations = []; @@ -106,9 +107,9 @@ namespace ts { getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, - typeToTypeNode, - indexInfoToIndexSignatureDeclaration, - signatureToSignatureDeclaration, + typeToTypeNode: getNodeBuilder().typeToTypeNode, + indexInfoToIndexSignatureDeclaration: getNodeBuilder().indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: getNodeBuilder().signatureToSignatureDeclaration, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2191,476 +2192,526 @@ namespace ts { return result; } - function typeParameterToDeclaration(type: TypeParameter, enclosingDeclaration?: Node): TypeParameterDeclaration { - if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { - return undefined; + function unwrapNodeBuilderResult(result: NodeBuilderResult, returnValueOnError: boolean): T | undefined { + return !result.error || returnValueOnError ? result.value : undefined; + } + + function getNodeBuilder(): NodeBuilder { + if (nodeBuilderCache) { + return nodeBuilderCache; } - const constraint = typeToTypeNode(getConstraintFromTypeParameter(type), enclosingDeclaration); - const defaultParameter = typeToTypeNode(getDefaultFromTypeParameter(type), enclosingDeclaration); - - // TODO: use method internal to typeToTypeNode. - const name = symbolToString(type.symbol); - return createTypeParameterDeclaration(name, constraint, defaultParameter); - } - - function symbolToParameterDeclaration(parameterSymbol: Symbol, enclosingDeclaration?: Node): ParameterDeclaration { - const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; - const parameterType = getTypeOfSymbol(parameterSymbol); - const parameterTypeNode = typeToTypeNode(parameterType, enclosingDeclaration); - // TODO: check initializer accessibility correctly. - const parameterNode = createParameter( - parameterDeclaration.decorators, - parameterDeclaration.modifiers, - parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), - // Clone name to remove trivia. - getSynthesizedClone(parameterDeclaration.name), - parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), - parameterTypeNode, - parameterDeclaration.initializer); - return parameterNode; - } - - function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node): SignatureDeclaration { - const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, enclosingDeclaration)); - const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, enclosingDeclaration)); - const type = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); - - return createSignatureDeclaration(kind, typeParameters, parameters, type); - - function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { - const typeNode = typeToTypeNode(type, enclosingDeclaration); - return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; - } - } - - - // function typeToDisplayParts - - function typeToTypeNode(type: Type, enclosingDeclaration?: Node, returnNodeOnError?: boolean): TypeNode { let encounteredError = false; - let inObjectTypeLiteral = false; - let checkAlias = true; - let symbolStack: Symbol[] = undefined; + nodeBuilderCache = { + typeToTypeNode, + indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration + } - const result = typeToTypeNodeWorker(type); - // returnNodeOnError = true; // TODO: unset. - return encounteredError && !returnNodeOnError ? undefined: result; + return nodeBuilderCache; - function typeToTypeNodeWorker(type: Type): TypeNode { - if (!type) { - encounteredError = true; + function typeToTypeNode(type: Type, enclosingDeclaration?: Node, emitNodeOnError?: boolean): NodeBuilderResult { + let toNodeEncounteredErrorCache = encounteredError; + encounteredError = false; + let inObjectTypeLiteral = false; + let checkAlias = true; + let symbolStack: Symbol[] = undefined; + + const resultingNode = typeToTypeNodeWorker(type); + const result = encounteredError && !emitNodeOnError ? undefined : resultingNode; + encounteredError = toNodeEncounteredErrorCache; + return result; + + function typeToTypeNodeWorker(type: Type): NodeBuilderResult { + if (!type) { + encounteredError = true; + return undefined; + } + + if (type.flags & TypeFlags.Any) { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + if (type.flags & TypeFlags.String) { + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if (type.flags & TypeFlags.Number) { + return createKeywordTypeNode(SyntaxKind.NumberKeyword); + } + if (type.flags & TypeFlags.Boolean) { + return createKeywordTypeNode(SyntaxKind.BooleanKeyword); + } + if (type.flags & TypeFlags.Enum) { + const name = symbolToName(type.symbol, enclosingDeclaration); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & (TypeFlags.StringLiteral)) { + return createLiteralTypeNode((createLiteral((type).text))); + } + if (type.flags & (TypeFlags.NumberLiteral)) { + return createLiteralTypeNode((createNumericLiteral((type).text))); + } + if (type.flags & TypeFlags.BooleanLiteral) { + return (type).intrinsicName === "true" ? createTrue() : createFalse(); + } + if (type.flags & TypeFlags.EnumLiteral) { + const name = symbolToName(type.symbol, enclosingDeclaration); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.Void) { + return createKeywordTypeNode(SyntaxKind.VoidKeyword); + } + if (type.flags & TypeFlags.Undefined) { + return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); + } + if (type.flags & TypeFlags.Null) { + return createKeywordTypeNode(SyntaxKind.NullKeyword); + } + if (type.flags & TypeFlags.Never) { + return createKeywordTypeNode(SyntaxKind.NeverKeyword); + } + if (type.flags & TypeFlags.ESSymbol) { + throw new Error("ESSymbol not implemented"); + } + if (type.flags & TypeFlags.NonPrimitive) { + throw new Error("Non primitive not implemented"); + } + if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { + if (inObjectTypeLiteral) { + encounteredError = true; + } + return createThis(); + } + + const objectFlags = getObjectFlags(type); + + if (objectFlags & ObjectFlags.Reference) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + return typeReferenceToTypeReferenceNode(type); + } + if (objectFlags & ObjectFlags.ClassOrInterface) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const name = symbolToName(type.symbol, enclosingDeclaration); + // TODO(aozgaa): handle type arguments. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.TypeParameter) { + const name = symbolToName(type.symbol, enclosingDeclaration); + // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + + if (checkAlias && type.aliasSymbol) { + const name = symbolToName(type.aliasSymbol, enclosingDeclaration); + const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); + return createTypeReferenceNode(name, typeArgumentNodes); + } + checkAlias = false; + + if (type.flags & TypeFlags.Union) { + return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray(formatUnionTypes((type).types))); + } + + if (type.flags & TypeFlags.Intersection) { + return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); + } + + if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // The type is an object literal type. + return createAnonymousTypeNode(type); + } + + if (type.flags & TypeFlags.Index) { + const indexedType = (type).type; + const indexTypeNode = typeToTypeNodeWorker(indexedType); + return createTypeOperatorNode(indexTypeNode); + } + if (type.flags & TypeFlags.IndexedAccess) { + const objectTypeNode = typeToTypeNodeWorker((type).objectType); + const indexTypeNode = typeToTypeNodeWorker((type).indexType); + return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + + Debug.fail("Should be unreachable."); + + function mapToTypeNodeArray(types: Type[]): NodeArray { + return types && asNodeArray(types.map(typeToTypeNodeWorker) as TypeNode[]); + } + + function createMappedTypeNodeFromType(type: MappedType) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const typeParameter = getTypeParameterFromMappedType(type); + const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration); + + const templateTypeNode = typeToTypeNodeWorker(getTemplateTypeFromMappedType(type)); + const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; + const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + + return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + + function createAnonymousTypeNode(type: ObjectType): TypeNode { + const symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromType(type); + } + else if (contains(symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + const typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + const entityName = symbolToName(typeAlias, enclosingDeclaration); + return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + } + else { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!symbolStack) { + symbolStack = []; + } + symbolStack.push(symbol); + let result = createTypeNodeFromObjectType(type); + symbolStack.pop(); + return result; + } + } + else { + // Anonymous types without a symbol are never circular. + return createTypeNodeFromObjectType(type); + } + + function shouldWriteTypeOfFunctionSymbol() { + const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method + forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); + const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && + (symbol.parent || // is exported function symbol + forEach(symbol.declarations, declaration => + declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return contains(symbolStack, symbol); // it is type of the symbol uses itself recursively + } + } + } + + function createTypeNodeFromObjectType(type: ObjectType): TypeNode { + if (type.objectFlags & ObjectFlags.Mapped) { + if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { + return createMappedTypeNodeFromType(type); + } + } + + const resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return createTypeLiteralNode(/*members*/ undefined); + } + + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + const signature = resolved.callSignatures[0]; + return signatureToSignatureDeclaration(signature, SyntaxKind.FunctionType, enclosingDeclaration, emitNodeOnError); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + const signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclaration(signature, SyntaxKind.ConstructorType, enclosingDeclaration, emitNodeOnError); + } + } + + const saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; + const members = createTypeNodesFromResolvedType(resolved); + inObjectTypeLiteral = saveInObjectTypeLiteral; + return createTypeLiteralNode(members); + } + + function createTypeQueryNodeFromType(type: Type) { + const symbol = type.symbol; + if (symbol) { + const entityName = symbolToName(symbol, enclosingDeclaration); + return createTypeQueryNode(entityName); + } + } + + function typeReferenceToTypeReferenceNode(type: TypeReference) { + const typeArguments: Type[] = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + const elementType = typeToTypeNodeWorker(typeArguments[0]); + return createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & ObjectFlags.Tuple) { + return createTupleTypeNode(typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))) : undefined); + } + else { + const outerTypeParameters = type.target.outerTypeParameters; + let i = 0; + let qualifiedName: QualifiedName | undefined = undefined; + if (outerTypeParameters) { + const length = outerTypeParameters.length; + while (i < length) { + // Find group of type arguments for type parameters with the same declaring container. + const start = i; + const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + // When type parameters are their own type arguments for the whole group (i.e. we have + // the default outer type arguments), we don't show the group. + if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { + const qualifiedNamePart = symbolToName(parent, enclosingDeclaration, /*mustBeIdentifier*/ true); + if (!qualifiedName) { + qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); + } + else { + Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); + } + } + } + } + let entityName: EntityName = undefined; + const nameIdentifier = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true); + if (qualifiedName) { + Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + const typeParameterCount = (type.target.typeParameters || emptyArray).length; + const typeArgumentNodes = mapToTypeNodeArray(typeArguments.length > 0 ? typeArguments.slice(i, typeParameterCount - i) : undefined); + return createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + + function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { + const typeElements: TypeElement[] = []; + for (const signature of resolvedType.callSignatures) { + typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.CallSignature, enclosingDeclaration, emitNodeOnError)); + } + for (const signature of resolvedType.constructSignatures) { + typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.ConstructSignature, enclosingDeclaration, emitNodeOnError)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration, emitNodeOnError)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration, emitNodeOnError)); + } + + const properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + + for (const propertySymbol of properties) { + const propertyType = getTypeOfSymbol(propertySymbol); + const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; + if (!oldDeclaration) { + return; + } + const propertyName = oldDeclaration.name; + const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;; + if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { + const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); + for (const signature of signatures) { + const methodDeclaration = signatureToSignatureDeclaration(signature, SyntaxKind.MethodSignature, enclosingDeclaration, emitNodeOnError); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + typeElements.push(createPropertySignature( + propertyName, + optionalToken, + typeToTypeNodeWorker(propertyType), + /*initializer*/undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + } + + function indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node, emitNodeOnError?: boolean): IndexSignatureDeclaration { + const encounteredErrorCache = encounteredError; + encounteredError = false; + + const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); + + const name = getNameFromIndexInfo(indexInfo); + const indexingParameter = createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + name, + /*questionToken*/ undefined, + indexerTypeNode, + /*initializer*/ undefined); + const typeNode = typeToTypeNode(indexInfo.type, enclosingDeclaration, emitNodeOnError); + const result = !encounteredError || emitNodeOnError ? createIndexSignatureDeclaration( + [indexingParameter], + typeNode, + /*decorators*/ undefined, + indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined) + : undefined; + encounteredError = encounteredErrorCache; + return result; + } + + function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, emitNodeOnError?: boolean): SignatureDeclaration { + const encounteredErrorCache = encounteredError; + encounteredError = false; + + const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, enclosingDeclaration)); + const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, enclosingDeclaration)); + const type = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); + + const result = !encounteredError || emitNodeOnError ? createSignatureDeclaration(kind, typeParameters, parameters, type) : undefined; + encounteredError = encounteredErrorCache; + return result; + + function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { + const typeNode = typeToTypeNode(type, enclosingDeclaration, emitNodeOnError); + return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; + } + } + + function typeParameterToDeclaration(type: TypeParameter, enclosingDeclaration?: Node, returnNodeOnError?: boolean): TypeParameterDeclaration { + if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { return undefined; } - if (type.flags & TypeFlags.Any) { - return createKeywordTypeNode(SyntaxKind.AnyKeyword); + const constraint = typeToTypeNode(getConstraintFromTypeParameter(type), enclosingDeclaration); + const defaultParameter = typeToTypeNode(getDefaultFromTypeParameter(type), enclosingDeclaration); + + let toNodeEncounteredErrorCache = encounteredError; + encounteredError = false; + const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true); + let result = encounteredError && !returnNodeOnError ? undefined : createTypeParameterDeclaration(name, constraint, defaultParameter); + encounteredError = toNodeEncounteredErrorCache; + return result; + } + + function symbolToParameterDeclaration(parameterSymbol: Symbol, enclosingDeclaration?: Node): ParameterDeclaration { + const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; + const parameterType = getTypeOfSymbol(parameterSymbol); + const parameterTypeNode = typeToTypeNode(parameterType, enclosingDeclaration); + // TODO(aozgaa): check initializer accessibility correctly. + const parameterNode = createParameter( + parameterDeclaration.decorators, + parameterDeclaration.modifiers, + parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), + // Clone name to remove trivia. + getSynthesizedClone(parameterDeclaration.name), + parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), + parameterTypeNode, + parameterDeclaration.initializer); + return parameterNode; + } + + function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: true): Identifier; + function symbolToName(symbol: Symbol, enclosingDeclaration?: Node, mustBeIdentifier?: false): EntityName; + function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: boolean | undefined): EntityName { + let parentSymbol: Symbol; + let meaning: SymbolFlags; + + // Get qualified name if the symbol is not a type parameter + // and there is an enclosing declaration. + let chain: Symbol[]; + const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; + if (!isTypeParameter && enclosingDeclaration) { + chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); + // TODO: check whether type pointed to by symbol requires type arguments to be printed. + Debug.assert(chain && chain.length > 0); } - if (type.flags & TypeFlags.String) { - return createKeywordTypeNode(SyntaxKind.StringKeyword); - } - if (type.flags & TypeFlags.Number) { - return createKeywordTypeNode(SyntaxKind.NumberKeyword); - } - if(type.flags & TypeFlags.Boolean) { - return createKeywordTypeNode(SyntaxKind.BooleanKeyword); - } - if (type.flags & TypeFlags.Enum) { - const name = createNameFromSymbol(type.symbol); - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & (TypeFlags.StringLiteral)) { - return createLiteralTypeNode((createLiteral((type).text))); - } - if (type.flags & (TypeFlags.NumberLiteral)) { - return createLiteralTypeNode((createNumericLiteral((type).text))); - } - if(type.flags & TypeFlags.BooleanLiteral) { - return (type).intrinsicName === "true" ? createTrue() : createFalse(); - } - if (type.flags & TypeFlags.EnumLiteral) { - const name = createNameFromSymbol(type.symbol); - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & TypeFlags.Void) { - return createKeywordTypeNode(SyntaxKind.VoidKeyword); - } - if (type.flags & TypeFlags.Undefined) { - return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); - } - if (type.flags & TypeFlags.Null) { - return createKeywordTypeNode(SyntaxKind.NullKeyword); - } - if (type.flags & TypeFlags.Never) { - return createKeywordTypeNode(SyntaxKind.NeverKeyword); - } - if (type.flags & TypeFlags.ESSymbol) { - throw new Error("ESSymbol not implemented"); - } - if (type.flags & TypeFlags.NonPrimitive) { - throw new Error("Non primitive not implemented"); - } - if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { - if (inObjectTypeLiteral) { - encounteredError = true; - } - return createThis(); + else { + chain = [symbol]; } - const objectFlags = getObjectFlags(type); - - if (objectFlags & ObjectFlags.Reference) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - return typeReferenceToTypeReferenceNode(type); - } - if (objectFlags & ObjectFlags.ClassOrInterface) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const name = createNameFromSymbol(type.symbol); - // TODO: handle type arguments. - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & TypeFlags.TypeParameter) { - const name = createNameFromSymbol(type.symbol); - // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. - return createTypeReferenceNode(name, /*typeArguments*/ undefined); + parentSymbol = undefined; + if (mustBeIdentifier && chain.length !== 1) { + encounteredError = true; + // TODO: failing to get an identifier when we expect one generates an unprintable node. + // Should error handling be more severe? } + return createEntityNameFromSymbolChain(chain, chain.length - 1); - if (checkAlias && type.aliasSymbol) { - const name = createNameFromSymbol(type.aliasSymbol); - const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(name, typeArgumentNodes); - } - checkAlias = false; - - if (type.flags & TypeFlags.Union) { - return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray(formatUnionTypes((type).types))); - } - - if (type.flags & TypeFlags.Intersection) { - return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); - } - - if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // The type is an object literal type. - return createAnonymousTypeNode(type); - } - - // TODO (aozgaa): implement string and number literals here once there is a testable case. - - if (type.flags & TypeFlags.Index) { - const indexedType = (type).type; - const indexTypeNode = typeToTypeNodeWorker(indexedType); - return createTypeOperatorNode(indexTypeNode); - } - if (type.flags & TypeFlags.IndexedAccess) { - const objectTypeNode = typeToTypeNodeWorker((type).objectType); - const indexTypeNode = typeToTypeNodeWorker((type).indexType); - return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); - } - - Debug.fail("Should be unreachable."); - - function mapToTypeNodeArray(types: Type[]): NodeArray { - return types && asNodeArray(types.map(typeToTypeNodeWorker) as TypeNode[]); - } - - function createMappedTypeNodeFromType(type: MappedType) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const typeParameter = getTypeParameterFromMappedType(type); - const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration); - - const templateTypeNode = typeToTypeNode(getTemplateTypeFromMappedType(type), enclosingDeclaration); - const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; - const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; - - return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); - } - - function createAnonymousTypeNode(type: ObjectType): TypeNode { - const symbol = type.symbol; - if (symbol) { - // Always use 'typeof T' for type of class, enum, and module objects - if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || - symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || - shouldWriteTypeOfFunctionSymbol()) { - return createTypeQueryNodeFromType(type); - } - else if (contains(symbolStack, symbol)) { - // If type is an anonymous type literal in a type alias declaration, use type alias name - const typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - // The specified symbol flags need to be reinterpreted as type flags - const entityName = createNameFromSymbol(typeAlias); - return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); - } - else { - return createKeywordTypeNode(SyntaxKind.AnyKeyword); - } + function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { + Debug.assert(chain && 0 <= index && index < chain.length); + // const parentIndex = index - 1; + const symbol = chain[index]; + let typeParameterString = ""; + if (index > 0) { + // TODO: is the parentSymbol wrong? + const parentSymbol = chain[index - 1]; + let typeParameters: TypeParameter[]; + if (getCheckFlags(symbol) & CheckFlags.Instantiated) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!symbolStack) { - symbolStack = []; + const targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeAlias)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); } - symbolStack.push(symbol); - let result = createTypeNodeFromObjectType(type); - symbolStack.pop(); - return result; } - } - else { - // Anonymous types without a symbol are never circular. - return createTypeNodeFromObjectType(type); - } + if (typeParameters && typeParameters.length > 0) { + encounteredError = true; + const writer = getSingleLineStringWriter(); + const displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, 0); + typeParameterString = writer.string(); + releaseStringWriter(writer); - function shouldWriteTypeOfFunctionSymbol() { - const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method - forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); - const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && - (symbol.parent || // is exported function symbol - forEach(symbol.declarations, declaration => - declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - // typeof is allowed only for static/non local functions - return contains(symbolStack, symbol); // it is type of the symbol uses itself recursively } } + const symbolName = getNameOfSymbol(symbol); + const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName; + let identifier = createIdentifier(symbolNameWithTypeParameters); + + return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } - function createTypeNodeFromObjectType(type: ObjectType): TypeNode { - if (type.objectFlags & ObjectFlags.Mapped) { - if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { - return createMappedTypeNodeFromType(type); - } - } + /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ + function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { + let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); - const resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - return createTypeLiteralNode(/*members*/ undefined); - } + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - const signature = resolved.callSignatures[0]; - return signatureToSignatureDeclaration(signature, SyntaxKind.FunctionType, enclosingDeclaration); - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - const signature = resolved.constructSignatures[0]; - return signatureToSignatureDeclaration(signature, SyntaxKind.ConstructorType, enclosingDeclaration); - } - } - - const saveInObjectTypeLiteral = inObjectTypeLiteral; - inObjectTypeLiteral = true; - const members = createTypeNodesFromResolvedType(resolved); - inObjectTypeLiteral = saveInObjectTypeLiteral; - return createTypeLiteralNode(members); - } - - function createTypeQueryNodeFromType(type: Type) { - const symbol = type.symbol; - if (symbol) { - const entityName = createNameFromSymbol(symbol); - return createTypeQueryNode(entityName); - } - } - - function typeReferenceToTypeReferenceNode(type: TypeReference) { - const typeArguments: Type[] = type.typeArguments || emptyArray; - if (type.target === globalArrayType) { - const elementType = typeToTypeNodeWorker(typeArguments[0]); - return createArrayTypeNode(elementType); - } - else if (type.target.objectFlags & ObjectFlags.Tuple) { - return createTupleTypeNode(typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))) : undefined); - } - else { - const outerTypeParameters = type.target.outerTypeParameters; - let i = 0; - let qualifiedName: QualifiedName | undefined = undefined; - if (outerTypeParameters) { - const length = outerTypeParameters.length; - while (i < length) { - // Find group of type arguments for type parameters with the same declaring container. - const start = i; - const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); - do { - i++; - } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); - // When type parameters are their own type arguments for the whole group (i.e. we have - // the default outer type arguments), we don't show the group. - if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const qualifiedNamePart = createNameFromSymbol(parent, /*mustBeIdentifier*/ true); - if (!qualifiedName) { - qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); - } - else { - Debug.assert(!qualifiedName.right); - qualifiedName.right = qualifiedNamePart; - qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); - } - } + // Go up and add our parent. + const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); } } - let entityName: EntityName = undefined; - const nameIdentifier = createNameFromSymbol(type.symbol, /*mustBeIdentifier*/ true); - if (qualifiedName) { - Debug.assert(!qualifiedName.right); - qualifiedName.right = nameIdentifier; - entityName = qualifiedName; - } - else { - entityName = nameIdentifier; - } - const typeParameterCount = (type.target.typeParameters || emptyArray).length; - const typeArgumentNodes = mapToTypeNodeArray(typeArguments.length > 0 ? typeArguments.slice(i, typeParameterCount - i) : undefined); - return createTypeReferenceNode(entityName, typeArgumentNodes); - } - } - - function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { - const typeElements: TypeElement[] = []; - for (const signature of resolvedType.callSignatures) { - typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.CallSignature, enclosingDeclaration)); - } - for (const signature of resolvedType.constructSignatures) { - typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.ConstructSignature, enclosingDeclaration)); - } - if (resolvedType.stringIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration)); - } - if (resolvedType.numberIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration)); } - const properties = resolvedType.properties; - if (!properties) { - return typeElements; + if (accessibleSymbolChain) { + return accessibleSymbolChain; } - for (const propertySymbol of properties) { - const propertyType = getTypeOfSymbol(propertySymbol); - const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; - if (!oldDeclaration) { - return; - } - const propertyName = oldDeclaration.name; - const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;; - if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { - const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); - for (const signature of signatures) { - const methodDeclaration = signatureToSignatureDeclaration(signature, SyntaxKind.MethodSignature, enclosingDeclaration); - methodDeclaration.name = propertyName; - methodDeclaration.questionToken = optionalToken; - typeElements.push(methodDeclaration); - } - } - else { - typeElements.push(createPropertySignature( - propertyName, - optionalToken, - typeToTypeNodeWorker(propertyType), - /*initializer*/undefined)); - } - } - return typeElements.length ? typeElements : undefined; - } + else if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - function createNameFromSymbol(symbol: Symbol, mustBeIdentifier: true): Identifier; - function createNameFromSymbol(symbol: Symbol, mustBeIdentifier?: false): EntityName; - function createNameFromSymbol(symbol: Symbol, mustBeIdentifier: boolean | undefined): EntityName { - let parentSymbol: Symbol; - let meaning: SymbolFlags; - - // Get qualified name if the symbol is not a type parameter - // and there is an enclosing declaration. - let chain: Symbol[]; - const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; - if (!isTypeParameter && enclosingDeclaration) { - chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); - // TODO: check whether type pointed to by symbol requires type arguments to be printed. - Debug.assert(chain && chain.length > 0); - } - else { - chain = [symbol]; - } - - parentSymbol = undefined; - if(mustBeIdentifier && chain.length !== 1) { - encounteredError = true; - // TODO: failing to get an identifier when we expect one generates an unprintable node. - // Should error handling be more severe? - } - return createEntityNameFromSymbolChain(chain, chain.length - 1); - - function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { - Debug.assert(chain && 0 <= index && index < chain.length); - // const parentIndex = index - 1; - const symbol = chain[index]; - let typeParameterString = ""; - if(index > 0) { - // TODO: is the parentSymbol wrong? - const parentSymbol = chain[index - 1]; - let typeParameters: TypeParameter[]; - if(getCheckFlags(symbol) & CheckFlags.Instantiated) { - typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); - } - else { - const targetSymbol = getTargetSymbol(parentSymbol); - if(targetSymbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeAlias)) { - typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - } - } - if(typeParameters && typeParameters.length > 0) { - encounteredError = true; - const writer = getSingleLineStringWriter(); - const displayBuilder = getSymbolDisplayBuilder(); - displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, 0); - typeParameterString = writer.string(); - releaseStringWriter(writer); - - } - } - const symbolName = getNameOfSymbol(symbol); - const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName; - let identifier = createIdentifier(symbolNameWithTypeParameters); - - return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; - } - - /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ - function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { - let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); - - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - - // Go up and add our parent. - const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent) { - const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); - if (parentChain) { - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); - } - } - } - - if (accessibleSymbolChain) { - return accessibleSymbolChain; - } - - else if ( - // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. - endOfChain || - // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) - !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && - // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - - return [symbol]; - } + return [symbol]; } } @@ -2687,26 +2738,6 @@ namespace ts { } } - function indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration { - const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); - - const name = getNameFromIndexInfo(indexInfo); - const indexingParameter = createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, - name, - /*questionToken*/ undefined, - indexerTypeNode, - /*initializer*/ undefined); - const typeNode = typeToTypeNode(indexInfo.type, enclosingDeclaration); - return createIndexSignatureDeclaration( - [indexingParameter], - typeNode, - /*decorators*/ undefined, - indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); - } - function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string { const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5ccdd79f199..288d0942b78 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2473,11 +2473,11 @@ namespace ts { getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration: Node): TypeNode; + typeToTypeNode(type: Type, enclosingDeclaration?: Node, returnNodeOnError?: boolean): TypeNode; /** Note that the resulting nodes cannot be checked. */ - indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration; + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, returnNodeOnError?: boolean): SignatureDeclaration; /** Note that the resulting nodes cannot be checked. */ - signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node): SignatureDeclaration; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, returnNodeOnError?: boolean): IndexSignatureDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -2530,6 +2530,20 @@ namespace ts { /* @internal */ getTypeCount(): number; } + /** Note that the resulting nodes cannot be checked. */ + /* @internal */ + export interface NodeBuilder { + typeToTypeNode(type: Type, enclosingDeclaration?: Node, returnNodeOnError?: boolean): NodeBuilderResult; + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node): NodeBuilderResult; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): NodeBuilderResult; + } + + /* @internal */ + export interface NodeBuilderResult { + value: T; + error?: boolean; + } + export interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; From 868802b223a03114ea5d5aaed972d17725830251 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 23 Mar 2017 00:41:07 -0700 Subject: [PATCH 168/207] Port updated dom files (#14805) --- src/lib/dom.generated.d.ts | 41 +++++++++++++++++++++++++------- src/lib/webworker.generated.d.ts | 19 +++++++++++++++ 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index 5d4bb9ce6e4..348e52246a7 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -1396,6 +1396,7 @@ interface AudioNode extends EventTarget { readonly numberOfInputs: number; readonly numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: number): void; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -2152,7 +2153,9 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; drawFocusIfNeeded(element: Element): void; - drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -2449,10 +2452,10 @@ declare var DOMException: { } interface DOMImplementation { - createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(): boolean; + hasFeature(feature: string | null, version: string | null): boolean; } declare var DOMImplementation: { @@ -3449,6 +3452,7 @@ declare var Document: { } interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; } declare var DocumentFragment: { @@ -11837,7 +11841,7 @@ interface URL { protocol: string; search: string; username: string; - readonly searchparams: URLSearchParams; + readonly searchParams: URLSearchParams; toString(): string; } @@ -12161,12 +12165,12 @@ interface WebGLRenderingContext { stencilMaskSeparate(face: number, mask: number): void; stencilOp(fail: number, zfail: number, zpass: number): void; stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; - texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels?: ArrayBufferView): void; - texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; texParameterf(target: number, pname: number, param: number): void; texParameteri(target: number, pname: number, param: number): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels?: ArrayBufferView): void; - texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; uniform1f(location: WebGLUniformLocation | null, x: number): void; uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform1i(location: WebGLUniformLocation | null, x: number): void; @@ -13260,6 +13264,8 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; scroll(options?: ScrollToOptions): void; scrollTo(options?: ScrollToOptions): void; scrollBy(options?: ScrollToOptions): void; @@ -13473,6 +13479,7 @@ interface Body { blob(): Promise; json(): Promise; text(): Promise; + formData(): Promise; } interface CanvasPathMethods { @@ -13835,6 +13842,21 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + interface URLSearchParams { /** * Appends a specified key/value pair as a new search parameter. @@ -13879,6 +13901,7 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; + [index: number]: T; } interface BlobPropertyBag { @@ -14840,6 +14863,8 @@ declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function scroll(options?: ScrollToOptions): void; declare function scrollTo(options?: ScrollToOptions): void; declare function scrollBy(options?: ScrollToOptions): void; diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index e9563db1bcd..326a3a9546e 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -1407,6 +1407,8 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo readonly performance: Performance; readonly self: WorkerGlobalScope; msWriteProfilerMark(profilerMarkName: string): void; + createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1467,6 +1469,21 @@ interface ErrorEventInit { error?: any; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + interface BlobPropertyBag { type?: string; endings?: string; @@ -1697,6 +1714,8 @@ declare var onerror: (this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any; declare var performance: Performance; declare var self: WorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function dispatchEvent(evt: Event): boolean; declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare var indexedDB: IDBFactory; From 1f3029d4f15e8d6fa8617318a8655c71756ce2bf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 23 Mar 2017 08:34:58 -0700 Subject: [PATCH 169/207] error handling --- src/compiler/checker.ts | 960 +++++++++++++++++++++------------------- src/compiler/types.ts | 23 +- 2 files changed, 517 insertions(+), 466 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b681d1298d2..c981d0673b8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -61,6 +61,7 @@ namespace ts { const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; const emitResolver = createResolver(); + let nodeBuilderCache: NodeBuilder | undefined; const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined"); undefinedSymbol.declarations = []; @@ -106,9 +107,9 @@ namespace ts { getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, - typeToTypeNode, - indexInfoToIndexSignatureDeclaration, - signatureToSignatureDeclaration, + typeToTypeNode: getNodeBuilder().typeToTypeNode, + indexInfoToIndexSignatureDeclaration: getNodeBuilder().indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: getNodeBuilder().signatureToSignatureDeclaration, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2191,476 +2192,529 @@ namespace ts { return result; } - function typeParameterToDeclaration(type: TypeParameter, enclosingDeclaration?: Node): TypeParameterDeclaration { - if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { - return undefined; + function getNodeBuilder(): NodeBuilder { + if (nodeBuilderCache) { + return nodeBuilderCache; } - const constraint = typeToTypeNode(getConstraintFromTypeParameter(type), enclosingDeclaration); - const defaultParameter = typeToTypeNode(getDefaultFromTypeParameter(type), enclosingDeclaration); - - // TODO: use method internal to typeToTypeNode. - const name = symbolToString(type.symbol); - return createTypeParameterDeclaration(name, constraint, defaultParameter); - } - - function symbolToParameterDeclaration(parameterSymbol: Symbol, enclosingDeclaration?: Node): ParameterDeclaration { - const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; - const parameterType = getTypeOfSymbol(parameterSymbol); - const parameterTypeNode = typeToTypeNode(parameterType, enclosingDeclaration); - // TODO: check initializer accessibility correctly. - const parameterNode = createParameter( - parameterDeclaration.decorators, - parameterDeclaration.modifiers, - parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), - // Clone name to remove trivia. - getSynthesizedClone(parameterDeclaration.name), - parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), - parameterTypeNode, - parameterDeclaration.initializer); - return parameterNode; - } - - function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node): SignatureDeclaration { - const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, enclosingDeclaration)); - const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, enclosingDeclaration)); - const type = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); - - return createSignatureDeclaration(kind, typeParameters, parameters, type); - - function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { - const typeNode = typeToTypeNode(type, enclosingDeclaration); - return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; - } - } - - - // function typeToDisplayParts - - function typeToTypeNode(type: Type, enclosingDeclaration?: Node, returnNodeOnError?: boolean): TypeNode { let encounteredError = false; - let inObjectTypeLiteral = false; - let checkAlias = true; - let symbolStack: Symbol[] = undefined; - const result = typeToTypeNodeWorker(type); - // returnNodeOnError = true; // TODO: unset. - return encounteredError && !returnNodeOnError ? undefined: result; + nodeBuilderCache = { + typeToTypeNode, + indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration + } - function typeToTypeNodeWorker(type: Type): TypeNode { - if (!type) { - encounteredError = true; + return nodeBuilderCache; + + function typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode { + const helper = () => typeToTypeNodeHelper(type, enclosingDeclaration, flags); + return callHelperWithErrorHandling(helper); + } + + function indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration { + const helper = () => indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, enclosingDeclaration, flags); + return callHelperWithErrorHandling(helper); + } + + function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration { + const helper = () => signatureToSignatureDeclarationHelper(signature, kind, enclosingDeclaration, flags); + return callHelperWithErrorHandling(helper); + } + + function callHelperWithErrorHandling(nodeBuilderHelper: () => T): T | undefined { + const encounteredErrorCache = encounteredError; + const resultingNode = nodeBuilderHelper(); + const result = encounteredError ? undefined : resultingNode; + encounteredError = encounteredErrorCache; + return result; + } + + function typeToTypeNodeHelper(type: Type, enclosingDeclaration: Node, flags: NodeBuilderFlags): TypeNode { + let inObjectTypeLiteral = false; + let checkAlias = true; + let symbolStack: Symbol[] = undefined; + + return typeToTypeNodeWorker(type, flags); + + function typeToTypeNodeWorker(type: Type, flags: NodeBuilderFlags): TypeNode { + if (!type) { + encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowUndefinedNode); + return undefined; + } + flags = flags & ~NodeBuilderFlags.allowUndefinedNode; + + if (type.flags & TypeFlags.Any) { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + if (type.flags & TypeFlags.String) { + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if (type.flags & TypeFlags.Number) { + return createKeywordTypeNode(SyntaxKind.NumberKeyword); + } + if (type.flags & TypeFlags.Boolean) { + return createKeywordTypeNode(SyntaxKind.BooleanKeyword); + } + if (type.flags & TypeFlags.Enum) { + const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & (TypeFlags.StringLiteral)) { + return createLiteralTypeNode((createLiteral((type).text))); + } + if (type.flags & (TypeFlags.NumberLiteral)) { + return createLiteralTypeNode((createNumericLiteral((type).text))); + } + if (type.flags & TypeFlags.BooleanLiteral) { + return (type).intrinsicName === "true" ? createTrue() : createFalse(); + } + if (type.flags & TypeFlags.EnumLiteral) { + const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.Void) { + return createKeywordTypeNode(SyntaxKind.VoidKeyword); + } + if (type.flags & TypeFlags.Undefined) { + return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); + } + if (type.flags & TypeFlags.Null) { + return createKeywordTypeNode(SyntaxKind.NullKeyword); + } + if (type.flags & TypeFlags.Never) { + return createKeywordTypeNode(SyntaxKind.NeverKeyword); + } + if (type.flags & TypeFlags.ESSymbol) { + throw new Error("ESSymbol not implemented"); + } + if (type.flags & TypeFlags.NonPrimitive) { + throw new Error("Non primitive not implemented"); + } + if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { + if (inObjectTypeLiteral) { + encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowThisInObjectLiteral); + } + return createThis(); + } + + const objectFlags = getObjectFlags(type); + + if (objectFlags & ObjectFlags.Reference) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + return typeReferenceToTypeReferenceNode(type); + } + if (objectFlags & ObjectFlags.ClassOrInterface) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + // TODO(aozgaa): handle type arguments. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.TypeParameter) { + const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + + if (checkAlias && type.aliasSymbol) { + const name = symbolToName(type.aliasSymbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); + return createTypeReferenceNode(name, typeArgumentNodes); + } + checkAlias = false; + + if (type.flags & TypeFlags.Union) { + return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray(formatUnionTypes((type).types))); + } + + if (type.flags & TypeFlags.Intersection) { + return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); + } + + if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // The type is an object literal type. + return createAnonymousTypeNode(type); + } + + if (type.flags & TypeFlags.Index) { + const indexedType = (type).type; + const indexTypeNode = typeToTypeNodeWorker(indexedType, flags); + return createTypeOperatorNode(indexTypeNode); + } + if (type.flags & TypeFlags.IndexedAccess) { + const objectTypeNode = typeToTypeNodeWorker((type).objectType, flags); + const indexTypeNode = typeToTypeNodeWorker((type).indexType, flags); + return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + + Debug.fail("Should be unreachable."); + + function mapToTypeNodeArray(types: Type[]): NodeArray { + return types && asNodeArray(types.map(typeToTypeNodeWorker) as TypeNode[]); + } + + function createMappedTypeNodeFromType(type: MappedType) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const typeParameter = getTypeParameterFromMappedType(type); + const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration, flags); + + const templateTypeNode = typeToTypeNodeWorker(getTemplateTypeFromMappedType(type), flags | NodeBuilderFlags.allowUndefinedNode); + const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; + const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + + return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + + function createAnonymousTypeNode(type: ObjectType): TypeNode { + const symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromType(type); + } + else if (contains(symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + const typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + const entityName = symbolToName(typeAlias, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + } + else { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!symbolStack) { + symbolStack = []; + } + symbolStack.push(symbol); + let result = createTypeNodeFromObjectType(type); + symbolStack.pop(); + return result; + } + } + else { + // Anonymous types without a symbol are never circular. + return createTypeNodeFromObjectType(type); + } + + function shouldWriteTypeOfFunctionSymbol() { + const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method + forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); + const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && + (symbol.parent || // is exported function symbol + forEach(symbol.declarations, declaration => + declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return contains(symbolStack, symbol); // it is type of the symbol uses itself recursively + } + } + } + + function createTypeNodeFromObjectType(type: ObjectType): TypeNode { + if (type.objectFlags & ObjectFlags.Mapped) { + if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { + return createMappedTypeNodeFromType(type); + } + } + + const resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return createTypeLiteralNode(/*members*/ undefined); + } + + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + const signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, SyntaxKind.FunctionType, enclosingDeclaration, flags); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + const signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructorType, enclosingDeclaration, flags); + } + } + + const saveInObjectTypeLiteral = inObjectTypeLiteral; + inObjectTypeLiteral = true; + const members = createTypeNodesFromResolvedType(resolved); + inObjectTypeLiteral = saveInObjectTypeLiteral; + return createTypeLiteralNode(members); + } + + function createTypeQueryNodeFromType(type: Type) { + const symbol = type.symbol; + if (symbol) { + const entityName = symbolToName(symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + return createTypeQueryNode(entityName); + } + } + + function typeReferenceToTypeReferenceNode(type: TypeReference) { + const typeArguments: Type[] = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + const elementType = typeToTypeNodeWorker(typeArguments[0], flags); + return createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & ObjectFlags.Tuple) { + return createTupleTypeNode(typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))) : undefined); + } + else { + const outerTypeParameters = type.target.outerTypeParameters; + let i = 0; + let qualifiedName: QualifiedName | undefined = undefined; + if (outerTypeParameters) { + const length = outerTypeParameters.length; + while (i < length) { + // Find group of type arguments for type parameters with the same declaring container. + const start = i; + const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + // When type parameters are their own type arguments for the whole group (i.e. we have + // the default outer type arguments), we don't show the group. + if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { + const qualifiedNamePart = symbolToName(parent, enclosingDeclaration, /*mustBeIdentifier*/ true, flags); + if (!qualifiedName) { + qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); + } + else { + Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); + } + } + } + } + let entityName: EntityName = undefined; + const nameIdentifier = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true, flags); + if (qualifiedName) { + Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + const typeParameterCount = (type.target.typeParameters || emptyArray).length; + const typeArgumentNodes = mapToTypeNodeArray(typeArguments.length > 0 ? typeArguments.slice(i, typeParameterCount - i) : undefined); + return createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + + function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { + const typeElements: TypeElement[] = []; + for (const signature of resolvedType.callSignatures) { + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature, enclosingDeclaration, flags)); + } + for (const signature of resolvedType.constructSignatures) { + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature, enclosingDeclaration, flags)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration, flags)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration, flags)); + } + + const properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + + for (const propertySymbol of properties) { + const propertyType = getTypeOfSymbol(propertySymbol); + const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; + if (!oldDeclaration) { + return; + } + const propertyName = oldDeclaration.name; + const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;; + if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { + const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); + for (const signature of signatures) { + const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature, enclosingDeclaration, flags); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + typeElements.push(createPropertySignature( + propertyName, + optionalToken, + typeToTypeNodeWorker(propertyType, flags), + /*initializer*/undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + } + + function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node, flags: NodeBuilderFlags): IndexSignatureDeclaration { + const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); + + const name = getNameFromIndexInfo(indexInfo); + const indexingParameter = createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, + name, + /*questionToken*/ undefined, + indexerTypeNode, + /*initializer*/ undefined); + const typeNode = typeToTypeNodeHelper(indexInfo.type, enclosingDeclaration, flags); + return createIndexSignatureDeclaration( + [indexingParameter], + typeNode, + /*decorators*/ undefined, + indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); + } + + function signatureToSignatureDeclarationHelper(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node, flags: NodeBuilderFlags): SignatureDeclaration { + + const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, enclosingDeclaration, flags)); + const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, enclosingDeclaration, flags)); + const type = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); + + return createSignatureDeclaration(kind, typeParameters, parameters, type); + + function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { + // Note, this call will *not* mark encounteredError. + const typeNode = typeToTypeNode(type, enclosingDeclaration); + return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; + } + } + + function typeParameterToDeclaration(type: TypeParameter, enclosingDeclaration: Node, flags: NodeBuilderFlags): TypeParameterDeclaration { + if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { return undefined; } - if (type.flags & TypeFlags.Any) { - return createKeywordTypeNode(SyntaxKind.AnyKeyword); + const constraint = typeToTypeNodeHelper(getConstraintFromTypeParameter(type), enclosingDeclaration, flags | NodeBuilderFlags.allowUndefinedNode); + const defaultParameter = typeToTypeNodeHelper(getDefaultFromTypeParameter(type), enclosingDeclaration, flags | NodeBuilderFlags.allowUndefinedNode); +; + const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true, flags); + return createTypeParameterDeclaration(name, constraint, defaultParameter); + } + + function symbolToParameterDeclaration(parameterSymbol: Symbol, enclosingDeclaration: Node, flags: NodeBuilderFlags): ParameterDeclaration { + const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; + const parameterType = getTypeOfSymbol(parameterSymbol); + const parameterTypeNode = typeToTypeNodeHelper(parameterType, enclosingDeclaration, flags); + // TODO(aozgaa): check initializer accessibility correctly. + const parameterNode = createParameter( + parameterDeclaration.decorators, + parameterDeclaration.modifiers, + parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), + // Clone name to remove trivia. + getSynthesizedClone(parameterDeclaration.name), + parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), + parameterTypeNode, + parameterDeclaration.initializer); + return parameterNode; + } + + function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: true, flags: NodeBuilderFlags): Identifier; + function symbolToName(symbol: Symbol, enclosingDeclaration: Node, mustBeIdentifier: false, flags: NodeBuilderFlags): EntityName; + function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: boolean, flags: NodeBuilderFlags): EntityName { + let parentSymbol: Symbol; + let meaning: SymbolFlags; + + // Get qualified name if the symbol is not a type parameter + // and there is an enclosing declaration. + let chain: Symbol[]; + const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; + if (!isTypeParameter && enclosingDeclaration) { + chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); + // TODO: check whether type pointed to by symbol requires type arguments to be printed. + Debug.assert(chain && chain.length > 0); } - if (type.flags & TypeFlags.String) { - return createKeywordTypeNode(SyntaxKind.StringKeyword); - } - if (type.flags & TypeFlags.Number) { - return createKeywordTypeNode(SyntaxKind.NumberKeyword); - } - if(type.flags & TypeFlags.Boolean) { - return createKeywordTypeNode(SyntaxKind.BooleanKeyword); - } - if (type.flags & TypeFlags.Enum) { - const name = createNameFromSymbol(type.symbol); - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & (TypeFlags.StringLiteral)) { - return createLiteralTypeNode((createLiteral((type).text))); - } - if (type.flags & (TypeFlags.NumberLiteral)) { - return createLiteralTypeNode((createNumericLiteral((type).text))); - } - if(type.flags & TypeFlags.BooleanLiteral) { - return (type).intrinsicName === "true" ? createTrue() : createFalse(); - } - if (type.flags & TypeFlags.EnumLiteral) { - const name = createNameFromSymbol(type.symbol); - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & TypeFlags.Void) { - return createKeywordTypeNode(SyntaxKind.VoidKeyword); - } - if (type.flags & TypeFlags.Undefined) { - return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); - } - if (type.flags & TypeFlags.Null) { - return createKeywordTypeNode(SyntaxKind.NullKeyword); - } - if (type.flags & TypeFlags.Never) { - return createKeywordTypeNode(SyntaxKind.NeverKeyword); - } - if (type.flags & TypeFlags.ESSymbol) { - throw new Error("ESSymbol not implemented"); - } - if (type.flags & TypeFlags.NonPrimitive) { - throw new Error("Non primitive not implemented"); - } - if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { - if (inObjectTypeLiteral) { - encounteredError = true; - } - return createThis(); + else { + chain = [symbol]; } - const objectFlags = getObjectFlags(type); - - if (objectFlags & ObjectFlags.Reference) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - return typeReferenceToTypeReferenceNode(type); - } - if (objectFlags & ObjectFlags.ClassOrInterface) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const name = createNameFromSymbol(type.symbol); - // TODO: handle type arguments. - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & TypeFlags.TypeParameter) { - const name = createNameFromSymbol(type.symbol); - // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. - return createTypeReferenceNode(name, /*typeArguments*/ undefined); + parentSymbol = undefined; + if (mustBeIdentifier && chain.length !== 1) { + encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier); + // TODO: failing to get an identifier when we expect one generates an unprintable node. + // Should error handling be more severe? } + return createEntityNameFromSymbolChain(chain, chain.length - 1); - if (checkAlias && type.aliasSymbol) { - const name = createNameFromSymbol(type.aliasSymbol); - const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(name, typeArgumentNodes); - } - checkAlias = false; - - if (type.flags & TypeFlags.Union) { - return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray(formatUnionTypes((type).types))); - } - - if (type.flags & TypeFlags.Intersection) { - return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); - } - - if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // The type is an object literal type. - return createAnonymousTypeNode(type); - } - - // TODO (aozgaa): implement string and number literals here once there is a testable case. - - if (type.flags & TypeFlags.Index) { - const indexedType = (type).type; - const indexTypeNode = typeToTypeNodeWorker(indexedType); - return createTypeOperatorNode(indexTypeNode); - } - if (type.flags & TypeFlags.IndexedAccess) { - const objectTypeNode = typeToTypeNodeWorker((type).objectType); - const indexTypeNode = typeToTypeNodeWorker((type).indexType); - return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); - } - - Debug.fail("Should be unreachable."); - - function mapToTypeNodeArray(types: Type[]): NodeArray { - return types && asNodeArray(types.map(typeToTypeNodeWorker) as TypeNode[]); - } - - function createMappedTypeNodeFromType(type: MappedType) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const typeParameter = getTypeParameterFromMappedType(type); - const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration); - - const templateTypeNode = typeToTypeNode(getTemplateTypeFromMappedType(type), enclosingDeclaration); - const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; - const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; - - return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); - } - - function createAnonymousTypeNode(type: ObjectType): TypeNode { - const symbol = type.symbol; - if (symbol) { - // Always use 'typeof T' for type of class, enum, and module objects - if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || - symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || - shouldWriteTypeOfFunctionSymbol()) { - return createTypeQueryNodeFromType(type); - } - else if (contains(symbolStack, symbol)) { - // If type is an anonymous type literal in a type alias declaration, use type alias name - const typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - // The specified symbol flags need to be reinterpreted as type flags - const entityName = createNameFromSymbol(typeAlias); - return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); - } - else { - return createKeywordTypeNode(SyntaxKind.AnyKeyword); - } + function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { + Debug.assert(chain && 0 <= index && index < chain.length); + // const parentIndex = index - 1; + const symbol = chain[index]; + let typeParameterString = ""; + if (index > 0) { + // TODO: is the parentSymbol wrong? + const parentSymbol = chain[index - 1]; + let typeParameters: TypeParameter[]; + if (getCheckFlags(symbol) & CheckFlags.Instantiated) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!symbolStack) { - symbolStack = []; + const targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeAlias)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); } - symbolStack.push(symbol); - let result = createTypeNodeFromObjectType(type); - symbolStack.pop(); - return result; } - } - else { - // Anonymous types without a symbol are never circular. - return createTypeNodeFromObjectType(type); - } + if (typeParameters && typeParameters.length > 0) { + encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowTypeParameterInQualifiedName);; + const writer = getSingleLineStringWriter(); + const displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, 0); + typeParameterString = writer.string(); + releaseStringWriter(writer); - function shouldWriteTypeOfFunctionSymbol() { - const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method - forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); - const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && - (symbol.parent || // is exported function symbol - forEach(symbol.declarations, declaration => - declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - // typeof is allowed only for static/non local functions - return contains(symbolStack, symbol); // it is type of the symbol uses itself recursively } } + const symbolName = getNameOfSymbol(symbol); + const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName; + let identifier = createIdentifier(symbolNameWithTypeParameters); + + return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } - function createTypeNodeFromObjectType(type: ObjectType): TypeNode { - if (type.objectFlags & ObjectFlags.Mapped) { - if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { - return createMappedTypeNodeFromType(type); - } - } + /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ + function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { + let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); - const resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - return createTypeLiteralNode(/*members*/ undefined); - } + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - const signature = resolved.callSignatures[0]; - return signatureToSignatureDeclaration(signature, SyntaxKind.FunctionType, enclosingDeclaration); - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - const signature = resolved.constructSignatures[0]; - return signatureToSignatureDeclaration(signature, SyntaxKind.ConstructorType, enclosingDeclaration); - } - } - - const saveInObjectTypeLiteral = inObjectTypeLiteral; - inObjectTypeLiteral = true; - const members = createTypeNodesFromResolvedType(resolved); - inObjectTypeLiteral = saveInObjectTypeLiteral; - return createTypeLiteralNode(members); - } - - function createTypeQueryNodeFromType(type: Type) { - const symbol = type.symbol; - if (symbol) { - const entityName = createNameFromSymbol(symbol); - return createTypeQueryNode(entityName); - } - } - - function typeReferenceToTypeReferenceNode(type: TypeReference) { - const typeArguments: Type[] = type.typeArguments || emptyArray; - if (type.target === globalArrayType) { - const elementType = typeToTypeNodeWorker(typeArguments[0]); - return createArrayTypeNode(elementType); - } - else if (type.target.objectFlags & ObjectFlags.Tuple) { - return createTupleTypeNode(typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))) : undefined); - } - else { - const outerTypeParameters = type.target.outerTypeParameters; - let i = 0; - let qualifiedName: QualifiedName | undefined = undefined; - if (outerTypeParameters) { - const length = outerTypeParameters.length; - while (i < length) { - // Find group of type arguments for type parameters with the same declaring container. - const start = i; - const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); - do { - i++; - } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); - // When type parameters are their own type arguments for the whole group (i.e. we have - // the default outer type arguments), we don't show the group. - if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const qualifiedNamePart = createNameFromSymbol(parent, /*mustBeIdentifier*/ true); - if (!qualifiedName) { - qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); - } - else { - Debug.assert(!qualifiedName.right); - qualifiedName.right = qualifiedNamePart; - qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); - } - } + // Go up and add our parent. + const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); } } - let entityName: EntityName = undefined; - const nameIdentifier = createNameFromSymbol(type.symbol, /*mustBeIdentifier*/ true); - if (qualifiedName) { - Debug.assert(!qualifiedName.right); - qualifiedName.right = nameIdentifier; - entityName = qualifiedName; - } - else { - entityName = nameIdentifier; - } - const typeParameterCount = (type.target.typeParameters || emptyArray).length; - const typeArgumentNodes = mapToTypeNodeArray(typeArguments.length > 0 ? typeArguments.slice(i, typeParameterCount - i) : undefined); - return createTypeReferenceNode(entityName, typeArgumentNodes); - } - } - - function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { - const typeElements: TypeElement[] = []; - for (const signature of resolvedType.callSignatures) { - typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.CallSignature, enclosingDeclaration)); - } - for (const signature of resolvedType.constructSignatures) { - typeElements.push(signatureToSignatureDeclaration(signature, SyntaxKind.ConstructSignature, enclosingDeclaration)); - } - if (resolvedType.stringIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration)); - } - if (resolvedType.numberIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclaration(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration)); } - const properties = resolvedType.properties; - if (!properties) { - return typeElements; + if (accessibleSymbolChain) { + return accessibleSymbolChain; } - for (const propertySymbol of properties) { - const propertyType = getTypeOfSymbol(propertySymbol); - const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; - if (!oldDeclaration) { - return; - } - const propertyName = oldDeclaration.name; - const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined;; - if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { - const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); - for (const signature of signatures) { - const methodDeclaration = signatureToSignatureDeclaration(signature, SyntaxKind.MethodSignature, enclosingDeclaration); - methodDeclaration.name = propertyName; - methodDeclaration.questionToken = optionalToken; - typeElements.push(methodDeclaration); - } - } - else { - typeElements.push(createPropertySignature( - propertyName, - optionalToken, - typeToTypeNodeWorker(propertyType), - /*initializer*/undefined)); - } - } - return typeElements.length ? typeElements : undefined; - } + else if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - function createNameFromSymbol(symbol: Symbol, mustBeIdentifier: true): Identifier; - function createNameFromSymbol(symbol: Symbol, mustBeIdentifier?: false): EntityName; - function createNameFromSymbol(symbol: Symbol, mustBeIdentifier: boolean | undefined): EntityName { - let parentSymbol: Symbol; - let meaning: SymbolFlags; - - // Get qualified name if the symbol is not a type parameter - // and there is an enclosing declaration. - let chain: Symbol[]; - const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; - if (!isTypeParameter && enclosingDeclaration) { - chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); - // TODO: check whether type pointed to by symbol requires type arguments to be printed. - Debug.assert(chain && chain.length > 0); - } - else { - chain = [symbol]; - } - - parentSymbol = undefined; - if(mustBeIdentifier && chain.length !== 1) { - encounteredError = true; - // TODO: failing to get an identifier when we expect one generates an unprintable node. - // Should error handling be more severe? - } - return createEntityNameFromSymbolChain(chain, chain.length - 1); - - function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { - Debug.assert(chain && 0 <= index && index < chain.length); - // const parentIndex = index - 1; - const symbol = chain[index]; - let typeParameterString = ""; - if(index > 0) { - // TODO: is the parentSymbol wrong? - const parentSymbol = chain[index - 1]; - let typeParameters: TypeParameter[]; - if(getCheckFlags(symbol) & CheckFlags.Instantiated) { - typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); - } - else { - const targetSymbol = getTargetSymbol(parentSymbol); - if(targetSymbol.flags & (SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeAlias)) { - typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); - } - } - if(typeParameters && typeParameters.length > 0) { - encounteredError = true; - const writer = getSingleLineStringWriter(); - const displayBuilder = getSymbolDisplayBuilder(); - displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, 0); - typeParameterString = writer.string(); - releaseStringWriter(writer); - - } - } - const symbolName = getNameOfSymbol(symbol); - const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName; - let identifier = createIdentifier(symbolNameWithTypeParameters); - - return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; - } - - /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ - function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { - let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); - - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - - // Go up and add our parent. - const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent) { - const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); - if (parentChain) { - accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); - } - } - } - - if (accessibleSymbolChain) { - return accessibleSymbolChain; - } - - else if ( - // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. - endOfChain || - // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) - !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && - // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - - return [symbol]; - } + return [symbol]; } } @@ -2673,7 +2727,7 @@ namespace ts { if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { return declarationNameToString((declaration.parent).name); } - encounteredError = true; + encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowAnonymousIdentifier); switch (declaration.kind) { case SyntaxKind.ClassExpression: return "(Anonymous class)"; @@ -2687,26 +2741,6 @@ namespace ts { } } - function indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration { - const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); - - const name = getNameFromIndexInfo(indexInfo); - const indexingParameter = createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, - name, - /*questionToken*/ undefined, - indexerTypeNode, - /*initializer*/ undefined); - const typeNode = typeToTypeNode(indexInfo.type, enclosingDeclaration); - return createIndexSignatureDeclaration( - [indexingParameter], - typeNode, - /*decorators*/ undefined, - indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); - } - function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string { const writer = getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5ccdd79f199..d6faf8cc647 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2473,11 +2473,11 @@ namespace ts { getNonNullableType(type: Type): Type; /** Note that the resulting nodes cannot be checked. */ - typeToTypeNode(type: Type, enclosingDeclaration: Node): TypeNode; + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; /** Note that the resulting nodes cannot be checked. */ - indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node): IndexSignatureDeclaration; + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; /** Note that the resulting nodes cannot be checked. */ - signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node): SignatureDeclaration; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; @@ -2530,6 +2530,23 @@ namespace ts { /* @internal */ getTypeCount(): number; } + /** Note that any resulting nodes cannot be checked. */ + /* @internal */ + export interface NodeBuilder { + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; + } + + export enum NodeBuilderFlags { + None = 0, + allowUndefinedNode = 1 << 0, + allowThisInObjectLiteral = 1 << 1, + allowQualifedNameInPlaceOfIdentifier = 1 << 2, + allowTypeParameterInQualifiedName = 1 << 3, + allowAnonymousIdentifier = 1 << 4 + } + export interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; From dfb4df92c8f7e5d80af3213f27e70187dd9287a9 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 23 Mar 2017 11:17:25 -0700 Subject: [PATCH 170/207] move undefined handling to caller --- src/compiler/checker.ts | 44 ++++++++++++++++++++++------------------- src/compiler/types.ts | 9 ++++----- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c981d0673b8..f996f738f12 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2235,14 +2235,14 @@ namespace ts { let checkAlias = true; let symbolStack: Symbol[] = undefined; - return typeToTypeNodeWorker(type, flags); + return typeToTypeNodeWorker(type); - function typeToTypeNodeWorker(type: Type, flags: NodeBuilderFlags): TypeNode { + function typeToTypeNodeWorker(type: Type): TypeNode { if (!type) { - encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowUndefinedNode); + encounteredError = true; + // TODO(aozgaa): should we return implict any (undefined) or explicit any (keywordtypenode)? return undefined; } - flags = flags & ~NodeBuilderFlags.allowUndefinedNode; if (type.flags & TypeFlags.Any) { return createKeywordTypeNode(SyntaxKind.AnyKeyword); @@ -2302,7 +2302,7 @@ namespace ts { if (objectFlags & ObjectFlags.Reference) { Debug.assert(!!(type.flags & TypeFlags.Object)); - return typeReferenceToTypeReferenceNode(type); + return typeReferenceToTypeNode (type); } if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); @@ -2339,19 +2339,19 @@ namespace ts { if (type.flags & TypeFlags.Index) { const indexedType = (type).type; - const indexTypeNode = typeToTypeNodeWorker(indexedType, flags); + const indexTypeNode = typeToTypeNodeWorker(indexedType); return createTypeOperatorNode(indexTypeNode); } if (type.flags & TypeFlags.IndexedAccess) { - const objectTypeNode = typeToTypeNodeWorker((type).objectType, flags); - const indexTypeNode = typeToTypeNodeWorker((type).indexType, flags); + const objectTypeNode = typeToTypeNodeWorker((type).objectType); + const indexTypeNode = typeToTypeNodeWorker((type).indexType); return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } Debug.fail("Should be unreachable."); function mapToTypeNodeArray(types: Type[]): NodeArray { - return types && asNodeArray(types.map(typeToTypeNodeWorker) as TypeNode[]); + return types && asNodeArray(types.map(typeToTypeNodeWorker).filter(node => !!node)); } function createMappedTypeNodeFromType(type: MappedType) { @@ -2359,7 +2359,8 @@ namespace ts { const typeParameter = getTypeParameterFromMappedType(type); const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration, flags); - const templateTypeNode = typeToTypeNodeWorker(getTemplateTypeFromMappedType(type), flags | NodeBuilderFlags.allowUndefinedNode); + const templateType = getTemplateTypeFromMappedType(type) + const templateTypeNode = templateType && typeToTypeNodeWorker(templateType); const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -2456,10 +2457,10 @@ namespace ts { } } - function typeReferenceToTypeReferenceNode(type: TypeReference) { + function typeReferenceToTypeNode(type: TypeReference) { const typeArguments: Type[] = type.typeArguments || emptyArray; if (type.target === globalArrayType) { - const elementType = typeToTypeNodeWorker(typeArguments[0], flags); + const elementType = typeToTypeNodeWorker(typeArguments[0]); return createArrayTypeNode(elementType); } else if (type.target.objectFlags & ObjectFlags.Tuple) { @@ -2547,10 +2548,12 @@ namespace ts { } } else { + // TODO(aozgaa): should we create a node with explicit or implict any? + const propertyTypeNode = propertyType ? typeToTypeNodeWorker(propertyType) : createKeywordTypeNode(SyntaxKind.AnyKeyword); typeElements.push(createPropertySignature( propertyName, optionalToken, - typeToTypeNodeWorker(propertyType, flags), + propertyTypeNode, /*initializer*/undefined)); } } @@ -2599,11 +2602,12 @@ namespace ts { return undefined; } - const constraint = typeToTypeNodeHelper(getConstraintFromTypeParameter(type), enclosingDeclaration, flags | NodeBuilderFlags.allowUndefinedNode); - const defaultParameter = typeToTypeNodeHelper(getDefaultFromTypeParameter(type), enclosingDeclaration, flags | NodeBuilderFlags.allowUndefinedNode); -; + const constraint = getConstraintFromTypeParameter(type); + const constraintNode = constraint && typeToTypeNodeHelper(constraint, enclosingDeclaration, flags); + const defaultParameter = getDefaultFromTypeParameter(type); + const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, enclosingDeclaration, flags); const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true, flags); - return createTypeParameterDeclaration(name, constraint, defaultParameter); + return createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); } function symbolToParameterDeclaration(parameterSymbol: Symbol, enclosingDeclaration: Node, flags: NodeBuilderFlags): ParameterDeclaration { @@ -2635,7 +2639,7 @@ namespace ts { const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; if (!isTypeParameter && enclosingDeclaration) { chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); - // TODO: check whether type pointed to by symbol requires type arguments to be printed. + // TODO(aozgaa): check whether type pointed to by symbol requires type arguments to be printed. Debug.assert(chain && chain.length > 0); } else { @@ -2645,7 +2649,7 @@ namespace ts { parentSymbol = undefined; if (mustBeIdentifier && chain.length !== 1) { encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier); - // TODO: failing to get an identifier when we expect one generates an unprintable node. + // TODO(aozgaa): failing to get an identifier when we expect one generates an unprintable node. // Should error handling be more severe? } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -2656,7 +2660,7 @@ namespace ts { const symbol = chain[index]; let typeParameterString = ""; if (index > 0) { - // TODO: is the parentSymbol wrong? + // TODO(aozgaa): is the parentSymbol wrong? const parentSymbol = chain[index - 1]; let typeParameters: TypeParameter[]; if (getCheckFlags(symbol) & CheckFlags.Instantiated) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d6faf8cc647..03569788d25 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2540,11 +2540,10 @@ namespace ts { export enum NodeBuilderFlags { None = 0, - allowUndefinedNode = 1 << 0, - allowThisInObjectLiteral = 1 << 1, - allowQualifedNameInPlaceOfIdentifier = 1 << 2, - allowTypeParameterInQualifiedName = 1 << 3, - allowAnonymousIdentifier = 1 << 4 + allowThisInObjectLiteral = 1 << 0, + allowQualifedNameInPlaceOfIdentifier = 1 << 1, + allowTypeParameterInQualifiedName = 1 << 2, + allowAnonymousIdentifier = 1 << 3 } export interface SymbolDisplayBuilder { From f4fc9ed61f2352e429ff7db24fd39d1c71c0f3c6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 23 Mar 2017 11:23:13 -0700 Subject: [PATCH 171/207] Fix deeply nested type check --- src/compiler/checker.ts | 36 +++++++++++++++++++----------------- src/compiler/types.ts | 1 - 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 24ca7da87c4..3ab09aff04b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8277,8 +8277,8 @@ namespace ts { maybeStack[depth].set(id, RelationComparisonResult.Succeeded); depth++; const saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) expandingFlags |= 2; + if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; + if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; let result: Ternary; if (expandingFlags === 3) { result = Ternary.Maybe; @@ -8698,21 +8698,23 @@ namespace ts { return false; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type: Type, stack: Type[], depth: number): boolean { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (getObjectFlags(type) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && depth >= 5) { + // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons + // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely + // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 + // levels, but unequal at some level beyond that. + function isDeeplyNestedType(type: Type, stack: Type[], depth: number): boolean { + // We track all object types that have an associated symbol (representing the origin of the type) + if (depth >= 5 && type.flags & TypeFlags.Object) { const symbol = type.symbol; - let count = 0; - for (let i = 0; i < depth; i++) { - const t = stack[i]; - if (getObjectFlags(t) & (ObjectFlags.Reference | ObjectFlags.Instantiated) && t.symbol === symbol) { - count++; - if (count >= 5) return true; + if (symbol) { + let count = 0; + for (let i = 0; i < depth; i++) { + const t = stack[i]; + if (t.flags & TypeFlags.Object && t.symbol === symbol) { + count++; + if (count >= 5) return true; + } } } } @@ -9455,7 +9457,7 @@ namespace ts { if (isInProcess(source, target)) { return; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { return; } const key = source.id + "," + target.id; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2377cd81f16..ceeb2922d42 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3014,7 +3014,6 @@ namespace ts { ObjectLiteral = 1 << 7, // Originates in an object literal EvolvingArray = 1 << 8, // Evolving array type ObjectLiteralPatternWithComputedProperties = 1 << 9, // Object literal pattern with computed properties - NonPrimitive = 1 << 10, // NonPrimitive object type ClassOrInterface = Class | Interface } From 5ea146334a14abf2f58232a261cea5a83a4652f7 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 23 Mar 2017 11:23:26 -0700 Subject: [PATCH 172/207] Add regression test --- tests/cases/compiler/deeplyNestedCheck.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 tests/cases/compiler/deeplyNestedCheck.ts diff --git a/tests/cases/compiler/deeplyNestedCheck.ts b/tests/cases/compiler/deeplyNestedCheck.ts new file mode 100644 index 00000000000..e95233af985 --- /dev/null +++ b/tests/cases/compiler/deeplyNestedCheck.ts @@ -0,0 +1,9 @@ +// Repro from #14794 + +interface DataSnapshot { + child(path: string): DataSnapshot; +} + +interface Snapshot extends DataSnapshot { + child(path: U): Snapshot; +} From f139a6c58a6ea8df8f3561d8f342f625f1d4415e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 23 Mar 2017 11:24:01 -0700 Subject: [PATCH 173/207] Accept new baselines --- .../baselines/reference/deeplyNestedCheck.js | 14 +++++++++ .../reference/deeplyNestedCheck.symbols | 29 +++++++++++++++++++ .../reference/deeplyNestedCheck.types | 29 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/baselines/reference/deeplyNestedCheck.js create mode 100644 tests/baselines/reference/deeplyNestedCheck.symbols create mode 100644 tests/baselines/reference/deeplyNestedCheck.types diff --git a/tests/baselines/reference/deeplyNestedCheck.js b/tests/baselines/reference/deeplyNestedCheck.js new file mode 100644 index 00000000000..466ae94f12d --- /dev/null +++ b/tests/baselines/reference/deeplyNestedCheck.js @@ -0,0 +1,14 @@ +//// [deeplyNestedCheck.ts] +// Repro from #14794 + +interface DataSnapshot { + child(path: string): DataSnapshot; +} + +interface Snapshot extends DataSnapshot { + child(path: U): Snapshot; +} + + +//// [deeplyNestedCheck.js] +// Repro from #14794 diff --git a/tests/baselines/reference/deeplyNestedCheck.symbols b/tests/baselines/reference/deeplyNestedCheck.symbols new file mode 100644 index 00000000000..a8b5af60880 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedCheck.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/deeplyNestedCheck.ts === +// Repro from #14794 + +interface DataSnapshot { +>DataSnapshot : Symbol(DataSnapshot, Decl(deeplyNestedCheck.ts, 0, 0)) +>X : Symbol(X, Decl(deeplyNestedCheck.ts, 2, 23)) + + child(path: string): DataSnapshot; +>child : Symbol(DataSnapshot.child, Decl(deeplyNestedCheck.ts, 2, 32)) +>path : Symbol(path, Decl(deeplyNestedCheck.ts, 3, 8)) +>DataSnapshot : Symbol(DataSnapshot, Decl(deeplyNestedCheck.ts, 0, 0)) +} + +interface Snapshot extends DataSnapshot { +>Snapshot : Symbol(Snapshot, Decl(deeplyNestedCheck.ts, 4, 1)) +>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19)) +>DataSnapshot : Symbol(DataSnapshot, Decl(deeplyNestedCheck.ts, 0, 0)) + + child(path: U): Snapshot; +>child : Symbol(Snapshot.child, Decl(deeplyNestedCheck.ts, 6, 44)) +>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8)) +>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19)) +>path : Symbol(path, Decl(deeplyNestedCheck.ts, 7, 27)) +>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8)) +>Snapshot : Symbol(Snapshot, Decl(deeplyNestedCheck.ts, 4, 1)) +>T : Symbol(T, Decl(deeplyNestedCheck.ts, 6, 19)) +>U : Symbol(U, Decl(deeplyNestedCheck.ts, 7, 8)) +} + diff --git a/tests/baselines/reference/deeplyNestedCheck.types b/tests/baselines/reference/deeplyNestedCheck.types new file mode 100644 index 00000000000..e500fc75ed1 --- /dev/null +++ b/tests/baselines/reference/deeplyNestedCheck.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/deeplyNestedCheck.ts === +// Repro from #14794 + +interface DataSnapshot { +>DataSnapshot : DataSnapshot +>X : X + + child(path: string): DataSnapshot; +>child : (path: string) => DataSnapshot<{}> +>path : string +>DataSnapshot : DataSnapshot +} + +interface Snapshot extends DataSnapshot { +>Snapshot : Snapshot +>T : T +>DataSnapshot : DataSnapshot + + child(path: U): Snapshot; +>child : (path: U) => Snapshot +>U : U +>T : T +>path : U +>U : U +>Snapshot : Snapshot +>T : T +>U : U +} + From 8915cb9a0f5f12c03ddb054ab20f4a5eb00bbc7a Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 23 Mar 2017 13:36:38 -0700 Subject: [PATCH 174/207] Split signature factory methods --- src/compiler/factory.ts | 63 ++++++++++++++++++++++++------- src/compiler/visitor.ts | 35 ++++++++++++----- src/services/codefixes/helpers.ts | 8 ++-- 3 files changed, 79 insertions(+), 27 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 0ae42459709..0d2dee8cfdc 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -378,28 +378,65 @@ namespace ts { } // TODO: Split according to AST nodes. - export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): T; - export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): T; - export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name?: string | PropertyName, questionToken?: QuestionToken): T { - const signatureDeclaration = createSynthesizedNode(kind) as T; + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + const signatureDeclaration = createSynthesizedNode(kind) as SignatureDeclaration; signatureDeclaration.typeParameters = asNodeArray(typeParameters); signatureDeclaration.parameters = asNodeArray(parameters); signatureDeclaration.type = type; - signatureDeclaration.name = asName(name); - signatureDeclaration.questionToken = questionToken; return signatureDeclaration; } - // TODO: figure out right type annotation for this function. - export function updateSignatureDeclaration(node: T, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T; - export function updateSignatureDeclaration(node: T, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): T; - export function updateSignatureDeclaration(node: T, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name?: PropertyName, questionToken?: QuestionToken): T { + export function updateSignatureDeclaration(node: SignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + + export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode { + return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode; + } + + export function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode { + return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode; + } + export function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration { + return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration; + } + export function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration { + return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration; + } + export function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature{ + const methodSignature = createSignatureDeclaration(SyntaxKind.MethodSignature, typeParameters, parameters, type) as MethodSignature; + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + + export function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name?: PropertyName, questionToken?: QuestionToken): MethodSignature { return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.name !== name || node.questionToken !== questionToken - ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type, name, questionToken), node) + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) : node; } @@ -502,7 +539,7 @@ namespace ts { : node; } - export function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + export function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.MethodDeclaration); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -525,7 +562,7 @@ namespace ts { || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) + ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 57de104b0ca..e6df9c211e7 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -260,21 +260,36 @@ namespace ts { // Signatures and Signature Elements case SyntaxKind.FunctionType: + return updateFunctionTypeNode(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.ConstructorType: + return updateConstructorTypeNode(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.CallSignature: + return updateCallSignatureDeclaration(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.ConstructSignature: - return updateSignatureDeclaration(node, - nodesVisitor((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode)); + return updateConstructSignatureDeclaration(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.MethodSignature: - return updateSignatureDeclaration(node, - nodesVisitor((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode), - visitNode((node).name, visitor, isPropertyName), - visitNode((node).questionToken, tokenVisitor, isToken)); + return updateMethodSignature(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, tokenVisitor, isToken)); case SyntaxKind.IndexSignature: return updateIndexSignatureDeclaration(node, diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index da729215087..0000bd97c56 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -100,7 +100,7 @@ namespace ts.codefix { if (declarations.length === 1) { Debug.assert(signatures.length === 1); const signature = signatures[0]; - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration) as MethodDeclaration; + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -111,7 +111,7 @@ namespace ts.codefix { let signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { const signature = signatures[i]; - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration) as MethodDeclaration; + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -120,7 +120,7 @@ namespace ts.codefix { if (declarations.length > signatures.length) { let signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration) as MethodDeclaration; + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -197,7 +197,7 @@ namespace ts.codefix { } export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { - return createMethod( + return createMethodDeclaration( /*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, From ee7e9fc502ec45f93812ab0f4844a9765d7149a7 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 23 Mar 2017 14:00:49 -0700 Subject: [PATCH 175/207] handle todo's --- src/compiler/checker.ts | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f996f738f12..e98ac3be4dc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2257,7 +2257,7 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.BooleanKeyword); } if (type.flags & TypeFlags.Enum) { - const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (type.flags & (TypeFlags.StringLiteral)) { @@ -2270,7 +2270,7 @@ namespace ts { return (type).intrinsicName === "true" ? createTrue() : createFalse(); } if (type.flags & TypeFlags.EnumLiteral) { - const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (type.flags & TypeFlags.Void) { @@ -2306,18 +2306,18 @@ namespace ts { } if (objectFlags & ObjectFlags.ClassOrInterface) { Debug.assert(!!(type.flags & TypeFlags.Object)); - const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); // TODO(aozgaa): handle type arguments. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (type.flags & TypeFlags.TypeParameter) { - const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } if (checkAlias && type.aliasSymbol) { - const name = symbolToName(type.aliasSymbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const name = symbolToName(type.aliasSymbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); return createTypeReferenceNode(name, typeArgumentNodes); } @@ -2381,7 +2381,7 @@ namespace ts { const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - const entityName = symbolToName(typeAlias, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const entityName = symbolToName(typeAlias, enclosingDeclaration, /*expectsIdentifier*/ false, flags); return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); } else { @@ -2452,7 +2452,7 @@ namespace ts { function createTypeQueryNodeFromType(type: Type) { const symbol = type.symbol; if (symbol) { - const entityName = symbolToName(symbol, enclosingDeclaration, /*mustBeIdentifier*/ false, flags); + const entityName = symbolToName(symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); return createTypeQueryNode(entityName); } } @@ -2482,7 +2482,7 @@ namespace ts { // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const qualifiedNamePart = symbolToName(parent, enclosingDeclaration, /*mustBeIdentifier*/ true, flags); + const qualifiedNamePart = symbolToName(parent, enclosingDeclaration, /*expectsIdentifier*/ true, flags); if (!qualifiedName) { qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); } @@ -2495,7 +2495,7 @@ namespace ts { } } let entityName: EntityName = undefined; - const nameIdentifier = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true, flags); + const nameIdentifier = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ true, flags); if (qualifiedName) { Debug.assert(!qualifiedName.right); qualifiedName.right = nameIdentifier; @@ -2606,7 +2606,7 @@ namespace ts { const constraintNode = constraint && typeToTypeNodeHelper(constraint, enclosingDeclaration, flags); const defaultParameter = getDefaultFromTypeParameter(type); const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, enclosingDeclaration, flags); - const name = symbolToName(type.symbol, enclosingDeclaration, /*mustBeIdentifier*/ true, flags); + const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ true, flags); return createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); } @@ -2627,19 +2627,17 @@ namespace ts { return parameterNode; } - function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: true, flags: NodeBuilderFlags): Identifier; - function symbolToName(symbol: Symbol, enclosingDeclaration: Node, mustBeIdentifier: false, flags: NodeBuilderFlags): EntityName; - function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, mustBeIdentifier: boolean, flags: NodeBuilderFlags): EntityName { + function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: true, flags: NodeBuilderFlags): Identifier; + function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: false, flags: NodeBuilderFlags): EntityName; + function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: boolean, flags: NodeBuilderFlags): EntityName { let parentSymbol: Symbol; let meaning: SymbolFlags; - // Get qualified name if the symbol is not a type parameter - // and there is an enclosing declaration. + // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. let chain: Symbol[]; const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; if (!isTypeParameter && enclosingDeclaration) { chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); - // TODO(aozgaa): check whether type pointed to by symbol requires type arguments to be printed. Debug.assert(chain && chain.length > 0); } else { @@ -2647,10 +2645,8 @@ namespace ts { } parentSymbol = undefined; - if (mustBeIdentifier && chain.length !== 1) { + if (expectsIdentifier && chain.length !== 1) { encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier); - // TODO(aozgaa): failing to get an identifier when we expect one generates an unprintable node. - // Should error handling be more severe? } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -2660,7 +2656,6 @@ namespace ts { const symbol = chain[index]; let typeParameterString = ""; if (index > 0) { - // TODO(aozgaa): is the parentSymbol wrong? const parentSymbol = chain[index - 1]; let typeParameters: TypeParameter[]; if (getCheckFlags(symbol) & CheckFlags.Instantiated) { From 5421812f1e1f3f926e01fd3bcd3a36aef75accad Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Thu, 23 Mar 2017 16:54:13 -0700 Subject: [PATCH 176/207] build builder --- src/compiler/checker.ts | 72 ++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b02b33e56ba..9dd1fda7f53 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -61,7 +61,7 @@ namespace ts { const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; const emitResolver = createResolver(); - let nodeBuilderCache: NodeBuilder | undefined; + const nodeBuilder = getNodeBuilder(); const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined"); undefinedSymbol.declarations = []; @@ -107,9 +107,9 @@ namespace ts { getParameterType: getTypeAtPosition, getReturnTypeOfSignature, getNonNullableType, - typeToTypeNode: getNodeBuilder().typeToTypeNode, - indexInfoToIndexSignatureDeclaration: getNodeBuilder().indexInfoToIndexSignatureDeclaration, - signatureToSignatureDeclaration: getNodeBuilder().signatureToSignatureDeclaration, + typeToTypeNode: nodeBuilder.typeToTypeNode, + indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, getSymbolsInScope: (location, meaning) => { location = getParseTreeNode(location); return location ? getSymbolsInScope(location, meaning) : []; @@ -2203,43 +2203,36 @@ namespace ts { } function getNodeBuilder(): NodeBuilder { - if (nodeBuilderCache) { - return nodeBuilderCache; - } let encounteredError = false; - nodeBuilderCache = { - typeToTypeNode, - indexInfoToIndexSignatureDeclaration, - signatureToSignatureDeclaration + return { + typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { + Debug.assert(encounteredError === false, "Nested call into nodeBuilder are forbidden."); + encounteredError = false; + const resultingNode = typeToTypeNodeHelper(type, enclosingDeclaration, flags); + const result = encounteredError ? undefined : resultingNode; + encounteredError = false; + return result; + }, + indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { + Debug.assert(encounteredError === false, "Nested call into nodeBuilder are forbidden."); + encounteredError = false; + const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, enclosingDeclaration, flags) + const result = encounteredError ? undefined : resultingNode; + encounteredError = false; + return result; + }, + signatureToSignatureDeclaration: (signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { + Debug.assert(encounteredError === false, "Nested call into nodeBuilder are forbidden."); + encounteredError = false; + const resultingNode = signatureToSignatureDeclarationHelper(signature, kind, enclosingDeclaration, flags); + const result = encounteredError ? undefined : resultingNode; + encounteredError = false; + return result; + } }; - return nodeBuilderCache; - - function typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode { - const helper = () => typeToTypeNodeHelper(type, enclosingDeclaration, flags); - return callHelperWithErrorHandling(helper); - } - - function indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration { - const helper = () => indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, enclosingDeclaration, flags); - return callHelperWithErrorHandling(helper); - } - - function signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration { - const helper = () => signatureToSignatureDeclarationHelper(signature, kind, enclosingDeclaration, flags); - return callHelperWithErrorHandling(helper); - } - - function callHelperWithErrorHandling(nodeBuilderHelper: () => T): T | undefined { - const encounteredErrorCache = encounteredError; - const resultingNode = nodeBuilderHelper(); - const result = encounteredError ? undefined : resultingNode; - encounteredError = encounteredErrorCache; - return result; - } - function typeToTypeNodeHelper(type: Type, enclosingDeclaration: Node, flags: NodeBuilderFlags): TypeNode { let inObjectTypeLiteral = false; let checkAlias = true; @@ -2597,13 +2590,12 @@ namespace ts { const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, enclosingDeclaration, flags)); const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, enclosingDeclaration, flags)); - const type = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); + const returnTypeNode = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); - return createSignatureDeclaration(kind, typeParameters, parameters, type); + return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode); function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { - // Note, this call will *not* mark encounteredError. - const typeNode = typeToTypeNode(type, enclosingDeclaration); + const typeNode = type && typeToTypeNodeHelper(type, enclosingDeclaration, flags); return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; } } From ed1d5f45ca0ca1fce9a0829d4aac46fee4cdce65 Mon Sep 17 00:00:00 2001 From: rbuckton Date: Thu, 23 Mar 2017 19:16:00 -0700 Subject: [PATCH 177/207] Type parameter default is 'any' in js files --- src/compiler/checker.ts | 35 +-- .../reference/genericDefaultsJs.symbols | 226 ++++++++++++++++ .../reference/genericDefaultsJs.types | 254 ++++++++++++++++++ tests/cases/compiler/genericDefaultsJs.ts | 80 ++++++ 4 files changed, 579 insertions(+), 16 deletions(-) create mode 100644 tests/baselines/reference/genericDefaultsJs.symbols create mode 100644 tests/baselines/reference/genericDefaultsJs.types create mode 100644 tests/cases/compiler/genericDefaultsJs.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 24ca7da87c4..86193a58077 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3993,14 +3993,15 @@ namespace ts { return getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { + function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[], location: Node): Signature[] { const typeArgCount = length(typeArgumentNodes); + const isJavaScript = isInJavaScriptFile(location); return filter(getSignaturesOfType(type, SignatureKind.Construct), - sig => typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= length(sig.typeParameters)); + sig => (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= length(sig.typeParameters)); } - function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[]): Signature[] { - let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: TypeNode[], location: Node): Signature[] { + let signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); if (typeArgumentNodes) { const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); signatures = map(signatures, sig => getSignatureInstantiation(sig, typeArguments)); @@ -4083,7 +4084,7 @@ namespace ts { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere // we check that all instantiated signatures return the same type. - const constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments); + const constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { error(baseTypeNode.expression, Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -4593,14 +4594,15 @@ namespace ts { return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } const baseTypeNode = getBaseTypeNodeOfClass(classType); + const isJavaScript = isInJavaScriptFile(baseTypeNode); const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); const typeArgCount = length(typeArguments); const result: Signature[] = []; for (const baseSig of baseSignatures) { const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); const typeParamCount = length(baseSig.typeParameters); - if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { - const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); + if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { + const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -5433,11 +5435,12 @@ namespace ts { * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number) { + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, location?: Node) { const numTypeParameters = length(typeParameters); if (numTypeParameters) { const numTypeArguments = length(typeArguments); - if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + const isJavaScript = isInJavaScriptFile(location); + if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; } @@ -5446,12 +5449,12 @@ namespace ts { // If a type parameter does not have a default type, or if the default type // is a forward reference, the empty object type is used. for (let i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = emptyObjectType; + typeArguments[i] = isJavaScript ? anyType : emptyObjectType; } for (let i = numTypeArguments; i < numTypeParameters; i++) { const mapper = createTypeMapper(typeParameters, typeArguments); const defaultType = getDefaultFromTypeParameter(typeParameters[i]); - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : isJavaScript ? anyType : emptyObjectType; } } } @@ -5825,7 +5828,7 @@ namespace ts { if (typeParameters) { const numTypeArguments = length(node.typeArguments); const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + if (!isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? Diagnostics.Generic_type_0_requires_1_type_argument_s @@ -5838,7 +5841,7 @@ namespace ts { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -14481,7 +14484,7 @@ namespace ts { // with the type arguments specified in the extends clause. const baseTypeNode = getClassExtendsHeritageClauseElement(getContainingClass(node)); if (baseTypeNode) { - const baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + const baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); } } @@ -19595,7 +19598,7 @@ namespace ts { checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { forEach(baseTypeNode.typeArguments, checkSourceElement); - for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments)) { + for (const constructor of getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode)) { if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; } @@ -19613,7 +19616,7 @@ namespace ts { // that all instantiated base constructor signatures return the same type. We can simply compare the type // references (as opposed to checking the structure of the types) because elsewhere we have already checked // that the base type is a class or interface type (and not, for example, an anonymous object type). - const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + const constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); if (forEach(constructors, sig => getReturnTypeOfSignature(sig) !== baseType)) { error(baseTypeNode.expression, Diagnostics.Base_constructors_must_all_have_the_same_return_type); } diff --git a/tests/baselines/reference/genericDefaultsJs.symbols b/tests/baselines/reference/genericDefaultsJs.symbols new file mode 100644 index 00000000000..633e4cc8fe9 --- /dev/null +++ b/tests/baselines/reference/genericDefaultsJs.symbols @@ -0,0 +1,226 @@ +=== tests/cases/compiler/decls.d.ts === +declare function f0(x?: T): T; +>f0 : Symbol(f0, Decl(decls.d.ts, 0, 0)) +>T : Symbol(T, Decl(decls.d.ts, 0, 20)) +>x : Symbol(x, Decl(decls.d.ts, 0, 23)) +>T : Symbol(T, Decl(decls.d.ts, 0, 20)) +>T : Symbol(T, Decl(decls.d.ts, 0, 20)) + +declare function f1(x?: T): [T, U]; +>f1 : Symbol(f1, Decl(decls.d.ts, 0, 33)) +>T : Symbol(T, Decl(decls.d.ts, 1, 20)) +>U : Symbol(U, Decl(decls.d.ts, 1, 22)) +>x : Symbol(x, Decl(decls.d.ts, 1, 35)) +>T : Symbol(T, Decl(decls.d.ts, 1, 20)) +>T : Symbol(T, Decl(decls.d.ts, 1, 20)) +>U : Symbol(U, Decl(decls.d.ts, 1, 22)) + +declare class C0 { +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) +>T : Symbol(T, Decl(decls.d.ts, 2, 17)) + + y: T; +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>T : Symbol(T, Decl(decls.d.ts, 2, 17)) + + constructor(x?: T); +>x : Symbol(x, Decl(decls.d.ts, 4, 16)) +>T : Symbol(T, Decl(decls.d.ts, 2, 17)) +} +declare class C1 { +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) +>T : Symbol(T, Decl(decls.d.ts, 6, 17)) +>U : Symbol(U, Decl(decls.d.ts, 6, 19)) + + y: [T, U]; +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>T : Symbol(T, Decl(decls.d.ts, 6, 17)) +>U : Symbol(U, Decl(decls.d.ts, 6, 19)) + + constructor(x?: T); +>x : Symbol(x, Decl(decls.d.ts, 8, 16)) +>T : Symbol(T, Decl(decls.d.ts, 6, 17)) +} +=== tests/cases/compiler/main.js === +const f0_v0 = f0(); +>f0_v0 : Symbol(f0_v0, Decl(main.js, 0, 5)) +>f0 : Symbol(f0, Decl(decls.d.ts, 0, 0)) + +const f0_v1 = f0(1); +>f0_v1 : Symbol(f0_v1, Decl(main.js, 1, 5)) +>f0 : Symbol(f0, Decl(decls.d.ts, 0, 0)) + +const f1_c0 = f1(); +>f1_c0 : Symbol(f1_c0, Decl(main.js, 3, 5)) +>f1 : Symbol(f1, Decl(decls.d.ts, 0, 33)) + +const f1_c1 = f1(1); +>f1_c1 : Symbol(f1_c1, Decl(main.js, 4, 5)) +>f1 : Symbol(f1, Decl(decls.d.ts, 0, 33)) + +const C0_v0 = new C0(); +>C0_v0 : Symbol(C0_v0, Decl(main.js, 6, 5)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + +const C0_v0_y = C0_v0.y; +>C0_v0_y : Symbol(C0_v0_y, Decl(main.js, 7, 5)) +>C0_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_v0 : Symbol(C0_v0, Decl(main.js, 6, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_v1 = new C0(1); +>C0_v1 : Symbol(C0_v1, Decl(main.js, 9, 5)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + +const C0_v1_y = C0_v1.y; +>C0_v1_y : Symbol(C0_v1_y, Decl(main.js, 10, 5)) +>C0_v1.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_v1 : Symbol(C0_v1, Decl(main.js, 9, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C1_v0 = new C1(); +>C1_v0 : Symbol(C1_v0, Decl(main.js, 12, 5)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + +const C1_v0_y = C1_v0.y; +>C1_v0_y : Symbol(C1_v0_y, Decl(main.js, 13, 5)) +>C1_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_v0 : Symbol(C1_v0, Decl(main.js, 12, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_v1 = new C1(1); +>C1_v1 : Symbol(C1_v1, Decl(main.js, 15, 5)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + +const C1_v1_y = C1_v1.y; +>C1_v1_y : Symbol(C1_v1_y, Decl(main.js, 16, 5)) +>C1_v1.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_v1 : Symbol(C1_v1, Decl(main.js, 15, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +class C0_B0 extends C0 {} +>C0_B0 : Symbol(C0_B0, Decl(main.js, 16, 24)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + +class C0_B1 extends C0 { +>C0_B1 : Symbol(C0_B1, Decl(main.js, 18, 25)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + + constructor() { + super(); +>super : Symbol(C0, Decl(decls.d.ts, 1, 50)) + } +} +class C0_B2 extends C0 { +>C0_B2 : Symbol(C0_B2, Decl(main.js, 23, 1)) +>C0 : Symbol(C0, Decl(decls.d.ts, 1, 50)) + + constructor() { + super(1); +>super : Symbol(C0, Decl(decls.d.ts, 1, 50)) + } +} + +const C0_B0_v0 = new C0_B0(); +>C0_B0_v0 : Symbol(C0_B0_v0, Decl(main.js, 30, 5)) +>C0_B0 : Symbol(C0_B0, Decl(main.js, 16, 24)) + +const C0_B0_v0_y = C0_B0_v0.y; +>C0_B0_v0_y : Symbol(C0_B0_v0_y, Decl(main.js, 31, 5)) +>C0_B0_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B0_v0 : Symbol(C0_B0_v0, Decl(main.js, 30, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_B0_v1 = new C0_B0(1); +>C0_B0_v1 : Symbol(C0_B0_v1, Decl(main.js, 33, 5)) +>C0_B0 : Symbol(C0_B0, Decl(main.js, 16, 24)) + +const C0_B0_v1_y = C0_B0_v1.y; +>C0_B0_v1_y : Symbol(C0_B0_v1_y, Decl(main.js, 34, 5)) +>C0_B0_v1.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B0_v1 : Symbol(C0_B0_v1, Decl(main.js, 33, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_B1_v0 = new C0_B1(); +>C0_B1_v0 : Symbol(C0_B1_v0, Decl(main.js, 36, 5)) +>C0_B1 : Symbol(C0_B1, Decl(main.js, 18, 25)) + +const C0_B1_v0_y = C0_B1_v0.y; +>C0_B1_v0_y : Symbol(C0_B1_v0_y, Decl(main.js, 37, 5)) +>C0_B1_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B1_v0 : Symbol(C0_B1_v0, Decl(main.js, 36, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +const C0_B2_v0 = new C0_B2(); +>C0_B2_v0 : Symbol(C0_B2_v0, Decl(main.js, 39, 5)) +>C0_B2 : Symbol(C0_B2, Decl(main.js, 23, 1)) + +const C0_B2_v0_y = C0_B2_v0.y; +>C0_B2_v0_y : Symbol(C0_B2_v0_y, Decl(main.js, 40, 5)) +>C0_B2_v0.y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) +>C0_B2_v0 : Symbol(C0_B2_v0, Decl(main.js, 39, 5)) +>y : Symbol(C0.y, Decl(decls.d.ts, 2, 21)) + +class C1_B0 extends C1 {} +>C1_B0 : Symbol(C1_B0, Decl(main.js, 40, 30)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + +class C1_B1 extends C1 { +>C1_B1 : Symbol(C1_B1, Decl(main.js, 42, 25)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + + constructor() { + super(); +>super : Symbol(C1, Decl(decls.d.ts, 5, 1)) + } +} +class C1_B2 extends C1 { +>C1_B2 : Symbol(C1_B2, Decl(main.js, 47, 1)) +>C1 : Symbol(C1, Decl(decls.d.ts, 5, 1)) + + constructor() { + super(1); +>super : Symbol(C1, Decl(decls.d.ts, 5, 1)) + } +} + +const C1_B0_v0 = new C1_B0(); +>C1_B0_v0 : Symbol(C1_B0_v0, Decl(main.js, 54, 5)) +>C1_B0 : Symbol(C1_B0, Decl(main.js, 40, 30)) + +const C1_B0_v0_y = C1_B0_v0.y; +>C1_B0_v0_y : Symbol(C1_B0_v0_y, Decl(main.js, 55, 5)) +>C1_B0_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B0_v0 : Symbol(C1_B0_v0, Decl(main.js, 54, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_B0_v1 = new C1_B0(1); +>C1_B0_v1 : Symbol(C1_B0_v1, Decl(main.js, 57, 5)) +>C1_B0 : Symbol(C1_B0, Decl(main.js, 40, 30)) + +const C1_B0_v1_y = C1_B0_v1.y; +>C1_B0_v1_y : Symbol(C1_B0_v1_y, Decl(main.js, 58, 5)) +>C1_B0_v1.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B0_v1 : Symbol(C1_B0_v1, Decl(main.js, 57, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_B1_v0 = new C1_B1(); +>C1_B1_v0 : Symbol(C1_B1_v0, Decl(main.js, 60, 5)) +>C1_B1 : Symbol(C1_B1, Decl(main.js, 42, 25)) + +const C1_B1_v0_y = C1_B1_v0.y; +>C1_B1_v0_y : Symbol(C1_B1_v0_y, Decl(main.js, 61, 5)) +>C1_B1_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B1_v0 : Symbol(C1_B1_v0, Decl(main.js, 60, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + +const C1_B2_v0 = new C1_B2(); +>C1_B2_v0 : Symbol(C1_B2_v0, Decl(main.js, 63, 5)) +>C1_B2 : Symbol(C1_B2, Decl(main.js, 47, 1)) + +const C1_B2_v0_y = C1_B2_v0.y; +>C1_B2_v0_y : Symbol(C1_B2_v0_y, Decl(main.js, 64, 5)) +>C1_B2_v0.y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) +>C1_B2_v0 : Symbol(C1_B2_v0, Decl(main.js, 63, 5)) +>y : Symbol(C1.y, Decl(decls.d.ts, 6, 33)) + diff --git a/tests/baselines/reference/genericDefaultsJs.types b/tests/baselines/reference/genericDefaultsJs.types new file mode 100644 index 00000000000..3275e757d79 --- /dev/null +++ b/tests/baselines/reference/genericDefaultsJs.types @@ -0,0 +1,254 @@ +=== tests/cases/compiler/decls.d.ts === +declare function f0(x?: T): T; +>f0 : (x?: T) => T +>T : T +>x : T +>T : T +>T : T + +declare function f1(x?: T): [T, U]; +>f1 : (x?: T) => [T, U] +>T : T +>U : U +>x : T +>T : T +>T : T +>U : U + +declare class C0 { +>C0 : C0 +>T : T + + y: T; +>y : T +>T : T + + constructor(x?: T); +>x : T +>T : T +} +declare class C1 { +>C1 : C1 +>T : T +>U : U + + y: [T, U]; +>y : [T, U] +>T : T +>U : U + + constructor(x?: T); +>x : T +>T : T +} +=== tests/cases/compiler/main.js === +const f0_v0 = f0(); +>f0_v0 : any +>f0() : any +>f0 : (x?: T) => T + +const f0_v1 = f0(1); +>f0_v1 : 1 +>f0(1) : 1 +>f0 : (x?: T) => T +>1 : 1 + +const f1_c0 = f1(); +>f1_c0 : [any, number] +>f1() : [any, number] +>f1 : (x?: T) => [T, U] + +const f1_c1 = f1(1); +>f1_c1 : [number, number] +>f1(1) : [number, number] +>f1 : (x?: T) => [T, U] +>1 : 1 + +const C0_v0 = new C0(); +>C0_v0 : C0 +>new C0() : C0 +>C0 : typeof C0 + +const C0_v0_y = C0_v0.y; +>C0_v0_y : any +>C0_v0.y : any +>C0_v0 : C0 +>y : any + +const C0_v1 = new C0(1); +>C0_v1 : C0 +>new C0(1) : C0 +>C0 : typeof C0 +>1 : 1 + +const C0_v1_y = C0_v1.y; +>C0_v1_y : number +>C0_v1.y : number +>C0_v1 : C0 +>y : number + +const C1_v0 = new C1(); +>C1_v0 : C1 +>new C1() : C1 +>C1 : typeof C1 + +const C1_v0_y = C1_v0.y; +>C1_v0_y : [any, number] +>C1_v0.y : [any, number] +>C1_v0 : C1 +>y : [any, number] + +const C1_v1 = new C1(1); +>C1_v1 : C1 +>new C1(1) : C1 +>C1 : typeof C1 +>1 : 1 + +const C1_v1_y = C1_v1.y; +>C1_v1_y : [number, number] +>C1_v1.y : [number, number] +>C1_v1 : C1 +>y : [number, number] + +class C0_B0 extends C0 {} +>C0_B0 : C0_B0 +>C0 : C0 + +class C0_B1 extends C0 { +>C0_B1 : C0_B1 +>C0 : C0 + + constructor() { + super(); +>super() : void +>super : typeof C0 + } +} +class C0_B2 extends C0 { +>C0_B2 : C0_B2 +>C0 : C0 + + constructor() { + super(1); +>super(1) : void +>super : typeof C0 +>1 : 1 + } +} + +const C0_B0_v0 = new C0_B0(); +>C0_B0_v0 : C0_B0 +>new C0_B0() : C0_B0 +>C0_B0 : typeof C0_B0 + +const C0_B0_v0_y = C0_B0_v0.y; +>C0_B0_v0_y : any +>C0_B0_v0.y : any +>C0_B0_v0 : C0_B0 +>y : any + +const C0_B0_v1 = new C0_B0(1); +>C0_B0_v1 : C0_B0 +>new C0_B0(1) : C0_B0 +>C0_B0 : typeof C0_B0 +>1 : 1 + +const C0_B0_v1_y = C0_B0_v1.y; +>C0_B0_v1_y : any +>C0_B0_v1.y : any +>C0_B0_v1 : C0_B0 +>y : any + +const C0_B1_v0 = new C0_B1(); +>C0_B1_v0 : C0_B1 +>new C0_B1() : C0_B1 +>C0_B1 : typeof C0_B1 + +const C0_B1_v0_y = C0_B1_v0.y; +>C0_B1_v0_y : any +>C0_B1_v0.y : any +>C0_B1_v0 : C0_B1 +>y : any + +const C0_B2_v0 = new C0_B2(); +>C0_B2_v0 : C0_B2 +>new C0_B2() : C0_B2 +>C0_B2 : typeof C0_B2 + +const C0_B2_v0_y = C0_B2_v0.y; +>C0_B2_v0_y : any +>C0_B2_v0.y : any +>C0_B2_v0 : C0_B2 +>y : any + +class C1_B0 extends C1 {} +>C1_B0 : C1_B0 +>C1 : C1 + +class C1_B1 extends C1 { +>C1_B1 : C1_B1 +>C1 : C1 + + constructor() { + super(); +>super() : void +>super : typeof C1 + } +} +class C1_B2 extends C1 { +>C1_B2 : C1_B2 +>C1 : C1 + + constructor() { + super(1); +>super(1) : void +>super : typeof C1 +>1 : 1 + } +} + +const C1_B0_v0 = new C1_B0(); +>C1_B0_v0 : C1_B0 +>new C1_B0() : C1_B0 +>C1_B0 : typeof C1_B0 + +const C1_B0_v0_y = C1_B0_v0.y; +>C1_B0_v0_y : [any, number] +>C1_B0_v0.y : [any, number] +>C1_B0_v0 : C1_B0 +>y : [any, number] + +const C1_B0_v1 = new C1_B0(1); +>C1_B0_v1 : C1_B0 +>new C1_B0(1) : C1_B0 +>C1_B0 : typeof C1_B0 +>1 : 1 + +const C1_B0_v1_y = C1_B0_v1.y; +>C1_B0_v1_y : [any, number] +>C1_B0_v1.y : [any, number] +>C1_B0_v1 : C1_B0 +>y : [any, number] + +const C1_B1_v0 = new C1_B1(); +>C1_B1_v0 : C1_B1 +>new C1_B1() : C1_B1 +>C1_B1 : typeof C1_B1 + +const C1_B1_v0_y = C1_B1_v0.y; +>C1_B1_v0_y : [any, number] +>C1_B1_v0.y : [any, number] +>C1_B1_v0 : C1_B1 +>y : [any, number] + +const C1_B2_v0 = new C1_B2(); +>C1_B2_v0 : C1_B2 +>new C1_B2() : C1_B2 +>C1_B2 : typeof C1_B2 + +const C1_B2_v0_y = C1_B2_v0.y; +>C1_B2_v0_y : [any, number] +>C1_B2_v0.y : [any, number] +>C1_B2_v0 : C1_B2 +>y : [any, number] + diff --git a/tests/cases/compiler/genericDefaultsJs.ts b/tests/cases/compiler/genericDefaultsJs.ts new file mode 100644 index 00000000000..6aa3640d961 --- /dev/null +++ b/tests/cases/compiler/genericDefaultsJs.ts @@ -0,0 +1,80 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true +// @filename: decls.d.ts +declare function f0(x?: T): T; +declare function f1(x?: T): [T, U]; +declare class C0 { + y: T; + constructor(x?: T); +} +declare class C1 { + y: [T, U]; + constructor(x?: T); +} +// @filename: main.js +const f0_v0 = f0(); +const f0_v1 = f0(1); + +const f1_c0 = f1(); +const f1_c1 = f1(1); + +const C0_v0 = new C0(); +const C0_v0_y = C0_v0.y; + +const C0_v1 = new C0(1); +const C0_v1_y = C0_v1.y; + +const C1_v0 = new C1(); +const C1_v0_y = C1_v0.y; + +const C1_v1 = new C1(1); +const C1_v1_y = C1_v1.y; + +class C0_B0 extends C0 {} +class C0_B1 extends C0 { + constructor() { + super(); + } +} +class C0_B2 extends C0 { + constructor() { + super(1); + } +} + +const C0_B0_v0 = new C0_B0(); +const C0_B0_v0_y = C0_B0_v0.y; + +const C0_B0_v1 = new C0_B0(1); +const C0_B0_v1_y = C0_B0_v1.y; + +const C0_B1_v0 = new C0_B1(); +const C0_B1_v0_y = C0_B1_v0.y; + +const C0_B2_v0 = new C0_B2(); +const C0_B2_v0_y = C0_B2_v0.y; + +class C1_B0 extends C1 {} +class C1_B1 extends C1 { + constructor() { + super(); + } +} +class C1_B2 extends C1 { + constructor() { + super(1); + } +} + +const C1_B0_v0 = new C1_B0(); +const C1_B0_v0_y = C1_B0_v0.y; + +const C1_B0_v1 = new C1_B0(1); +const C1_B0_v1_y = C1_B0_v1.y; + +const C1_B1_v0 = new C1_B1(); +const C1_B1_v0_y = C1_B1_v0.y; + +const C1_B2_v0 = new C1_B2(); +const C1_B2_v0_y = C1_B2_v0.y; From 6b5330f3432bc35dfb19963bfdc3cc317e495fdd Mon Sep 17 00:00:00 2001 From: Vadi Taslim Date: Fri, 24 Mar 2017 12:39:36 +0800 Subject: [PATCH 178/207] Bug fix for issue #14696, things changed are; - Empty class type will now throw an error, - Trailing comma in class type will also throw an error, - Added tests for empty class type parameter, - Updated tests for class type parameters with trailing comma This behavior is consistently following function or method like when its type parameter is either empty or has trailing comma. --- src/compiler/checker.ts | 7 ++++++- .../reference/classWithEmptyTypeParameter.errors.txt | 8 ++++++++ .../baselines/reference/classWithEmptyTypeParameter.js | 10 ++++++++++ .../typeParameterListWithTrailingComma1.errors.txt | 8 ++++++++ tests/cases/compiler/classWithEmptyTypeParameter.ts | 2 ++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/classWithEmptyTypeParameter.errors.txt create mode 100644 tests/baselines/reference/classWithEmptyTypeParameter.js create mode 100644 tests/baselines/reference/typeParameterListWithTrailingComma1.errors.txt create mode 100644 tests/cases/compiler/classWithEmptyTypeParameter.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70cbda14f6d..448a15e513b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19559,7 +19559,7 @@ namespace ts { } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { - checkGrammarClassDeclarationHeritageClauses(node); + checkGrammarClassLikeDeclaration(node); checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0); @@ -22520,6 +22520,11 @@ namespace ts { checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } + function checkGrammarClassLikeDeclaration(node: ClassLikeDeclaration): boolean { + const file = getSourceFileOfNode(node); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); + } + function checkGrammarArrowFunction(node: FunctionLikeDeclaration, file: SourceFile): boolean { if (node.kind === SyntaxKind.ArrowFunction) { const arrowFunction = node; diff --git a/tests/baselines/reference/classWithEmptyTypeParameter.errors.txt b/tests/baselines/reference/classWithEmptyTypeParameter.errors.txt new file mode 100644 index 00000000000..8114bbd7ba0 --- /dev/null +++ b/tests/baselines/reference/classWithEmptyTypeParameter.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/classWithEmptyTypeParameter.ts(1,8): error TS1098: Type parameter list cannot be empty. + + +==== tests/cases/compiler/classWithEmptyTypeParameter.ts (1 errors) ==== + class C<> { + ~~ +!!! error TS1098: Type parameter list cannot be empty. + } \ No newline at end of file diff --git a/tests/baselines/reference/classWithEmptyTypeParameter.js b/tests/baselines/reference/classWithEmptyTypeParameter.js new file mode 100644 index 00000000000..c25ace495b4 --- /dev/null +++ b/tests/baselines/reference/classWithEmptyTypeParameter.js @@ -0,0 +1,10 @@ +//// [classWithEmptyTypeParameter.ts] +class C<> { +} + +//// [classWithEmptyTypeParameter.js] +var C = (function () { + function C() { + } + return C; +}()); diff --git a/tests/baselines/reference/typeParameterListWithTrailingComma1.errors.txt b/tests/baselines/reference/typeParameterListWithTrailingComma1.errors.txt new file mode 100644 index 00000000000..ac20e826969 --- /dev/null +++ b/tests/baselines/reference/typeParameterListWithTrailingComma1.errors.txt @@ -0,0 +1,8 @@ +tests/cases/compiler/typeParameterListWithTrailingComma1.ts(1,10): error TS1009: Trailing comma not allowed. + + +==== tests/cases/compiler/typeParameterListWithTrailingComma1.ts (1 errors) ==== + class C { + ~ +!!! error TS1009: Trailing comma not allowed. + } \ No newline at end of file diff --git a/tests/cases/compiler/classWithEmptyTypeParameter.ts b/tests/cases/compiler/classWithEmptyTypeParameter.ts new file mode 100644 index 00000000000..42541c8e467 --- /dev/null +++ b/tests/cases/compiler/classWithEmptyTypeParameter.ts @@ -0,0 +1,2 @@ +class C<> { +} \ No newline at end of file From 25d8367aaf5b79b5852c80d2387e9809b0e5e377 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Tue, 21 Mar 2017 14:49:20 -0700 Subject: [PATCH 179/207] Suppress semantic errors in JS only configured projects (cherry picked from commit 4ee8bdb762f870351da9be51d13dae6c9328e72f) --- src/server/session.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/server/session.ts b/src/server/session.ts index 8dd0411d077..11c99dfe46c 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -25,8 +25,14 @@ namespace ts.server { return ((1e9 * seconds) + nanoseconds) / 1000000.0; } - function shouldSkipSematicCheck(project: Project) { - return (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) && project.isJsOnlyProject(); + function shouldSkipSemanticCheck(project: Project) { + if (project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) { + return project.isJsOnlyProject(); + } + else { + // For configured projects, require that skipLibCheck be set also + return project.getCompilerOptions().skipLibCheck && project.isJsOnlyProject(); + } } interface FileStart { @@ -447,7 +453,7 @@ namespace ts.server { private semanticCheck(file: NormalizedPath, project: Project) { try { let diags: Diagnostic[] = []; - if (!shouldSkipSematicCheck(project)) { + if (!shouldSkipSemanticCheck(project)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } @@ -555,7 +561,7 @@ namespace ts.server { private getDiagnosticsWorker(args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) { const { project, file } = this.getFileAndProject(args); - if (isSemantic && shouldSkipSematicCheck(project)) { + if (isSemantic && shouldSkipSemanticCheck(project)) { return []; } const scriptInfo = project.getScriptInfoForNormalizedPath(file); From 71e296042aa4495308456d2797837dd543bd450f Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 17 Mar 2017 12:56:31 -0700 Subject: [PATCH 180/207] Apply the 20 MB non-TS source limit across all projects (cherry picked from commit cc8ce5975cbda492834d43ec1b743126a3334df4) (cherry picked from commit de8fb9e8335d9bf34d0bbd5e61fee4df40cb5222) --- src/server/editorServices.ts | 25 +++++++++++++++++++------ src/server/project.ts | 2 +- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 397de9ead30..3252e2114a6 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -254,6 +254,7 @@ namespace ts.server { private compilerOptionsForInferredProjects: CompilerOptions; private compileOnSaveForInferredProjects: boolean; + private readonly projectToSizeMap: Map = createMap(); private readonly directoryWatchers: DirectoryWatchers; private readonly throttledOperations: ThrottledOperations; @@ -563,9 +564,11 @@ namespace ts.server { switch (project.projectKind) { case ProjectKind.External: removeItemFromSet(this.externalProjects, project); + this.projectToSizeMap.delete((project as ExternalProject).externalProjectName); break; case ProjectKind.Configured: removeItemFromSet(this.configuredProjects, project); + this.projectToSizeMap.delete((project as ConfiguredProject).canonicalConfigFilePath); break; case ProjectKind.Inferred: removeItemFromSet(this.inferredProjects, project); @@ -852,10 +855,17 @@ namespace ts.server { return { success: true, projectOptions, configFileErrors: errors }; } - private exceededTotalSizeLimitForNonTsFiles(options: CompilerOptions, fileNames: T[], propertyReader: FilePropertyReader) { + private exceededTotalSizeLimitForNonTsFiles(name: string, options: CompilerOptions, fileNames: T[], propertyReader: FilePropertyReader) { if (options && options.disableSizeLimit || !this.host.getFileSize) { return false; } + + let availableSpace = maxProgramSizeForNonTsFiles; + this.projectToSizeMap.set(name, 0); + this.projectToSizeMap.forEach(size => { + availableSpace -= size; + }); + let totalNonTsFileSize = 0; for (const f of fileNames) { const fileName = propertyReader.getFileName(f); @@ -863,10 +873,13 @@ namespace ts.server { continue; } totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > maxProgramSizeForNonTsFiles) { + if (totalNonTsFileSize > availableSpace) { + this.projectToSizeMap.set(name, totalNonTsFileSize); return true; } } + + this.projectToSizeMap.set(name, totalNonTsFileSize); return false; } @@ -877,7 +890,7 @@ namespace ts.server { this, this.documentRegistry, compilerOptions, - /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), + /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, /*clientFileName*/ undefined, typeAcquisition, /*configFileErrors*/ undefined); @@ -897,7 +910,7 @@ namespace ts.server { } private createAndAddConfiguredProject(configFileName: NormalizedPath, projectOptions: ProjectOptions, configFileErrors: Diagnostic[], clientFileName?: string) { - const sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + const sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); const project = new ConfiguredProject( configFileName, this, @@ -1050,7 +1063,7 @@ namespace ts.server { return configFileErrors; } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { project.setCompilerOptions(projectOptions.compilerOptions); if (!project.languageServiceEnabled) { // language service is already disabled @@ -1414,7 +1427,7 @@ namespace ts.server { if (externalProject) { if (!tsConfigFiles) { const compilerOptions = convertCompilerOptions(proj.options); - if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { externalProject.disableLanguageService(); } else { diff --git a/src/server/project.ts b/src/server/project.ts index 385816b1029..e57e605d65b 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1031,7 +1031,7 @@ namespace ts.server { export class ExternalProject extends Project { private typeAcquisition: TypeAcquisition; - constructor(externalProjectName: string, + constructor(public externalProjectName: string, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, compilerOptions: CompilerOptions, From afbe63ae990577a4d3ce603b4ab78f7095636a29 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 17 Mar 2017 15:36:15 -0700 Subject: [PATCH 181/207] Make compatible with 2.1 maps # Conflicts: # src/server/editorServices.ts # src/server/project.ts (cherry picked from commit 456614f7e0d8ac0f5d420a6caf42f57cf5dda313) (cherry picked from commit be30adc77f450a4871045c48d7d614c196fe37a5) --- src/server/editorServices.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 3252e2114a6..196df1a2cb0 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -564,11 +564,11 @@ namespace ts.server { switch (project.projectKind) { case ProjectKind.External: removeItemFromSet(this.externalProjects, project); - this.projectToSizeMap.delete((project as ExternalProject).externalProjectName); + delete this.projectToSizeMap[(project as ExternalProject).externalProjectName]; break; case ProjectKind.Configured: removeItemFromSet(this.configuredProjects, project); - this.projectToSizeMap.delete((project as ConfiguredProject).canonicalConfigFilePath); + delete this.projectToSizeMap[(project as ConfiguredProject).canonicalConfigFilePath]; break; case ProjectKind.Inferred: removeItemFromSet(this.inferredProjects, project); @@ -861,10 +861,10 @@ namespace ts.server { } let availableSpace = maxProgramSizeForNonTsFiles; - this.projectToSizeMap.set(name, 0); - this.projectToSizeMap.forEach(size => { - availableSpace -= size; - }); + this.projectToSizeMap[name] = 0; + for (const key in this.projectToSizeMap) { + availableSpace -= (this.projectToSizeMap[key] || 0); + } let totalNonTsFileSize = 0; for (const f of fileNames) { @@ -874,12 +874,12 @@ namespace ts.server { } totalNonTsFileSize += this.host.getFileSize(fileName); if (totalNonTsFileSize > availableSpace) { - this.projectToSizeMap.set(name, totalNonTsFileSize); + this.projectToSizeMap[name] = totalNonTsFileSize; return true; } } - this.projectToSizeMap.set(name, totalNonTsFileSize); + this.projectToSizeMap[name] = totalNonTsFileSize; return false; } From d69a18d9d971872fe14341755e1259e988a49117 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 21 Mar 2017 11:37:22 -0700 Subject: [PATCH 182/207] Store the size of the project properly (cherry picked from commit 16c7bcfebbeb8490a86dd994167283414d9d43a0) (cherry picked from commit 8b3c54dbfb04c084061c287a342e7e6ffa0f0612) --- src/server/editorServices.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 196df1a2cb0..5c7dfcae64e 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -873,14 +873,14 @@ namespace ts.server { continue; } totalNonTsFileSize += this.host.getFileSize(fileName); - if (totalNonTsFileSize > availableSpace) { + if (totalNonTsFileSize > maxProgramSizeForNonTsFiles) { this.projectToSizeMap[name] = totalNonTsFileSize; return true; } } this.projectToSizeMap[name] = totalNonTsFileSize; - return false; + return totalNonTsFileSize < availableSpace; } private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typeAcquisition: TypeAcquisition) { From 5b7a099aa6ad568a57347f1cd4c3b0f37979a74a Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 21 Mar 2017 11:41:58 -0700 Subject: [PATCH 183/207] Math (cherry picked from commit 7b17f6affecd6fb5e478607bf43e4cc29edf3f45) (cherry picked from commit 63aeacb83f2c00eef903bb6d2f39d3aa6b72254d) --- src/server/editorServices.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 5c7dfcae64e..1bdf68fe080 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -880,7 +880,7 @@ namespace ts.server { } this.projectToSizeMap[name] = totalNonTsFileSize; - return totalNonTsFileSize < availableSpace; + return totalNonTsFileSize > availableSpace; } private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typeAcquisition: TypeAcquisition) { From 390e63200a85dd52649f7fad509555e3e7117d2d Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 21 Mar 2017 12:08:51 -0700 Subject: [PATCH 184/207] Add unit test (cherry picked from commit ff0947996c03c07a7d2c1d8fdaf25e60dce6039c) (cherry picked from commit c66a5359e2bdc45b0a37941f614dda40661ae2cd) --- .../unittests/tsserverProjectSystem.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 5ea0df91caa..356a7a8962d 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1007,6 +1007,41 @@ namespace ts.projectSystem { checkProjectRootFiles(projectService.configuredProjects[0], [commonFile1.path, commonFile2.path]); }); + it("should disable features when the files are too large", () => { + const file1 = { + path: "/a/b/f1.js", + content: "let x =1;", + fileSize: 10 * 1024 * 1024 + }; + const file2 = { + path: "/a/b/f2.js", + content: "let y =1;", + fileSize: 6 * 1024 * 1024 + }; + const file3 = { + path: "/a/b/f3.js", + content: "let y =1;", + fileSize: 6 * 1024 * 1024 + }; + + const proj1name = "proj1", proj2name = "proj2", proj3name = "proj3"; + + const host = createServerHost([file1, file2, file3]); + const projectService = createProjectService(host); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file1.path]), options: {}, projectFileName: proj1name }); + const proj1 = projectService.findProject(proj1name); + assert.isTrue(proj1.languageServiceEnabled); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file2.path]), options: {}, projectFileName: proj2name }); + const proj2 = projectService.findProject(proj2name); + assert.isTrue(proj2.languageServiceEnabled); + + projectService.openExternalProject({ rootFiles: toExternalFiles([file3.path]), options: {}, projectFileName: proj3name }); + const proj3 = projectService.findProject(proj3name); + assert.isFalse(proj3.languageServiceEnabled); + }); + it("should use only one inferred project if 'useOneInferredProject' is set", () => { const file1 = { path: "/a/b/main.ts", From e5313bda21180a6bad7023e258d7b27b64d9197d Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 21 Mar 2017 13:01:06 -0700 Subject: [PATCH 185/207] Don't add in size of disabled projects (cherry picked from commit 2721a8c8b4fcacc551e68594964ea581b713f83c) (cherry picked from commit 1696df6c9eca388b72b73a1e1897ab9b85080a7e) --- src/server/editorServices.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 1bdf68fe080..c4c299a0675 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -874,7 +874,7 @@ namespace ts.server { } totalNonTsFileSize += this.host.getFileSize(fileName); if (totalNonTsFileSize > maxProgramSizeForNonTsFiles) { - this.projectToSizeMap[name] = totalNonTsFileSize; + // Keep the size as zero since it's disabled return true; } } From eef0505f55b37999d8d37f22dfd4a142b5372950 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 21 Mar 2017 16:02:54 -0700 Subject: [PATCH 186/207] Store diabled projects as 0 (cherry picked from commit e9e7271fc3ab50654cb234c813e46fc90d70a736) (cherry picked from commit 35e77171e98d134c64ae1000d94b1be317879a05) --- src/server/editorServices.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index c4c299a0675..291fa83d602 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -879,8 +879,12 @@ namespace ts.server { } } + if (totalNonTsFileSize > availableSpace) { + return true; + } + this.projectToSizeMap[name] = totalNonTsFileSize; - return totalNonTsFileSize > availableSpace; + return false; } private createAndAddExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typeAcquisition: TypeAcquisition) { From 21c954717c6cdafa2d689f88d63aff572ad5d38d Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Wed, 22 Mar 2017 19:48:20 -0700 Subject: [PATCH 187/207] Changes for Map implementation (cherry picked from commit 8a67b6ddd43bdb33c89c1877d2755b738cb4c4c1) --- src/server/editorServices.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 291fa83d602..8af6fe5d347 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -564,11 +564,11 @@ namespace ts.server { switch (project.projectKind) { case ProjectKind.External: removeItemFromSet(this.externalProjects, project); - delete this.projectToSizeMap[(project as ExternalProject).externalProjectName]; + this.projectToSizeMap.delete((project as ExternalProject).externalProjectName); break; case ProjectKind.Configured: removeItemFromSet(this.configuredProjects, project); - delete this.projectToSizeMap[(project as ConfiguredProject).canonicalConfigFilePath]; + this.projectToSizeMap.delete((project as ConfiguredProject).canonicalConfigFilePath); break; case ProjectKind.Inferred: removeItemFromSet(this.inferredProjects, project); @@ -861,10 +861,8 @@ namespace ts.server { } let availableSpace = maxProgramSizeForNonTsFiles; - this.projectToSizeMap[name] = 0; - for (const key in this.projectToSizeMap) { - availableSpace -= (this.projectToSizeMap[key] || 0); - } + this.projectToSizeMap.set(name, 0); + this.projectToSizeMap.forEach(val => (availableSpace -= (val || 0))); let totalNonTsFileSize = 0; for (const f of fileNames) { @@ -883,7 +881,7 @@ namespace ts.server { return true; } - this.projectToSizeMap[name] = totalNonTsFileSize; + this.projectToSizeMap.set(name, totalNonTsFileSize); return false; } From a7c166c4a5ecea91565c7512aa0ea0b7f0c70efb Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 24 Mar 2017 12:56:54 -0700 Subject: [PATCH 188/207] optional signature --- src/compiler/checker.ts | 4 +- src/services/codefixes/helpers.ts | 41 ++++++++++--------- ...ClassImplementClassMemberAnonymousClass.ts | 9 +--- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9dd1fda7f53..7c5e8153a66 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2218,7 +2218,7 @@ namespace ts { indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { Debug.assert(encounteredError === false, "Nested call into nodeBuilder are forbidden."); encounteredError = false; - const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, enclosingDeclaration, flags) + const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, enclosingDeclaration, flags); const result = encounteredError ? undefined : resultingNode; encounteredError = false; return result; @@ -2568,8 +2568,8 @@ namespace ts { function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node, flags: NodeBuilderFlags): IndexSignatureDeclaration { const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); - const name = getNameFromIndexInfo(indexInfo); + const indexingParameter = createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index d26edbac17a..49f95243c95 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -67,6 +67,7 @@ namespace ts.codefix { const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined; const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); + const optional = !!(symbol.flags & SymbolFlags.Optional); switch (declaration.kind) { case SyntaxKind.GetAccessor: @@ -78,7 +79,7 @@ namespace ts.codefix { /*decorators*/undefined, modifiers, name, - /*questionToken*/ undefined, + optional ? createToken(SyntaxKind.QuestionToken) : undefined, typeNode, /*initializer*/ undefined); return property; @@ -96,36 +97,27 @@ namespace ts.codefix { return undefined; } - const optional = !!(symbol.flags & SymbolFlags.Optional); if (declarations.length === 1) { Debug.assert(signatures.length === 1); const signature = signatures[0]; - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); - signatureDeclaration.modifiers = modifiers; - signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; - signatureDeclaration.body = createStubbedMethodBody(); - return signatureDeclaration; + return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } const signatureDeclarations = []; for (let i = 0; i < signatures.length; i++) { const signature = signatures[i]; - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); - signatureDeclaration.modifiers = modifiers; - signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; - signatureDeclarations.push(signatureDeclaration); + const methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } if (declarations.length > signatures.length) { const signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1] as SignatureDeclaration); - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); - signatureDeclaration.modifiers = modifiers; - signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; - signatureDeclaration.body = createStubbedMethodBody(); - signatureDeclarations.push(signatureDeclaration); + const methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } else { Debug.assert(declarations.length === signatures.length); @@ -136,6 +128,17 @@ namespace ts.codefix { default: return undefined; } + + function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) { + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); + if (signatureDeclaration) { + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; + signatureDeclaration.body = body; + } + return signatureDeclaration; + } } function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration { diff --git a/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts b/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts index a8a024d194b..ee8b8cafffe 100644 --- a/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts +++ b/tests/cases/fourslash/codeFixClassImplementClassMemberAnonymousClass.ts @@ -10,11 +10,4 @@ //// } //// class C implements A {[| |]} -verify.rangeAfterCodeFix(` - foo() { - throw new Error("Method not implemented."); - } - bar() { - throw new Error("Method not implemented."); - } -`); +verify.not.codeFixAvailable(); From 797f6dac028fb3f4f8a16b60053a8610f2ee6aca Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 24 Mar 2017 13:01:27 -0700 Subject: [PATCH 189/207] rename helper --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7c5e8153a66..694763f6c06 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -61,7 +61,7 @@ namespace ts { const noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; const emitResolver = createResolver(); - const nodeBuilder = getNodeBuilder(); + const nodeBuilder = createNodeBuilder(); const undefinedSymbol = createSymbol(SymbolFlags.Property, "undefined"); undefinedSymbol.declarations = []; @@ -2202,7 +2202,7 @@ namespace ts { return result; } - function getNodeBuilder(): NodeBuilder { + function createNodeBuilder(): NodeBuilder { let encounteredError = false; From 85986ddaee1d9df121bdcfb30b31c4b33ac7e475 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Fri, 24 Mar 2017 13:12:07 -0700 Subject: [PATCH 190/207] dont check isPartOfTypeNode --- src/compiler/utilities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 57c00ed8fb4..f4f288d0cbc 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3735,7 +3735,7 @@ namespace ts { * of a TypeNode. */ export function isTypeNode(node: Node): node is TypeNode { - return node && isTypeNodeKind(node.kind) && (!node.parent || isPartOfTypeNode(node)); + return node && isTypeNodeKind(node.kind); } // Binding patterns From f1339ecb8ee84d0f73191bdf83bfdba90579de3a Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 24 Mar 2017 16:07:23 -0700 Subject: [PATCH 191/207] Remove trailing WS --- src/server/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/server.ts b/src/server/server.ts index e80b6f6b7b1..e38f82f35f6 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -733,7 +733,7 @@ namespace ts.server { if (localeStr) { validateLocaleAndSetLanguage(localeStr, sys); } - + const typingSafeListLocation = findArgument("--typingSafeListLocation"); const useSingleInferredProject = hasArgument("--useSingleInferredProject"); From a065331d694a9864c074833316d9eef2ea098f0f Mon Sep 17 00:00:00 2001 From: IgorNovozhilov Date: Sat, 25 Mar 2017 17:26:18 +0300 Subject: [PATCH 192/207] [object Generator] 25.3 Generator Objects http://www.ecma-international.org/ecma-262/6.0/#sec-generator-objects ``` C:\Users> node > GF = function* (){} [Function: GF] > GF.constructor.name 'GeneratorFunction' > G = GF() {} > G + '' '[object Generator]' ``` --- src/lib/es2015.generator.d.ts | 11 ++++++++++- src/lib/es2015.symbol.wellknown.d.ts | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib/es2015.generator.d.ts b/src/lib/es2015.generator.d.ts index 2f522ad8770..d7a3ff16069 100644 --- a/src/lib/es2015.generator.d.ts +++ b/src/lib/es2015.generator.d.ts @@ -1,4 +1,13 @@ -interface GeneratorFunction extends Function { } +interface Generator extends Iterator { } + +interface GeneratorFunction { + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): Generator; + (...args: any[]): Generator; +} interface GeneratorFunctionConstructor { /** diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 71e4cb7c893..5334dae9e01 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -137,7 +137,7 @@ interface Function { [Symbol.hasInstance](value: any): boolean; } -interface GeneratorFunction extends Function { +interface GeneratorFunction { readonly [Symbol.toStringTag]: "GeneratorFunction"; } From a94f874b06e687b6856c9a9e315a28af2598642b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sat, 25 Mar 2017 14:14:36 -0700 Subject: [PATCH 193/207] use NodeBuilderContext --- src/compiler/checker.ts | 697 +++++++++++++++++++++------------------- src/compiler/factory.ts | 4 +- src/compiler/types.ts | 4 +- 3 files changed, 373 insertions(+), 332 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 694763f6c06..a45f3424efe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2204,369 +2204,403 @@ namespace ts { function createNodeBuilder(): NodeBuilder { - let encounteredError = false; + interface NodeBuilderContext { + readonly enclosingDeclaration: Node | undefined; + readonly flags: NodeBuilderFlags | undefined; + encounteredError: boolean; + inObjectTypeLiteral: boolean; + checkAlias: boolean; + symbolStack: Symbol[] | undefined; + } + + function createNodeBuilderContext(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeBuilderContext { + return { + enclosingDeclaration, + flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + + let context: NodeBuilderContext; return { typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { - Debug.assert(encounteredError === false, "Nested call into nodeBuilder are forbidden."); - encounteredError = false; - const resultingNode = typeToTypeNodeHelper(type, enclosingDeclaration, flags); - const result = encounteredError ? undefined : resultingNode; - encounteredError = false; + context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = typeToTypeNodeHelper(type); + const result = context.encounteredError ? undefined : resultingNode; return result; }, indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { - Debug.assert(encounteredError === false, "Nested call into nodeBuilder are forbidden."); - encounteredError = false; - const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, enclosingDeclaration, flags); - const result = encounteredError ? undefined : resultingNode; - encounteredError = false; + context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + const result = context.encounteredError ? undefined : resultingNode; return result; }, signatureToSignatureDeclaration: (signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { - Debug.assert(encounteredError === false, "Nested call into nodeBuilder are forbidden."); - encounteredError = false; - const resultingNode = signatureToSignatureDeclarationHelper(signature, kind, enclosingDeclaration, flags); - const result = encounteredError ? undefined : resultingNode; - encounteredError = false; + context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + const result = context.encounteredError ? undefined : resultingNode; return result; } }; - function typeToTypeNodeHelper(type: Type, enclosingDeclaration: Node, flags: NodeBuilderFlags): TypeNode { - let inObjectTypeLiteral = false; - let checkAlias = true; - let symbolStack: Symbol[] = undefined; + function typeToTypeNodeHelper(type: Type): TypeNode { + if (!type) { + context.encounteredError = true; + // TODO(aozgaa): should we return implict any (undefined) or explicit any (keywordtypenode)? + return undefined; + } - return typeToTypeNodeWorker(type); + if (type.flags & TypeFlags.Any) { + return createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + if (type.flags & TypeFlags.String) { + return createKeywordTypeNode(SyntaxKind.StringKeyword); + } + if (type.flags & TypeFlags.Number) { + return createKeywordTypeNode(SyntaxKind.NumberKeyword); + } + if (type.flags & TypeFlags.Boolean) { + return createKeywordTypeNode(SyntaxKind.BooleanKeyword); + } + if (type.flags & TypeFlags.Enum) { + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & (TypeFlags.StringLiteral)) { + return createLiteralTypeNode((createLiteral((type).text))); + } + if (type.flags & (TypeFlags.NumberLiteral)) { + return createLiteralTypeNode((createNumericLiteral((type).text))); + } + if (type.flags & TypeFlags.BooleanLiteral) { + return (type).intrinsicName === "true" ? createTrue() : createFalse(); + } + if (type.flags & TypeFlags.EnumLiteral) { + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.Void) { + return createKeywordTypeNode(SyntaxKind.VoidKeyword); + } + if (type.flags & TypeFlags.Undefined) { + return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); + } + if (type.flags & TypeFlags.Null) { + return createKeywordTypeNode(SyntaxKind.NullKeyword); + } + if (type.flags & TypeFlags.Never) { + return createKeywordTypeNode(SyntaxKind.NeverKeyword); + } + if (type.flags & TypeFlags.ESSymbol) { + throw new Error("ESSymbol not implemented"); + } + if (type.flags & TypeFlags.NonPrimitive) { + throw new Error("Non primitive not implemented"); + } + if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { + if (context.inObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowThisInObjectLiteral)) { + context.encounteredError = true; + } + } + return createThis(); + } - function typeToTypeNodeWorker(type: Type): TypeNode { - if (!type) { - encounteredError = true; - // TODO(aozgaa): should we return implict any (undefined) or explicit any (keywordtypenode)? + const objectFlags = getObjectFlags(type); + + if (objectFlags & ObjectFlags.Reference) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + return typeReferenceToTypeNode(type); + } + if (objectFlags & ObjectFlags.ClassOrInterface) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // TODO(aozgaa): handle type arguments. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.TypeParameter) { + const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. + return createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + + if (context.checkAlias && type.aliasSymbol) { + const name = symbolToName(type.aliasSymbol, /*expectsIdentifier*/ false); + const typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + return createTypeReferenceNode(name, typeArgumentNodes); + } + context.checkAlias = false; + + if (type.flags & TypeFlags.Union) { + const formattedUnionTypes = formatUnionTypes((type).types); + const unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); + if (unionTypeNodes && unionTypeNodes.length > 0) { + return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, unionTypeNodes); + } + else { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + context.encounteredError = true; + } return undefined; } + } - if (type.flags & TypeFlags.Any) { - return createKeywordTypeNode(SyntaxKind.AnyKeyword); - } - if (type.flags & TypeFlags.String) { - return createKeywordTypeNode(SyntaxKind.StringKeyword); - } - if (type.flags & TypeFlags.Number) { - return createKeywordTypeNode(SyntaxKind.NumberKeyword); - } - if (type.flags & TypeFlags.Boolean) { - return createKeywordTypeNode(SyntaxKind.BooleanKeyword); - } - if (type.flags & TypeFlags.Enum) { - const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & (TypeFlags.StringLiteral)) { - return createLiteralTypeNode((createLiteral((type).text))); - } - if (type.flags & (TypeFlags.NumberLiteral)) { - return createLiteralTypeNode((createNumericLiteral((type).text))); - } - if (type.flags & TypeFlags.BooleanLiteral) { - return (type).intrinsicName === "true" ? createTrue() : createFalse(); - } - if (type.flags & TypeFlags.EnumLiteral) { - const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & TypeFlags.Void) { - return createKeywordTypeNode(SyntaxKind.VoidKeyword); - } - if (type.flags & TypeFlags.Undefined) { - return createKeywordTypeNode(SyntaxKind.UndefinedKeyword); - } - if (type.flags & TypeFlags.Null) { - return createKeywordTypeNode(SyntaxKind.NullKeyword); - } - if (type.flags & TypeFlags.Never) { - return createKeywordTypeNode(SyntaxKind.NeverKeyword); - } - if (type.flags & TypeFlags.ESSymbol) { - throw new Error("ESSymbol not implemented"); - } - if (type.flags & TypeFlags.NonPrimitive) { - throw new Error("Non primitive not implemented"); - } - if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { - if (inObjectTypeLiteral) { - encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowThisInObjectLiteral); + if (type.flags & TypeFlags.Intersection) { + return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); + } + + if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + // The type is an object literal type. + return createAnonymousTypeNode(type); + } + + if (type.flags & TypeFlags.Index) { + const indexedType = (type).type; + const indexTypeNode = typeToTypeNodeHelper(indexedType); + return createTypeOperatorNode(indexTypeNode); + } + if (type.flags & TypeFlags.IndexedAccess) { + const objectTypeNode = typeToTypeNodeHelper((type).objectType); + const indexTypeNode = typeToTypeNodeHelper((type).indexType); + return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + + Debug.fail("Should be unreachable."); + + function mapToTypeNodeArray(types: Type[]): TypeNode[] { + const result = []; + for (const type of types) { + const typeNode = typeToTypeNodeHelper(type); + if (typeNode) { + result.push(typeNode); } - return createThis(); } + return result; + } - const objectFlags = getObjectFlags(type); + function createMappedTypeNodeFromType(type: MappedType) { + Debug.assert(!!(type.flags & TypeFlags.Object)); + const typeParameter = getTypeParameterFromMappedType(type); + const typeParameterNode = typeParameterToDeclaration(typeParameter); - if (objectFlags & ObjectFlags.Reference) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - return typeReferenceToTypeNode (type); - } - if (objectFlags & ObjectFlags.ClassOrInterface) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); - // TODO(aozgaa): handle type arguments. - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & TypeFlags.TypeParameter) { - const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); - // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } + const templateType = getTemplateTypeFromMappedType(type); + const templateTypeNode = templateType && typeToTypeNodeHelper(templateType); + const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; + const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; - if (checkAlias && type.aliasSymbol) { - const name = symbolToName(type.aliasSymbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); - const typeArgumentNodes = mapToTypeNodeArray(type.aliasTypeArguments); - return createTypeReferenceNode(name, typeArgumentNodes); - } - checkAlias = false; + return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } - if (type.flags & TypeFlags.Union) { - return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, mapToTypeNodeArray(formatUnionTypes((type).types))); - } - - if (type.flags & TypeFlags.Intersection) { - return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); - } - - if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - // The type is an object literal type. - return createAnonymousTypeNode(type); - } - - if (type.flags & TypeFlags.Index) { - const indexedType = (type).type; - const indexTypeNode = typeToTypeNodeWorker(indexedType); - return createTypeOperatorNode(indexTypeNode); - } - if (type.flags & TypeFlags.IndexedAccess) { - const objectTypeNode = typeToTypeNodeWorker((type).objectType); - const indexTypeNode = typeToTypeNodeWorker((type).indexType); - return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); - } - - Debug.fail("Should be unreachable."); - - function mapToTypeNodeArray(types: Type[]): NodeArray { - return types && asNodeArray(types.map(typeToTypeNodeWorker).filter(node => !!node)); - } - - function createMappedTypeNodeFromType(type: MappedType) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const typeParameter = getTypeParameterFromMappedType(type); - const typeParameterNode = typeParameterToDeclaration(typeParameter, enclosingDeclaration, flags); - - const templateType = getTemplateTypeFromMappedType(type); - const templateTypeNode = templateType && typeToTypeNodeWorker(templateType); - const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; - const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; - - return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); - } - - function createAnonymousTypeNode(type: ObjectType): TypeNode { - const symbol = type.symbol; - if (symbol) { - // Always use 'typeof T' for type of class, enum, and module objects - if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || - symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || - shouldWriteTypeOfFunctionSymbol()) { - return createTypeQueryNodeFromType(type); - } - else if (contains(symbolStack, symbol)) { - // If type is an anonymous type literal in a type alias declaration, use type alias name - const typeAlias = getTypeAliasForTypeLiteral(type); - if (typeAlias) { - // The specified symbol flags need to be reinterpreted as type flags - const entityName = symbolToName(typeAlias, enclosingDeclaration, /*expectsIdentifier*/ false, flags); - return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); - } - else { - return createKeywordTypeNode(SyntaxKind.AnyKeyword); - } + function createAnonymousTypeNode(type: ObjectType): TypeNode { + const symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromType(type); + } + else if (contains(context.symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + const typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + const entityName = symbolToName(typeAlias, /*expectsIdentifier*/ false); + return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!symbolStack) { - symbolStack = []; - } - symbolStack.push(symbol); - const result = createTypeNodeFromObjectType(type); - symbolStack.pop(); - return result; + return createKeywordTypeNode(SyntaxKind.AnyKeyword); } } else { - // Anonymous types without a symbol are never circular. - return createTypeNodeFromObjectType(type); - } - - function shouldWriteTypeOfFunctionSymbol() { - const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method - forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); - const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && - (symbol.parent || // is exported function symbol - forEach(symbol.declarations, declaration => - declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); - if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { - // typeof is allowed only for static/non local functions - return contains(symbolStack, symbol); // it is type of the symbol uses itself recursively + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.symbolStack) { + context.symbolStack = []; } + context.symbolStack.push(symbol); + const result = createTypeNodeFromObjectType(type); + context.symbolStack.pop(); + return result; + } + } + else { + // Anonymous types without a symbol are never circular. + return createTypeNodeFromObjectType(type); + } + + function shouldWriteTypeOfFunctionSymbol() { + const isStaticMethodSymbol = !!(symbol.flags & SymbolFlags.Method && // typeof static method + forEach(symbol.declarations, declaration => getModifierFlags(declaration) & ModifierFlags.Static)); + const isNonLocalFunctionSymbol = !!(symbol.flags & SymbolFlags.Function) && + (symbol.parent || // is exported function symbol + forEach(symbol.declarations, declaration => + declaration.parent.kind === SyntaxKind.SourceFile || declaration.parent.kind === SyntaxKind.ModuleBlock)); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return contains(context.symbolStack, symbol); // it is type of the symbol uses itself recursively + } + } + } + + function createTypeNodeFromObjectType(type: ObjectType): TypeNode { + if (type.objectFlags & ObjectFlags.Mapped) { + if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { + return createMappedTypeNodeFromType(type); } } - function createTypeNodeFromObjectType(type: ObjectType): TypeNode { - if (type.objectFlags & ObjectFlags.Mapped) { - if (getConstraintTypeFromMappedType(type).flags & (TypeFlags.TypeParameter | TypeFlags.Index)) { - return createMappedTypeNodeFromType(type); - } + const resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return createTypeLiteralNode(/*members*/ undefined); } - const resolved = resolveStructuredTypeMembers(type); - if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { - if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - return createTypeLiteralNode(/*members*/ undefined); - } - - if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { - const signature = resolved.callSignatures[0]; - return signatureToSignatureDeclarationHelper(signature, SyntaxKind.FunctionType, enclosingDeclaration, flags); - } - if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { - const signature = resolved.constructSignatures[0]; - return signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructorType, enclosingDeclaration, flags); - } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + const signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, SyntaxKind.FunctionType); } - - const saveInObjectTypeLiteral = inObjectTypeLiteral; - inObjectTypeLiteral = true; - const members = createTypeNodesFromResolvedType(resolved); - inObjectTypeLiteral = saveInObjectTypeLiteral; - return createTypeLiteralNode(members); - } - - function createTypeQueryNodeFromType(type: Type) { - const symbol = type.symbol; - if (symbol) { - const entityName = symbolToName(symbol, enclosingDeclaration, /*expectsIdentifier*/ false, flags); - return createTypeQueryNode(entityName); + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + const signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructorType); } } - function typeReferenceToTypeNode(type: TypeReference) { - const typeArguments: Type[] = type.typeArguments || emptyArray; - if (type.target === globalArrayType) { - const elementType = typeToTypeNodeWorker(typeArguments[0]); - return createArrayTypeNode(elementType); + const saveInObjectTypeLiteral = context.inObjectTypeLiteral; + context.inObjectTypeLiteral = true; + const members = createTypeNodesFromResolvedType(resolved); + context.inObjectTypeLiteral = saveInObjectTypeLiteral; + return createTypeLiteralNode(members); + } + + function createTypeQueryNodeFromType(type: Type) { + const symbol = type.symbol; + if (symbol) { + const entityName = symbolToName(symbol, /*expectsIdentifier*/ false); + return createTypeQueryNode(entityName); + } + } + + function typeReferenceToTypeNode(type: TypeReference) { + const typeArguments: Type[] = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + const elementType = typeToTypeNodeHelper(typeArguments[0]); + return createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & ObjectFlags.Tuple) { + if (typeArguments.length > 0) { + const tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + return createTupleTypeNode(tupleConstituentNodes); + } } - else if (type.target.objectFlags & ObjectFlags.Tuple) { - return createTupleTypeNode(typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))) : undefined); + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyTuple)) { + context.encounteredError = true; } - else { - const outerTypeParameters = type.target.outerTypeParameters; - let i = 0; - let qualifiedName: QualifiedName | undefined = undefined; - if (outerTypeParameters) { - const length = outerTypeParameters.length; - while (i < length) { - // Find group of type arguments for type parameters with the same declaring container. - const start = i; - const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); - do { - i++; - } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); - // When type parameters are their own type arguments for the whole group (i.e. we have - // the default outer type arguments), we don't show the group. - if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const qualifiedNamePart = symbolToName(parent, enclosingDeclaration, /*expectsIdentifier*/ true, flags); - if (!qualifiedName) { - qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); - } - else { - Debug.assert(!qualifiedName.right); - qualifiedName.right = qualifiedNamePart; - qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); - } + return undefined; + } + else { + const outerTypeParameters = type.target.outerTypeParameters; + let i = 0; + let qualifiedName: QualifiedName | undefined = undefined; + if (outerTypeParameters) { + const length = outerTypeParameters.length; + while (i < length) { + // Find group of type arguments for type parameters with the same declaring container. + const start = i; + const parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + // When type parameters are their own type arguments for the whole group (i.e. we have + // the default outer type arguments), we don't show the group. + if (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { + const qualifiedNamePart = symbolToName(parent, /*expectsIdentifier*/ true); + if (!qualifiedName) { + qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); + } + else { + Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); } } } - let entityName: EntityName = undefined; - const nameIdentifier = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ true, flags); - if (qualifiedName) { - Debug.assert(!qualifiedName.right); - qualifiedName.right = nameIdentifier; - entityName = qualifiedName; - } - else { - entityName = nameIdentifier; - } - const typeParameterCount = (type.target.typeParameters || emptyArray).length; - const typeArgumentNodes = mapToTypeNodeArray(typeArguments.length > 0 ? typeArguments.slice(i, typeParameterCount - i) : undefined); - return createTypeReferenceNode(entityName, typeArgumentNodes); } + let entityName: EntityName = undefined; + const nameIdentifier = symbolToName(type.symbol, /*expectsIdentifier*/ true); + if (qualifiedName) { + Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + const typeParameterCount = (type.target.typeParameters || emptyArray).length; + const typeArgumentNodes = typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + return createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + + function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { + const typeElements: TypeElement[] = []; + for (const signature of resolvedType.callSignatures) { + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature)); + } + for (const signature of resolvedType.constructSignatures) { + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number)); } - function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { - const typeElements: TypeElement[] = []; - for (const signature of resolvedType.callSignatures) { - typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature, enclosingDeclaration, flags)); - } - for (const signature of resolvedType.constructSignatures) { - typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature, enclosingDeclaration, flags)); - } - if (resolvedType.stringIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String, enclosingDeclaration, flags)); - } - if (resolvedType.numberIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number, enclosingDeclaration, flags)); - } + const properties = resolvedType.properties; + if (!properties) { + return typeElements; + } - const properties = resolvedType.properties; - if (!properties) { - return typeElements; + for (const propertySymbol of properties) { + const propertyType = getTypeOfSymbol(propertySymbol); + const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; + if (!oldDeclaration) { + return; } - - for (const propertySymbol of properties) { - const propertyType = getTypeOfSymbol(propertySymbol); - const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; - if (!oldDeclaration) { - return; + const propertyName = oldDeclaration.name; + const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined; + if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { + const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); + for (const signature of signatures) { + const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); } - const propertyName = oldDeclaration.name; - const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined; - if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { - const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); - for (const signature of signatures) { - const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature, enclosingDeclaration, flags); - methodDeclaration.name = propertyName; - methodDeclaration.questionToken = optionalToken; - typeElements.push(methodDeclaration); - } - } - else { + } + else { - // TODO(aozgaa): should we create a node with explicit or implict any? - const propertyTypeNode = propertyType ? typeToTypeNodeWorker(propertyType) : createKeywordTypeNode(SyntaxKind.AnyKeyword); - typeElements.push(createPropertySignature( - propertyName, - optionalToken, - propertyTypeNode, + // TODO(aozgaa): should we create a node with explicit or implict any? + const propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : createKeywordTypeNode(SyntaxKind.AnyKeyword); + typeElements.push(createPropertySignature( + propertyName, + optionalToken, + propertyTypeNode, /*initializer*/undefined)); - } } - return typeElements.length ? typeElements : undefined; } + return typeElements.length ? typeElements : undefined; } } - function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration: Node, flags: NodeBuilderFlags): IndexSignatureDeclaration { + function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration { const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); const name = getNameFromIndexInfo(indexInfo); @@ -2578,7 +2612,7 @@ namespace ts { /*questionToken*/ undefined, indexerTypeNode, /*initializer*/ undefined); - const typeNode = typeToTypeNodeHelper(indexInfo.type, enclosingDeclaration, flags); + const typeNode = typeToTypeNodeHelper(indexInfo.type); return createIndexSignatureDeclaration( [indexingParameter], typeNode, @@ -2586,37 +2620,37 @@ namespace ts { indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); } - function signatureToSignatureDeclarationHelper(signature: Signature, kind: SyntaxKind, enclosingDeclaration: Node, flags: NodeBuilderFlags): SignatureDeclaration { + function signatureToSignatureDeclarationHelper(signature: Signature, kind: SyntaxKind): SignatureDeclaration { - const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, enclosingDeclaration, flags)); - const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, enclosingDeclaration, flags)); + const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter)); + const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter)); const returnTypeNode = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode); function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { - const typeNode = type && typeToTypeNodeHelper(type, enclosingDeclaration, flags); + const typeNode = type && typeToTypeNodeHelper(type); return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; } } - function typeParameterToDeclaration(type: TypeParameter, enclosingDeclaration: Node, flags: NodeBuilderFlags): TypeParameterDeclaration { + function typeParameterToDeclaration(type: TypeParameter): TypeParameterDeclaration { if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { return undefined; } const constraint = getConstraintFromTypeParameter(type); - const constraintNode = constraint && typeToTypeNodeHelper(constraint, enclosingDeclaration, flags); + const constraintNode = constraint && typeToTypeNodeHelper(constraint); const defaultParameter = getDefaultFromTypeParameter(type); - const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, enclosingDeclaration, flags); - const name = symbolToName(type.symbol, enclosingDeclaration, /*expectsIdentifier*/ true, flags); + const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); + const name = symbolToName(type.symbol, /*expectsIdentifier*/ true); return createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); } - function symbolToParameterDeclaration(parameterSymbol: Symbol, enclosingDeclaration: Node, flags: NodeBuilderFlags): ParameterDeclaration { + function symbolToParameterDeclaration(parameterSymbol: Symbol): ParameterDeclaration { const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; const parameterType = getTypeOfSymbol(parameterSymbol); - const parameterTypeNode = typeToTypeNodeHelper(parameterType, enclosingDeclaration, flags); + const parameterTypeNode = typeToTypeNodeHelper(parameterType); // TODO(aozgaa): check initializer accessibility correctly. const parameterNode = createParameter( parameterDeclaration.decorators, @@ -2630,15 +2664,15 @@ namespace ts { return parameterNode; } - function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: true, flags: NodeBuilderFlags): Identifier; - function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: false, flags: NodeBuilderFlags): EntityName; - function symbolToName(symbol: Symbol, enclosingDeclaration: Node | undefined, expectsIdentifier: boolean, flags: NodeBuilderFlags): EntityName { + function symbolToName(symbol: Symbol, expectsIdentifier: true): Identifier; + function symbolToName(symbol: Symbol, expectsIdentifier: false): EntityName; + function symbolToName(symbol: Symbol, expectsIdentifier: boolean): EntityName { let parentSymbol: Symbol; // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. let chain: Symbol[]; const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; - if (!isTypeParameter && enclosingDeclaration) { + if (!isTypeParameter && context.enclosingDeclaration) { chain = getSymbolChain(symbol, SymbolFlags.None, /*endOfChain*/ true); Debug.assert(chain && chain.length > 0); } @@ -2648,8 +2682,10 @@ namespace ts { parentSymbol = undefined; - if (expectsIdentifier && chain.length !== 1) { - encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier); + if (expectsIdentifier && chain.length !== 1 + && !context.encounteredError + && !(context.flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -2672,11 +2708,12 @@ namespace ts { } } if (typeParameters && typeParameters.length > 0) { - encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowTypeParameterInQualifiedName); - + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowTypeParameterInQualifiedName)) { + context.encounteredError = true; + } const writer = getSingleLineStringWriter(); const displayBuilder = getSymbolDisplayBuilder(); - displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, 0); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); typeParameterString = writer.string(); releaseStringWriter(writer); @@ -2691,10 +2728,10 @@ namespace ts { /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { - let accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); + let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); @@ -2731,7 +2768,9 @@ namespace ts { if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { return declarationNameToString((declaration.parent).name); } - encounteredError = encounteredError || !(flags & NodeBuilderFlags.allowAnonymousIdentifier); + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowAnonymousIdentifier)) { + context.encounteredError = true; + } switch (declaration.kind) { case SyntaxKind.ClassExpression: return "(Anonymous class)"; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 08dc91c6b27..e1e4e2c4ae5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -238,10 +238,10 @@ namespace ts { : node; } - export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: NodeArray | undefined) { + export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined) { const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; typeReference.typeName = asName(typeName); - typeReference.typeArguments = typeArguments; + typeReference.typeArguments = asNodeArray(typeArguments); return typeReference; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 461e33426e9..178e6fe7795 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2548,7 +2548,9 @@ namespace ts { allowThisInObjectLiteral = 1 << 0, allowQualifedNameInPlaceOfIdentifier = 1 << 1, allowTypeParameterInQualifiedName = 1 << 2, - allowAnonymousIdentifier = 1 << 3 + allowAnonymousIdentifier = 1 << 3, + allowEmptyUnionOrIntersection = 1 << 4, + allowEmptyTuple = 1 << 5 } export interface SymbolDisplayBuilder { From ee2a909f54cae61621d5a4cf52ff217d8e817d86 Mon Sep 17 00:00:00 2001 From: IgorNovozhilov Date: Sun, 26 Mar 2017 17:08:27 +0300 Subject: [PATCH 194/207] ["Two small changes"] --- src/lib/es2015.generator.d.ts | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/lib/es2015.generator.d.ts b/src/lib/es2015.generator.d.ts index d7a3ff16069..5637ef816de 100644 --- a/src/lib/es2015.generator.d.ts +++ b/src/lib/es2015.generator.d.ts @@ -6,7 +6,23 @@ interface GeneratorFunction { * @param args A list of arguments the function accepts. */ new (...args: any[]): Generator; + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ (...args: any[]): Generator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: Generator; } interface GeneratorFunctionConstructor { @@ -15,7 +31,22 @@ interface GeneratorFunctionConstructor { * @param args A list of arguments the function accepts. */ new (...args: string[]): GeneratorFunction; + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ (...args: string[]): GeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; From 6366719de89676c34c3849459752cb35fa9ca29d Mon Sep 17 00:00:00 2001 From: ncoley Date: Sat, 25 Mar 2017 19:27:15 -0400 Subject: [PATCH 195/207] Add missing methods for FormData type --- src/lib/dom.iterable.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index 9a04b723ac2..ea0d43d3640 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -4,6 +4,23 @@ interface DOMTokenList { [Symbol.iterator](): IterableIterator; } +interface FormData { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[string, any]>; + /** + * Returns a list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns a list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + interface NodeList { /** * Returns an array of key, value pairs for every entry in the list From e2b3c9c66374365381d3704c642bb3f4f59424bf Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 26 Mar 2017 22:29:17 -0700 Subject: [PATCH 196/207] remove NodeBuilder --- src/compiler/checker.ts | 43 ++++++++++++++++++++--------------------- src/compiler/types.ts | 8 -------- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a45f3424efe..3c2eb8c513c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2202,28 +2202,7 @@ namespace ts { return result; } - function createNodeBuilder(): NodeBuilder { - - interface NodeBuilderContext { - readonly enclosingDeclaration: Node | undefined; - readonly flags: NodeBuilderFlags | undefined; - encounteredError: boolean; - inObjectTypeLiteral: boolean; - checkAlias: boolean; - symbolStack: Symbol[] | undefined; - } - - function createNodeBuilderContext(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeBuilderContext { - return { - enclosingDeclaration, - flags, - encounteredError: false, - inObjectTypeLiteral: false, - checkAlias: true, - symbolStack: undefined - }; - } - + function createNodeBuilder() { let context: NodeBuilderContext; return { @@ -2247,6 +2226,26 @@ namespace ts { } }; + interface NodeBuilderContext { + readonly enclosingDeclaration: Node | undefined; + readonly flags: NodeBuilderFlags | undefined; + encounteredError: boolean; + inObjectTypeLiteral: boolean; + checkAlias: boolean; + symbolStack: Symbol[] | undefined; + } + + function createNodeBuilderContext(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeBuilderContext { + return { + enclosingDeclaration, + flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + function typeToTypeNodeHelper(type: Type): TypeNode { if (!type) { context.encounteredError = true; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 178e6fe7795..a93e8bddef1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2535,14 +2535,6 @@ namespace ts { /* @internal */ getTypeCount(): number; } - /** Note that any resulting nodes cannot be checked. */ - /* @internal */ - export interface NodeBuilder { - typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; - signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; - indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; - } - export enum NodeBuilderFlags { None = 0, allowThisInObjectLiteral = 1 << 0, From fb4e3d87bd93a3299735271e659ca3e410ee1c2b Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Sun, 26 Mar 2017 22:45:13 -0700 Subject: [PATCH 197/207] essymbol and object --- src/compiler/checker.ts | 4 ++-- ...ts => codeFixClassImplementInterfaceProperty.ts} | 10 ++++++++-- ...FixClassImplementInterfacePropertyEnumLiteral.ts | 13 ------------- 3 files changed, 10 insertions(+), 17 deletions(-) rename tests/cases/fourslash/{codeFixClassImplementInterfacePropertyEnum.ts => codeFixClassImplementInterfaceProperty.ts} (57%) delete mode 100644 tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3c2eb8c513c..7a7ce2536fe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2295,10 +2295,10 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.NeverKeyword); } if (type.flags & TypeFlags.ESSymbol) { - throw new Error("ESSymbol not implemented"); + return createKeywordTypeNode(SyntaxKind.SymbolKeyword); } if (type.flags & TypeFlags.NonPrimitive) { - throw new Error("Non primitive not implemented"); + return createKeywordTypeNode(SyntaxKind.ObjectKeyword); } if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { if (context.inObjectTypeLiteral) { diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnum.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts similarity index 57% rename from tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnum.ts rename to tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts index 8b04e4a4b45..53cfce5ff6e 100644 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnum.ts +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceProperty.ts @@ -4,10 +4,16 @@ //// enum E { a,b,c } //// interface I { -//// a: E; +//// x: E; +//// y: E.a +//// z: symbol; +//// w: object; //// } //// class C implements I {[| |]} verify.rangeAfterCodeFix(` - a: E; + x: E; + y: E.a; + z: symbol; + w: object; `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts b/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts deleted file mode 100644 index 720acc1cccf..00000000000 --- a/tests/cases/fourslash/codeFixClassImplementInterfacePropertyEnumLiteral.ts +++ /dev/null @@ -1,13 +0,0 @@ -/// - -// @lib: es2017 - -//// enum E { a,b,c } -//// interface I { -//// a: E.a -//// } -//// class C implements I {[| |]} - -verify.rangeAfterCodeFix(` - a: E.a; -`); \ No newline at end of file From a39bb0aaaaa161daeaac2c84ca0aaa1ade913418 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 27 Mar 2017 00:34:48 -0700 Subject: [PATCH 198/207] midway through response to ron's comments --- src/compiler/checker.ts | 64 +++++++-------- src/compiler/factory.ts | 167 +++++++++++++++++++--------------------- src/compiler/types.ts | 6 +- 3 files changed, 110 insertions(+), 127 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7a7ce2536fe..6c24def1500 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2384,13 +2384,13 @@ namespace ts { function createMappedTypeNodeFromType(type: MappedType) { Debug.assert(!!(type.flags & TypeFlags.Object)); - const typeParameter = getTypeParameterFromMappedType(type); + const typeParameter = getTypeParameterFromMappedType(type); const typeParameterNode = typeParameterToDeclaration(typeParameter); - const templateType = getTemplateTypeFromMappedType(type); - const templateTypeNode = templateType && typeToTypeNodeHelper(templateType); - const readonlyToken = (type).declaration && (type).declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; - const questionToken = (type).declaration && (type).declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + const templateType = getTemplateTypeFromMappedType(type); + const templateTypeNode = typeToTypeNodeHelper(templateType); + const readonlyToken = type.declaration && type.declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; + const questionToken = type.declaration && type.declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); } @@ -2402,7 +2402,7 @@ namespace ts { if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || shouldWriteTypeOfFunctionSymbol()) { - return createTypeQueryNodeFromType(type); + return createTypeQueryNodeFromSymbol(symbol); } else if (contains(context.symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name @@ -2477,12 +2477,9 @@ namespace ts { return createTypeLiteralNode(members); } - function createTypeQueryNodeFromType(type: Type) { - const symbol = type.symbol; - if (symbol) { - const entityName = symbolToName(symbol, /*expectsIdentifier*/ false); - return createTypeQueryNode(entityName); - } + function createTypeQueryNodeFromSymbol(symbol: Symbol) { + const entityName = symbolToName(symbol, /*expectsIdentifier*/ false); + return createTypeQueryNode(entityName); } function typeReferenceToTypeNode(type: TypeReference) { @@ -2542,7 +2539,7 @@ namespace ts { entityName = nameIdentifier; } const typeParameterCount = (type.target.typeParameters || emptyArray).length; - const typeArgumentNodes = typeArguments.length > 0 ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + const typeArgumentNodes = some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; return createTypeReferenceNode(entityName, typeArgumentNodes); } } @@ -2604,13 +2601,13 @@ namespace ts { const name = getNameFromIndexInfo(indexInfo); const indexingParameter = createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, name, - /*questionToken*/ undefined, + /*questionToken*/ undefined, indexerTypeNode, - /*initializer*/ undefined); + /*initializer*/ undefined); const typeNode = typeToTypeNodeHelper(indexInfo.type); return createIndexSignatureDeclaration( [indexingParameter], @@ -2623,21 +2620,14 @@ namespace ts { const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter)); const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter)); - const returnTypeNode = typeToTypeNodeExceptAny(getReturnTypeOfSignature(signature)); + const returnType = getReturnTypeOfSignature(signature); + const returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + const returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== SyntaxKind.AnyKeyword ? returnTypeNode : undefined; - return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode); - - function typeToTypeNodeExceptAny(type: Type): TypeNode | undefined { - const typeNode = type && typeToTypeNodeHelper(type); - return typeNode && typeNode.kind !== SyntaxKind.AnyKeyword ? typeNode : undefined; - } + return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); } function typeParameterToDeclaration(type: TypeParameter): TypeParameterDeclaration { - if (!(type && type.symbol && type.flags & TypeFlags.TypeParameter)) { - return undefined; - } - const constraint = getConstraintFromTypeParameter(type); const constraintNode = constraint && typeToTypeNodeHelper(constraint); const defaultParameter = getDefaultFromTypeParameter(type); @@ -2647,10 +2637,10 @@ namespace ts { } function symbolToParameterDeclaration(parameterSymbol: Symbol): ParameterDeclaration { - const parameterDeclaration = parameterSymbol.declarations[0] as ParameterDeclaration; + const parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); const parameterType = getTypeOfSymbol(parameterSymbol); const parameterTypeNode = typeToTypeNodeHelper(parameterType); - // TODO(aozgaa): check initializer accessibility correctly. + // TODO(aozgaa): In the future, check initializer accessibility. const parameterNode = createParameter( parameterDeclaration.decorators, parameterDeclaration.modifiers, @@ -2666,7 +2656,6 @@ namespace ts { function symbolToName(symbol: Symbol, expectsIdentifier: true): Identifier; function symbolToName(symbol: Symbol, expectsIdentifier: false): EntityName; function symbolToName(symbol: Symbol, expectsIdentifier: boolean): EntityName { - let parentSymbol: Symbol; // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. let chain: Symbol[]; @@ -2679,8 +2668,6 @@ namespace ts { chain = [symbol]; } - parentSymbol = undefined; - if (expectsIdentifier && chain.length !== 1 && !context.encounteredError && !(context.flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { @@ -2728,6 +2715,7 @@ namespace ts { /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): Symbol[] | undefined { let accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/false); + let parentSymbol: Symbol; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -2737,6 +2725,7 @@ namespace ts { if (parent) { const parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + parentSymbol = parent; accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); } } @@ -2745,8 +2734,7 @@ namespace ts { if (accessibleSymbolChain) { return accessibleSymbolChain; } - - else if ( + if ( // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) @@ -2759,8 +2747,8 @@ namespace ts { } function getNameOfSymbol(symbol: Symbol): string { - if (symbol.declarations && symbol.declarations.length) { - const declaration = symbol.declarations[0]; + const declaration = firstOrUndefined(symbol.declarations); + if (declaration) { if (declaration.name) { return declarationNameToString(declaration.name); } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index e1e4e2c4ae5..4c5a4b4067f 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -46,9 +46,6 @@ namespace ts { */ /* @internal */ export function getSynthesizedClone(node: T | undefined): T { - if (node === undefined) { - return undefined; - } // We don't use "clone" from core.ts here, as we need to preserve the prototype chain of // the original node. We also need to exclude specific properties and only include own- // properties (to skip members already defined on the shared prototype). @@ -169,23 +166,23 @@ namespace ts { // Reserved words export function createSuper() { - return createSynthesizedNode(SyntaxKind.SuperKeyword); + return createSynthesizedNode(SyntaxKind.SuperKeyword); } export function createThis() { - return createSynthesizedNode(SyntaxKind.ThisKeyword); + return >createSynthesizedNode(SyntaxKind.ThisKeyword); } export function createNull() { - return createSynthesizedNode(SyntaxKind.NullKeyword); + return >createSynthesizedNode(SyntaxKind.NullKeyword); } export function createTrue() { - return createSynthesizedNode(SyntaxKind.TrueKeyword); + return >createSynthesizedNode(SyntaxKind.TrueKeyword); } export function createFalse() { - return createSynthesizedNode(SyntaxKind.FalseKeyword); + return >createSynthesizedNode(SyntaxKind.FalseKeyword); } // Names @@ -218,11 +215,74 @@ namespace ts { // Type Elements - // TODO: add signatures + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + const signatureDeclaration = createSynthesizedNode(kind) as SignatureDeclaration; + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + + function updateSignatureDeclaration(node: SignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + + export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode; + } + + export function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode; + } + + export function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration; + } + + export function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration; + } + + export function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined) { + const methodSignature = createSignatureDeclaration(SyntaxKind.MethodSignature, typeParameters, parameters, type) as MethodSignature; + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + + export function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } // Types - export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode { + export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]) { return createSynthesizedNode(kind); } @@ -259,10 +319,10 @@ namespace ts { } export function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName) { - return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName) , node) : node; + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; } - export function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode { + export function createArrayTypeNode(elementType: TypeNode) { const arrayTypeNode = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode; arrayTypeNode.elementType = elementType; return arrayTypeNode; @@ -277,9 +337,9 @@ namespace ts { export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode; export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode; export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode; - export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode { + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]) { const unionTypeNode = createSynthesizedNode(kind) as UnionTypeNode | IntersectionTypeNode; - unionTypeNode.types = asNodeArray(types); + unionTypeNode.types = createNodeArray(types); return unionTypeNode; } @@ -291,7 +351,7 @@ namespace ts { export function createTypeLiteralNode(members: TypeElement[]) { const typeLiteralNode = createSynthesizedNode(SyntaxKind.TypeLiteral) as TypeLiteralNode; - typeLiteralNode.members = asNodeArray(members); + typeLiteralNode.members = createNodeArray(members); return typeLiteralNode; } @@ -303,7 +363,7 @@ namespace ts { export function createTupleTypeNode(elementTypes: TypeNode[]) { const tupleTypeNode = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode; - tupleTypeNode.elementTypes = asNodeArray(elementTypes); + tupleTypeNode.elementTypes = createNodeArray(elementTypes); return tupleTypeNode; } @@ -349,7 +409,6 @@ namespace ts { return indexedAccessTypeNode; } - export function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) { return node.objectType !== objectType || node.indexType !== indexType @@ -357,86 +416,22 @@ namespace ts { : node; } - // Type Declarations - export function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultParameter: TypeNode | undefined) { + export function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) { const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; typeParameter.name = asName(name); typeParameter.constraint = constraint; - typeParameter.default = defaultParameter; + typeParameter.default = defaultType; return typeParameter; } - export function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultParameter: TypeNode | undefined) { + export function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) { return node.name !== name || node.constraint !== constraint - || node.default !== defaultParameter - ? updateNode(createTypeParameterDeclaration(name, constraint, defaultParameter), node) - : node; - } - - // TODO: Split according to AST nodes. - export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { - const signatureDeclaration = createSynthesizedNode(kind) as SignatureDeclaration; - signatureDeclaration.typeParameters = asNodeArray(typeParameters); - signatureDeclaration.parameters = asNodeArray(parameters); - signatureDeclaration.type = type; - return signatureDeclaration; - } - - export function updateSignatureDeclaration(node: SignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { - return node.typeParameters !== typeParameters - || node.parameters !== parameters - || node.type !== type - ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) - : node; - } - - export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode { - return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode; - } - - export function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode { - return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode; - } - export function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration { - return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration; - } - export function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration { - return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration; - } - export function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature { - const methodSignature = createSignatureDeclaration(SyntaxKind.MethodSignature, typeParameters, parameters, type) as MethodSignature; - methodSignature.name = asName(name); - methodSignature.questionToken = questionToken; - return methodSignature; - } - - export function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name?: PropertyName, questionToken?: QuestionToken): MethodSignature { - return node.typeParameters !== typeParameters - || node.parameters !== parameters - || node.type !== type - || node.name !== name - || node.questionToken !== questionToken - ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + || node.default !== defaultType + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node) : node; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a93e8bddef1..45a4de01c9f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1034,15 +1034,15 @@ namespace ts { _primaryExpressionBrand: any; } - export interface NullLiteral extends PrimaryExpression { + export interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - export interface BooleanLiteral extends PrimaryExpression { + export interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - export interface ThisExpression extends PrimaryExpression { + export interface ThisExpression extends PrimaryExpression, TypeNode { kind: SyntaxKind.ThisKeyword; } From cca7ac25578593db034bfa09df33558b105b5a8c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 27 Mar 2017 11:37:27 +0200 Subject: [PATCH 199/207] Use immediate constraint, not base constraint, of indexed access --- src/compiler/checker.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70cbda14f6d..b29916c62f9 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7942,16 +7942,9 @@ namespace ts { } } else if (target.flags & TypeFlags.IndexedAccess) { - // if we have indexed access types with identical index types, see if relationship holds for - // the two object types. - if (source.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { - if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { - return result; - } - } // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - const constraint = getBaseConstraintOfType(target); + const constraint = getConstraintOfType(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -7998,6 +7991,13 @@ namespace ts { return result; } } + else if (target.flags & TypeFlags.IndexedAccess && (source).indexType === (target).indexType) { + // if we have indexed access types with identical index types, see if relationship holds for + // the two object types. + if (result = isRelatedTo((source).objectType, (target).objectType, reportErrors)) { + return result; + } + } } else { if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { From 4aeab77783bbae630b3708ca2da42baa8a04cb86 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 27 Mar 2017 11:38:05 +0200 Subject: [PATCH 200/207] Accept new baselines --- .../mappedTypeRelationships.errors.txt | 128 ++++++++++++++---- 1 file changed, 104 insertions(+), 24 deletions(-) diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index bc26bb272f5..ec2bacbe663 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -1,39 +1,71 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(12,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(17,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(21,5): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,5): error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. Type 'T[string]' is not assignable to type 'U[keyof U]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof U]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(22,12): error TS2536: Type 'keyof U' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(26,5): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(27,12): error TS2536: Type 'K' cannot be used to index type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(31,5): error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(36,5): error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(41,5): error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. Type 'undefined' is not assignable to type 'T[keyof T]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(42,5): error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. - Type 'T[string]' is not assignable to type 'U[keyof T]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[keyof T]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[keyof T]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(46,5): error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. Type 'undefined' is not assignable to type 'T[K]'. + Type 'undefined' is not assignable to type 'T[string]'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(47,5): error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. Type 'T[string]' is not assignable to type 'U[K] | undefined'. Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T[K]' is not assignable to type 'U[K]'. - Type 'T[string]' is not assignable to type 'U[K]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[K]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[K]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(52,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(57,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(62,5): error TS2542: Index signature in type 'Readonly' only permits reading. @@ -44,7 +76,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(126,5): error TS tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(142,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[P]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[P]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(147,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof U]: U[P]; }'. Type 'keyof U' is not assignable to type 'keyof T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(152,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in keyof T]: T[P]; }'. @@ -56,7 +92,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(162,5): error TS tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. Type 'T[string]' is not assignable to type 'U[P]'. - Type 'T' is not assignable to type 'U'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. + Type 'T[P]' is not assignable to type 'U[string]'. + Type 'T[string]' is not assignable to type 'U[string]'. + Type 'T' is not assignable to type 'U'. ==== tests/cases/conformance/types/mapped/mappedTypeRelationships.ts (27 errors) ==== @@ -75,7 +115,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f4(x: T, y: U, k: K) { @@ -84,7 +128,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f5(x: T, y: U, k: keyof U) { @@ -95,7 +143,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[keyof U]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof U]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof U]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'keyof U' cannot be used to index type 'T'. } @@ -108,7 +160,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. ~~~~ !!! error TS2536: Type 'K' cannot be used to index type 'T'. } @@ -118,6 +174,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'T[keyof T] | undefined' is not assignable to type 'T[keyof T]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; } @@ -126,6 +183,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'T[K] | undefined' is not assignable to type 'T[K]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; } @@ -134,14 +192,21 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'U[keyof T] | undefined' is not assignable to type 'T[keyof T]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[keyof T]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[keyof T]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[keyof T]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f13(x: T, y: Partial, k: K) { @@ -149,14 +214,21 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS ~~~~ !!! error TS2322: Type 'U[K] | undefined' is not assignable to type 'T[K]'. !!! error TS2322: Type 'undefined' is not assignable to type 'T[K]'. +!!! error TS2322: Type 'undefined' is not assignable to type 'T[string]'. y[k] = x[k]; // Error ~~~~ !!! error TS2322: Type 'T[K]' is not assignable to type 'U[K] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K] | undefined'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[K]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[K]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f20(x: T, y: Readonly, k: keyof T) { @@ -270,7 +342,11 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } function f72(x: { [P in keyof T]: T[P] }, y: { [P in keyof U]: U[P] }) { @@ -312,6 +388,10 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(167,5): error TS !!! error TS2322: Type '{ [P in K]: T[P]; }' is not assignable to type '{ [P in K]: U[P]; }'. !!! error TS2322: Type 'T[P]' is not assignable to type 'U[P]'. !!! error TS2322: Type 'T[string]' is not assignable to type 'U[P]'. -!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. +!!! error TS2322: Type 'T[P]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T[string]' is not assignable to type 'U[string]'. +!!! error TS2322: Type 'T' is not assignable to type 'U'. } \ No newline at end of file From 0b8a9fc3d0d912276d12d025bcaff60dff41e194 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 27 Mar 2017 11:44:49 +0200 Subject: [PATCH 201/207] Add regression test --- .../reference/indexedAccessRelation.js | 56 +++++++++++++++++++ .../reference/indexedAccessRelation.symbols | 53 ++++++++++++++++++ .../reference/indexedAccessRelation.types | 55 ++++++++++++++++++ tests/cases/compiler/indexedAccessRelation.ts | 18 ++++++ 4 files changed, 182 insertions(+) create mode 100644 tests/baselines/reference/indexedAccessRelation.js create mode 100644 tests/baselines/reference/indexedAccessRelation.symbols create mode 100644 tests/baselines/reference/indexedAccessRelation.types create mode 100644 tests/cases/compiler/indexedAccessRelation.ts diff --git a/tests/baselines/reference/indexedAccessRelation.js b/tests/baselines/reference/indexedAccessRelation.js new file mode 100644 index 00000000000..c58c214e69e --- /dev/null +++ b/tests/baselines/reference/indexedAccessRelation.js @@ -0,0 +1,56 @@ +//// [indexedAccessRelation.ts] +// Repro from #14723 + +class Component { + setState(state: Pick) {} +} + +export interface State { + a?: T; +} + +class Foo {} + +class Comp extends Component> +{ + foo(a: T) { + this.setState({ a: a }); + } +} + + +//// [indexedAccessRelation.js] +// Repro from #14723 +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var Component = (function () { + function Component() { + } + Component.prototype.setState = function (state) { }; + return Component; +}()); +var Foo = (function () { + function Foo() { + } + return Foo; +}()); +var Comp = (function (_super) { + __extends(Comp, _super); + function Comp() { + return _super !== null && _super.apply(this, arguments) || this; + } + Comp.prototype.foo = function (a) { + this.setState({ a: a }); + }; + return Comp; +}(Component)); diff --git a/tests/baselines/reference/indexedAccessRelation.symbols b/tests/baselines/reference/indexedAccessRelation.symbols new file mode 100644 index 00000000000..40fa52652f9 --- /dev/null +++ b/tests/baselines/reference/indexedAccessRelation.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/indexedAccessRelation.ts === +// Repro from #14723 + +class Component { +>Component : Symbol(Component, Decl(indexedAccessRelation.ts, 0, 0)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16)) + + setState(state: Pick) {} +>setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20)) +>K : Symbol(K, Decl(indexedAccessRelation.ts, 3, 13)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16)) +>state : Symbol(state, Decl(indexedAccessRelation.ts, 3, 32)) +>Pick : Symbol(Pick, Decl(lib.d.ts, --, --)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 2, 16)) +>K : Symbol(K, Decl(indexedAccessRelation.ts, 3, 13)) +} + +export interface State { +>State : Symbol(State, Decl(indexedAccessRelation.ts, 4, 1)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 6, 23)) + + a?: T; +>a : Symbol(State.a, Decl(indexedAccessRelation.ts, 6, 27)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 6, 23)) +} + +class Foo {} +>Foo : Symbol(Foo, Decl(indexedAccessRelation.ts, 8, 1)) + +class Comp extends Component> +>Comp : Symbol(Comp, Decl(indexedAccessRelation.ts, 10, 12)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11)) +>Foo : Symbol(Foo, Decl(indexedAccessRelation.ts, 8, 1)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 12, 25)) +>Component : Symbol(Component, Decl(indexedAccessRelation.ts, 0, 0)) +>S : Symbol(S, Decl(indexedAccessRelation.ts, 12, 25)) +>State : Symbol(State, Decl(indexedAccessRelation.ts, 4, 1)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11)) +{ + foo(a: T) { +>foo : Symbol(Comp.foo, Decl(indexedAccessRelation.ts, 13, 1)) +>a : Symbol(a, Decl(indexedAccessRelation.ts, 14, 8)) +>T : Symbol(T, Decl(indexedAccessRelation.ts, 12, 11)) + + this.setState({ a: a }); +>this.setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20)) +>this : Symbol(Comp, Decl(indexedAccessRelation.ts, 10, 12)) +>setState : Symbol(Component.setState, Decl(indexedAccessRelation.ts, 2, 20)) +>a : Symbol(a, Decl(indexedAccessRelation.ts, 15, 23)) +>a : Symbol(a, Decl(indexedAccessRelation.ts, 14, 8)) + } +} + diff --git a/tests/baselines/reference/indexedAccessRelation.types b/tests/baselines/reference/indexedAccessRelation.types new file mode 100644 index 00000000000..2564a82702d --- /dev/null +++ b/tests/baselines/reference/indexedAccessRelation.types @@ -0,0 +1,55 @@ +=== tests/cases/compiler/indexedAccessRelation.ts === +// Repro from #14723 + +class Component { +>Component : Component +>S : S + + setState(state: Pick) {} +>setState : (state: Pick) => void +>K : K +>S : S +>state : Pick +>Pick : Pick +>S : S +>K : K +} + +export interface State { +>State : State +>T : T + + a?: T; +>a : T +>T : T +} + +class Foo {} +>Foo : Foo + +class Comp extends Component> +>Comp : Comp +>T : T +>Foo : Foo +>S : S +>Component : Component> +>S : S +>State : State +>T : T +{ + foo(a: T) { +>foo : (a: T) => void +>a : T +>T : T + + this.setState({ a: a }); +>this.setState({ a: a }) : void +>this.setState : )>(state: Pick, K>) => void +>this : this +>setState : )>(state: Pick, K>) => void +>{ a: a } : { a: T; } +>a : T +>a : T + } +} + diff --git a/tests/cases/compiler/indexedAccessRelation.ts b/tests/cases/compiler/indexedAccessRelation.ts new file mode 100644 index 00000000000..ccfcd559e20 --- /dev/null +++ b/tests/cases/compiler/indexedAccessRelation.ts @@ -0,0 +1,18 @@ +// Repro from #14723 + +class Component { + setState(state: Pick) {} +} + +export interface State { + a?: T; +} + +class Foo {} + +class Comp extends Component> +{ + foo(a: T) { + this.setState({ a: a }); + } +} From 523ced704f49604bc566efa45a2026ab033d48f7 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 27 Mar 2017 16:51:38 +0100 Subject: [PATCH 202/207] symbolDisplay comment fix: "experts" vs "exports" --- src/services/symbolDisplay.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index b457165b67f..3fcc467f6ab 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -419,7 +419,7 @@ namespace ts.SymbolDisplay { if (!documentation) { documentation = symbol.getDocumentationComment(); if (documentation.length === 0 && symbol.flags & SymbolFlags.Property) { - // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` + // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) { From 7340c4ca1ef40521b66074ece970cbfeec037ba3 Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 27 Mar 2017 11:53:44 -0700 Subject: [PATCH 203/207] type predicate support --- src/compiler/checker.ts | 19 ++++++-- src/compiler/factory.ts | 35 ++++++++++---- src/compiler/types.ts | 8 +--- src/compiler/utilities.ts | 2 +- src/compiler/visitor.ts | 47 +++++-------------- src/services/codefixes/fixAddMissingMember.ts | 6 +-- src/services/codefixes/helpers.ts | 8 ---- src/services/textChanges.ts | 20 ++++++++ ...ssImplementInterfaceMethodTypePredicate.ts | 16 +++++++ 9 files changed, 93 insertions(+), 68 deletions(-) create mode 100644 tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6c24def1500..2471ebcb52f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2610,18 +2610,27 @@ namespace ts { /*initializer*/ undefined); const typeNode = typeToTypeNodeHelper(indexInfo.type); return createIndexSignatureDeclaration( - [indexingParameter], - typeNode, /*decorators*/ undefined, - indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined); + indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined, + [indexingParameter], + typeNode); } function signatureToSignatureDeclarationHelper(signature: Signature, kind: SyntaxKind): SignatureDeclaration { const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter)); const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter)); - const returnType = getReturnTypeOfSignature(signature); - const returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + let returnTypeNode: TypeNode | TypePredicate; + if (signature.typePredicate) { + const typePredicate = signature.typePredicate; + const parameterName = typePredicate.kind === TypePredicateKind.Identifier ? createIdentifier((typePredicate).parameterName) : createThisTypeNode(); + const typeNode = typeToTypeNodeHelper(typePredicate.type); + returnTypeNode = createTypePredicateNode(parameterName, typeNode); + } + else { + const returnType = getReturnTypeOfSignature(signature); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + } const returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== SyntaxKind.AnyKeyword ? returnTypeNode : undefined; return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 4c5a4b4067f..66b3eb713e5 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -286,6 +286,10 @@ namespace ts { return createSynthesizedNode(kind); } + export function createThisTypeNode() { + return createSynthesizedNode(SyntaxKind.ThisType); + } + export function createLiteralTypeNode(literal: Expression) { const literalTypeNode = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; literalTypeNode.literal = literal; @@ -312,6 +316,20 @@ namespace ts { : node; } + export function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode) { + const typePredicateNode = createSynthesizedNode(SyntaxKind.TypePredicate) as TypePredicateNode; + typePredicateNode.parameterName = asName(parameterName); + typePredicateNode.type = type; + return typePredicateNode; + } + + export function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + export function createTypeQueryNode(exprName: EntityName) { const typeQueryNode = createSynthesizedNode(SyntaxKind.TypeQuery) as TypeQueryNode; typeQueryNode.exprName = exprName; @@ -455,21 +473,21 @@ namespace ts { : node; } - export function createIndexSignatureDeclaration(parameters: ParameterDeclaration[], type: TypeNode, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined): IndexSignatureDeclaration { + export function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration { const indexSignature = createSynthesizedNode(SyntaxKind.IndexSignature) as IndexSignatureDeclaration; - indexSignature.parameters = asNodeArray(parameters); - indexSignature.type = type; indexSignature.decorators = asNodeArray(decorators); indexSignature.modifiers = asNodeArray(modifiers); + indexSignature.parameters = createNodeArray(parameters); + indexSignature.type = type; return indexSignature; } - export function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, parameters: ParameterDeclaration[], type: TypeNode, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined) { + export function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode) { return node.parameters !== parameters || node.type !== type || node.decorators !== decorators || node.modifiers !== modifiers - ? updateNode(createIndexSignatureDeclaration(parameters, type, decorators, modifiers), node) + ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) : node; } @@ -542,7 +560,7 @@ namespace ts { node.name = asName(name); node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); - node.parameters = asNodeArray(parameters); + node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; @@ -2052,7 +2070,8 @@ namespace ts { function asName(name: string | BindingName): BindingName; function asName(name: string | PropertyName): PropertyName; function asName(name: string | EntityName): EntityName; - function asName(name: string | Identifier | BindingName | PropertyName | QualifiedName) { + function asName(name: string | Identifier | ThisTypeNode): Identifier | ThisTypeNode; + function asName(name: string | Identifier | BindingName | PropertyName | QualifiedName | ThisTypeNode) { return typeof name === "string" ? createIdentifier(name) : name; } @@ -2060,7 +2079,7 @@ namespace ts { return typeof value === "string" || typeof value === "number" ? createLiteral(value) : value; } - export function asNodeArray(array: T[] | undefined): NodeArray | undefined { + function asNodeArray(array: T[] | undefined): NodeArray | undefined { return array ? createNodeArray(array) : undefined; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 45a4de01c9f..038f8bf3166 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1042,7 +1042,7 @@ namespace ts { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - export interface ThisExpression extends PrimaryExpression, TypeNode { + export interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } @@ -3248,12 +3248,6 @@ namespace ts { declaration?: SignatureDeclaration; } - export interface SignatureParts { - typeParameters: TypeParameterDeclaration[] | undefined; - parameters: ParameterDeclaration[]; - type: TypeNode; - } - /* @internal */ export interface TypeMapper { (t: TypeParameter): Type; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f4f288d0cbc..33cb0d8f489 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3735,7 +3735,7 @@ namespace ts { * of a TypeNode. */ export function isTypeNode(node: Node): node is TypeNode { - return node && isTypeNodeKind(node.kind); + return isTypeNodeKind(node.kind); } // Binding patterns diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index b8eb0210d08..c110ea42277 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -3,26 +3,6 @@ /// namespace ts { - export const nullTransformationContext: TransformationContext = { - enableEmitNotification: noop, - enableSubstitution: noop, - endLexicalEnvironment: () => undefined, - getCompilerOptions: notImplemented, - getEmitHost: notImplemented, - getEmitResolver: notImplemented, - hoistFunctionDeclaration: noop, - hoistVariableDeclaration: noop, - isEmitNotificationEnabled: notImplemented, - isSubstitutionEnabled: notImplemented, - onEmitNode: noop, - onSubstituteNode: notImplemented, - readEmitHelpers: notImplemented, - requestEmitHelper: noop, - resumeLexicalEnvironment: noop, - startLexicalEnvironment: noop, - suspendLexicalEnvironment: noop - }; - /** * Visits a Node using the supplied visitor, possibly returning a new Node in its place. * @@ -234,7 +214,7 @@ namespace ts { const kind = node.kind; // No need to visit nodes with no children. - if ((kind > SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken)) { + if ((kind > SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken) || kind === SyntaxKind.ThisType) { return node; } @@ -293,10 +273,10 @@ namespace ts { case SyntaxKind.IndexSignature: return updateIndexSignatureDeclaration(node, - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode), nodesVisitor((node).decorators, visitor, isDecorator), - nodesVisitor((node).modifiers, visitor, isModifier)); + nodesVisitor((node).modifiers, visitor, isModifier), + visitParameterList((node).parameters, visitor, context, nodesVisitor), + visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.Parameter: return updateParameter(node, @@ -314,13 +294,16 @@ namespace ts { // Types - case SyntaxKind.TypePredicate: - throw new Error("reached unsupported type in visitor."); case SyntaxKind.TypeReference: return updateTypeReferenceNode(node, visitNode((node).typeName, visitor, isEntityName), nodesVisitor((node).typeArguments, visitor, isTypeNode)); + case SyntaxKind.TypePredicate: + return updateTypePredicateNode(node, + visitNode((node).parameterName, visitor), + visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.TypeQuery: return updateTypeQueryNode((node), visitNode((node).exprName, visitor, isEntityName)); @@ -339,9 +322,8 @@ namespace ts { nodesVisitor((node).types, visitor, isTypeNode)); case SyntaxKind.ParenthesizedType: - throw new Error("reached unsupported type in visitor."); - case SyntaxKind.ThisType: - throw new Error("reached unsupported type in visitor."); + Debug.fail("not implemented."); + case SyntaxKind.TypeOperator: return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); case SyntaxKind.IndexedAccessType: @@ -376,13 +358,6 @@ namespace ts { visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); - case SyntaxKind.IndexSignature: - return updateIndexSignatureDeclaration(node, - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode), - nodesVisitor((node).decorators, visitor, isDecorator), - nodesVisitor((node).modifiers, visitor, isModifier)); - case SyntaxKind.PropertyDeclaration: return updateProperty(node, nodesVisitor((node).decorators, visitor, isDecorator), diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 4ef9fce0672..bfb931e8668 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -65,10 +65,10 @@ namespace ts.codefix { stringTypeNode, /*initializer*/ undefined); const indexSignature = createIndexSignatureDeclaration( - [indexingParameter], - typeNode, /*decorators*/undefined, - /*modifiers*/ undefined); + /*modifiers*/ undefined, + [indexingParameter], + typeNode); const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context); indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 49f95243c95..a7809cdd215 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -230,12 +230,4 @@ namespace ts.codefix { } return undefined; } - - function stripComments(node: Node): Node { - if (node === undefined) { - return node; - } - const strippedChildren = visitEachChild(node, stripComments, nullTransformationContext); - return strippedChildren === node ? getSynthesizedClone(strippedChildren) : strippedChildren; - } } \ No newline at end of file diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index f5b0ec678d0..73d5fc61bca 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -528,6 +528,26 @@ namespace ts.textChanges { return skipTrivia(s, 0) === s.length; } + const nullTransformationContext: TransformationContext = { + enableEmitNotification: noop, + enableSubstitution: noop, + endLexicalEnvironment: () => undefined, + getCompilerOptions: notImplemented, + getEmitHost: notImplemented, + getEmitResolver: notImplemented, + hoistFunctionDeclaration: noop, + hoistVariableDeclaration: noop, + isEmitNotificationEnabled: notImplemented, + isSubstitutionEnabled: notImplemented, + onEmitNode: noop, + onSubstituteNode: notImplemented, + readEmitHelpers: notImplemented, + requestEmitHelper: noop, + resumeLexicalEnvironment: noop, + startLexicalEnvironment: noop, + suspendLexicalEnvironment: noop + }; + function assignPositionsToNode(node: Node): Node { const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes diff --git a/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts new file mode 100644 index 00000000000..2eb6c2fabcb --- /dev/null +++ b/tests/cases/fourslash/codeFixClassImplementInterfaceMethodTypePredicate.ts @@ -0,0 +1,16 @@ +/// + +//// interface I { +//// f(i: any): i is I; +//// f(): this is I; +//// } +//// +//// class C implements I {[| |]} + +verify.rangeAfterCodeFix(` +f(i: any): i is I; +f(): this is I; +f(i?: any) { + throw new Error("Method not implemented."); +} +`); From 4329b4524eb4b215752fc2a81d1676d8d4830aea Mon Sep 17 00:00:00 2001 From: Arthur Ozga Date: Mon, 27 Mar 2017 12:01:56 -0700 Subject: [PATCH 204/207] Cleanup --- src/compiler/visitor.ts | 2 ++ src/harness/fourslash.ts | 2 +- src/services/codefixes/helpers.ts | 13 +++++++------ src/services/textChanges.ts | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index c110ea42277..297d2cc0dde 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -326,10 +326,12 @@ namespace ts { case SyntaxKind.TypeOperator: return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.IndexedAccessType: return updateIndexedAccessTypeNode((node), visitNode((node).objectType, visitor, isTypeNode), visitNode((node).indexType, visitor, isTypeNode)); + case SyntaxKind.MappedType: return updateMappedTypeNode((node), visitNode((node).readonlyToken, tokenVisitor, isToken), diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 4ef6b54e1bd..98ebacd49b1 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1676,7 +1676,7 @@ namespace FourSlash { // We get back a set of edits, but langSvc.editScript only accepts one at a time. Use this to keep track // of the incremental offset from each edit to the next. Assumption is that these edit ranges don't overlap let runningOffset = 0; - edits = ts.stableSort(edits, (a, b) => a.span.start - b.span.start); + edits = edits.sort((a, b) => a.span.start - b.span.start); // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters const oldContent = this.getFileContent(fileName); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index a7809cdd215..b836815fc27 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -11,7 +11,7 @@ namespace ts.codefix { } const changes = changeTracker.getChanges(); - if (!(changes && changes.length > 0)) { + if (!some(changes)) { return changes; } @@ -93,7 +93,7 @@ namespace ts.codefix { // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); - if (!(signatures && signatures.length > 0)) { + if (!some(signatures)) { return undefined; } @@ -103,7 +103,7 @@ namespace ts.codefix { return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } - const signatureDeclarations = []; + const signatureDeclarations: MethodDeclaration[] = []; for (let i = 0; i < signatures.length; i++) { const signature = signatures[i]; const methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); @@ -132,6 +132,7 @@ namespace ts.codefix { function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) { const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); if (signatureDeclaration) { + signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -142,8 +143,6 @@ namespace ts.codefix { } function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration { - Debug.assert(signatures && signatures.length > 0); - /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. @@ -154,7 +153,9 @@ namespace ts.codefix { for (let i = 0; i < signatures.length; i++) { const sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - someSigHasRestParameter = someSigHasRestParameter || sig.hasRestParameter; + if (sig.hasRestParameter) { + someSigHasRestParameter = true; + } if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { maxArgsSignature = sig; } diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 73d5fc61bca..afc98927495 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -276,7 +276,7 @@ namespace ts.textChanges { /** * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, * i.e. arguments in arguments lists, parameters in parameter lists etc. - * Note that separators are art of the node in statements and class elements. + * Note that separators are part of the node in statements and class elements. */ public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); @@ -484,7 +484,7 @@ namespace ts.textChanges { private static normalize(changes: Change[]) { // order changes by start position const normalized = stableSort(changes, (a, b) => a.range.pos - b.range.pos); - // verify that change intervals to not overlap, except possible at end points. + // verify that change intervals do not overlap, except possibly at end points. for (let i = 0; i < normalized.length - 2; i++) { Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); } From e630ab1a3181b6b5d6a25069d15cbcb77bc3eb1b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 27 Mar 2017 14:20:00 -0700 Subject: [PATCH 205/207] Report semantic errors for JS files if checkJs is enabled --- src/server/session.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/session.ts b/src/server/session.ts index 11c99dfe46c..337aab1c3fb 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -31,7 +31,8 @@ namespace ts.server { } else { // For configured projects, require that skipLibCheck be set also - return project.getCompilerOptions().skipLibCheck && project.isJsOnlyProject(); + const options = project.getCompilerOptions(); + return options.skipLibCheck && !options.checkJs && project.isJsOnlyProject(); } } From dd06cbb3156aa6499756cf4da75e3492ae4b2e0a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 27 Mar 2017 14:32:45 -0700 Subject: [PATCH 206/207] getSpecialPropertyAssignmentKind: Always check for BinaryExpression *outside*, always check for JS file *inside* --- src/compiler/binder.ts | 48 +++++++++++++++++++-------------------- src/compiler/checker.ts | 6 ++--- src/compiler/utilities.ts | 5 +--- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 650797c6dba..45e8efdf512 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -259,7 +259,7 @@ namespace ts { case SyntaxKind.ExportAssignment: return (node).isExportEquals ? "export=" : "default"; case SyntaxKind.BinaryExpression: - switch (getSpecialPropertyAssignmentKind(node)) { + switch (getSpecialPropertyAssignmentKind(node as BinaryExpression)) { case SpecialPropertyAssignmentKind.ModuleExports: // module.exports = ... return "export="; @@ -2017,30 +2017,28 @@ namespace ts { } break; case SyntaxKind.BinaryExpression: - if (isInJavaScriptFile(node)) { - const specialKind = getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case SpecialPropertyAssignmentKind.ExportsProperty: - bindExportsPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.ModuleExports: - bindModuleExportsAssignment(node); - break; - case SpecialPropertyAssignmentKind.PrototypeProperty: - bindPrototypePropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.ThisProperty: - bindThisPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.Property: - bindStaticPropertyAssignment(node); - break; - case SpecialPropertyAssignmentKind.None: - // Nothing to do - break; - default: - Debug.fail("Unknown special property assignment kind"); - } + const specialKind = getSpecialPropertyAssignmentKind(node as BinaryExpression); + switch (specialKind) { + case SpecialPropertyAssignmentKind.ExportsProperty: + bindExportsPropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.ModuleExports: + bindModuleExportsAssignment(node); + break; + case SpecialPropertyAssignmentKind.PrototypeProperty: + bindPrototypePropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.ThisProperty: + bindThisPropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.Property: + bindStaticPropertyAssignment(node); + break; + case SpecialPropertyAssignmentKind.None: + // Nothing to do + break; + default: + Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); case SyntaxKind.CatchClause: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4e55a1c46b5..408739f480f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11929,8 +11929,8 @@ namespace ts { // If this is a function in a JS file, it might be a class method. Check if it's the RHS // of a x.prototype.y = function [name]() { .... } if (container.kind === SyntaxKind.FunctionExpression && - isInJavaScriptFile(container.parent) && - getSpecialPropertyAssignmentKind(container.parent) === SpecialPropertyAssignmentKind.PrototypeProperty) { + container.parent.kind === SyntaxKind.BinaryExpression && + getSpecialPropertyAssignmentKind(container.parent as BinaryExpression) === SpecialPropertyAssignmentKind.PrototypeProperty) { // Get the 'x' of 'x.prototype.y = f' (here, 'f' is 'container') const className = (((container.parent as BinaryExpression) // x.prototype.y = f .left as PropertyAccessExpression) // x.prototype.y @@ -21641,7 +21641,7 @@ namespace ts { } function getSpecialPropertyAssignmentSymbolFromEntityName(entityName: EntityName | PropertyAccessExpression) { - const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent); + const specialPropertyAssignmentKind = getSpecialPropertyAssignmentKind(entityName.parent.parent as BinaryExpression); switch (specialPropertyAssignmentKind) { case SpecialPropertyAssignmentKind.ExportsProperty: case SpecialPropertyAssignmentKind.PrototypeProperty: diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 33cb0d8f489..f0916855986 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1450,13 +1450,10 @@ namespace ts { /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder - export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind { + export function getSpecialPropertyAssignmentKind(expression: ts.BinaryExpression): SpecialPropertyAssignmentKind { if (!isInJavaScriptFile(expression)) { return SpecialPropertyAssignmentKind.None; } - if (expression.kind !== SyntaxKind.BinaryExpression) { - return SpecialPropertyAssignmentKind.None; - } const expr = expression; if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || expr.left.kind !== SyntaxKind.PropertyAccessExpression) { return SpecialPropertyAssignmentKind.None; From cac60457b18f880c850c1a8d585016e52dcc6ee0 Mon Sep 17 00:00:00 2001 From: ncoley Date: Tue, 28 Mar 2017 21:53:14 -0400 Subject: [PATCH 207/207] Update FormData methods with appropriate types --- src/lib/dom.iterable.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/dom.iterable.d.ts b/src/lib/dom.iterable.d.ts index ea0d43d3640..c79e0079962 100644 --- a/src/lib/dom.iterable.d.ts +++ b/src/lib/dom.iterable.d.ts @@ -8,7 +8,7 @@ interface FormData { /** * Returns an array of key, value pairs for every entry in the list */ - entries(): IterableIterator<[string, any]>; + entries(): IterableIterator<[string, string | File]>; /** * Returns a list of keys in the list */ @@ -16,9 +16,9 @@ interface FormData { /** * Returns a list of values in the list */ - values(): IterableIterator; + values(): IterableIterator; - [Symbol.iterator](): IterableIterator; + [Symbol.iterator](): IterableIterator; } interface NodeList {