mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'navbar_class_child_item' into navbar_modules
This commit is contained in:
+27
-22
@@ -726,24 +726,40 @@ function runConsoleTests(defaultReporter, defaultSubsets) {
|
||||
subsetRegexes = subsets.map(function (sub) { return "^" + sub + ".*$"; });
|
||||
subsetRegexes.push("^(?!" + subsets.join("|") + ").*$");
|
||||
}
|
||||
var counter = subsetRegexes.length;
|
||||
var errorStatus;
|
||||
subsetRegexes.forEach(function (subsetRegex, i) {
|
||||
tests = subsetRegex ? ' -g "' + subsetRegex + '"' : '';
|
||||
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
|
||||
console.log(cmd);
|
||||
function finish() {
|
||||
function finish(status) {
|
||||
counter--;
|
||||
// save first error status
|
||||
if (status !== undefined && errorStatus === undefined) {
|
||||
errorStatus = status;
|
||||
}
|
||||
|
||||
deleteTemporaryProjectOutput();
|
||||
complete();
|
||||
if (counter !== 0 || errorStatus === undefined) {
|
||||
// run linter when last worker is finished
|
||||
if (lintFlag && counter === 0) {
|
||||
var lint = jake.Task['lint'];
|
||||
lint.addListener('complete', function () {
|
||||
complete();
|
||||
});
|
||||
lint.invoke();
|
||||
}
|
||||
complete();
|
||||
}
|
||||
else {
|
||||
fail("Process exited with code " + status);
|
||||
}
|
||||
}
|
||||
exec(cmd, function () {
|
||||
if (lintFlag && i === 0) {
|
||||
var lint = jake.Task['lint'];
|
||||
lint.addListener('complete', function () {
|
||||
complete();
|
||||
});
|
||||
lint.invoke();
|
||||
}
|
||||
finish();
|
||||
}, finish);
|
||||
}, function(e, status) {
|
||||
finish(status);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -962,24 +978,13 @@ function lintFileAsync(options, path, cb) {
|
||||
});
|
||||
}
|
||||
|
||||
var servicesLintTargets = [
|
||||
"navigateTo.ts",
|
||||
"navigationBar.ts",
|
||||
"outliningElementsCollector.ts",
|
||||
"patternMatcher.ts",
|
||||
"services.ts",
|
||||
"shims.ts",
|
||||
"jsTyping.ts"
|
||||
].map(function (s) {
|
||||
return path.join(servicesDirectory, s);
|
||||
});
|
||||
var lintTargets = compilerSources
|
||||
.concat(harnessSources)
|
||||
// Other harness sources
|
||||
.concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f) }))
|
||||
.concat(serverCoreSources)
|
||||
.concat(tslintRulesFiles)
|
||||
.concat(servicesLintTargets);
|
||||
.concat(servicesSources);
|
||||
|
||||
|
||||
desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex");
|
||||
|
||||
Vendored
+4
-20
@@ -965,38 +965,22 @@ interface JSON {
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
*/
|
||||
stringify(value: any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: any[]): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string;
|
||||
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
* @param replacer An array of strings and numbers that acts as a white list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: any[], space: string | number): string;
|
||||
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
|
||||
*/
|
||||
|
||||
Vendored
+4
-20
@@ -965,38 +965,22 @@ interface JSON {
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
*/
|
||||
stringify(value: any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: any[]): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string;
|
||||
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
* @param replacer An array of strings and numbers that acts as a white list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: any[], space: string | number): string;
|
||||
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
|
||||
*/
|
||||
|
||||
Vendored
+4
-20
@@ -965,38 +965,22 @@ interface JSON {
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
*/
|
||||
stringify(value: any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
*/
|
||||
stringify(value: any, replacer: any[]): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: (key: string, value: any) => any, space: string | number): string;
|
||||
stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer Array that transforms the results.
|
||||
* @param replacer An array of strings and numbers that acts as a white list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
stringify(value: any, replacer: any[], space: string | number): string;
|
||||
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
|
||||
*/
|
||||
|
||||
+262
-105
@@ -913,6 +913,10 @@ var ts;
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
function getDirectories(path) {
|
||||
var folder = fso.GetFolder(path);
|
||||
return getNames(folder.subfolders);
|
||||
}
|
||||
function readDirectory(path, extension, exclude) {
|
||||
var result = [];
|
||||
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
|
||||
@@ -967,6 +971,7 @@ var ts;
|
||||
getCurrentDirectory: function () {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
getDirectories: getDirectories,
|
||||
readDirectory: readDirectory,
|
||||
exit: function (exitCode) {
|
||||
try {
|
||||
@@ -1114,6 +1119,9 @@ var ts;
|
||||
function directoryExists(path) {
|
||||
return fileSystemEntryExists(path, 1);
|
||||
}
|
||||
function getDirectories(path) {
|
||||
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1); });
|
||||
}
|
||||
function readDirectory(path, extension, exclude) {
|
||||
var result = [];
|
||||
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
|
||||
@@ -1206,6 +1214,7 @@ var ts;
|
||||
getCurrentDirectory: function () {
|
||||
return process.cwd();
|
||||
},
|
||||
getDirectories: getDirectories,
|
||||
readDirectory: readDirectory,
|
||||
getModifiedTime: function (path) {
|
||||
try {
|
||||
@@ -1256,6 +1265,7 @@ var ts;
|
||||
createDirectory: ChakraHost.createDirectory,
|
||||
getExecutingFilePath: function () { return ChakraHost.executingFile; },
|
||||
getCurrentDirectory: function () { return ChakraHost.currentDirectory; },
|
||||
getDirectories: ChakraHost.getDirectories,
|
||||
readDirectory: ChakraHost.readDirectory,
|
||||
exit: ChakraHost.quit,
|
||||
realpath: realpath
|
||||
@@ -1389,7 +1399,7 @@ var ts;
|
||||
or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." },
|
||||
Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." },
|
||||
Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." },
|
||||
Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." },
|
||||
Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." },
|
||||
File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" },
|
||||
@@ -1759,6 +1769,8 @@ var ts;
|
||||
this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." },
|
||||
The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." },
|
||||
The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." },
|
||||
Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" },
|
||||
All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@@ -1852,7 +1864,7 @@ var ts;
|
||||
Option_paths_cannot_be_used_without_specifying_baseUrl_option: { code: 5060, category: ts.DiagnosticCategory.Error, key: "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", message: "Option 'paths' cannot be used without specifying '--baseUrl' option." },
|
||||
Pattern_0_can_have_at_most_one_Asterisk_character: { code: 5061, category: ts.DiagnosticCategory.Error, key: "Pattern_0_can_have_at_most_one_Asterisk_character_5061", message: "Pattern '{0}' can have at most one '*' character" },
|
||||
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { code: 5062, category: ts.DiagnosticCategory.Error, key: "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", message: "Substitution '{0}' in pattern '{1}' in can have at most one '*' character" },
|
||||
Substututions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substututions_for_pattern_0_should_be_an_array_5063", message: "Substututions for pattern '{0}' should be an array." },
|
||||
Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." },
|
||||
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." },
|
||||
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." },
|
||||
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." },
|
||||
@@ -1865,6 +1877,7 @@ var ts;
|
||||
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." },
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
@@ -1966,6 +1979,7 @@ var ts;
|
||||
Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" },
|
||||
The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." },
|
||||
Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" },
|
||||
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -5004,7 +5018,7 @@ var ts;
|
||||
}
|
||||
ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
|
||||
function getPropertyNameForPropertyNameNode(name) {
|
||||
if (name.kind === 69 || name.kind === 9 || name.kind === 8) {
|
||||
if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) {
|
||||
return name.text;
|
||||
}
|
||||
if (name.kind === 140) {
|
||||
@@ -12050,10 +12064,10 @@ var ts;
|
||||
case 145:
|
||||
case 144:
|
||||
case 266:
|
||||
return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455);
|
||||
return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0);
|
||||
case 253:
|
||||
case 254:
|
||||
return bindPropertyOrMethodOrAccessor(node, 4, 107455);
|
||||
return bindPropertyOrMethodOrAccessor(node, 4, 0);
|
||||
case 255:
|
||||
return bindPropertyOrMethodOrAccessor(node, 8, 107455);
|
||||
case 247:
|
||||
@@ -12065,7 +12079,7 @@ var ts;
|
||||
return declareSymbolAndAddToSymbolTable(node, 131072, 0);
|
||||
case 147:
|
||||
case 146:
|
||||
return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263);
|
||||
return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263);
|
||||
case 220:
|
||||
return bindFunctionDeclaration(node);
|
||||
case 148:
|
||||
@@ -12108,7 +12122,7 @@ var ts;
|
||||
case 238:
|
||||
return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608);
|
||||
case 228:
|
||||
return bindGlobalModuleExportDeclaration(node);
|
||||
return bindNamespaceExportDeclaration(node);
|
||||
case 231:
|
||||
return bindImportClause(node);
|
||||
case 236:
|
||||
@@ -12144,13 +12158,13 @@ var ts;
|
||||
bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
|
||||
}
|
||||
else if (boundExpression.kind === 69 && node.kind === 235) {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0 | 8388608);
|
||||
}
|
||||
else {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 4, 0 | 8388608);
|
||||
}
|
||||
}
|
||||
function bindGlobalModuleExportDeclaration(node) {
|
||||
function bindNamespaceExportDeclaration(node) {
|
||||
if (node.modifiers && node.modifiers.length) {
|
||||
file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
|
||||
}
|
||||
@@ -12202,7 +12216,7 @@ var ts;
|
||||
function bindThisPropertyAssignment(node) {
|
||||
if (container.kind === 179 || container.kind === 220) {
|
||||
container.symbol.members = container.symbol.members || {};
|
||||
declareSymbol(container.symbol.members, container.symbol, node, 4, 107455 & ~4);
|
||||
declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4);
|
||||
}
|
||||
}
|
||||
function bindPrototypePropertyAssignment(node) {
|
||||
@@ -12219,7 +12233,7 @@ var ts;
|
||||
if (!funcSymbol.members) {
|
||||
funcSymbol.members = {};
|
||||
}
|
||||
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 107455);
|
||||
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 0);
|
||||
}
|
||||
function bindCallExpression(node) {
|
||||
if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
|
||||
@@ -12295,7 +12309,7 @@ var ts;
|
||||
}
|
||||
if (ts.isParameterPropertyDeclaration(node)) {
|
||||
var classDeclaration = node.parent.parent;
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455);
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 0);
|
||||
}
|
||||
}
|
||||
function bindFunctionDeclaration(node) {
|
||||
@@ -12595,7 +12609,7 @@ var ts;
|
||||
if (flags & 1)
|
||||
result |= 107454;
|
||||
if (flags & 4)
|
||||
result |= 107455;
|
||||
result |= 0;
|
||||
if (flags & 8)
|
||||
result |= 107455;
|
||||
if (flags & 16)
|
||||
@@ -12851,6 +12865,7 @@ var ts;
|
||||
var propertyWithInvalidInitializer;
|
||||
var errorLocation = location;
|
||||
var grandparent;
|
||||
var isInExternalModule = false;
|
||||
loop: while (location) {
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = getSymbol(location.locals, name, meaning)) {
|
||||
@@ -12882,6 +12897,7 @@ var ts;
|
||||
case 256:
|
||||
if (!ts.isExternalOrCommonJsModule(location))
|
||||
break;
|
||||
isInExternalModule = true;
|
||||
case 225:
|
||||
var moduleExports = getSymbolOfNode(location).exports;
|
||||
if (location.kind === 256 || ts.isAmbientModule(location)) {
|
||||
@@ -13005,6 +13021,12 @@ var ts;
|
||||
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
||||
}
|
||||
}
|
||||
if (result && isInExternalModule) {
|
||||
var decls = result.declarations;
|
||||
if (decls && decls.length === 1 && decls[0].kind === 228) {
|
||||
error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -14480,7 +14502,7 @@ var ts;
|
||||
}
|
||||
function getTypeForBindingElementParent(node) {
|
||||
var symbol = getSymbolOfNode(node);
|
||||
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node);
|
||||
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
|
||||
}
|
||||
function getTextOfPropertyName(name) {
|
||||
switch (name.kind) {
|
||||
@@ -14585,7 +14607,7 @@ var ts;
|
||||
function addOptionality(type, optional) {
|
||||
return strictNullChecks && optional ? addNullableKind(type, 32) : type;
|
||||
}
|
||||
function getTypeForVariableLikeDeclaration(declaration) {
|
||||
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
||||
if (declaration.flags & 134217728) {
|
||||
var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration);
|
||||
if (type && type !== unknownType) {
|
||||
@@ -14602,7 +14624,7 @@ var ts;
|
||||
return getTypeForBindingElement(declaration);
|
||||
}
|
||||
if (declaration.type) {
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), !!declaration.questionToken);
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality);
|
||||
}
|
||||
if (declaration.kind === 142) {
|
||||
var func = declaration.parent;
|
||||
@@ -14621,11 +14643,11 @@ var ts;
|
||||
? getContextuallyTypedThisType(func)
|
||||
: getContextuallyTypedParameterType(declaration);
|
||||
if (type) {
|
||||
return addOptionality(type, !!declaration.questionToken);
|
||||
return addOptionality(type, declaration.questionToken && includeOptionality);
|
||||
}
|
||||
}
|
||||
if (declaration.initializer) {
|
||||
return addOptionality(checkExpressionCached(declaration.initializer), !!declaration.questionToken);
|
||||
return addOptionality(checkExpressionCached(declaration.initializer), declaration.questionToken && includeOptionality);
|
||||
}
|
||||
if (declaration.kind === 254) {
|
||||
return checkIdentifier(declaration.name);
|
||||
@@ -14693,7 +14715,7 @@ var ts;
|
||||
: getTypeFromArrayBindingPattern(pattern, includePatternInType);
|
||||
}
|
||||
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
||||
var type = getTypeForVariableLikeDeclaration(declaration);
|
||||
var type = getTypeForVariableLikeDeclaration(declaration, true);
|
||||
if (type) {
|
||||
if (reportErrors) {
|
||||
reportErrorsFromWidening(declaration, type);
|
||||
@@ -17010,7 +17032,7 @@ var ts;
|
||||
return isIdenticalTo(source, target);
|
||||
}
|
||||
if (!(target.flags & 134217728)) {
|
||||
if (target.flags & 1)
|
||||
if (target.flags & 1 || source.flags & 134217728)
|
||||
return -1;
|
||||
if (source.flags & 32) {
|
||||
if (!strictNullChecks || target.flags & (32 | 16) || source === emptyArrayElementType)
|
||||
@@ -17030,7 +17052,7 @@ var ts;
|
||||
if (source.flags & 256 && target === stringType)
|
||||
return -1;
|
||||
if (relation === assignableRelation || relation === comparableRelation) {
|
||||
if (source.flags & (1 | 134217728))
|
||||
if (source.flags & 1)
|
||||
return -1;
|
||||
if (source === numberType && target.flags & 128)
|
||||
return -1;
|
||||
@@ -17807,41 +17829,47 @@ var ts;
|
||||
getSignaturesOfType(type, 0).length === 0 &&
|
||||
getSignaturesOfType(type, 1).length === 0;
|
||||
}
|
||||
function createTransientSymbol(source, type) {
|
||||
var symbol = createSymbol(source.flags | 67108864, source.name);
|
||||
symbol.declarations = source.declarations;
|
||||
symbol.parent = source.parent;
|
||||
symbol.type = type;
|
||||
symbol.target = source;
|
||||
if (source.valueDeclaration) {
|
||||
symbol.valueDeclaration = source.valueDeclaration;
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
function transformTypeOfMembers(type, f) {
|
||||
var members = {};
|
||||
for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
|
||||
var property = _a[_i];
|
||||
var original = getTypeOfSymbol(property);
|
||||
var updated = f(original);
|
||||
members[property.name] = updated === original ? property : createTransientSymbol(property, updated);
|
||||
}
|
||||
;
|
||||
return members;
|
||||
}
|
||||
function getRegularTypeOfObjectLiteral(type) {
|
||||
if (type.flags & 1048576) {
|
||||
var regularType = type.regularType;
|
||||
if (!regularType) {
|
||||
regularType = createType(type.flags & ~1048576);
|
||||
regularType.symbol = type.symbol;
|
||||
regularType.members = type.members;
|
||||
regularType.properties = type.properties;
|
||||
regularType.callSignatures = type.callSignatures;
|
||||
regularType.constructSignatures = type.constructSignatures;
|
||||
regularType.stringIndexInfo = type.stringIndexInfo;
|
||||
regularType.numberIndexInfo = type.numberIndexInfo;
|
||||
type.regularType = regularType;
|
||||
}
|
||||
if (!(type.flags & 1048576)) {
|
||||
return type;
|
||||
}
|
||||
var regularType = type.regularType;
|
||||
if (regularType) {
|
||||
return regularType;
|
||||
}
|
||||
return type;
|
||||
var resolved = type;
|
||||
var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
|
||||
var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
|
||||
regularNew.flags = resolved.flags & ~1048576;
|
||||
type.regularType = regularNew;
|
||||
return regularNew;
|
||||
}
|
||||
function getWidenedTypeOfObjectLiteral(type) {
|
||||
var properties = getPropertiesOfObjectType(type);
|
||||
var members = {};
|
||||
ts.forEach(properties, function (p) {
|
||||
var propType = getTypeOfSymbol(p);
|
||||
var widenedType = getWidenedType(propType);
|
||||
if (propType !== widenedType) {
|
||||
var symbol = createSymbol(p.flags | 67108864, p.name);
|
||||
symbol.declarations = p.declarations;
|
||||
symbol.parent = p.parent;
|
||||
symbol.type = widenedType;
|
||||
symbol.target = p;
|
||||
if (p.valueDeclaration)
|
||||
symbol.valueDeclaration = p.valueDeclaration;
|
||||
p = symbol;
|
||||
}
|
||||
members[p.name] = p;
|
||||
var members = transformTypeOfMembers(type, function (prop) {
|
||||
var widened = getWidenedType(prop);
|
||||
return prop === widened ? prop : widened;
|
||||
});
|
||||
var stringIndexInfo = getIndexInfoOfType(type, 0);
|
||||
var numberIndexInfo = getIndexInfoOfType(type, 1);
|
||||
@@ -18062,7 +18090,7 @@ var ts;
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
if (target.flags & 16384 && typeParameterCount === 1) {
|
||||
if (typeParameterCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferiority--;
|
||||
@@ -19134,7 +19162,7 @@ var ts;
|
||||
}
|
||||
return nodeCheckFlag === 512
|
||||
? getBaseConstructorTypeOfClass(classType)
|
||||
: baseClassType;
|
||||
: getTypeWithThisArgument(baseClassType, classType.thisType);
|
||||
function isLegalUsageOfSuperExpression(container) {
|
||||
if (!container) {
|
||||
return false;
|
||||
@@ -21182,7 +21210,7 @@ var ts;
|
||||
var types = void 0;
|
||||
var funcIsGenerator = !!func.asteriskToken;
|
||||
if (funcIsGenerator) {
|
||||
types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper);
|
||||
types = checkAndAggregateYieldOperandTypes(func, contextualMapper);
|
||||
if (types.length === 0) {
|
||||
var iterableIteratorAny = createIterableIteratorType(anyType);
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
@@ -21192,8 +21220,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var hasImplicitReturn = !!(func.flags & 32768);
|
||||
types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync, hasImplicitReturn);
|
||||
types = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
|
||||
if (!types) {
|
||||
return neverType;
|
||||
}
|
||||
@@ -21240,9 +21267,9 @@ var ts;
|
||||
return widenedType;
|
||||
}
|
||||
}
|
||||
function checkAndAggregateYieldOperandTypes(body, contextualMapper) {
|
||||
function checkAndAggregateYieldOperandTypes(func, contextualMapper) {
|
||||
var aggregatedTypes = [];
|
||||
ts.forEachYieldExpression(body, function (yieldExpression) {
|
||||
ts.forEachYieldExpression(func.body, function (yieldExpression) {
|
||||
var expr = yieldExpression.expression;
|
||||
if (expr) {
|
||||
var type = checkExpressionCached(expr, contextualMapper);
|
||||
@@ -21256,28 +21283,34 @@ var ts;
|
||||
});
|
||||
return aggregatedTypes;
|
||||
}
|
||||
function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync, hasImplicitReturn) {
|
||||
function checkAndAggregateReturnExpressionTypes(func, contextualMapper) {
|
||||
var isAsync = ts.isAsyncFunctionLike(func);
|
||||
var aggregatedTypes = [];
|
||||
var hasOmittedExpressions = false;
|
||||
ts.forEachReturnStatement(body, function (returnStatement) {
|
||||
var hasReturnWithNoExpression = !!(func.flags & 32768);
|
||||
var hasReturnOfTypeNever = false;
|
||||
ts.forEachReturnStatement(func.body, function (returnStatement) {
|
||||
var expr = returnStatement.expression;
|
||||
if (expr) {
|
||||
var type = checkExpressionCached(expr, contextualMapper);
|
||||
if (isAsync) {
|
||||
type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
|
||||
type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
|
||||
}
|
||||
if (type !== neverType && !ts.contains(aggregatedTypes, type)) {
|
||||
if (type === neverType) {
|
||||
hasReturnOfTypeNever = true;
|
||||
}
|
||||
else if (!ts.contains(aggregatedTypes, type)) {
|
||||
aggregatedTypes.push(type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
hasOmittedExpressions = true;
|
||||
hasReturnWithNoExpression = true;
|
||||
}
|
||||
});
|
||||
if (aggregatedTypes.length === 0 && !hasOmittedExpressions && !hasImplicitReturn) {
|
||||
if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever ||
|
||||
func.kind === 179 || func.kind === 180)) {
|
||||
return undefined;
|
||||
}
|
||||
if (strictNullChecks && aggregatedTypes.length && (hasOmittedExpressions || hasImplicitReturn)) {
|
||||
if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) {
|
||||
if (!ts.contains(aggregatedTypes, undefinedType)) {
|
||||
aggregatedTypes.push(undefinedType);
|
||||
}
|
||||
@@ -21407,7 +21440,9 @@ var ts;
|
||||
(expr.kind === 172 || expr.kind === 173) &&
|
||||
expr.expression.kind === 97) {
|
||||
var func = ts.getContainingFunction(expr);
|
||||
return !(func && func.kind === 148 && func.parent === symbol.valueDeclaration.parent);
|
||||
if (!(func && func.kind === 148))
|
||||
return true;
|
||||
return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -22231,6 +22266,79 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkClassForDuplicateDeclarations(node) {
|
||||
var getter = 1, setter = 2, property = getter | setter;
|
||||
var instanceNames = {};
|
||||
var staticNames = {};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (member.kind === 148) {
|
||||
for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
|
||||
var param = _c[_b];
|
||||
if (ts.isParameterPropertyDeclaration(param)) {
|
||||
addName(instanceNames, param.name, param.name.text, property);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var static = ts.forEach(member.modifiers, function (m) { return m.kind === 113; });
|
||||
var names = static ? staticNames : instanceNames;
|
||||
var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name);
|
||||
if (memberName) {
|
||||
switch (member.kind) {
|
||||
case 149:
|
||||
addName(names, member.name, memberName, getter);
|
||||
break;
|
||||
case 150:
|
||||
addName(names, member.name, memberName, setter);
|
||||
break;
|
||||
case 145:
|
||||
addName(names, member.name, memberName, property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function addName(names, location, name, meaning) {
|
||||
if (ts.hasProperty(names, name)) {
|
||||
var prev = names[name];
|
||||
if (prev & meaning) {
|
||||
error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
|
||||
}
|
||||
else {
|
||||
names[name] = prev | meaning;
|
||||
}
|
||||
}
|
||||
else {
|
||||
names[name] = meaning;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkObjectTypeForDuplicateDeclarations(node) {
|
||||
var names = {};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (member.kind == 144) {
|
||||
var memberName = void 0;
|
||||
switch (member.name.kind) {
|
||||
case 9:
|
||||
case 8:
|
||||
case 69:
|
||||
memberName = member.name.text;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if (ts.hasProperty(names, memberName)) {
|
||||
error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
|
||||
error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
|
||||
}
|
||||
else {
|
||||
names[memberName] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkTypeForDuplicateIndexSignatures(node) {
|
||||
if (node.kind === 222) {
|
||||
var nodeSymbol = getSymbolOfNode(node);
|
||||
@@ -22449,6 +22557,7 @@ var ts;
|
||||
var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
|
||||
checkIndexConstraints(type);
|
||||
checkTypeForDuplicateIndexSignatures(node);
|
||||
checkObjectTypeForDuplicateDeclarations(node);
|
||||
}
|
||||
}
|
||||
function checkArrayType(node) {
|
||||
@@ -23208,6 +23317,10 @@ var ts;
|
||||
if (node.initializer) {
|
||||
checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined);
|
||||
}
|
||||
if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
|
||||
error(symbol.valueDeclaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
|
||||
error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
|
||||
}
|
||||
}
|
||||
if (node.kind !== 145 && node.kind !== 144) {
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
@@ -23220,6 +23333,18 @@ var ts;
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
}
|
||||
}
|
||||
function areDeclarationFlagsIdentical(left, right) {
|
||||
if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
|
||||
return false;
|
||||
}
|
||||
var interestingFlags = 8 |
|
||||
16 |
|
||||
256 |
|
||||
128 |
|
||||
64 |
|
||||
32;
|
||||
return (left.flags & interestingFlags) === (right.flags & interestingFlags);
|
||||
}
|
||||
function checkVariableDeclaration(node) {
|
||||
checkGrammarVariableDeclaration(node);
|
||||
return checkVariableLikeDeclaration(node);
|
||||
@@ -23770,6 +23895,7 @@ var ts;
|
||||
var typeWithThis = getTypeWithThisArgument(type);
|
||||
var staticType = getTypeOfSymbol(symbol);
|
||||
checkTypeParameterListsIdentical(node, symbol);
|
||||
checkClassForDuplicateDeclarations(node);
|
||||
var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node);
|
||||
if (baseTypeNode) {
|
||||
var baseTypes = getBaseTypes(type);
|
||||
@@ -23981,6 +24107,7 @@ var ts;
|
||||
checkIndexConstraints(type);
|
||||
}
|
||||
}
|
||||
checkObjectTypeForDuplicateDeclarations(node);
|
||||
}
|
||||
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
|
||||
if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) {
|
||||
@@ -24735,10 +24862,8 @@ var ts;
|
||||
function checkSourceFileWorker(node) {
|
||||
var links = getNodeLinks(node);
|
||||
if (!(links.flags & 1)) {
|
||||
if (compilerOptions.skipDefaultLibCheck) {
|
||||
if (node.hasNoDefaultLib) {
|
||||
return;
|
||||
}
|
||||
if (compilerOptions.skipLibCheck && node.isDeclarationFile || compilerOptions.skipDefaultLibCheck && node.hasNoDefaultLib) {
|
||||
return;
|
||||
}
|
||||
checkGrammarSourceFile(node);
|
||||
potentialThisCollisions.length = 0;
|
||||
@@ -25107,7 +25232,7 @@ var ts;
|
||||
return symbol && getTypeOfSymbol(symbol);
|
||||
}
|
||||
if (ts.isBindingPattern(node)) {
|
||||
return getTypeForVariableLikeDeclaration(node.parent);
|
||||
return getTypeForVariableLikeDeclaration(node.parent, true);
|
||||
}
|
||||
if (isInRightSideOfImportOrExportAssignment(node)) {
|
||||
var symbol = getSymbolAtLocation(node);
|
||||
@@ -25546,7 +25671,7 @@ var ts;
|
||||
if (file.moduleAugmentations.length) {
|
||||
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
|
||||
}
|
||||
if (file.wasReferenced && file.symbol && file.symbol.globalExports) {
|
||||
if (file.symbol && file.symbol.globalExports) {
|
||||
mergeSymbolTable(globals, file.symbol.globalExports);
|
||||
}
|
||||
});
|
||||
@@ -26116,7 +26241,6 @@ var ts;
|
||||
if (prop.kind === 193 ||
|
||||
name_20.kind === 140) {
|
||||
checkGrammarComputedPropertyName(name_20);
|
||||
return "continue";
|
||||
}
|
||||
if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) {
|
||||
return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) };
|
||||
@@ -26146,17 +26270,21 @@ var ts;
|
||||
else {
|
||||
ts.Debug.fail("Unexpected syntax kind:" + prop.kind);
|
||||
}
|
||||
if (!ts.hasProperty(seen, name_20.text)) {
|
||||
seen[name_20.text] = currentKind;
|
||||
var effectiveName = ts.getPropertyNameForPropertyNameNode(name_20);
|
||||
if (effectiveName === undefined) {
|
||||
return "continue";
|
||||
}
|
||||
if (!ts.hasProperty(seen, effectiveName)) {
|
||||
seen[effectiveName] = currentKind;
|
||||
}
|
||||
else {
|
||||
var existingKind = seen[name_20.text];
|
||||
var existingKind = seen[effectiveName];
|
||||
if (currentKind === Property && existingKind === Property) {
|
||||
return "continue";
|
||||
grammarErrorOnNode(name_20, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_20));
|
||||
}
|
||||
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
|
||||
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
|
||||
seen[name_20.text] = currentKind | existingKind;
|
||||
seen[effectiveName] = currentKind | existingKind;
|
||||
}
|
||||
else {
|
||||
return { value: grammarErrorOnNode(name_20, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) };
|
||||
@@ -34613,7 +34741,7 @@ var ts;
|
||||
skipTsx: true,
|
||||
traceEnabled: traceEnabled
|
||||
};
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : undefined);
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
|
||||
if (traceEnabled) {
|
||||
if (containingFile === undefined) {
|
||||
if (rootDir === undefined) {
|
||||
@@ -35116,12 +35244,25 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(rootPath) {
|
||||
var localTypes = ts.combinePaths(rootPath, "types");
|
||||
var npmTypes = ts.combinePaths(rootPath, "node_modules/@types");
|
||||
var result = [];
|
||||
if (ts.sys.directoryExists(localTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(localTypes));
|
||||
}
|
||||
if (ts.sys.directoryExists(npmTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(npmTypes));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function getDefaultLibLocation() {
|
||||
return ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath()));
|
||||
}
|
||||
var newLine = ts.getNewLineCharacter(options);
|
||||
var realpath = ts.sys.realpath && (function (path) { return ts.sys.realpath(path); });
|
||||
return {
|
||||
getDefaultTypeDirectiveNames: getDefaultTypeDirectiveNames,
|
||||
getSourceFile: getSourceFile,
|
||||
getDefaultLibLocation: getDefaultLibLocation,
|
||||
getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
|
||||
@@ -35189,6 +35330,19 @@ var ts;
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(options, rootFiles, host) {
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
}
|
||||
if (host && host.getDefaultTypeDirectiveNames) {
|
||||
var commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), function (f) { return host.getCanonicalFileName(f); });
|
||||
if (commonRoot) {
|
||||
return host.getDefaultTypeDirectiveNames(commonRoot);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
ts.getDefaultTypeDirectiveNames = getDefaultTypeDirectiveNames;
|
||||
function createProgram(rootNames, options, host, oldProgram) {
|
||||
var program;
|
||||
var files = [];
|
||||
@@ -35224,13 +35378,14 @@ var ts;
|
||||
var filesByName = ts.createFileMap();
|
||||
var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined;
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
if (options.types && options.types.length) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(options.types, undefined);
|
||||
for (var i = 0; i < options.types.length; i++) {
|
||||
processTypeReferenceDirective(options.types[i], resolutions[i]);
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, false); });
|
||||
var typeReferences = getDefaultTypeDirectiveNames(options, rootNames, host);
|
||||
if (typeReferences) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, undefined);
|
||||
for (var i = 0; i < typeReferences.length; i++) {
|
||||
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
|
||||
}
|
||||
}
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, false); });
|
||||
if (!skipDefaultLib) {
|
||||
if (!options.lib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
@@ -35807,9 +35962,6 @@ var ts;
|
||||
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
if (file_1) {
|
||||
file_1.wasReferenced = file_1.wasReferenced || isReference;
|
||||
}
|
||||
return file_1;
|
||||
}
|
||||
var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
|
||||
@@ -35822,7 +35974,6 @@ var ts;
|
||||
});
|
||||
filesByName.set(path, file);
|
||||
if (file) {
|
||||
file.wasReferenced = file.wasReferenced || isReference;
|
||||
file.path = path;
|
||||
if (host.useCaseSensitiveFileNames()) {
|
||||
var existingFile = filesByNameIgnoreCase.get(path);
|
||||
@@ -35923,17 +36074,7 @@ var ts;
|
||||
!options.noResolve &&
|
||||
i < file.imports.length;
|
||||
if (shouldAddFile) {
|
||||
var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
if (!ts.isExternalModule(importedFile) && importedFile.statements.length) {
|
||||
var start_5 = ts.getTokenPosOfNode(file.imports[i], file);
|
||||
fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_5, file.imports[i].end - start_5, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
}
|
||||
else if (importedFile.referencedFiles.length) {
|
||||
var firstRef = importedFile.referencedFiles[0];
|
||||
fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
|
||||
}
|
||||
}
|
||||
findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36018,7 +36159,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substututions_for_pattern_0_should_be_an_array, key));
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36067,13 +36208,19 @@ var ts;
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
if (options.module === ts.ModuleKind.ES6 && languageVersion < 2) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
if (outFile && options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
}
|
||||
else if (options.module === undefined && firstExternalModuleSourceFile) {
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
|
||||
}
|
||||
}
|
||||
if (options.outDir ||
|
||||
options.sourceRoot ||
|
||||
@@ -36156,6 +36303,11 @@ var ts;
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Print_this_message
|
||||
},
|
||||
{
|
||||
name: "help",
|
||||
shortName: "?",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "init",
|
||||
type: "boolean",
|
||||
@@ -36258,6 +36410,11 @@ var ts;
|
||||
name: "skipDefaultLibCheck",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "skipLibCheck",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Skip_type_checking_of_declaration_files
|
||||
},
|
||||
{
|
||||
name: "out",
|
||||
type: "string",
|
||||
|
||||
+299
-134
@@ -918,6 +918,10 @@ var ts;
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
function getDirectories(path) {
|
||||
var folder = fso.GetFolder(path);
|
||||
return getNames(folder.subfolders);
|
||||
}
|
||||
function readDirectory(path, extension, exclude) {
|
||||
var result = [];
|
||||
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
|
||||
@@ -972,6 +976,7 @@ var ts;
|
||||
getCurrentDirectory: function () {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
getDirectories: getDirectories,
|
||||
readDirectory: readDirectory,
|
||||
exit: function (exitCode) {
|
||||
try {
|
||||
@@ -1119,6 +1124,9 @@ var ts;
|
||||
function directoryExists(path) {
|
||||
return fileSystemEntryExists(path, 1);
|
||||
}
|
||||
function getDirectories(path) {
|
||||
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1); });
|
||||
}
|
||||
function readDirectory(path, extension, exclude) {
|
||||
var result = [];
|
||||
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
|
||||
@@ -1211,6 +1219,7 @@ var ts;
|
||||
getCurrentDirectory: function () {
|
||||
return process.cwd();
|
||||
},
|
||||
getDirectories: getDirectories,
|
||||
readDirectory: readDirectory,
|
||||
getModifiedTime: function (path) {
|
||||
try {
|
||||
@@ -1261,6 +1270,7 @@ var ts;
|
||||
createDirectory: ChakraHost.createDirectory,
|
||||
getExecutingFilePath: function () { return ChakraHost.executingFile; },
|
||||
getCurrentDirectory: function () { return ChakraHost.currentDirectory; },
|
||||
getDirectories: ChakraHost.getDirectories,
|
||||
readDirectory: ChakraHost.readDirectory,
|
||||
exit: ChakraHost.quit,
|
||||
realpath: realpath
|
||||
@@ -1394,7 +1404,7 @@ var ts;
|
||||
or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." },
|
||||
Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." },
|
||||
Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." },
|
||||
Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." },
|
||||
Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." },
|
||||
File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" },
|
||||
@@ -1764,6 +1774,8 @@ var ts;
|
||||
this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." },
|
||||
The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." },
|
||||
The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." },
|
||||
Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" },
|
||||
All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@@ -1857,7 +1869,7 @@ var ts;
|
||||
Option_paths_cannot_be_used_without_specifying_baseUrl_option: { code: 5060, category: ts.DiagnosticCategory.Error, key: "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", message: "Option 'paths' cannot be used without specifying '--baseUrl' option." },
|
||||
Pattern_0_can_have_at_most_one_Asterisk_character: { code: 5061, category: ts.DiagnosticCategory.Error, key: "Pattern_0_can_have_at_most_one_Asterisk_character_5061", message: "Pattern '{0}' can have at most one '*' character" },
|
||||
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { code: 5062, category: ts.DiagnosticCategory.Error, key: "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", message: "Substitution '{0}' in pattern '{1}' in can have at most one '*' character" },
|
||||
Substututions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substututions_for_pattern_0_should_be_an_array_5063", message: "Substututions for pattern '{0}' should be an array." },
|
||||
Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." },
|
||||
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." },
|
||||
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." },
|
||||
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." },
|
||||
@@ -1870,6 +1882,7 @@ var ts;
|
||||
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." },
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
@@ -1971,6 +1984,7 @@ var ts;
|
||||
Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" },
|
||||
The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." },
|
||||
Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" },
|
||||
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -3537,6 +3551,11 @@ var ts;
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Print_this_message
|
||||
},
|
||||
{
|
||||
name: "help",
|
||||
shortName: "?",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "init",
|
||||
type: "boolean",
|
||||
@@ -3639,6 +3658,11 @@ var ts;
|
||||
name: "skipDefaultLibCheck",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "skipLibCheck",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Skip_type_checking_of_declaration_files
|
||||
},
|
||||
{
|
||||
name: "out",
|
||||
type: "string",
|
||||
@@ -5758,7 +5782,7 @@ var ts;
|
||||
}
|
||||
ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
|
||||
function getPropertyNameForPropertyNameNode(name) {
|
||||
if (name.kind === 69 || name.kind === 9 || name.kind === 8) {
|
||||
if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) {
|
||||
return name.text;
|
||||
}
|
||||
if (name.kind === 140) {
|
||||
@@ -12804,10 +12828,10 @@ var ts;
|
||||
case 145:
|
||||
case 144:
|
||||
case 266:
|
||||
return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455);
|
||||
return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0);
|
||||
case 253:
|
||||
case 254:
|
||||
return bindPropertyOrMethodOrAccessor(node, 4, 107455);
|
||||
return bindPropertyOrMethodOrAccessor(node, 4, 0);
|
||||
case 255:
|
||||
return bindPropertyOrMethodOrAccessor(node, 8, 107455);
|
||||
case 247:
|
||||
@@ -12819,7 +12843,7 @@ var ts;
|
||||
return declareSymbolAndAddToSymbolTable(node, 131072, 0);
|
||||
case 147:
|
||||
case 146:
|
||||
return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263);
|
||||
return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263);
|
||||
case 220:
|
||||
return bindFunctionDeclaration(node);
|
||||
case 148:
|
||||
@@ -12862,7 +12886,7 @@ var ts;
|
||||
case 238:
|
||||
return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608);
|
||||
case 228:
|
||||
return bindGlobalModuleExportDeclaration(node);
|
||||
return bindNamespaceExportDeclaration(node);
|
||||
case 231:
|
||||
return bindImportClause(node);
|
||||
case 236:
|
||||
@@ -12898,13 +12922,13 @@ var ts;
|
||||
bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
|
||||
}
|
||||
else if (boundExpression.kind === 69 && node.kind === 235) {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0 | 8388608);
|
||||
}
|
||||
else {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 4, 0 | 8388608);
|
||||
}
|
||||
}
|
||||
function bindGlobalModuleExportDeclaration(node) {
|
||||
function bindNamespaceExportDeclaration(node) {
|
||||
if (node.modifiers && node.modifiers.length) {
|
||||
file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
|
||||
}
|
||||
@@ -12956,7 +12980,7 @@ var ts;
|
||||
function bindThisPropertyAssignment(node) {
|
||||
if (container.kind === 179 || container.kind === 220) {
|
||||
container.symbol.members = container.symbol.members || {};
|
||||
declareSymbol(container.symbol.members, container.symbol, node, 4, 107455 & ~4);
|
||||
declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4);
|
||||
}
|
||||
}
|
||||
function bindPrototypePropertyAssignment(node) {
|
||||
@@ -12973,7 +12997,7 @@ var ts;
|
||||
if (!funcSymbol.members) {
|
||||
funcSymbol.members = {};
|
||||
}
|
||||
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 107455);
|
||||
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 0);
|
||||
}
|
||||
function bindCallExpression(node) {
|
||||
if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
|
||||
@@ -13049,7 +13073,7 @@ var ts;
|
||||
}
|
||||
if (ts.isParameterPropertyDeclaration(node)) {
|
||||
var classDeclaration = node.parent.parent;
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455);
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 0);
|
||||
}
|
||||
}
|
||||
function bindFunctionDeclaration(node) {
|
||||
@@ -13349,7 +13373,7 @@ var ts;
|
||||
if (flags & 1)
|
||||
result |= 107454;
|
||||
if (flags & 4)
|
||||
result |= 107455;
|
||||
result |= 0;
|
||||
if (flags & 8)
|
||||
result |= 107455;
|
||||
if (flags & 16)
|
||||
@@ -13605,6 +13629,7 @@ var ts;
|
||||
var propertyWithInvalidInitializer;
|
||||
var errorLocation = location;
|
||||
var grandparent;
|
||||
var isInExternalModule = false;
|
||||
loop: while (location) {
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = getSymbol(location.locals, name, meaning)) {
|
||||
@@ -13636,6 +13661,7 @@ var ts;
|
||||
case 256:
|
||||
if (!ts.isExternalOrCommonJsModule(location))
|
||||
break;
|
||||
isInExternalModule = true;
|
||||
case 225:
|
||||
var moduleExports = getSymbolOfNode(location).exports;
|
||||
if (location.kind === 256 || ts.isAmbientModule(location)) {
|
||||
@@ -13759,6 +13785,12 @@ var ts;
|
||||
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
||||
}
|
||||
}
|
||||
if (result && isInExternalModule) {
|
||||
var decls = result.declarations;
|
||||
if (decls && decls.length === 1 && decls[0].kind === 228) {
|
||||
error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -15234,7 +15266,7 @@ var ts;
|
||||
}
|
||||
function getTypeForBindingElementParent(node) {
|
||||
var symbol = getSymbolOfNode(node);
|
||||
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node);
|
||||
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
|
||||
}
|
||||
function getTextOfPropertyName(name) {
|
||||
switch (name.kind) {
|
||||
@@ -15339,7 +15371,7 @@ var ts;
|
||||
function addOptionality(type, optional) {
|
||||
return strictNullChecks && optional ? addNullableKind(type, 32) : type;
|
||||
}
|
||||
function getTypeForVariableLikeDeclaration(declaration) {
|
||||
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
||||
if (declaration.flags & 134217728) {
|
||||
var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration);
|
||||
if (type && type !== unknownType) {
|
||||
@@ -15356,7 +15388,7 @@ var ts;
|
||||
return getTypeForBindingElement(declaration);
|
||||
}
|
||||
if (declaration.type) {
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), !!declaration.questionToken);
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality);
|
||||
}
|
||||
if (declaration.kind === 142) {
|
||||
var func = declaration.parent;
|
||||
@@ -15375,11 +15407,11 @@ var ts;
|
||||
? getContextuallyTypedThisType(func)
|
||||
: getContextuallyTypedParameterType(declaration);
|
||||
if (type) {
|
||||
return addOptionality(type, !!declaration.questionToken);
|
||||
return addOptionality(type, declaration.questionToken && includeOptionality);
|
||||
}
|
||||
}
|
||||
if (declaration.initializer) {
|
||||
return addOptionality(checkExpressionCached(declaration.initializer), !!declaration.questionToken);
|
||||
return addOptionality(checkExpressionCached(declaration.initializer), declaration.questionToken && includeOptionality);
|
||||
}
|
||||
if (declaration.kind === 254) {
|
||||
return checkIdentifier(declaration.name);
|
||||
@@ -15447,7 +15479,7 @@ var ts;
|
||||
: getTypeFromArrayBindingPattern(pattern, includePatternInType);
|
||||
}
|
||||
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
||||
var type = getTypeForVariableLikeDeclaration(declaration);
|
||||
var type = getTypeForVariableLikeDeclaration(declaration, true);
|
||||
if (type) {
|
||||
if (reportErrors) {
|
||||
reportErrorsFromWidening(declaration, type);
|
||||
@@ -17764,7 +17796,7 @@ var ts;
|
||||
return isIdenticalTo(source, target);
|
||||
}
|
||||
if (!(target.flags & 134217728)) {
|
||||
if (target.flags & 1)
|
||||
if (target.flags & 1 || source.flags & 134217728)
|
||||
return -1;
|
||||
if (source.flags & 32) {
|
||||
if (!strictNullChecks || target.flags & (32 | 16) || source === emptyArrayElementType)
|
||||
@@ -17784,7 +17816,7 @@ var ts;
|
||||
if (source.flags & 256 && target === stringType)
|
||||
return -1;
|
||||
if (relation === assignableRelation || relation === comparableRelation) {
|
||||
if (source.flags & (1 | 134217728))
|
||||
if (source.flags & 1)
|
||||
return -1;
|
||||
if (source === numberType && target.flags & 128)
|
||||
return -1;
|
||||
@@ -18561,41 +18593,47 @@ var ts;
|
||||
getSignaturesOfType(type, 0).length === 0 &&
|
||||
getSignaturesOfType(type, 1).length === 0;
|
||||
}
|
||||
function createTransientSymbol(source, type) {
|
||||
var symbol = createSymbol(source.flags | 67108864, source.name);
|
||||
symbol.declarations = source.declarations;
|
||||
symbol.parent = source.parent;
|
||||
symbol.type = type;
|
||||
symbol.target = source;
|
||||
if (source.valueDeclaration) {
|
||||
symbol.valueDeclaration = source.valueDeclaration;
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
function transformTypeOfMembers(type, f) {
|
||||
var members = {};
|
||||
for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
|
||||
var property = _a[_i];
|
||||
var original = getTypeOfSymbol(property);
|
||||
var updated = f(original);
|
||||
members[property.name] = updated === original ? property : createTransientSymbol(property, updated);
|
||||
}
|
||||
;
|
||||
return members;
|
||||
}
|
||||
function getRegularTypeOfObjectLiteral(type) {
|
||||
if (type.flags & 1048576) {
|
||||
var regularType = type.regularType;
|
||||
if (!regularType) {
|
||||
regularType = createType(type.flags & ~1048576);
|
||||
regularType.symbol = type.symbol;
|
||||
regularType.members = type.members;
|
||||
regularType.properties = type.properties;
|
||||
regularType.callSignatures = type.callSignatures;
|
||||
regularType.constructSignatures = type.constructSignatures;
|
||||
regularType.stringIndexInfo = type.stringIndexInfo;
|
||||
regularType.numberIndexInfo = type.numberIndexInfo;
|
||||
type.regularType = regularType;
|
||||
}
|
||||
if (!(type.flags & 1048576)) {
|
||||
return type;
|
||||
}
|
||||
var regularType = type.regularType;
|
||||
if (regularType) {
|
||||
return regularType;
|
||||
}
|
||||
return type;
|
||||
var resolved = type;
|
||||
var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
|
||||
var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
|
||||
regularNew.flags = resolved.flags & ~1048576;
|
||||
type.regularType = regularNew;
|
||||
return regularNew;
|
||||
}
|
||||
function getWidenedTypeOfObjectLiteral(type) {
|
||||
var properties = getPropertiesOfObjectType(type);
|
||||
var members = {};
|
||||
ts.forEach(properties, function (p) {
|
||||
var propType = getTypeOfSymbol(p);
|
||||
var widenedType = getWidenedType(propType);
|
||||
if (propType !== widenedType) {
|
||||
var symbol = createSymbol(p.flags | 67108864, p.name);
|
||||
symbol.declarations = p.declarations;
|
||||
symbol.parent = p.parent;
|
||||
symbol.type = widenedType;
|
||||
symbol.target = p;
|
||||
if (p.valueDeclaration)
|
||||
symbol.valueDeclaration = p.valueDeclaration;
|
||||
p = symbol;
|
||||
}
|
||||
members[p.name] = p;
|
||||
var members = transformTypeOfMembers(type, function (prop) {
|
||||
var widened = getWidenedType(prop);
|
||||
return prop === widened ? prop : widened;
|
||||
});
|
||||
var stringIndexInfo = getIndexInfoOfType(type, 0);
|
||||
var numberIndexInfo = getIndexInfoOfType(type, 1);
|
||||
@@ -18816,7 +18854,7 @@ var ts;
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
if (target.flags & 16384 && typeParameterCount === 1) {
|
||||
if (typeParameterCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferiority--;
|
||||
@@ -19888,7 +19926,7 @@ var ts;
|
||||
}
|
||||
return nodeCheckFlag === 512
|
||||
? getBaseConstructorTypeOfClass(classType)
|
||||
: baseClassType;
|
||||
: getTypeWithThisArgument(baseClassType, classType.thisType);
|
||||
function isLegalUsageOfSuperExpression(container) {
|
||||
if (!container) {
|
||||
return false;
|
||||
@@ -21936,7 +21974,7 @@ var ts;
|
||||
var types = void 0;
|
||||
var funcIsGenerator = !!func.asteriskToken;
|
||||
if (funcIsGenerator) {
|
||||
types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper);
|
||||
types = checkAndAggregateYieldOperandTypes(func, contextualMapper);
|
||||
if (types.length === 0) {
|
||||
var iterableIteratorAny = createIterableIteratorType(anyType);
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
@@ -21946,8 +21984,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var hasImplicitReturn = !!(func.flags & 32768);
|
||||
types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync, hasImplicitReturn);
|
||||
types = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
|
||||
if (!types) {
|
||||
return neverType;
|
||||
}
|
||||
@@ -21994,9 +22031,9 @@ var ts;
|
||||
return widenedType;
|
||||
}
|
||||
}
|
||||
function checkAndAggregateYieldOperandTypes(body, contextualMapper) {
|
||||
function checkAndAggregateYieldOperandTypes(func, contextualMapper) {
|
||||
var aggregatedTypes = [];
|
||||
ts.forEachYieldExpression(body, function (yieldExpression) {
|
||||
ts.forEachYieldExpression(func.body, function (yieldExpression) {
|
||||
var expr = yieldExpression.expression;
|
||||
if (expr) {
|
||||
var type = checkExpressionCached(expr, contextualMapper);
|
||||
@@ -22010,28 +22047,34 @@ var ts;
|
||||
});
|
||||
return aggregatedTypes;
|
||||
}
|
||||
function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync, hasImplicitReturn) {
|
||||
function checkAndAggregateReturnExpressionTypes(func, contextualMapper) {
|
||||
var isAsync = ts.isAsyncFunctionLike(func);
|
||||
var aggregatedTypes = [];
|
||||
var hasOmittedExpressions = false;
|
||||
ts.forEachReturnStatement(body, function (returnStatement) {
|
||||
var hasReturnWithNoExpression = !!(func.flags & 32768);
|
||||
var hasReturnOfTypeNever = false;
|
||||
ts.forEachReturnStatement(func.body, function (returnStatement) {
|
||||
var expr = returnStatement.expression;
|
||||
if (expr) {
|
||||
var type = checkExpressionCached(expr, contextualMapper);
|
||||
if (isAsync) {
|
||||
type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
|
||||
type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
|
||||
}
|
||||
if (type !== neverType && !ts.contains(aggregatedTypes, type)) {
|
||||
if (type === neverType) {
|
||||
hasReturnOfTypeNever = true;
|
||||
}
|
||||
else if (!ts.contains(aggregatedTypes, type)) {
|
||||
aggregatedTypes.push(type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
hasOmittedExpressions = true;
|
||||
hasReturnWithNoExpression = true;
|
||||
}
|
||||
});
|
||||
if (aggregatedTypes.length === 0 && !hasOmittedExpressions && !hasImplicitReturn) {
|
||||
if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever ||
|
||||
func.kind === 179 || func.kind === 180)) {
|
||||
return undefined;
|
||||
}
|
||||
if (strictNullChecks && aggregatedTypes.length && (hasOmittedExpressions || hasImplicitReturn)) {
|
||||
if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) {
|
||||
if (!ts.contains(aggregatedTypes, undefinedType)) {
|
||||
aggregatedTypes.push(undefinedType);
|
||||
}
|
||||
@@ -22161,7 +22204,9 @@ var ts;
|
||||
(expr.kind === 172 || expr.kind === 173) &&
|
||||
expr.expression.kind === 97) {
|
||||
var func = ts.getContainingFunction(expr);
|
||||
return !(func && func.kind === 148 && func.parent === symbol.valueDeclaration.parent);
|
||||
if (!(func && func.kind === 148))
|
||||
return true;
|
||||
return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -22985,6 +23030,79 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkClassForDuplicateDeclarations(node) {
|
||||
var getter = 1, setter = 2, property = getter | setter;
|
||||
var instanceNames = {};
|
||||
var staticNames = {};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (member.kind === 148) {
|
||||
for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
|
||||
var param = _c[_b];
|
||||
if (ts.isParameterPropertyDeclaration(param)) {
|
||||
addName(instanceNames, param.name, param.name.text, property);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var static = ts.forEach(member.modifiers, function (m) { return m.kind === 113; });
|
||||
var names = static ? staticNames : instanceNames;
|
||||
var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name);
|
||||
if (memberName) {
|
||||
switch (member.kind) {
|
||||
case 149:
|
||||
addName(names, member.name, memberName, getter);
|
||||
break;
|
||||
case 150:
|
||||
addName(names, member.name, memberName, setter);
|
||||
break;
|
||||
case 145:
|
||||
addName(names, member.name, memberName, property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function addName(names, location, name, meaning) {
|
||||
if (ts.hasProperty(names, name)) {
|
||||
var prev = names[name];
|
||||
if (prev & meaning) {
|
||||
error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
|
||||
}
|
||||
else {
|
||||
names[name] = prev | meaning;
|
||||
}
|
||||
}
|
||||
else {
|
||||
names[name] = meaning;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkObjectTypeForDuplicateDeclarations(node) {
|
||||
var names = {};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (member.kind == 144) {
|
||||
var memberName = void 0;
|
||||
switch (member.name.kind) {
|
||||
case 9:
|
||||
case 8:
|
||||
case 69:
|
||||
memberName = member.name.text;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if (ts.hasProperty(names, memberName)) {
|
||||
error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
|
||||
error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
|
||||
}
|
||||
else {
|
||||
names[memberName] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkTypeForDuplicateIndexSignatures(node) {
|
||||
if (node.kind === 222) {
|
||||
var nodeSymbol = getSymbolOfNode(node);
|
||||
@@ -23203,6 +23321,7 @@ var ts;
|
||||
var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
|
||||
checkIndexConstraints(type);
|
||||
checkTypeForDuplicateIndexSignatures(node);
|
||||
checkObjectTypeForDuplicateDeclarations(node);
|
||||
}
|
||||
}
|
||||
function checkArrayType(node) {
|
||||
@@ -23962,6 +24081,10 @@ var ts;
|
||||
if (node.initializer) {
|
||||
checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined);
|
||||
}
|
||||
if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
|
||||
error(symbol.valueDeclaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
|
||||
error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
|
||||
}
|
||||
}
|
||||
if (node.kind !== 145 && node.kind !== 144) {
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
@@ -23974,6 +24097,18 @@ var ts;
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
}
|
||||
}
|
||||
function areDeclarationFlagsIdentical(left, right) {
|
||||
if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
|
||||
return false;
|
||||
}
|
||||
var interestingFlags = 8 |
|
||||
16 |
|
||||
256 |
|
||||
128 |
|
||||
64 |
|
||||
32;
|
||||
return (left.flags & interestingFlags) === (right.flags & interestingFlags);
|
||||
}
|
||||
function checkVariableDeclaration(node) {
|
||||
checkGrammarVariableDeclaration(node);
|
||||
return checkVariableLikeDeclaration(node);
|
||||
@@ -24524,6 +24659,7 @@ var ts;
|
||||
var typeWithThis = getTypeWithThisArgument(type);
|
||||
var staticType = getTypeOfSymbol(symbol);
|
||||
checkTypeParameterListsIdentical(node, symbol);
|
||||
checkClassForDuplicateDeclarations(node);
|
||||
var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node);
|
||||
if (baseTypeNode) {
|
||||
var baseTypes = getBaseTypes(type);
|
||||
@@ -24735,6 +24871,7 @@ var ts;
|
||||
checkIndexConstraints(type);
|
||||
}
|
||||
}
|
||||
checkObjectTypeForDuplicateDeclarations(node);
|
||||
}
|
||||
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
|
||||
if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) {
|
||||
@@ -25489,10 +25626,8 @@ var ts;
|
||||
function checkSourceFileWorker(node) {
|
||||
var links = getNodeLinks(node);
|
||||
if (!(links.flags & 1)) {
|
||||
if (compilerOptions.skipDefaultLibCheck) {
|
||||
if (node.hasNoDefaultLib) {
|
||||
return;
|
||||
}
|
||||
if (compilerOptions.skipLibCheck && node.isDeclarationFile || compilerOptions.skipDefaultLibCheck && node.hasNoDefaultLib) {
|
||||
return;
|
||||
}
|
||||
checkGrammarSourceFile(node);
|
||||
potentialThisCollisions.length = 0;
|
||||
@@ -25861,7 +25996,7 @@ var ts;
|
||||
return symbol && getTypeOfSymbol(symbol);
|
||||
}
|
||||
if (ts.isBindingPattern(node)) {
|
||||
return getTypeForVariableLikeDeclaration(node.parent);
|
||||
return getTypeForVariableLikeDeclaration(node.parent, true);
|
||||
}
|
||||
if (isInRightSideOfImportOrExportAssignment(node)) {
|
||||
var symbol = getSymbolAtLocation(node);
|
||||
@@ -26300,7 +26435,7 @@ var ts;
|
||||
if (file.moduleAugmentations.length) {
|
||||
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
|
||||
}
|
||||
if (file.wasReferenced && file.symbol && file.symbol.globalExports) {
|
||||
if (file.symbol && file.symbol.globalExports) {
|
||||
mergeSymbolTable(globals, file.symbol.globalExports);
|
||||
}
|
||||
});
|
||||
@@ -26870,7 +27005,6 @@ var ts;
|
||||
if (prop.kind === 193 ||
|
||||
name_20.kind === 140) {
|
||||
checkGrammarComputedPropertyName(name_20);
|
||||
return "continue";
|
||||
}
|
||||
if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) {
|
||||
return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) };
|
||||
@@ -26900,17 +27034,21 @@ var ts;
|
||||
else {
|
||||
ts.Debug.fail("Unexpected syntax kind:" + prop.kind);
|
||||
}
|
||||
if (!ts.hasProperty(seen, name_20.text)) {
|
||||
seen[name_20.text] = currentKind;
|
||||
var effectiveName = ts.getPropertyNameForPropertyNameNode(name_20);
|
||||
if (effectiveName === undefined) {
|
||||
return "continue";
|
||||
}
|
||||
if (!ts.hasProperty(seen, effectiveName)) {
|
||||
seen[effectiveName] = currentKind;
|
||||
}
|
||||
else {
|
||||
var existingKind = seen[name_20.text];
|
||||
var existingKind = seen[effectiveName];
|
||||
if (currentKind === Property && existingKind === Property) {
|
||||
return "continue";
|
||||
grammarErrorOnNode(name_20, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_20));
|
||||
}
|
||||
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
|
||||
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
|
||||
seen[name_20.text] = currentKind | existingKind;
|
||||
seen[effectiveName] = currentKind | existingKind;
|
||||
}
|
||||
else {
|
||||
return { value: grammarErrorOnNode(name_20, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) };
|
||||
@@ -35367,7 +35505,7 @@ var ts;
|
||||
skipTsx: true,
|
||||
traceEnabled: traceEnabled
|
||||
};
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : undefined);
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
|
||||
if (traceEnabled) {
|
||||
if (containingFile === undefined) {
|
||||
if (rootDir === undefined) {
|
||||
@@ -35870,12 +36008,25 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(rootPath) {
|
||||
var localTypes = ts.combinePaths(rootPath, "types");
|
||||
var npmTypes = ts.combinePaths(rootPath, "node_modules/@types");
|
||||
var result = [];
|
||||
if (ts.sys.directoryExists(localTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(localTypes));
|
||||
}
|
||||
if (ts.sys.directoryExists(npmTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(npmTypes));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function getDefaultLibLocation() {
|
||||
return ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath()));
|
||||
}
|
||||
var newLine = ts.getNewLineCharacter(options);
|
||||
var realpath = ts.sys.realpath && (function (path) { return ts.sys.realpath(path); });
|
||||
return {
|
||||
getDefaultTypeDirectiveNames: getDefaultTypeDirectiveNames,
|
||||
getSourceFile: getSourceFile,
|
||||
getDefaultLibLocation: getDefaultLibLocation,
|
||||
getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
|
||||
@@ -35943,6 +36094,19 @@ var ts;
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(options, rootFiles, host) {
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
}
|
||||
if (host && host.getDefaultTypeDirectiveNames) {
|
||||
var commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), function (f) { return host.getCanonicalFileName(f); });
|
||||
if (commonRoot) {
|
||||
return host.getDefaultTypeDirectiveNames(commonRoot);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
ts.getDefaultTypeDirectiveNames = getDefaultTypeDirectiveNames;
|
||||
function createProgram(rootNames, options, host, oldProgram) {
|
||||
var program;
|
||||
var files = [];
|
||||
@@ -35978,13 +36142,14 @@ var ts;
|
||||
var filesByName = ts.createFileMap();
|
||||
var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined;
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
if (options.types && options.types.length) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(options.types, undefined);
|
||||
for (var i = 0; i < options.types.length; i++) {
|
||||
processTypeReferenceDirective(options.types[i], resolutions[i]);
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, false); });
|
||||
var typeReferences = getDefaultTypeDirectiveNames(options, rootNames, host);
|
||||
if (typeReferences) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, undefined);
|
||||
for (var i = 0; i < typeReferences.length; i++) {
|
||||
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
|
||||
}
|
||||
}
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, false); });
|
||||
if (!skipDefaultLib) {
|
||||
if (!options.lib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
@@ -36561,9 +36726,6 @@ var ts;
|
||||
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
if (file_1) {
|
||||
file_1.wasReferenced = file_1.wasReferenced || isReference;
|
||||
}
|
||||
return file_1;
|
||||
}
|
||||
var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
|
||||
@@ -36576,7 +36738,6 @@ var ts;
|
||||
});
|
||||
filesByName.set(path, file);
|
||||
if (file) {
|
||||
file.wasReferenced = file.wasReferenced || isReference;
|
||||
file.path = path;
|
||||
if (host.useCaseSensitiveFileNames()) {
|
||||
var existingFile = filesByNameIgnoreCase.get(path);
|
||||
@@ -36677,17 +36838,7 @@ var ts;
|
||||
!options.noResolve &&
|
||||
i < file.imports.length;
|
||||
if (shouldAddFile) {
|
||||
var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
if (!ts.isExternalModule(importedFile) && importedFile.statements.length) {
|
||||
var start_5 = ts.getTokenPosOfNode(file.imports[i], file);
|
||||
fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_5, file.imports[i].end - start_5, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
}
|
||||
else if (importedFile.referencedFiles.length) {
|
||||
var firstRef = importedFile.referencedFiles[0];
|
||||
fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
|
||||
}
|
||||
}
|
||||
findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36772,7 +36923,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substututions_for_pattern_0_should_be_an_array, key));
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36821,13 +36972,19 @@ var ts;
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
if (options.module === ts.ModuleKind.ES6 && languageVersion < 2) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
if (outFile && options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
}
|
||||
else if (options.module === undefined && firstExternalModuleSourceFile) {
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
|
||||
}
|
||||
}
|
||||
if (options.outDir ||
|
||||
options.sourceRoot ||
|
||||
@@ -37517,7 +37674,7 @@ var ts;
|
||||
(function (ts) {
|
||||
var NavigateTo;
|
||||
(function (NavigateTo) {
|
||||
function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) {
|
||||
function getNavigateToItems(program, checker, cancellationToken, searchValue, maxResultCount) {
|
||||
var patternMatcher = ts.createPatternMatcher(searchValue);
|
||||
var rawItems = [];
|
||||
var baseSensitivity = { sensitivity: "base" };
|
||||
@@ -37550,6 +37707,17 @@ var ts;
|
||||
}
|
||||
}
|
||||
});
|
||||
rawItems = ts.filter(rawItems, function (item) {
|
||||
var decl = item.declaration;
|
||||
if (decl.kind === 231 || decl.kind === 234 || decl.kind === 229) {
|
||||
var importer = checker.getSymbolAtLocation(decl.name);
|
||||
var imported = checker.getAliasedSymbol(importer);
|
||||
return importer.name !== imported.name;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
rawItems.sort(compareNavigateToItems);
|
||||
if (maxResultCount !== undefined) {
|
||||
rawItems = rawItems.slice(0, maxResultCount);
|
||||
@@ -37892,8 +38060,12 @@ var ts;
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement);
|
||||
case 153:
|
||||
return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement);
|
||||
case 224:
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.enumElement);
|
||||
case 255:
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement);
|
||||
case 222:
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.interfaceElement);
|
||||
case 151:
|
||||
return createItem(node, "()", ts.ScriptElementKind.callSignatureElement);
|
||||
case 152:
|
||||
@@ -39263,7 +39435,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) {
|
||||
for (var i = exclusiveStartPosition - 1; i >= 0; --i) {
|
||||
for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
|
||||
if (nodeHasTokens(children[i])) {
|
||||
return children[i];
|
||||
}
|
||||
@@ -39889,18 +40061,17 @@ var ts;
|
||||
if (!isStarted) {
|
||||
scanner.scan();
|
||||
}
|
||||
var t;
|
||||
var pos = scanner.getStartPos();
|
||||
while (pos < endPos) {
|
||||
var t_1 = scanner.getToken();
|
||||
if (!ts.isTrivia(t_1)) {
|
||||
var t = scanner.getToken();
|
||||
if (!ts.isTrivia(t)) {
|
||||
break;
|
||||
}
|
||||
scanner.scan();
|
||||
var item = {
|
||||
pos: pos,
|
||||
end: scanner.getStartPos(),
|
||||
kind: t_1
|
||||
kind: t
|
||||
};
|
||||
pos = scanner.getStartPos();
|
||||
if (!leadingTrivia) {
|
||||
@@ -41550,7 +41721,7 @@ var ts;
|
||||
else {
|
||||
parts = [];
|
||||
var startPos = commentRange.pos;
|
||||
for (var line = startLine; line < endLine; ++line) {
|
||||
for (var line = startLine; line < endLine; line++) {
|
||||
var endOfLine = ts.getEndLinePosition(line, sourceFile);
|
||||
parts.push({ pos: startPos, end: endOfLine });
|
||||
startPos = ts.getStartPositionOfLine(line + 1, sourceFile);
|
||||
@@ -41568,7 +41739,7 @@ var ts;
|
||||
startLine++;
|
||||
}
|
||||
var delta = indentation - nonWhitespaceColumnInFirstPart.column;
|
||||
for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) {
|
||||
for (var i = startIndex, len = parts.length; i < len; i++, startLine++) {
|
||||
var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile);
|
||||
var nonWhitespaceCharacterAndColumn = i === 0
|
||||
? nonWhitespaceColumnInFirstPart
|
||||
@@ -41584,7 +41755,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function trimTrailingWhitespacesForLines(line1, line2, range) {
|
||||
for (var line = line1; line < line2; ++line) {
|
||||
for (var line = line1; line < line2; line++) {
|
||||
var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile);
|
||||
var lineEndPosition = ts.getEndLinePosition(line, sourceFile);
|
||||
if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
|
||||
@@ -41627,7 +41798,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) {
|
||||
var between;
|
||||
switch (rule.Operation.Action) {
|
||||
case 1:
|
||||
return;
|
||||
@@ -41657,14 +41827,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function isSomeBlock(kind) {
|
||||
switch (kind) {
|
||||
case 199:
|
||||
case 226:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getOpenTokenForList(node, list) {
|
||||
switch (node.kind) {
|
||||
case 148:
|
||||
@@ -41722,7 +41884,7 @@ var ts;
|
||||
internedTabsIndentation = [];
|
||||
}
|
||||
if (internedTabsIndentation[tabs] === undefined) {
|
||||
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
|
||||
internedTabsIndentation[tabs] = tabString = repeat("\t", tabs);
|
||||
}
|
||||
else {
|
||||
tabString = internedTabsIndentation[tabs];
|
||||
@@ -41747,7 +41909,7 @@ var ts;
|
||||
}
|
||||
function repeat(value, count) {
|
||||
var s = "";
|
||||
for (var i = 0; i < count; ++i) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
s += value;
|
||||
}
|
||||
return s;
|
||||
@@ -42015,7 +42177,7 @@ var ts;
|
||||
ts.Debug.assert(index >= 0 && index < list.length);
|
||||
var node = list[index];
|
||||
var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
|
||||
for (var i = index - 1; i >= 0; --i) {
|
||||
for (var i = index - 1; i >= 0; i--) {
|
||||
if (list[i].kind === 24) {
|
||||
continue;
|
||||
}
|
||||
@@ -42034,7 +42196,7 @@ var ts;
|
||||
function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) {
|
||||
var character = 0;
|
||||
var column = 0;
|
||||
for (var pos = startPos; pos < endPos; ++pos) {
|
||||
for (var pos = startPos; pos < endPos; pos++) {
|
||||
var ch = sourceFile.text.charCodeAt(pos);
|
||||
if (!ts.isWhiteSpace(ch)) {
|
||||
break;
|
||||
@@ -44005,9 +44167,9 @@ var ts;
|
||||
log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start));
|
||||
var contextToken = previousToken;
|
||||
if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) {
|
||||
var start_6 = new Date().getTime();
|
||||
var start_5 = new Date().getTime();
|
||||
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile);
|
||||
log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_6));
|
||||
log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_5));
|
||||
}
|
||||
var node = currentToken;
|
||||
var isRightOfDot = false;
|
||||
@@ -44234,9 +44396,9 @@ var ts;
|
||||
|| contextToken.kind === 166
|
||||
|| contextToken.kind === 10
|
||||
|| ts.isTemplateLiteralKind(contextToken.kind)) {
|
||||
var start_7 = contextToken.getStart();
|
||||
var start_6 = contextToken.getStart();
|
||||
var end = contextToken.getEnd();
|
||||
if (start_7 < position && position < end) {
|
||||
if (start_6 < position && position < end) {
|
||||
return true;
|
||||
}
|
||||
if (position === end) {
|
||||
@@ -45314,8 +45476,7 @@ var ts;
|
||||
}
|
||||
function getDocumentHighlights(fileName, position, filesToSearch) {
|
||||
synchronizeHostData();
|
||||
filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes);
|
||||
var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); });
|
||||
var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return program.getSourceFile(f); });
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
var node = ts.getTouchingWord(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -46498,7 +46659,8 @@ var ts;
|
||||
}
|
||||
function getNavigateToItems(searchValue, maxResultCount) {
|
||||
synchronizeHostData();
|
||||
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
|
||||
var checker = getProgram().getTypeChecker();
|
||||
return ts.NavigateTo.getNavigateToItems(program, checker, cancellationToken, searchValue, maxResultCount);
|
||||
}
|
||||
function getEmitOutput(fileName) {
|
||||
synchronizeHostData();
|
||||
@@ -51195,6 +51357,9 @@ var ts;
|
||||
LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () {
|
||||
return this.shimHost.getCurrentDirectory();
|
||||
};
|
||||
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
|
||||
return this.shimHost.getDirectories(path);
|
||||
};
|
||||
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
};
|
||||
|
||||
Vendored
+39
-9
@@ -247,7 +247,7 @@ declare namespace ts {
|
||||
ModuleDeclaration = 225,
|
||||
ModuleBlock = 226,
|
||||
CaseBlock = 227,
|
||||
GlobalModuleExportDeclaration = 228,
|
||||
NamespaceExportDeclaration = 228,
|
||||
ImportEqualsDeclaration = 229,
|
||||
ImportDeclaration = 230,
|
||||
ImportClause = 231,
|
||||
@@ -925,7 +925,7 @@ declare namespace ts {
|
||||
interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
interface GlobalModuleExportDeclaration extends DeclarationStatement {
|
||||
interface NamespaceExportDeclaration extends DeclarationStatement {
|
||||
name: Identifier;
|
||||
moduleReference: LiteralLikeNode;
|
||||
}
|
||||
@@ -1087,7 +1087,6 @@ declare namespace ts {
|
||||
scriptKind: ScriptKind;
|
||||
externalModuleIndicator: Node;
|
||||
commonJsModuleIndicator: Node;
|
||||
wasReferenced?: boolean;
|
||||
identifiers: Map<string>;
|
||||
nodeCount: number;
|
||||
identifierCount: number;
|
||||
@@ -1381,7 +1380,7 @@ declare namespace ts {
|
||||
FunctionScopedVariableExcludes = 107454,
|
||||
BlockScopedVariableExcludes = 107455,
|
||||
ParameterExcludes = 107455,
|
||||
PropertyExcludes = 107455,
|
||||
PropertyExcludes = 0,
|
||||
EnumMemberExcludes = 107455,
|
||||
FunctionExcludes = 106927,
|
||||
ClassExcludes = 899519,
|
||||
@@ -1735,6 +1734,7 @@ declare namespace ts {
|
||||
allowJs?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
strictNullChecks?: boolean;
|
||||
skipLibCheck?: boolean;
|
||||
listEmittedFiles?: boolean;
|
||||
lib?: string[];
|
||||
stripInternal?: boolean;
|
||||
@@ -1967,6 +1967,7 @@ declare namespace ts {
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
realpath?(path: string): string;
|
||||
getCurrentDirectory?(): string;
|
||||
}
|
||||
interface ResolvedModule {
|
||||
resolvedFileName: string;
|
||||
@@ -1990,6 +1991,7 @@ declare namespace ts {
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
getDefaultTypeDirectiveNames?(rootPath: string): string[];
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
@@ -2136,6 +2138,7 @@ declare namespace ts {
|
||||
createDirectory(path: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getModifiedTime?(path: string): Date;
|
||||
createHash?(data: string): string;
|
||||
@@ -2820,7 +2823,7 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: {
|
||||
Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
@@ -5040,6 +5043,18 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Identifier_0_must_be_imported_from_a_module: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
All_declarations_of_0_must_have_identical_modifiers: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Import_declaration_0_is_using_private_name_1: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
@@ -5598,7 +5613,7 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Substututions_for_pattern_0_should_be_an_array: {
|
||||
Substitutions_for_pattern_0_should_be_an_array: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
@@ -5676,6 +5691,12 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Skip_type_checking_of_declaration_files: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
@@ -6282,6 +6303,12 @@ declare namespace ts {
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
key: string;
|
||||
message: string;
|
||||
};
|
||||
Variable_0_implicitly_has_an_1_type: {
|
||||
code: number;
|
||||
category: DiagnosticCategory;
|
||||
@@ -7024,6 +7051,7 @@ declare namespace ts {
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts.BreakpointResolver {
|
||||
@@ -7033,7 +7061,7 @@ declare namespace ts.OutliningElementsCollector {
|
||||
function collectElements(sourceFile: SourceFile): OutliningSpan[];
|
||||
}
|
||||
declare namespace ts.NavigateTo {
|
||||
function getNavigateToItems(program: Program, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[];
|
||||
function getNavigateToItems(program: Program, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number): NavigateToItem[];
|
||||
}
|
||||
declare namespace ts.NavigationBar {
|
||||
function getNavigationBarItems(sourceFile: SourceFile, compilerOptions: CompilerOptions): ts.NavigationBarItem[];
|
||||
@@ -7431,7 +7459,7 @@ declare namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
declare namespace ts.formatting {
|
||||
module Shared {
|
||||
namespace Shared {
|
||||
interface ITokenAccess {
|
||||
GetTokens(): SyntaxKind[];
|
||||
Contains(token: SyntaxKind): boolean;
|
||||
@@ -7516,7 +7544,7 @@ declare namespace ts.formatting {
|
||||
function getIndentationString(indentation: number, options: FormatCodeOptions): string;
|
||||
}
|
||||
declare namespace ts.formatting {
|
||||
module SmartIndenter {
|
||||
namespace SmartIndenter {
|
||||
function getIndentation(position: number, sourceFile: SourceFile, options: EditorOptions): number;
|
||||
function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number;
|
||||
function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean;
|
||||
@@ -8487,6 +8515,7 @@ declare namespace ts {
|
||||
getLocalizedDiagnosticMessages(): string;
|
||||
getCancellationToken(): HostCancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
getDefaultLibFileName(options: string): string;
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
@@ -8582,6 +8611,7 @@ declare namespace ts {
|
||||
getLocalizedDiagnosticMessages(): any;
|
||||
getCancellationToken(): HostCancellationToken;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
}
|
||||
class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost {
|
||||
|
||||
+299
-134
@@ -918,6 +918,10 @@ var ts;
|
||||
}
|
||||
return result.sort();
|
||||
}
|
||||
function getDirectories(path) {
|
||||
var folder = fso.GetFolder(path);
|
||||
return getNames(folder.subfolders);
|
||||
}
|
||||
function readDirectory(path, extension, exclude) {
|
||||
var result = [];
|
||||
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
|
||||
@@ -972,6 +976,7 @@ var ts;
|
||||
getCurrentDirectory: function () {
|
||||
return new ActiveXObject("WScript.Shell").CurrentDirectory;
|
||||
},
|
||||
getDirectories: getDirectories,
|
||||
readDirectory: readDirectory,
|
||||
exit: function (exitCode) {
|
||||
try {
|
||||
@@ -1119,6 +1124,9 @@ var ts;
|
||||
function directoryExists(path) {
|
||||
return fileSystemEntryExists(path, 1);
|
||||
}
|
||||
function getDirectories(path) {
|
||||
return ts.filter(_fs.readdirSync(path), function (p) { return fileSystemEntryExists(ts.combinePaths(path, p), 1); });
|
||||
}
|
||||
function readDirectory(path, extension, exclude) {
|
||||
var result = [];
|
||||
exclude = ts.map(exclude, function (s) { return getCanonicalPath(ts.combinePaths(path, s)); });
|
||||
@@ -1211,6 +1219,7 @@ var ts;
|
||||
getCurrentDirectory: function () {
|
||||
return process.cwd();
|
||||
},
|
||||
getDirectories: getDirectories,
|
||||
readDirectory: readDirectory,
|
||||
getModifiedTime: function (path) {
|
||||
try {
|
||||
@@ -1261,6 +1270,7 @@ var ts;
|
||||
createDirectory: ChakraHost.createDirectory,
|
||||
getExecutingFilePath: function () { return ChakraHost.executingFile; },
|
||||
getCurrentDirectory: function () { return ChakraHost.currentDirectory; },
|
||||
getDirectories: ChakraHost.getDirectories,
|
||||
readDirectory: ChakraHost.readDirectory,
|
||||
exit: ChakraHost.quit,
|
||||
realpath: realpath
|
||||
@@ -1394,7 +1404,7 @@ var ts;
|
||||
or_expected: { code: 1144, category: ts.DiagnosticCategory.Error, key: "or_expected_1144", message: "'{' or ';' expected." },
|
||||
Declaration_expected: { code: 1146, category: ts.DiagnosticCategory.Error, key: "Declaration_expected_1146", message: "Declaration expected." },
|
||||
Import_declarations_in_a_namespace_cannot_reference_a_module: { code: 1147, category: ts.DiagnosticCategory.Error, key: "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", message: "Import declarations in a namespace cannot reference a module." },
|
||||
Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting__1148", message: "Cannot compile modules unless the '--module' flag is provided with a valid module type. Consider setting the 'module' compiler option in a 'tsconfig.json' file." },
|
||||
Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." },
|
||||
File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", message: "File name '{0}' differs from already included file name '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", message: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized" },
|
||||
@@ -1764,6 +1774,8 @@ var ts;
|
||||
this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation: { code: 2683, category: ts.DiagnosticCategory.Error, key: "this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_2683", message: "'this' implicitly has type 'any' because it does not have a type annotation." },
|
||||
The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1: { code: 2684, category: ts.DiagnosticCategory.Error, key: "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684", message: "The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'." },
|
||||
The_this_types_of_each_signature_are_incompatible: { code: 2685, category: ts.DiagnosticCategory.Error, key: "The_this_types_of_each_signature_are_incompatible_2685", message: "The 'this' types of each signature are incompatible." },
|
||||
Identifier_0_must_be_imported_from_a_module: { code: 2686, category: ts.DiagnosticCategory.Error, key: "Identifier_0_must_be_imported_from_a_module_2686", message: "Identifier '{0}' must be imported from a module" },
|
||||
All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." },
|
||||
@@ -1857,7 +1869,7 @@ var ts;
|
||||
Option_paths_cannot_be_used_without_specifying_baseUrl_option: { code: 5060, category: ts.DiagnosticCategory.Error, key: "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", message: "Option 'paths' cannot be used without specifying '--baseUrl' option." },
|
||||
Pattern_0_can_have_at_most_one_Asterisk_character: { code: 5061, category: ts.DiagnosticCategory.Error, key: "Pattern_0_can_have_at_most_one_Asterisk_character_5061", message: "Pattern '{0}' can have at most one '*' character" },
|
||||
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: { code: 5062, category: ts.DiagnosticCategory.Error, key: "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", message: "Substitution '{0}' in pattern '{1}' in can have at most one '*' character" },
|
||||
Substututions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substututions_for_pattern_0_should_be_an_array_5063", message: "Substututions for pattern '{0}' should be an array." },
|
||||
Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." },
|
||||
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." },
|
||||
Concatenate_and_emit_output_to_single_file: { code: 6001, category: ts.DiagnosticCategory.Message, key: "Concatenate_and_emit_output_to_single_file_6001", message: "Concatenate and emit output to single file." },
|
||||
Generates_corresponding_d_ts_file: { code: 6002, category: ts.DiagnosticCategory.Message, key: "Generates_corresponding_d_ts_file_6002", message: "Generates corresponding '.d.ts' file." },
|
||||
@@ -1870,6 +1882,7 @@ var ts;
|
||||
Do_not_emit_comments_to_output: { code: 6009, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_comments_to_output_6009", message: "Do not emit comments to output." },
|
||||
Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." },
|
||||
Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." },
|
||||
Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES2015'" },
|
||||
Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" },
|
||||
Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." },
|
||||
@@ -1971,6 +1984,7 @@ var ts;
|
||||
Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" },
|
||||
The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." },
|
||||
Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" },
|
||||
Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." },
|
||||
Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_an_1_type_7005", message: "Variable '{0}' implicitly has an '{1}' type." },
|
||||
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter_0_implicitly_has_an_1_type_7006", message: "Parameter '{0}' implicitly has an '{1}' type." },
|
||||
Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member_0_implicitly_has_an_1_type_7008", message: "Member '{0}' implicitly has an '{1}' type." },
|
||||
@@ -3537,6 +3551,11 @@ var ts;
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Print_this_message
|
||||
},
|
||||
{
|
||||
name: "help",
|
||||
shortName: "?",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "init",
|
||||
type: "boolean",
|
||||
@@ -3639,6 +3658,11 @@ var ts;
|
||||
name: "skipDefaultLibCheck",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
name: "skipLibCheck",
|
||||
type: "boolean",
|
||||
description: ts.Diagnostics.Skip_type_checking_of_declaration_files
|
||||
},
|
||||
{
|
||||
name: "out",
|
||||
type: "string",
|
||||
@@ -5758,7 +5782,7 @@ var ts;
|
||||
}
|
||||
ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
|
||||
function getPropertyNameForPropertyNameNode(name) {
|
||||
if (name.kind === 69 || name.kind === 9 || name.kind === 8) {
|
||||
if (name.kind === 69 || name.kind === 9 || name.kind === 8 || name.kind === 142) {
|
||||
return name.text;
|
||||
}
|
||||
if (name.kind === 140) {
|
||||
@@ -12804,10 +12828,10 @@ var ts;
|
||||
case 145:
|
||||
case 144:
|
||||
case 266:
|
||||
return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455);
|
||||
return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 0);
|
||||
case 253:
|
||||
case 254:
|
||||
return bindPropertyOrMethodOrAccessor(node, 4, 107455);
|
||||
return bindPropertyOrMethodOrAccessor(node, 4, 0);
|
||||
case 255:
|
||||
return bindPropertyOrMethodOrAccessor(node, 8, 107455);
|
||||
case 247:
|
||||
@@ -12819,7 +12843,7 @@ var ts;
|
||||
return declareSymbolAndAddToSymbolTable(node, 131072, 0);
|
||||
case 147:
|
||||
case 146:
|
||||
return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263);
|
||||
return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263);
|
||||
case 220:
|
||||
return bindFunctionDeclaration(node);
|
||||
case 148:
|
||||
@@ -12862,7 +12886,7 @@ var ts;
|
||||
case 238:
|
||||
return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608);
|
||||
case 228:
|
||||
return bindGlobalModuleExportDeclaration(node);
|
||||
return bindNamespaceExportDeclaration(node);
|
||||
case 231:
|
||||
return bindImportClause(node);
|
||||
case 236:
|
||||
@@ -12898,13 +12922,13 @@ var ts;
|
||||
bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
|
||||
}
|
||||
else if (boundExpression.kind === 69 && node.kind === 235) {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0 | 8388608);
|
||||
}
|
||||
else {
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 4, 107455 | 8388608);
|
||||
declareSymbol(container.symbol.exports, container.symbol, node, 4, 0 | 8388608);
|
||||
}
|
||||
}
|
||||
function bindGlobalModuleExportDeclaration(node) {
|
||||
function bindNamespaceExportDeclaration(node) {
|
||||
if (node.modifiers && node.modifiers.length) {
|
||||
file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
|
||||
}
|
||||
@@ -12956,7 +12980,7 @@ var ts;
|
||||
function bindThisPropertyAssignment(node) {
|
||||
if (container.kind === 179 || container.kind === 220) {
|
||||
container.symbol.members = container.symbol.members || {};
|
||||
declareSymbol(container.symbol.members, container.symbol, node, 4, 107455 & ~4);
|
||||
declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4);
|
||||
}
|
||||
}
|
||||
function bindPrototypePropertyAssignment(node) {
|
||||
@@ -12973,7 +12997,7 @@ var ts;
|
||||
if (!funcSymbol.members) {
|
||||
funcSymbol.members = {};
|
||||
}
|
||||
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 107455);
|
||||
declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 0);
|
||||
}
|
||||
function bindCallExpression(node) {
|
||||
if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
|
||||
@@ -13049,7 +13073,7 @@ var ts;
|
||||
}
|
||||
if (ts.isParameterPropertyDeclaration(node)) {
|
||||
var classDeclaration = node.parent.parent;
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455);
|
||||
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 0);
|
||||
}
|
||||
}
|
||||
function bindFunctionDeclaration(node) {
|
||||
@@ -13349,7 +13373,7 @@ var ts;
|
||||
if (flags & 1)
|
||||
result |= 107454;
|
||||
if (flags & 4)
|
||||
result |= 107455;
|
||||
result |= 0;
|
||||
if (flags & 8)
|
||||
result |= 107455;
|
||||
if (flags & 16)
|
||||
@@ -13605,6 +13629,7 @@ var ts;
|
||||
var propertyWithInvalidInitializer;
|
||||
var errorLocation = location;
|
||||
var grandparent;
|
||||
var isInExternalModule = false;
|
||||
loop: while (location) {
|
||||
if (location.locals && !isGlobalSourceFile(location)) {
|
||||
if (result = getSymbol(location.locals, name, meaning)) {
|
||||
@@ -13636,6 +13661,7 @@ var ts;
|
||||
case 256:
|
||||
if (!ts.isExternalOrCommonJsModule(location))
|
||||
break;
|
||||
isInExternalModule = true;
|
||||
case 225:
|
||||
var moduleExports = getSymbolOfNode(location).exports;
|
||||
if (location.kind === 256 || ts.isAmbientModule(location)) {
|
||||
@@ -13759,6 +13785,12 @@ var ts;
|
||||
checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
|
||||
}
|
||||
}
|
||||
if (result && isInExternalModule) {
|
||||
var decls = result.declarations;
|
||||
if (decls && decls.length === 1 && decls[0].kind === 228) {
|
||||
error(errorLocation, ts.Diagnostics.Identifier_0_must_be_imported_from_a_module, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -15234,7 +15266,7 @@ var ts;
|
||||
}
|
||||
function getTypeForBindingElementParent(node) {
|
||||
var symbol = getSymbolOfNode(node);
|
||||
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node);
|
||||
return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
|
||||
}
|
||||
function getTextOfPropertyName(name) {
|
||||
switch (name.kind) {
|
||||
@@ -15339,7 +15371,7 @@ var ts;
|
||||
function addOptionality(type, optional) {
|
||||
return strictNullChecks && optional ? addNullableKind(type, 32) : type;
|
||||
}
|
||||
function getTypeForVariableLikeDeclaration(declaration) {
|
||||
function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
|
||||
if (declaration.flags & 134217728) {
|
||||
var type = getTypeForVariableLikeDeclarationFromJSDocComment(declaration);
|
||||
if (type && type !== unknownType) {
|
||||
@@ -15356,7 +15388,7 @@ var ts;
|
||||
return getTypeForBindingElement(declaration);
|
||||
}
|
||||
if (declaration.type) {
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), !!declaration.questionToken);
|
||||
return addOptionality(getTypeFromTypeNode(declaration.type), declaration.questionToken && includeOptionality);
|
||||
}
|
||||
if (declaration.kind === 142) {
|
||||
var func = declaration.parent;
|
||||
@@ -15375,11 +15407,11 @@ var ts;
|
||||
? getContextuallyTypedThisType(func)
|
||||
: getContextuallyTypedParameterType(declaration);
|
||||
if (type) {
|
||||
return addOptionality(type, !!declaration.questionToken);
|
||||
return addOptionality(type, declaration.questionToken && includeOptionality);
|
||||
}
|
||||
}
|
||||
if (declaration.initializer) {
|
||||
return addOptionality(checkExpressionCached(declaration.initializer), !!declaration.questionToken);
|
||||
return addOptionality(checkExpressionCached(declaration.initializer), declaration.questionToken && includeOptionality);
|
||||
}
|
||||
if (declaration.kind === 254) {
|
||||
return checkIdentifier(declaration.name);
|
||||
@@ -15447,7 +15479,7 @@ var ts;
|
||||
: getTypeFromArrayBindingPattern(pattern, includePatternInType);
|
||||
}
|
||||
function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
|
||||
var type = getTypeForVariableLikeDeclaration(declaration);
|
||||
var type = getTypeForVariableLikeDeclaration(declaration, true);
|
||||
if (type) {
|
||||
if (reportErrors) {
|
||||
reportErrorsFromWidening(declaration, type);
|
||||
@@ -17764,7 +17796,7 @@ var ts;
|
||||
return isIdenticalTo(source, target);
|
||||
}
|
||||
if (!(target.flags & 134217728)) {
|
||||
if (target.flags & 1)
|
||||
if (target.flags & 1 || source.flags & 134217728)
|
||||
return -1;
|
||||
if (source.flags & 32) {
|
||||
if (!strictNullChecks || target.flags & (32 | 16) || source === emptyArrayElementType)
|
||||
@@ -17784,7 +17816,7 @@ var ts;
|
||||
if (source.flags & 256 && target === stringType)
|
||||
return -1;
|
||||
if (relation === assignableRelation || relation === comparableRelation) {
|
||||
if (source.flags & (1 | 134217728))
|
||||
if (source.flags & 1)
|
||||
return -1;
|
||||
if (source === numberType && target.flags & 128)
|
||||
return -1;
|
||||
@@ -18561,41 +18593,47 @@ var ts;
|
||||
getSignaturesOfType(type, 0).length === 0 &&
|
||||
getSignaturesOfType(type, 1).length === 0;
|
||||
}
|
||||
function createTransientSymbol(source, type) {
|
||||
var symbol = createSymbol(source.flags | 67108864, source.name);
|
||||
symbol.declarations = source.declarations;
|
||||
symbol.parent = source.parent;
|
||||
symbol.type = type;
|
||||
symbol.target = source;
|
||||
if (source.valueDeclaration) {
|
||||
symbol.valueDeclaration = source.valueDeclaration;
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
function transformTypeOfMembers(type, f) {
|
||||
var members = {};
|
||||
for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
|
||||
var property = _a[_i];
|
||||
var original = getTypeOfSymbol(property);
|
||||
var updated = f(original);
|
||||
members[property.name] = updated === original ? property : createTransientSymbol(property, updated);
|
||||
}
|
||||
;
|
||||
return members;
|
||||
}
|
||||
function getRegularTypeOfObjectLiteral(type) {
|
||||
if (type.flags & 1048576) {
|
||||
var regularType = type.regularType;
|
||||
if (!regularType) {
|
||||
regularType = createType(type.flags & ~1048576);
|
||||
regularType.symbol = type.symbol;
|
||||
regularType.members = type.members;
|
||||
regularType.properties = type.properties;
|
||||
regularType.callSignatures = type.callSignatures;
|
||||
regularType.constructSignatures = type.constructSignatures;
|
||||
regularType.stringIndexInfo = type.stringIndexInfo;
|
||||
regularType.numberIndexInfo = type.numberIndexInfo;
|
||||
type.regularType = regularType;
|
||||
}
|
||||
if (!(type.flags & 1048576)) {
|
||||
return type;
|
||||
}
|
||||
var regularType = type.regularType;
|
||||
if (regularType) {
|
||||
return regularType;
|
||||
}
|
||||
return type;
|
||||
var resolved = type;
|
||||
var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
|
||||
var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
|
||||
regularNew.flags = resolved.flags & ~1048576;
|
||||
type.regularType = regularNew;
|
||||
return regularNew;
|
||||
}
|
||||
function getWidenedTypeOfObjectLiteral(type) {
|
||||
var properties = getPropertiesOfObjectType(type);
|
||||
var members = {};
|
||||
ts.forEach(properties, function (p) {
|
||||
var propType = getTypeOfSymbol(p);
|
||||
var widenedType = getWidenedType(propType);
|
||||
if (propType !== widenedType) {
|
||||
var symbol = createSymbol(p.flags | 67108864, p.name);
|
||||
symbol.declarations = p.declarations;
|
||||
symbol.parent = p.parent;
|
||||
symbol.type = widenedType;
|
||||
symbol.target = p;
|
||||
if (p.valueDeclaration)
|
||||
symbol.valueDeclaration = p.valueDeclaration;
|
||||
p = symbol;
|
||||
}
|
||||
members[p.name] = p;
|
||||
var members = transformTypeOfMembers(type, function (prop) {
|
||||
var widened = getWidenedType(prop);
|
||||
return prop === widened ? prop : widened;
|
||||
});
|
||||
var stringIndexInfo = getIndexInfoOfType(type, 0);
|
||||
var numberIndexInfo = getIndexInfoOfType(type, 1);
|
||||
@@ -18816,7 +18854,7 @@ var ts;
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
if (target.flags & 16384 && typeParameterCount === 1) {
|
||||
if (typeParameterCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferiority--;
|
||||
@@ -19888,7 +19926,7 @@ var ts;
|
||||
}
|
||||
return nodeCheckFlag === 512
|
||||
? getBaseConstructorTypeOfClass(classType)
|
||||
: baseClassType;
|
||||
: getTypeWithThisArgument(baseClassType, classType.thisType);
|
||||
function isLegalUsageOfSuperExpression(container) {
|
||||
if (!container) {
|
||||
return false;
|
||||
@@ -21936,7 +21974,7 @@ var ts;
|
||||
var types = void 0;
|
||||
var funcIsGenerator = !!func.asteriskToken;
|
||||
if (funcIsGenerator) {
|
||||
types = checkAndAggregateYieldOperandTypes(func.body, contextualMapper);
|
||||
types = checkAndAggregateYieldOperandTypes(func, contextualMapper);
|
||||
if (types.length === 0) {
|
||||
var iterableIteratorAny = createIterableIteratorType(anyType);
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
@@ -21946,8 +21984,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var hasImplicitReturn = !!(func.flags & 32768);
|
||||
types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync, hasImplicitReturn);
|
||||
types = checkAndAggregateReturnExpressionTypes(func, contextualMapper);
|
||||
if (!types) {
|
||||
return neverType;
|
||||
}
|
||||
@@ -21994,9 +22031,9 @@ var ts;
|
||||
return widenedType;
|
||||
}
|
||||
}
|
||||
function checkAndAggregateYieldOperandTypes(body, contextualMapper) {
|
||||
function checkAndAggregateYieldOperandTypes(func, contextualMapper) {
|
||||
var aggregatedTypes = [];
|
||||
ts.forEachYieldExpression(body, function (yieldExpression) {
|
||||
ts.forEachYieldExpression(func.body, function (yieldExpression) {
|
||||
var expr = yieldExpression.expression;
|
||||
if (expr) {
|
||||
var type = checkExpressionCached(expr, contextualMapper);
|
||||
@@ -22010,28 +22047,34 @@ var ts;
|
||||
});
|
||||
return aggregatedTypes;
|
||||
}
|
||||
function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync, hasImplicitReturn) {
|
||||
function checkAndAggregateReturnExpressionTypes(func, contextualMapper) {
|
||||
var isAsync = ts.isAsyncFunctionLike(func);
|
||||
var aggregatedTypes = [];
|
||||
var hasOmittedExpressions = false;
|
||||
ts.forEachReturnStatement(body, function (returnStatement) {
|
||||
var hasReturnWithNoExpression = !!(func.flags & 32768);
|
||||
var hasReturnOfTypeNever = false;
|
||||
ts.forEachReturnStatement(func.body, function (returnStatement) {
|
||||
var expr = returnStatement.expression;
|
||||
if (expr) {
|
||||
var type = checkExpressionCached(expr, contextualMapper);
|
||||
if (isAsync) {
|
||||
type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
|
||||
type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member);
|
||||
}
|
||||
if (type !== neverType && !ts.contains(aggregatedTypes, type)) {
|
||||
if (type === neverType) {
|
||||
hasReturnOfTypeNever = true;
|
||||
}
|
||||
else if (!ts.contains(aggregatedTypes, type)) {
|
||||
aggregatedTypes.push(type);
|
||||
}
|
||||
}
|
||||
else {
|
||||
hasOmittedExpressions = true;
|
||||
hasReturnWithNoExpression = true;
|
||||
}
|
||||
});
|
||||
if (aggregatedTypes.length === 0 && !hasOmittedExpressions && !hasImplicitReturn) {
|
||||
if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever ||
|
||||
func.kind === 179 || func.kind === 180)) {
|
||||
return undefined;
|
||||
}
|
||||
if (strictNullChecks && aggregatedTypes.length && (hasOmittedExpressions || hasImplicitReturn)) {
|
||||
if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) {
|
||||
if (!ts.contains(aggregatedTypes, undefinedType)) {
|
||||
aggregatedTypes.push(undefinedType);
|
||||
}
|
||||
@@ -22161,7 +22204,9 @@ var ts;
|
||||
(expr.kind === 172 || expr.kind === 173) &&
|
||||
expr.expression.kind === 97) {
|
||||
var func = ts.getContainingFunction(expr);
|
||||
return !(func && func.kind === 148 && func.parent === symbol.valueDeclaration.parent);
|
||||
if (!(func && func.kind === 148))
|
||||
return true;
|
||||
return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -22985,6 +23030,79 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkClassForDuplicateDeclarations(node) {
|
||||
var getter = 1, setter = 2, property = getter | setter;
|
||||
var instanceNames = {};
|
||||
var staticNames = {};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (member.kind === 148) {
|
||||
for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
|
||||
var param = _c[_b];
|
||||
if (ts.isParameterPropertyDeclaration(param)) {
|
||||
addName(instanceNames, param.name, param.name.text, property);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var static = ts.forEach(member.modifiers, function (m) { return m.kind === 113; });
|
||||
var names = static ? staticNames : instanceNames;
|
||||
var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name);
|
||||
if (memberName) {
|
||||
switch (member.kind) {
|
||||
case 149:
|
||||
addName(names, member.name, memberName, getter);
|
||||
break;
|
||||
case 150:
|
||||
addName(names, member.name, memberName, setter);
|
||||
break;
|
||||
case 145:
|
||||
addName(names, member.name, memberName, property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function addName(names, location, name, meaning) {
|
||||
if (ts.hasProperty(names, name)) {
|
||||
var prev = names[name];
|
||||
if (prev & meaning) {
|
||||
error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
|
||||
}
|
||||
else {
|
||||
names[name] = prev | meaning;
|
||||
}
|
||||
}
|
||||
else {
|
||||
names[name] = meaning;
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkObjectTypeForDuplicateDeclarations(node) {
|
||||
var names = {};
|
||||
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
||||
var member = _a[_i];
|
||||
if (member.kind == 144) {
|
||||
var memberName = void 0;
|
||||
switch (member.name.kind) {
|
||||
case 9:
|
||||
case 8:
|
||||
case 69:
|
||||
memberName = member.name.text;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if (ts.hasProperty(names, memberName)) {
|
||||
error(member.symbol.valueDeclaration.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
|
||||
error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
|
||||
}
|
||||
else {
|
||||
names[memberName] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function checkTypeForDuplicateIndexSignatures(node) {
|
||||
if (node.kind === 222) {
|
||||
var nodeSymbol = getSymbolOfNode(node);
|
||||
@@ -23203,6 +23321,7 @@ var ts;
|
||||
var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
|
||||
checkIndexConstraints(type);
|
||||
checkTypeForDuplicateIndexSignatures(node);
|
||||
checkObjectTypeForDuplicateDeclarations(node);
|
||||
}
|
||||
}
|
||||
function checkArrayType(node) {
|
||||
@@ -23962,6 +24081,10 @@ var ts;
|
||||
if (node.initializer) {
|
||||
checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined);
|
||||
}
|
||||
if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
|
||||
error(symbol.valueDeclaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
|
||||
error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
|
||||
}
|
||||
}
|
||||
if (node.kind !== 145 && node.kind !== 144) {
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
@@ -23974,6 +24097,18 @@ var ts;
|
||||
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
|
||||
}
|
||||
}
|
||||
function areDeclarationFlagsIdentical(left, right) {
|
||||
if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
|
||||
return false;
|
||||
}
|
||||
var interestingFlags = 8 |
|
||||
16 |
|
||||
256 |
|
||||
128 |
|
||||
64 |
|
||||
32;
|
||||
return (left.flags & interestingFlags) === (right.flags & interestingFlags);
|
||||
}
|
||||
function checkVariableDeclaration(node) {
|
||||
checkGrammarVariableDeclaration(node);
|
||||
return checkVariableLikeDeclaration(node);
|
||||
@@ -24524,6 +24659,7 @@ var ts;
|
||||
var typeWithThis = getTypeWithThisArgument(type);
|
||||
var staticType = getTypeOfSymbol(symbol);
|
||||
checkTypeParameterListsIdentical(node, symbol);
|
||||
checkClassForDuplicateDeclarations(node);
|
||||
var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node);
|
||||
if (baseTypeNode) {
|
||||
var baseTypes = getBaseTypes(type);
|
||||
@@ -24735,6 +24871,7 @@ var ts;
|
||||
checkIndexConstraints(type);
|
||||
}
|
||||
}
|
||||
checkObjectTypeForDuplicateDeclarations(node);
|
||||
}
|
||||
ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
|
||||
if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) {
|
||||
@@ -25489,10 +25626,8 @@ var ts;
|
||||
function checkSourceFileWorker(node) {
|
||||
var links = getNodeLinks(node);
|
||||
if (!(links.flags & 1)) {
|
||||
if (compilerOptions.skipDefaultLibCheck) {
|
||||
if (node.hasNoDefaultLib) {
|
||||
return;
|
||||
}
|
||||
if (compilerOptions.skipLibCheck && node.isDeclarationFile || compilerOptions.skipDefaultLibCheck && node.hasNoDefaultLib) {
|
||||
return;
|
||||
}
|
||||
checkGrammarSourceFile(node);
|
||||
potentialThisCollisions.length = 0;
|
||||
@@ -25861,7 +25996,7 @@ var ts;
|
||||
return symbol && getTypeOfSymbol(symbol);
|
||||
}
|
||||
if (ts.isBindingPattern(node)) {
|
||||
return getTypeForVariableLikeDeclaration(node.parent);
|
||||
return getTypeForVariableLikeDeclaration(node.parent, true);
|
||||
}
|
||||
if (isInRightSideOfImportOrExportAssignment(node)) {
|
||||
var symbol = getSymbolAtLocation(node);
|
||||
@@ -26300,7 +26435,7 @@ var ts;
|
||||
if (file.moduleAugmentations.length) {
|
||||
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
|
||||
}
|
||||
if (file.wasReferenced && file.symbol && file.symbol.globalExports) {
|
||||
if (file.symbol && file.symbol.globalExports) {
|
||||
mergeSymbolTable(globals, file.symbol.globalExports);
|
||||
}
|
||||
});
|
||||
@@ -26870,7 +27005,6 @@ var ts;
|
||||
if (prop.kind === 193 ||
|
||||
name_20.kind === 140) {
|
||||
checkGrammarComputedPropertyName(name_20);
|
||||
return "continue";
|
||||
}
|
||||
if (prop.kind === 254 && !inDestructuring && prop.objectAssignmentInitializer) {
|
||||
return { value: grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment) };
|
||||
@@ -26900,17 +27034,21 @@ var ts;
|
||||
else {
|
||||
ts.Debug.fail("Unexpected syntax kind:" + prop.kind);
|
||||
}
|
||||
if (!ts.hasProperty(seen, name_20.text)) {
|
||||
seen[name_20.text] = currentKind;
|
||||
var effectiveName = ts.getPropertyNameForPropertyNameNode(name_20);
|
||||
if (effectiveName === undefined) {
|
||||
return "continue";
|
||||
}
|
||||
if (!ts.hasProperty(seen, effectiveName)) {
|
||||
seen[effectiveName] = currentKind;
|
||||
}
|
||||
else {
|
||||
var existingKind = seen[name_20.text];
|
||||
var existingKind = seen[effectiveName];
|
||||
if (currentKind === Property && existingKind === Property) {
|
||||
return "continue";
|
||||
grammarErrorOnNode(name_20, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name_20));
|
||||
}
|
||||
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
|
||||
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
|
||||
seen[name_20.text] = currentKind | existingKind;
|
||||
seen[effectiveName] = currentKind | existingKind;
|
||||
}
|
||||
else {
|
||||
return { value: grammarErrorOnNode(name_20, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name) };
|
||||
@@ -35367,7 +35505,7 @@ var ts;
|
||||
skipTsx: true,
|
||||
traceEnabled: traceEnabled
|
||||
};
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : undefined);
|
||||
var rootDir = options.typesRoot || (options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
|
||||
if (traceEnabled) {
|
||||
if (containingFile === undefined) {
|
||||
if (rootDir === undefined) {
|
||||
@@ -35870,12 +36008,25 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(rootPath) {
|
||||
var localTypes = ts.combinePaths(rootPath, "types");
|
||||
var npmTypes = ts.combinePaths(rootPath, "node_modules/@types");
|
||||
var result = [];
|
||||
if (ts.sys.directoryExists(localTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(localTypes));
|
||||
}
|
||||
if (ts.sys.directoryExists(npmTypes)) {
|
||||
result = result.concat(ts.sys.getDirectories(npmTypes));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function getDefaultLibLocation() {
|
||||
return ts.getDirectoryPath(ts.normalizePath(ts.sys.getExecutingFilePath()));
|
||||
}
|
||||
var newLine = ts.getNewLineCharacter(options);
|
||||
var realpath = ts.sys.realpath && (function (path) { return ts.sys.realpath(path); });
|
||||
return {
|
||||
getDefaultTypeDirectiveNames: getDefaultTypeDirectiveNames,
|
||||
getSourceFile: getSourceFile,
|
||||
getDefaultLibLocation: getDefaultLibLocation,
|
||||
getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
|
||||
@@ -35943,6 +36094,19 @@ var ts;
|
||||
}
|
||||
return resolutions;
|
||||
}
|
||||
function getDefaultTypeDirectiveNames(options, rootFiles, host) {
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
}
|
||||
if (host && host.getDefaultTypeDirectiveNames) {
|
||||
var commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), function (f) { return host.getCanonicalFileName(f); });
|
||||
if (commonRoot) {
|
||||
return host.getDefaultTypeDirectiveNames(commonRoot);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
ts.getDefaultTypeDirectiveNames = getDefaultTypeDirectiveNames;
|
||||
function createProgram(rootNames, options, host, oldProgram) {
|
||||
var program;
|
||||
var files = [];
|
||||
@@ -35978,13 +36142,14 @@ var ts;
|
||||
var filesByName = ts.createFileMap();
|
||||
var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? ts.createFileMap(function (fileName) { return fileName.toLowerCase(); }) : undefined;
|
||||
if (!tryReuseStructureFromOldProgram()) {
|
||||
if (options.types && options.types.length) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(options.types, undefined);
|
||||
for (var i = 0; i < options.types.length; i++) {
|
||||
processTypeReferenceDirective(options.types[i], resolutions[i]);
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, false); });
|
||||
var typeReferences = getDefaultTypeDirectiveNames(options, rootNames, host);
|
||||
if (typeReferences) {
|
||||
var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, undefined);
|
||||
for (var i = 0; i < typeReferences.length; i++) {
|
||||
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
|
||||
}
|
||||
}
|
||||
ts.forEach(rootNames, function (name) { return processRootFile(name, false); });
|
||||
if (!skipDefaultLib) {
|
||||
if (!options.lib) {
|
||||
processRootFile(host.getDefaultLibFileName(options), true);
|
||||
@@ -36561,9 +36726,6 @@ var ts;
|
||||
if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) {
|
||||
reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd);
|
||||
}
|
||||
if (file_1) {
|
||||
file_1.wasReferenced = file_1.wasReferenced || isReference;
|
||||
}
|
||||
return file_1;
|
||||
}
|
||||
var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) {
|
||||
@@ -36576,7 +36738,6 @@ var ts;
|
||||
});
|
||||
filesByName.set(path, file);
|
||||
if (file) {
|
||||
file.wasReferenced = file.wasReferenced || isReference;
|
||||
file.path = path;
|
||||
if (host.useCaseSensitiveFileNames()) {
|
||||
var existingFile = filesByNameIgnoreCase.get(path);
|
||||
@@ -36677,17 +36838,7 @@ var ts;
|
||||
!options.noResolve &&
|
||||
i < file.imports.length;
|
||||
if (shouldAddFile) {
|
||||
var importedFile = findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
if (!ts.isExternalModule(importedFile) && importedFile.statements.length) {
|
||||
var start_5 = ts.getTokenPosOfNode(file.imports[i], file);
|
||||
fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, start_5, file.imports[i].end - start_5, ts.Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
}
|
||||
else if (importedFile.referencedFiles.length) {
|
||||
var firstRef = importedFile.referencedFiles[0];
|
||||
fileProcessingDiagnostics.add(ts.createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, ts.Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
|
||||
}
|
||||
}
|
||||
findSourceFile(resolution.resolvedFileName, ts.toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), false, false, file, ts.skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36772,7 +36923,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
else {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substututions_for_pattern_0_should_be_an_array, key));
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36821,13 +36972,19 @@ var ts;
|
||||
}
|
||||
else if (firstExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided_with_a_valid_module_type_Consider_setting_the_module_compiler_option_in_a_tsconfig_json_file));
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
if (options.module === ts.ModuleKind.ES6 && languageVersion < 2) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
if (outFile && options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
|
||||
programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile"));
|
||||
}
|
||||
else if (options.module === undefined && firstExternalModuleSourceFile) {
|
||||
var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
programDiagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
|
||||
}
|
||||
}
|
||||
if (options.outDir ||
|
||||
options.sourceRoot ||
|
||||
@@ -37517,7 +37674,7 @@ var ts;
|
||||
(function (ts) {
|
||||
var NavigateTo;
|
||||
(function (NavigateTo) {
|
||||
function getNavigateToItems(program, cancellationToken, searchValue, maxResultCount) {
|
||||
function getNavigateToItems(program, checker, cancellationToken, searchValue, maxResultCount) {
|
||||
var patternMatcher = ts.createPatternMatcher(searchValue);
|
||||
var rawItems = [];
|
||||
var baseSensitivity = { sensitivity: "base" };
|
||||
@@ -37550,6 +37707,17 @@ var ts;
|
||||
}
|
||||
}
|
||||
});
|
||||
rawItems = ts.filter(rawItems, function (item) {
|
||||
var decl = item.declaration;
|
||||
if (decl.kind === 231 || decl.kind === 234 || decl.kind === 229) {
|
||||
var importer = checker.getSymbolAtLocation(decl.name);
|
||||
var imported = checker.getAliasedSymbol(importer);
|
||||
return importer.name !== imported.name;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
rawItems.sort(compareNavigateToItems);
|
||||
if (maxResultCount !== undefined) {
|
||||
rawItems = rawItems.slice(0, maxResultCount);
|
||||
@@ -37892,8 +38060,12 @@ var ts;
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement);
|
||||
case 153:
|
||||
return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement);
|
||||
case 224:
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.enumElement);
|
||||
case 255:
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement);
|
||||
case 222:
|
||||
return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.interfaceElement);
|
||||
case 151:
|
||||
return createItem(node, "()", ts.ScriptElementKind.callSignatureElement);
|
||||
case 152:
|
||||
@@ -39263,7 +39435,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition) {
|
||||
for (var i = exclusiveStartPosition - 1; i >= 0; --i) {
|
||||
for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
|
||||
if (nodeHasTokens(children[i])) {
|
||||
return children[i];
|
||||
}
|
||||
@@ -39889,18 +40061,17 @@ var ts;
|
||||
if (!isStarted) {
|
||||
scanner.scan();
|
||||
}
|
||||
var t;
|
||||
var pos = scanner.getStartPos();
|
||||
while (pos < endPos) {
|
||||
var t_1 = scanner.getToken();
|
||||
if (!ts.isTrivia(t_1)) {
|
||||
var t = scanner.getToken();
|
||||
if (!ts.isTrivia(t)) {
|
||||
break;
|
||||
}
|
||||
scanner.scan();
|
||||
var item = {
|
||||
pos: pos,
|
||||
end: scanner.getStartPos(),
|
||||
kind: t_1
|
||||
kind: t
|
||||
};
|
||||
pos = scanner.getStartPos();
|
||||
if (!leadingTrivia) {
|
||||
@@ -41550,7 +41721,7 @@ var ts;
|
||||
else {
|
||||
parts = [];
|
||||
var startPos = commentRange.pos;
|
||||
for (var line = startLine; line < endLine; ++line) {
|
||||
for (var line = startLine; line < endLine; line++) {
|
||||
var endOfLine = ts.getEndLinePosition(line, sourceFile);
|
||||
parts.push({ pos: startPos, end: endOfLine });
|
||||
startPos = ts.getStartPositionOfLine(line + 1, sourceFile);
|
||||
@@ -41568,7 +41739,7 @@ var ts;
|
||||
startLine++;
|
||||
}
|
||||
var delta = indentation - nonWhitespaceColumnInFirstPart.column;
|
||||
for (var i = startIndex, len = parts.length; i < len; ++i, ++startLine) {
|
||||
for (var i = startIndex, len = parts.length; i < len; i++, startLine++) {
|
||||
var startLinePos_1 = ts.getStartPositionOfLine(startLine, sourceFile);
|
||||
var nonWhitespaceCharacterAndColumn = i === 0
|
||||
? nonWhitespaceColumnInFirstPart
|
||||
@@ -41584,7 +41755,7 @@ var ts;
|
||||
}
|
||||
}
|
||||
function trimTrailingWhitespacesForLines(line1, line2, range) {
|
||||
for (var line = line1; line < line2; ++line) {
|
||||
for (var line = line1; line < line2; line++) {
|
||||
var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile);
|
||||
var lineEndPosition = ts.getEndLinePosition(line, sourceFile);
|
||||
if (range && (ts.isComment(range.kind) || ts.isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
|
||||
@@ -41627,7 +41798,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) {
|
||||
var between;
|
||||
switch (rule.Operation.Action) {
|
||||
case 1:
|
||||
return;
|
||||
@@ -41657,14 +41827,6 @@ var ts;
|
||||
}
|
||||
}
|
||||
}
|
||||
function isSomeBlock(kind) {
|
||||
switch (kind) {
|
||||
case 199:
|
||||
case 226:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function getOpenTokenForList(node, list) {
|
||||
switch (node.kind) {
|
||||
case 148:
|
||||
@@ -41722,7 +41884,7 @@ var ts;
|
||||
internedTabsIndentation = [];
|
||||
}
|
||||
if (internedTabsIndentation[tabs] === undefined) {
|
||||
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
|
||||
internedTabsIndentation[tabs] = tabString = repeat("\t", tabs);
|
||||
}
|
||||
else {
|
||||
tabString = internedTabsIndentation[tabs];
|
||||
@@ -41747,7 +41909,7 @@ var ts;
|
||||
}
|
||||
function repeat(value, count) {
|
||||
var s = "";
|
||||
for (var i = 0; i < count; ++i) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
s += value;
|
||||
}
|
||||
return s;
|
||||
@@ -42015,7 +42177,7 @@ var ts;
|
||||
ts.Debug.assert(index >= 0 && index < list.length);
|
||||
var node = list[index];
|
||||
var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
|
||||
for (var i = index - 1; i >= 0; --i) {
|
||||
for (var i = index - 1; i >= 0; i--) {
|
||||
if (list[i].kind === 24) {
|
||||
continue;
|
||||
}
|
||||
@@ -42034,7 +42196,7 @@ var ts;
|
||||
function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options) {
|
||||
var character = 0;
|
||||
var column = 0;
|
||||
for (var pos = startPos; pos < endPos; ++pos) {
|
||||
for (var pos = startPos; pos < endPos; pos++) {
|
||||
var ch = sourceFile.text.charCodeAt(pos);
|
||||
if (!ts.isWhiteSpace(ch)) {
|
||||
break;
|
||||
@@ -44005,9 +44167,9 @@ var ts;
|
||||
log("getCompletionData: Get previous token 1: " + (new Date().getTime() - start));
|
||||
var contextToken = previousToken;
|
||||
if (contextToken && position <= contextToken.end && ts.isWord(contextToken.kind)) {
|
||||
var start_6 = new Date().getTime();
|
||||
var start_5 = new Date().getTime();
|
||||
contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile);
|
||||
log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_6));
|
||||
log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_5));
|
||||
}
|
||||
var node = currentToken;
|
||||
var isRightOfDot = false;
|
||||
@@ -44234,9 +44396,9 @@ var ts;
|
||||
|| contextToken.kind === 166
|
||||
|| contextToken.kind === 10
|
||||
|| ts.isTemplateLiteralKind(contextToken.kind)) {
|
||||
var start_7 = contextToken.getStart();
|
||||
var start_6 = contextToken.getStart();
|
||||
var end = contextToken.getEnd();
|
||||
if (start_7 < position && position < end) {
|
||||
if (start_6 < position && position < end) {
|
||||
return true;
|
||||
}
|
||||
if (position === end) {
|
||||
@@ -45314,8 +45476,7 @@ var ts;
|
||||
}
|
||||
function getDocumentHighlights(fileName, position, filesToSearch) {
|
||||
synchronizeHostData();
|
||||
filesToSearch = ts.map(filesToSearch, ts.normalizeSlashes);
|
||||
var sourceFilesToSearch = ts.filter(program.getSourceFiles(), function (f) { return ts.contains(filesToSearch, f.fileName); });
|
||||
var sourceFilesToSearch = ts.map(filesToSearch, function (f) { return program.getSourceFile(f); });
|
||||
var sourceFile = getValidSourceFile(fileName);
|
||||
var node = ts.getTouchingWord(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -46498,7 +46659,8 @@ var ts;
|
||||
}
|
||||
function getNavigateToItems(searchValue, maxResultCount) {
|
||||
synchronizeHostData();
|
||||
return ts.NavigateTo.getNavigateToItems(program, cancellationToken, searchValue, maxResultCount);
|
||||
var checker = getProgram().getTypeChecker();
|
||||
return ts.NavigateTo.getNavigateToItems(program, checker, cancellationToken, searchValue, maxResultCount);
|
||||
}
|
||||
function getEmitOutput(fileName) {
|
||||
synchronizeHostData();
|
||||
@@ -50961,6 +51123,9 @@ var ts;
|
||||
LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () {
|
||||
return this.shimHost.getCurrentDirectory();
|
||||
};
|
||||
LanguageServiceShimHostAdapter.prototype.getDirectories = function (path) {
|
||||
return this.shimHost.getDirectories(path);
|
||||
};
|
||||
LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) {
|
||||
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
|
||||
};
|
||||
|
||||
Vendored
+37
-3
@@ -261,7 +261,7 @@ declare namespace ts {
|
||||
ModuleDeclaration = 225,
|
||||
ModuleBlock = 226,
|
||||
CaseBlock = 227,
|
||||
GlobalModuleExportDeclaration = 228,
|
||||
NamespaceExportDeclaration = 228,
|
||||
ImportEqualsDeclaration = 229,
|
||||
ImportDeclaration = 230,
|
||||
ImportClause = 231,
|
||||
@@ -934,7 +934,7 @@ declare namespace ts {
|
||||
interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
interface GlobalModuleExportDeclaration extends DeclarationStatement {
|
||||
interface NamespaceExportDeclaration extends DeclarationStatement {
|
||||
name: Identifier;
|
||||
moduleReference: LiteralLikeNode;
|
||||
}
|
||||
@@ -1329,7 +1329,7 @@ declare namespace ts {
|
||||
FunctionScopedVariableExcludes = 107454,
|
||||
BlockScopedVariableExcludes = 107455,
|
||||
ParameterExcludes = 107455,
|
||||
PropertyExcludes = 107455,
|
||||
PropertyExcludes = 0,
|
||||
EnumMemberExcludes = 107455,
|
||||
FunctionExcludes = 106927,
|
||||
ClassExcludes = 899519,
|
||||
@@ -1554,6 +1554,7 @@ declare namespace ts {
|
||||
allowJs?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
strictNullChecks?: boolean;
|
||||
skipLibCheck?: boolean;
|
||||
listEmittedFiles?: boolean;
|
||||
lib?: string[];
|
||||
types?: string[];
|
||||
@@ -1627,6 +1628,7 @@ declare namespace ts {
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
realpath?(path: string): string;
|
||||
getCurrentDirectory?(): string;
|
||||
}
|
||||
interface ResolvedModule {
|
||||
resolvedFileName: string;
|
||||
@@ -1650,6 +1652,7 @@ declare namespace ts {
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
getDefaultTypeDirectiveNames?(rootPath: string): string[];
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
@@ -1693,6 +1696,7 @@ declare namespace ts {
|
||||
createDirectory(path: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getModifiedTime?(path: string): Date;
|
||||
createHash?(data: string): string;
|
||||
@@ -1812,6 +1816,7 @@ declare namespace ts {
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
@@ -2345,26 +2350,55 @@ declare namespace ts {
|
||||
namespace ScriptElementKind {
|
||||
const unknown: string;
|
||||
const warning: string;
|
||||
/** predefined type (void) or keyword (class) */
|
||||
const keyword: string;
|
||||
/** top level script node */
|
||||
const scriptElement: string;
|
||||
/** module foo {} */
|
||||
const moduleElement: string;
|
||||
/** class X {} */
|
||||
const classElement: string;
|
||||
/** var x = class X {} */
|
||||
const localClassElement: string;
|
||||
/** interface Y {} */
|
||||
const interfaceElement: string;
|
||||
/** type T = ... */
|
||||
const typeElement: string;
|
||||
/** enum E */
|
||||
const enumElement: string;
|
||||
/**
|
||||
* Inside module and script only
|
||||
* const v = ..
|
||||
*/
|
||||
const variableElement: string;
|
||||
/** Inside function */
|
||||
const localVariableElement: string;
|
||||
/**
|
||||
* Inside module and script only
|
||||
* function f() { }
|
||||
*/
|
||||
const functionElement: string;
|
||||
/** Inside function */
|
||||
const localFunctionElement: string;
|
||||
/** class X { [public|private]* foo() {} } */
|
||||
const memberFunctionElement: string;
|
||||
/** class X { [public|private]* [get|set] foo:number; } */
|
||||
const memberGetAccessorElement: string;
|
||||
const memberSetAccessorElement: string;
|
||||
/**
|
||||
* class X { [public|private]* foo:number; }
|
||||
* interface Y { foo:number; }
|
||||
*/
|
||||
const memberVariableElement: string;
|
||||
/** class X { constructor() { } } */
|
||||
const constructorImplementationElement: string;
|
||||
/** interface Y { ():number; } */
|
||||
const callSignatureElement: string;
|
||||
/** interface Y { []:number; } */
|
||||
const indexSignatureElement: string;
|
||||
/** interface Y { new():Y; } */
|
||||
const constructSignatureElement: string;
|
||||
/** function foo(*Y*: string) */
|
||||
const parameterElement: string;
|
||||
const typeParameterElement: string;
|
||||
const primitiveType: string;
|
||||
|
||||
+376
-193
File diff suppressed because it is too large
Load Diff
Vendored
+37
-3
@@ -261,7 +261,7 @@ declare namespace ts {
|
||||
ModuleDeclaration = 225,
|
||||
ModuleBlock = 226,
|
||||
CaseBlock = 227,
|
||||
GlobalModuleExportDeclaration = 228,
|
||||
NamespaceExportDeclaration = 228,
|
||||
ImportEqualsDeclaration = 229,
|
||||
ImportDeclaration = 230,
|
||||
ImportClause = 231,
|
||||
@@ -934,7 +934,7 @@ declare namespace ts {
|
||||
interface NamespaceImport extends Declaration {
|
||||
name: Identifier;
|
||||
}
|
||||
interface GlobalModuleExportDeclaration extends DeclarationStatement {
|
||||
interface NamespaceExportDeclaration extends DeclarationStatement {
|
||||
name: Identifier;
|
||||
moduleReference: LiteralLikeNode;
|
||||
}
|
||||
@@ -1329,7 +1329,7 @@ declare namespace ts {
|
||||
FunctionScopedVariableExcludes = 107454,
|
||||
BlockScopedVariableExcludes = 107455,
|
||||
ParameterExcludes = 107455,
|
||||
PropertyExcludes = 107455,
|
||||
PropertyExcludes = 0,
|
||||
EnumMemberExcludes = 107455,
|
||||
FunctionExcludes = 106927,
|
||||
ClassExcludes = 899519,
|
||||
@@ -1554,6 +1554,7 @@ declare namespace ts {
|
||||
allowJs?: boolean;
|
||||
noImplicitUseStrict?: boolean;
|
||||
strictNullChecks?: boolean;
|
||||
skipLibCheck?: boolean;
|
||||
listEmittedFiles?: boolean;
|
||||
lib?: string[];
|
||||
types?: string[];
|
||||
@@ -1627,6 +1628,7 @@ declare namespace ts {
|
||||
trace?(s: string): void;
|
||||
directoryExists?(directoryName: string): boolean;
|
||||
realpath?(path: string): string;
|
||||
getCurrentDirectory?(): string;
|
||||
}
|
||||
interface ResolvedModule {
|
||||
resolvedFileName: string;
|
||||
@@ -1650,6 +1652,7 @@ declare namespace ts {
|
||||
getCancellationToken?(): CancellationToken;
|
||||
getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibLocation?(): string;
|
||||
getDefaultTypeDirectiveNames?(rootPath: string): string[];
|
||||
writeFile: WriteFileCallback;
|
||||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
@@ -1693,6 +1696,7 @@ declare namespace ts {
|
||||
createDirectory(path: string): void;
|
||||
getExecutingFilePath(): string;
|
||||
getCurrentDirectory(): string;
|
||||
getDirectories(path: string): string[];
|
||||
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
|
||||
getModifiedTime?(path: string): Date;
|
||||
createHash?(data: string): string;
|
||||
@@ -1812,6 +1816,7 @@ declare namespace ts {
|
||||
function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost;
|
||||
function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[];
|
||||
function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string;
|
||||
function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[];
|
||||
function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program;
|
||||
}
|
||||
declare namespace ts {
|
||||
@@ -2345,26 +2350,55 @@ declare namespace ts {
|
||||
namespace ScriptElementKind {
|
||||
const unknown: string;
|
||||
const warning: string;
|
||||
/** predefined type (void) or keyword (class) */
|
||||
const keyword: string;
|
||||
/** top level script node */
|
||||
const scriptElement: string;
|
||||
/** module foo {} */
|
||||
const moduleElement: string;
|
||||
/** class X {} */
|
||||
const classElement: string;
|
||||
/** var x = class X {} */
|
||||
const localClassElement: string;
|
||||
/** interface Y {} */
|
||||
const interfaceElement: string;
|
||||
/** type T = ... */
|
||||
const typeElement: string;
|
||||
/** enum E */
|
||||
const enumElement: string;
|
||||
/**
|
||||
* Inside module and script only
|
||||
* const v = ..
|
||||
*/
|
||||
const variableElement: string;
|
||||
/** Inside function */
|
||||
const localVariableElement: string;
|
||||
/**
|
||||
* Inside module and script only
|
||||
* function f() { }
|
||||
*/
|
||||
const functionElement: string;
|
||||
/** Inside function */
|
||||
const localFunctionElement: string;
|
||||
/** class X { [public|private]* foo() {} } */
|
||||
const memberFunctionElement: string;
|
||||
/** class X { [public|private]* [get|set] foo:number; } */
|
||||
const memberGetAccessorElement: string;
|
||||
const memberSetAccessorElement: string;
|
||||
/**
|
||||
* class X { [public|private]* foo:number; }
|
||||
* interface Y { foo:number; }
|
||||
*/
|
||||
const memberVariableElement: string;
|
||||
/** class X { constructor() { } } */
|
||||
const constructorImplementationElement: string;
|
||||
/** interface Y { ():number; } */
|
||||
const callSignatureElement: string;
|
||||
/** interface Y { []:number; } */
|
||||
const indexSignatureElement: string;
|
||||
/** interface Y { new():Y; } */
|
||||
const constructSignatureElement: string;
|
||||
/** function foo(*Y*: string) */
|
||||
const parameterElement: string;
|
||||
const typeParameterElement: string;
|
||||
const primitiveType: string;
|
||||
|
||||
+376
-193
File diff suppressed because it is too large
Load Diff
@@ -28,8 +28,15 @@ class IncrementDecrementWalker extends Lint.RuleWalker {
|
||||
}
|
||||
|
||||
visitIncrementDecrement(node: ts.UnaryExpression) {
|
||||
if (node.parent && (node.parent.kind === ts.SyntaxKind.ExpressionStatement ||
|
||||
node.parent.kind === ts.SyntaxKind.ForStatement)) {
|
||||
if (node.parent && (
|
||||
// Can be a statement
|
||||
node.parent.kind === ts.SyntaxKind.ExpressionStatement ||
|
||||
// Can be directly in a for-statement
|
||||
node.parent.kind === ts.SyntaxKind.ForStatement ||
|
||||
// Can be in a comma operator in a for statement (`for (let a = 0, b = 10; a < b; a++, b--)`)
|
||||
node.parent.kind === ts.SyntaxKind.BinaryExpression &&
|
||||
(<ts.BinaryExpression>node.parent).operatorToken.kind === ts.SyntaxKind.CommaToken &&
|
||||
node.parent.parent.kind === ts.SyntaxKind.ForStatement)) {
|
||||
return;
|
||||
}
|
||||
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.POSTFIX_FAILURE_STRING));
|
||||
|
||||
+16
-15
@@ -7158,11 +7158,10 @@ namespace ts {
|
||||
inferFromTypes(source, t);
|
||||
}
|
||||
}
|
||||
// Next, if target is a union type containing a single naked type parameter, make a
|
||||
// secondary inference to that type parameter. We don't do this for intersection types
|
||||
// because in a target type like Foo & T we don't know how which parts of the source type
|
||||
// should be matched by Foo and which should be inferred to T.
|
||||
if (target.flags & TypeFlags.Union && typeParameterCount === 1) {
|
||||
// Next, if target containings a single naked type parameter, make a secondary inference to that type
|
||||
// parameter. This gives meaningful results for union types in co-variant positions and intersection
|
||||
// types in contra-variant positions (such as callback parameters).
|
||||
if (typeParameterCount === 1) {
|
||||
inferiority++;
|
||||
inferFromTypes(source, typeParameter);
|
||||
inferiority--;
|
||||
@@ -12972,18 +12971,20 @@ namespace ts {
|
||||
const names = static ? staticNames : instanceNames;
|
||||
|
||||
const memberName = member.name && getPropertyNameForPropertyNameNode(member.name);
|
||||
switch (member.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
addName(names, member.name, memberName, getter);
|
||||
break;
|
||||
if (memberName) {
|
||||
switch (member.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
addName(names, member.name, memberName, getter);
|
||||
break;
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
addName(names, member.name, memberName, setter);
|
||||
break;
|
||||
case SyntaxKind.SetAccessor:
|
||||
addName(names, member.name, memberName, setter);
|
||||
break;
|
||||
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
addName(names, member.name, memberName, property);
|
||||
break;
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
addName(names, member.name, memberName, property);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1096,14 +1096,6 @@ namespace FourSlash {
|
||||
}
|
||||
addSpanInfoString();
|
||||
return resultString;
|
||||
|
||||
function repeatString(count: number, char: string) {
|
||||
let result = "";
|
||||
for (let i = 0; i < count; i++) {
|
||||
result += char;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public getBreakpointStatementLocation(pos: number) {
|
||||
@@ -2055,7 +2047,7 @@ namespace FourSlash {
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const item = items[i];
|
||||
Harness.IO.log(`name: ${item.text}, kind: ${item.kind}`);
|
||||
Harness.IO.log(`${repeatString(item.indent, " ")}name: ${item.text}, kind: ${item.kind}, childItems: ${item.childItems.map(child => child.text)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2742,6 +2734,14 @@ ${code}
|
||||
fileName: fileName
|
||||
};
|
||||
}
|
||||
|
||||
function repeatString(count: number, char: string) {
|
||||
let result = "";
|
||||
for (let i = 0; i < count; i++) {
|
||||
result += char;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
namespace FourSlashInterface {
|
||||
|
||||
+19
-19
@@ -15,7 +15,7 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
let tokenAtLocation = getTokenAtPosition(sourceFile, position);
|
||||
let lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
const lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart(sourceFile)).line > lineOfPosition) {
|
||||
// Get previous token if the token is returned starts on new line
|
||||
// eg: let x =10; |--- cursor is here
|
||||
@@ -216,7 +216,7 @@ namespace ts.BreakpointResolver {
|
||||
return spanInNodeIfStartsOnSameLine(findPrecedingToken(node.pos, sourceFile));
|
||||
|
||||
case SyntaxKind.CommaToken:
|
||||
return spanInPreviousNode(node)
|
||||
return spanInPreviousNode(node);
|
||||
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
return spanInOpenBraceToken(node);
|
||||
@@ -259,13 +259,13 @@ namespace ts.BreakpointResolver {
|
||||
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node)) {
|
||||
return spanInArrayLiteralOrObjectLiteralDestructuringPattern(<DestructuringPattern>node);
|
||||
}
|
||||
|
||||
|
||||
// Set breakpoint on identifier element of destructuring pattern
|
||||
// a or ...c or d: x from
|
||||
// [a, b, ...c] or { a, b } or { d: x } from destructuring pattern
|
||||
if ((node.kind === SyntaxKind.Identifier ||
|
||||
node.kind == SyntaxKind.SpreadElementExpression ||
|
||||
node.kind === SyntaxKind.PropertyAssignment ||
|
||||
node.kind == SyntaxKind.SpreadElementExpression ||
|
||||
node.kind === SyntaxKind.PropertyAssignment ||
|
||||
node.kind === SyntaxKind.ShorthandPropertyAssignment) &&
|
||||
isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
|
||||
return textSpan(node);
|
||||
@@ -325,14 +325,14 @@ namespace ts.BreakpointResolver {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If this is name of property assignment, set breakpoint in the initializer
|
||||
if (node.parent.kind === SyntaxKind.PropertyAssignment &&
|
||||
(<PropertyDeclaration>node.parent).name === node &&
|
||||
(<PropertyDeclaration>node.parent).name === node &&
|
||||
!isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) {
|
||||
return spanInNode((<PropertyDeclaration>node.parent).initializer);
|
||||
}
|
||||
|
||||
|
||||
// Breakpoint in type assertion goes to its operand
|
||||
if (node.parent.kind === SyntaxKind.TypeAssertionExpression && (<TypeAssertion>node.parent).type === node) {
|
||||
return spanInNextNode((<TypeAssertion>node.parent).type);
|
||||
@@ -370,7 +370,7 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function textSpanFromVariableDeclaration(variableDeclaration: VariableDeclaration): TextSpan {
|
||||
let declarations = variableDeclaration.parent.declarations;
|
||||
const declarations = variableDeclaration.parent.declarations;
|
||||
if (declarations && declarations[0] === variableDeclaration) {
|
||||
// First declaration - include let keyword
|
||||
return textSpan(findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration);
|
||||
@@ -386,7 +386,7 @@ namespace ts.BreakpointResolver {
|
||||
if (variableDeclaration.parent.parent.kind === SyntaxKind.ForInStatement) {
|
||||
return spanInNode(variableDeclaration.parent.parent);
|
||||
}
|
||||
|
||||
|
||||
// If this is a destructuring pattern, set breakpoint in binding pattern
|
||||
if (isBindingPattern(variableDeclaration.name)) {
|
||||
return spanInBindingPattern(<BindingPattern>variableDeclaration.name);
|
||||
@@ -400,7 +400,7 @@ namespace ts.BreakpointResolver {
|
||||
return textSpanFromVariableDeclaration(variableDeclaration);
|
||||
}
|
||||
|
||||
let declarations = variableDeclaration.parent.declarations;
|
||||
const declarations = variableDeclaration.parent.declarations;
|
||||
if (declarations && declarations[0] !== variableDeclaration) {
|
||||
// If we cannot set breakpoint on this declaration, set it on previous one
|
||||
// Because the variable declaration may be binding pattern and
|
||||
@@ -425,8 +425,8 @@ namespace ts.BreakpointResolver {
|
||||
return textSpan(parameter);
|
||||
}
|
||||
else {
|
||||
let functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
|
||||
let indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
|
||||
const functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
|
||||
const indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
|
||||
if (indexOfParameter) {
|
||||
// Not a first parameter, go to previous parameter
|
||||
return spanInParameterDeclaration(functionDeclaration.parameters[indexOfParameter - 1]);
|
||||
@@ -459,7 +459,7 @@ namespace ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function spanInFunctionBlock(block: Block): TextSpan {
|
||||
let nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
|
||||
const nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
|
||||
if (canFunctionHaveSpanInWholeDeclaration(<FunctionLikeDeclaration>block.parent)) {
|
||||
return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock);
|
||||
}
|
||||
@@ -493,7 +493,7 @@ namespace ts.BreakpointResolver {
|
||||
function spanInInitializerOfForLike(forLikeStatement: ForStatement | ForOfStatement | ForInStatement): TextSpan {
|
||||
if (forLikeStatement.initializer.kind === SyntaxKind.VariableDeclarationList) {
|
||||
// Declaration list - set breakpoint in first declaration
|
||||
let variableDeclarationList = <VariableDeclarationList>forLikeStatement.initializer;
|
||||
const variableDeclarationList = <VariableDeclarationList>forLikeStatement.initializer;
|
||||
if (variableDeclarationList.declarations.length > 0) {
|
||||
return spanInNode(variableDeclarationList.declarations[0]);
|
||||
}
|
||||
@@ -519,7 +519,7 @@ namespace ts.BreakpointResolver {
|
||||
|
||||
function spanInBindingPattern(bindingPattern: BindingPattern): TextSpan {
|
||||
// Set breakpoint in first binding element
|
||||
let firstBindingElement = forEach(bindingPattern.elements,
|
||||
const firstBindingElement = forEach(bindingPattern.elements,
|
||||
element => element.kind !== SyntaxKind.OmittedExpression ? element : undefined);
|
||||
|
||||
if (firstBindingElement) {
|
||||
@@ -616,7 +616,7 @@ namespace ts.BreakpointResolver {
|
||||
default:
|
||||
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
|
||||
// Breakpoint in last binding element or binding pattern if it contains no elements
|
||||
let objectLiteral = <ObjectLiteralExpression>node.parent;
|
||||
const objectLiteral = <ObjectLiteralExpression>node.parent;
|
||||
return textSpan(lastOrUndefined(objectLiteral.properties) || objectLiteral);
|
||||
}
|
||||
return spanInNode(node.parent);
|
||||
@@ -633,7 +633,7 @@ namespace ts.BreakpointResolver {
|
||||
default:
|
||||
if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) {
|
||||
// Breakpoint in last binding element or binding pattern if it contains no elements
|
||||
let arrayLiteral = <ArrayLiteralExpression>node.parent;
|
||||
const arrayLiteral = <ArrayLiteralExpression>node.parent;
|
||||
return textSpan(lastOrUndefined(arrayLiteral.elements) || arrayLiteral);
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ namespace ts.BreakpointResolver {
|
||||
function spanInColonToken(node: Node): TextSpan {
|
||||
// Is this : specifying return annotation of the function declaration
|
||||
if (isFunctionLike(node.parent) ||
|
||||
node.parent.kind === SyntaxKind.PropertyAssignment ||
|
||||
node.parent.kind === SyntaxKind.PropertyAssignment ||
|
||||
node.parent.kind === SyntaxKind.Parameter) {
|
||||
return spanInPreviousNode(node);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace ts.formatting {
|
||||
* while(true)
|
||||
* { let x;
|
||||
* }
|
||||
* Normally indentation is applied only to the first token in line so at glance 'var' should not be touched.
|
||||
* However if some format rule adds new line between '}' and 'var' 'var' will become
|
||||
* Normally indentation is applied only to the first token in line so at glance 'let' should not be touched.
|
||||
* However if some format rule adds new line between '}' and 'let' 'let' will become
|
||||
* the first token in line so it should be indented
|
||||
*/
|
||||
interface DynamicIndentation {
|
||||
@@ -64,11 +64,11 @@ namespace ts.formatting {
|
||||
|
||||
interface Indentation {
|
||||
indentation: number;
|
||||
delta: number
|
||||
delta: number;
|
||||
}
|
||||
|
||||
export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
let line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
const line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (line === 0) {
|
||||
return [];
|
||||
}
|
||||
@@ -81,12 +81,12 @@ namespace ts.formatting {
|
||||
while (isWhiteSpace(sourceFile.text.charCodeAt(endOfFormatSpan)) && !isLineBreak(sourceFile.text.charCodeAt(endOfFormatSpan))) {
|
||||
endOfFormatSpan--;
|
||||
}
|
||||
let span = {
|
||||
const span = {
|
||||
// get start position for the previous line
|
||||
pos: getStartPositionOfLine(line - 1, sourceFile),
|
||||
// end value is exclusive so add 1 to the result
|
||||
end: endOfFormatSpan + 1
|
||||
}
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, FormattingRequestKind.FormatOnEnter);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
export function formatDocument(sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
let span = {
|
||||
const span = {
|
||||
pos: 0,
|
||||
end: sourceFile.text.length
|
||||
};
|
||||
@@ -108,7 +108,7 @@ namespace ts.formatting {
|
||||
|
||||
export function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
// format from the beginning of the line
|
||||
let span = {
|
||||
const span = {
|
||||
pos: getLineStartPositionForPosition(start, sourceFile),
|
||||
end: end
|
||||
};
|
||||
@@ -116,11 +116,11 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function formatOutermostParent(position: number, expectedLastToken: SyntaxKind, sourceFile: SourceFile, options: FormatCodeOptions, rulesProvider: RulesProvider, requestKind: FormattingRequestKind): TextChange[] {
|
||||
let parent = findOutermostParent(position, expectedLastToken, sourceFile);
|
||||
const parent = findOutermostParent(position, expectedLastToken, sourceFile);
|
||||
if (!parent) {
|
||||
return [];
|
||||
}
|
||||
let span = {
|
||||
const span = {
|
||||
pos: getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
end: parent.end
|
||||
};
|
||||
@@ -128,7 +128,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function findOutermostParent(position: number, expectedTokenKind: SyntaxKind, sourceFile: SourceFile): Node {
|
||||
let precedingToken = findPrecedingToken(position, sourceFile);
|
||||
const precedingToken = findPrecedingToken(position, sourceFile);
|
||||
|
||||
// when it is claimed that trigger character was typed at given position
|
||||
// we verify that there is a token with a matching kind whose end is equal to position (because the character was just typed).
|
||||
@@ -168,7 +168,7 @@ namespace ts.formatting {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return rangeContainsRange((<InterfaceDeclaration>parent).members, node);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
let body = (<ModuleDeclaration>parent).body;
|
||||
const body = (<ModuleDeclaration>parent).body;
|
||||
return body && body.kind === SyntaxKind.Block && rangeContainsRange((<Block>body).statements, node);
|
||||
case SyntaxKind.SourceFile:
|
||||
case SyntaxKind.Block:
|
||||
@@ -186,9 +186,9 @@ namespace ts.formatting {
|
||||
return find(sourceFile);
|
||||
|
||||
function find(n: Node): Node {
|
||||
let candidate = forEachChild(n, c => startEndContainsRange(c.getStart(sourceFile), c.end, range) && c);
|
||||
const candidate = forEachChild(n, c => startEndContainsRange(c.getStart(sourceFile), c.end, range) && c);
|
||||
if (candidate) {
|
||||
let result = find(candidate);
|
||||
const result = find(candidate);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -208,7 +208,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
// pick only errors that fall in range
|
||||
let sorted = errors
|
||||
const sorted = errors
|
||||
.filter(d => rangeOverlapsWithStartEnd(originalRange, d.start, d.start + d.length))
|
||||
.sort((e1, e2) => e1.start - e2.start);
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace ts.formatting {
|
||||
return false;
|
||||
}
|
||||
|
||||
let error = sorted[index];
|
||||
const error = sorted[index];
|
||||
if (r.end <= error.start) {
|
||||
// specified range ends before the error refered by 'index' - no error in range
|
||||
return false;
|
||||
@@ -253,12 +253,12 @@ namespace ts.formatting {
|
||||
* and return its end as start position for the scanner.
|
||||
*/
|
||||
function getScanStartPosition(enclosingNode: Node, originalRange: TextRange, sourceFile: SourceFile): number {
|
||||
let start = enclosingNode.getStart(sourceFile);
|
||||
const start = enclosingNode.getStart(sourceFile);
|
||||
if (start === originalRange.pos && enclosingNode.end === originalRange.end) {
|
||||
return start;
|
||||
}
|
||||
|
||||
let precedingToken = findPrecedingToken(originalRange.pos, sourceFile);
|
||||
const precedingToken = findPrecedingToken(originalRange.pos, sourceFile);
|
||||
if (!precedingToken) {
|
||||
// no preceding token found - start from the beginning of enclosing node
|
||||
return enclosingNode.pos;
|
||||
@@ -292,7 +292,7 @@ namespace ts.formatting {
|
||||
let previousLine = Constants.Unknown;
|
||||
let child: Node;
|
||||
while (n) {
|
||||
let line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
const line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
if (previousLine !== Constants.Unknown && line !== previousLine) {
|
||||
break;
|
||||
}
|
||||
@@ -314,17 +314,17 @@ namespace ts.formatting {
|
||||
rulesProvider: RulesProvider,
|
||||
requestKind: FormattingRequestKind): TextChange[] {
|
||||
|
||||
let rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange);
|
||||
const rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange);
|
||||
|
||||
// formatting context is used by rules provider
|
||||
let formattingContext = new FormattingContext(sourceFile, requestKind);
|
||||
const formattingContext = new FormattingContext(sourceFile, requestKind);
|
||||
|
||||
// find the smallest node that fully wraps the range and compute the initial indentation for the node
|
||||
let enclosingNode = findEnclosingNode(originalRange, sourceFile);
|
||||
const enclosingNode = findEnclosingNode(originalRange, sourceFile);
|
||||
|
||||
let formattingScanner = getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end);
|
||||
const formattingScanner = getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end);
|
||||
|
||||
let initialIndentation = SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options);
|
||||
const initialIndentation = SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options);
|
||||
|
||||
let previousRangeHasError: boolean;
|
||||
let previousRange: TextRangeWithKind;
|
||||
@@ -334,23 +334,23 @@ namespace ts.formatting {
|
||||
let lastIndentedLine: number;
|
||||
let indentationOnLastIndentedLine: number;
|
||||
|
||||
let edits: TextChange[] = [];
|
||||
const edits: TextChange[] = [];
|
||||
|
||||
formattingScanner.advance();
|
||||
|
||||
if (formattingScanner.isOnToken()) {
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
const startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
let undecoratedStartLine = startLine;
|
||||
if (enclosingNode.decorators) {
|
||||
undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line;
|
||||
}
|
||||
|
||||
let delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
const delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta);
|
||||
}
|
||||
|
||||
if (!formattingScanner.isOnToken()) {
|
||||
let leadingTrivia = formattingScanner.getCurrentLeadingTrivia();
|
||||
const leadingTrivia = formattingScanner.getCurrentLeadingTrivia();
|
||||
if (leadingTrivia) {
|
||||
processTrivia(leadingTrivia, enclosingNode, enclosingNode, undefined);
|
||||
trimTrailingWhitespacesForRemainingRange();
|
||||
@@ -384,11 +384,11 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
else {
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
|
||||
let startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
let column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
const startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
|
||||
const startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
const column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
if (startLine !== parentStartLine || startPos === column) {
|
||||
return column
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ namespace ts.formatting {
|
||||
effectiveParentStartLine: number): Indentation {
|
||||
|
||||
let indentation = inheritedIndentation;
|
||||
var delta = SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0;
|
||||
let delta = SmartIndenter.shouldIndentChildNode(node) ? options.IndentSize : 0;
|
||||
|
||||
if (effectiveParentStartLine === startLine) {
|
||||
// if node is located on the same line with the parent
|
||||
@@ -427,7 +427,7 @@ namespace ts.formatting {
|
||||
return {
|
||||
indentation,
|
||||
delta
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getFirstNonDecoratorTokenOfNode(node: Node) {
|
||||
@@ -511,7 +511,7 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function getEffectiveDelta(delta: number, child: TextRangeWithKind) {
|
||||
// Delta value should be zero when the node explicitly prevents indentation of the child node
|
||||
@@ -524,7 +524,7 @@ namespace ts.formatting {
|
||||
return;
|
||||
}
|
||||
|
||||
let nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta);
|
||||
const nodeDynamicIndentation = getDynamicIndentation(node, nodeStartLine, indentation, delta);
|
||||
|
||||
// a useful observations when tracking context node
|
||||
// /
|
||||
@@ -545,7 +545,7 @@ namespace ts.formatting {
|
||||
forEachChild(
|
||||
node,
|
||||
child => {
|
||||
processChildNode(child, /*inheritedIndentation*/ Constants.Unknown, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false)
|
||||
processChildNode(child, /*inheritedIndentation*/ Constants.Unknown, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false);
|
||||
},
|
||||
(nodes: NodeArray<Node>) => {
|
||||
processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation);
|
||||
@@ -553,7 +553,7 @@ namespace ts.formatting {
|
||||
|
||||
// proceed any tokens in the node that are located after child nodes
|
||||
while (formattingScanner.isOnToken()) {
|
||||
let tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
const tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
if (tokenInfo.token.end > node.end) {
|
||||
break;
|
||||
}
|
||||
@@ -570,9 +570,9 @@ namespace ts.formatting {
|
||||
isListItem: boolean,
|
||||
isFirstListItem?: boolean): number {
|
||||
|
||||
let childStartPos = child.getStart(sourceFile);
|
||||
const childStartPos = child.getStart(sourceFile);
|
||||
|
||||
let childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line;
|
||||
const childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line;
|
||||
|
||||
let undecoratedChildStartLine = childStartLine;
|
||||
if (child.decorators) {
|
||||
@@ -599,7 +599,7 @@ namespace ts.formatting {
|
||||
|
||||
while (formattingScanner.isOnToken()) {
|
||||
// proceed any parent tokens that are located prior to child.getStart()
|
||||
let tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
const tokenInfo = formattingScanner.readTokenInfo(node);
|
||||
if (tokenInfo.token.end > childStartPos) {
|
||||
// stop when formatting scanner advances past the beginning of the child
|
||||
break;
|
||||
@@ -614,14 +614,14 @@ namespace ts.formatting {
|
||||
|
||||
if (isToken(child)) {
|
||||
// if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules
|
||||
let tokenInfo = formattingScanner.readTokenInfo(child);
|
||||
const tokenInfo = formattingScanner.readTokenInfo(child);
|
||||
Debug.assert(tokenInfo.token.end === child.end);
|
||||
consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child);
|
||||
return inheritedIndentation;
|
||||
}
|
||||
|
||||
let effectiveParentStartLine = child.kind === SyntaxKind.Decorator ? childStartLine : undecoratedParentStartLine;
|
||||
let childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine);
|
||||
const effectiveParentStartLine = child.kind === SyntaxKind.Decorator ? childStartLine : undecoratedParentStartLine;
|
||||
const childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine);
|
||||
|
||||
processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta);
|
||||
|
||||
@@ -639,8 +639,8 @@ namespace ts.formatting {
|
||||
parentStartLine: number,
|
||||
parentDynamicIndentation: DynamicIndentation): void {
|
||||
|
||||
let listStartToken = getOpenTokenForList(parent, nodes);
|
||||
let listEndToken = getCloseTokenForOpenToken(listStartToken);
|
||||
const listStartToken = getOpenTokenForList(parent, nodes);
|
||||
const listEndToken = getCloseTokenForOpenToken(listStartToken);
|
||||
|
||||
let listDynamicIndentation = parentDynamicIndentation;
|
||||
let startLine = parentStartLine;
|
||||
@@ -648,7 +648,7 @@ namespace ts.formatting {
|
||||
if (listStartToken !== SyntaxKind.Unknown) {
|
||||
// introduce a new indentation scope for lists (including list start and end tokens)
|
||||
while (formattingScanner.isOnToken()) {
|
||||
let tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
const tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
if (tokenInfo.token.end > nodes.pos) {
|
||||
// stop when formatting scanner moves past the beginning of node list
|
||||
break;
|
||||
@@ -656,7 +656,7 @@ namespace ts.formatting {
|
||||
else if (tokenInfo.token.kind === listStartToken) {
|
||||
// consume list start token
|
||||
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
|
||||
let indentation =
|
||||
const indentation =
|
||||
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, parentStartLine);
|
||||
|
||||
listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation.indentation, indentation.delta);
|
||||
@@ -672,12 +672,12 @@ namespace ts.formatting {
|
||||
let inheritedIndentation = Constants.Unknown;
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const child = nodes[i];
|
||||
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true, /*isFirstListItem*/ i === 0);
|
||||
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0);
|
||||
}
|
||||
|
||||
if (listEndToken !== SyntaxKind.Unknown) {
|
||||
if (formattingScanner.isOnToken()) {
|
||||
let tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
const tokenInfo = formattingScanner.readTokenInfo(parent);
|
||||
// consume the list end token only if it is still belong to the parent
|
||||
// there might be the case when current token matches end token but does not considered as one
|
||||
// function (x: function) <--
|
||||
@@ -693,7 +693,7 @@ namespace ts.formatting {
|
||||
function consumeTokenAndAdvanceScanner(currentTokenInfo: TokenInfo, parent: Node, dynamicIndentation: DynamicIndentation, container?: Node): void {
|
||||
Debug.assert(rangeContainsRange(parent, currentTokenInfo.token));
|
||||
|
||||
let lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine();
|
||||
const lastTriviaWasNewLine = formattingScanner.lastTrailingTriviaWasNewLine();
|
||||
let indentToken = false;
|
||||
|
||||
if (currentTokenInfo.leadingTrivia) {
|
||||
@@ -701,13 +701,13 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
let lineAdded: boolean;
|
||||
let isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
|
||||
const isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
|
||||
|
||||
let tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
|
||||
const tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
|
||||
if (isTokenInRange) {
|
||||
let rangeHasError = rangeContainsError(currentTokenInfo.token);
|
||||
const rangeHasError = rangeContainsError(currentTokenInfo.token);
|
||||
// save previousRange since processRange will overwrite this value with current one
|
||||
let savePreviousRange = previousRange;
|
||||
const savePreviousRange = previousRange;
|
||||
lineAdded = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation);
|
||||
if (rangeHasError) {
|
||||
// do not indent comments\token if token range overlaps with some error
|
||||
@@ -730,15 +730,15 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
if (indentToken) {
|
||||
let tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
|
||||
const tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ?
|
||||
dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container) :
|
||||
Constants.Unknown;
|
||||
|
||||
let indentNextTokenOrTrivia = true;
|
||||
if (currentTokenInfo.leadingTrivia) {
|
||||
let commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container);
|
||||
const commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container);
|
||||
|
||||
for (let triviaItem of currentTokenInfo.leadingTrivia) {
|
||||
for (const triviaItem of currentTokenInfo.leadingTrivia) {
|
||||
const triviaInRange = rangeContainsRange(originalRange, triviaItem);
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
@@ -776,9 +776,9 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function processTrivia(trivia: TextRangeWithKind[], parent: Node, contextNode: Node, dynamicIndentation: DynamicIndentation): void {
|
||||
for (let triviaItem of trivia) {
|
||||
for (const triviaItem of trivia) {
|
||||
if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
|
||||
let triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
|
||||
const triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
|
||||
processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation);
|
||||
}
|
||||
}
|
||||
@@ -790,17 +790,17 @@ namespace ts.formatting {
|
||||
contextNode: Node,
|
||||
dynamicIndentation: DynamicIndentation): boolean {
|
||||
|
||||
let rangeHasError = rangeContainsError(range);
|
||||
const rangeHasError = rangeContainsError(range);
|
||||
let lineAdded: boolean;
|
||||
if (!rangeHasError && !previousRangeHasError) {
|
||||
if (!previousRange) {
|
||||
// trim whitespaces starting from the beginning of the span up to the current line
|
||||
let originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
|
||||
const originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
|
||||
trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line);
|
||||
}
|
||||
else {
|
||||
lineAdded =
|
||||
processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation)
|
||||
processPair(range, rangeStart.line, parent, previousRange, previousRangeStartLine, previousParent, contextNode, dynamicIndentation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,7 +823,7 @@ namespace ts.formatting {
|
||||
|
||||
formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode);
|
||||
|
||||
let rule = rulesProvider.getRulesMap().GetRule(formattingContext);
|
||||
const rule = rulesProvider.getRulesMap().GetRule(formattingContext);
|
||||
|
||||
let trimTrailingWhitespaces: boolean;
|
||||
let lineAdded: boolean;
|
||||
@@ -835,7 +835,7 @@ namespace ts.formatting {
|
||||
// Handle the case where the next line is moved to be the end of this line.
|
||||
// In this case we don't indent the next line in the next pass.
|
||||
if (currentParent.getStart(sourceFile) === currentItem.pos) {
|
||||
dynamicIndentation.recomputeIndentation(/*lineAdded*/ false);
|
||||
dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false);
|
||||
}
|
||||
}
|
||||
else if (rule.Operation.Action & RuleAction.NewLine && currentStartLine === previousStartLine) {
|
||||
@@ -844,7 +844,7 @@ namespace ts.formatting {
|
||||
// In this case we indent token2 in the next pass but we set
|
||||
// sameLineIndent flag to notify the indenter that the indentation is within the line.
|
||||
if (currentParent.getStart(sourceFile) === currentItem.pos) {
|
||||
dynamicIndentation.recomputeIndentation(/*lineAdded*/ true);
|
||||
dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,15 +864,15 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function insertIndentation(pos: number, indentation: number, lineAdded: boolean): void {
|
||||
let indentationString = getIndentationString(indentation, options);
|
||||
const indentationString = getIndentationString(indentation, options);
|
||||
if (lineAdded) {
|
||||
// new line is added before the token by the formatting rules
|
||||
// insert indentation string at the very beginning of the token
|
||||
recordReplace(pos, 0, indentationString);
|
||||
}
|
||||
else {
|
||||
let tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
let startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
const tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
const startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
if (indentation !== tokenStart.character || indentationIsDifferent(indentationString, startLinePosition)) {
|
||||
recordReplace(startLinePosition, tokenStart.character, indentationString);
|
||||
}
|
||||
@@ -886,7 +886,7 @@ namespace ts.formatting {
|
||||
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
|
||||
// split comment in lines
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
|
||||
let endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
|
||||
const endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
|
||||
let parts: TextRange[];
|
||||
if (startLine === endLine) {
|
||||
if (!firstLineIsIndented) {
|
||||
@@ -898,8 +898,8 @@ namespace ts.formatting {
|
||||
else {
|
||||
parts = [];
|
||||
let startPos = commentRange.pos;
|
||||
for (let line = startLine; line < endLine; ++line) {
|
||||
let endOfLine = getEndLinePosition(line, sourceFile);
|
||||
for (let line = startLine; line < endLine; line++) {
|
||||
const endOfLine = getEndLinePosition(line, sourceFile);
|
||||
parts.push({ pos: startPos, end: endOfLine });
|
||||
startPos = getStartPositionOfLine(line + 1, sourceFile);
|
||||
}
|
||||
@@ -907,9 +907,9 @@ namespace ts.formatting {
|
||||
parts.push({ pos: startPos, end: commentRange.end });
|
||||
}
|
||||
|
||||
let startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
const startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
|
||||
let nonWhitespaceColumnInFirstPart =
|
||||
const nonWhitespaceColumnInFirstPart =
|
||||
SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(startLinePos, parts[0].pos, sourceFile, options);
|
||||
|
||||
if (indentation === nonWhitespaceColumnInFirstPart.column) {
|
||||
@@ -923,17 +923,17 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
// shift all parts on the delta size
|
||||
let delta = indentation - nonWhitespaceColumnInFirstPart.column;
|
||||
for (let i = startIndex, len = parts.length; i < len; ++i, ++startLine) {
|
||||
let startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
let nonWhitespaceCharacterAndColumn =
|
||||
const delta = indentation - nonWhitespaceColumnInFirstPart.column;
|
||||
for (let i = startIndex, len = parts.length; i < len; i++, startLine++) {
|
||||
const startLinePos = getStartPositionOfLine(startLine, sourceFile);
|
||||
const nonWhitespaceCharacterAndColumn =
|
||||
i === 0
|
||||
? nonWhitespaceColumnInFirstPart
|
||||
: SmartIndenter.findFirstNonWhitespaceCharacterAndColumn(parts[i].pos, parts[i].end, sourceFile, options);
|
||||
|
||||
let newIndentation = nonWhitespaceCharacterAndColumn.column + delta;
|
||||
const newIndentation = nonWhitespaceCharacterAndColumn.column + delta;
|
||||
if (newIndentation > 0) {
|
||||
let indentationString = getIndentationString(newIndentation, options);
|
||||
const indentationString = getIndentationString(newIndentation, options);
|
||||
recordReplace(startLinePos, nonWhitespaceCharacterAndColumn.character, indentationString);
|
||||
}
|
||||
else {
|
||||
@@ -943,16 +943,16 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function trimTrailingWhitespacesForLines(line1: number, line2: number, range?: TextRangeWithKind) {
|
||||
for (let line = line1; line < line2; ++line) {
|
||||
let lineStartPosition = getStartPositionOfLine(line, sourceFile);
|
||||
let lineEndPosition = getEndLinePosition(line, sourceFile);
|
||||
for (let line = line1; line < line2; line++) {
|
||||
const lineStartPosition = getStartPositionOfLine(line, sourceFile);
|
||||
const lineEndPosition = getEndLinePosition(line, sourceFile);
|
||||
|
||||
// do not trim whitespaces in comments or template expression
|
||||
if (range && (isComment(range.kind) || isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let whitespaceStart = getTrailingWhitespaceStartPosition(lineStartPosition, lineEndPosition);
|
||||
const whitespaceStart = getTrailingWhitespaceStartPosition(lineStartPosition, lineEndPosition);
|
||||
if (whitespaceStart !== -1) {
|
||||
Debug.assert(whitespaceStart === lineStartPosition || !isWhiteSpace(sourceFile.text.charCodeAt(whitespaceStart - 1)));
|
||||
recordDelete(whitespaceStart, lineEndPosition + 1 - whitespaceStart);
|
||||
@@ -979,16 +979,16 @@ namespace ts.formatting {
|
||||
* Trimming will be done for lines after the previous range
|
||||
*/
|
||||
function trimTrailingWhitespacesForRemainingRange() {
|
||||
let startPosition = previousRange ? previousRange.end : originalRange.pos;
|
||||
const startPosition = previousRange ? previousRange.end : originalRange.pos;
|
||||
|
||||
let startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line;
|
||||
let endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line;
|
||||
const startLine = sourceFile.getLineAndCharacterOfPosition(startPosition).line;
|
||||
const endLine = sourceFile.getLineAndCharacterOfPosition(originalRange.end).line;
|
||||
|
||||
trimTrailingWhitespacesForLines(startLine, endLine + 1, previousRange);
|
||||
}
|
||||
|
||||
function newTextChange(start: number, len: number, newText: string): TextChange {
|
||||
return { span: createTextSpan(start, len), newText }
|
||||
return { span: createTextSpan(start, len), newText };
|
||||
}
|
||||
|
||||
function recordDelete(start: number, len: number) {
|
||||
@@ -1009,7 +1009,6 @@ namespace ts.formatting {
|
||||
currentRange: TextRangeWithKind,
|
||||
currentStartLine: number): void {
|
||||
|
||||
let between: TextRange;
|
||||
switch (rule.Operation.Action) {
|
||||
case RuleAction.Ignore:
|
||||
// no action required
|
||||
@@ -1029,7 +1028,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
// edit should not be applied only if we have one line feed between elements
|
||||
let lineDelta = currentStartLine - previousStartLine;
|
||||
const lineDelta = currentStartLine - previousStartLine;
|
||||
if (lineDelta !== 1) {
|
||||
recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.NewLineCharacter);
|
||||
}
|
||||
@@ -1040,7 +1039,7 @@ namespace ts.formatting {
|
||||
return;
|
||||
}
|
||||
|
||||
let posDelta = currentRange.pos - previousRange.end;
|
||||
const posDelta = currentRange.pos - previousRange.end;
|
||||
if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== CharacterCodes.space) {
|
||||
recordReplace(previousRange.end, currentRange.pos - previousRange.end, " ");
|
||||
}
|
||||
@@ -1049,15 +1048,6 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
function isSomeBlock(kind: SyntaxKind): boolean {
|
||||
switch (kind) {
|
||||
case SyntaxKind.Block:
|
||||
case SyntaxKind.ModuleBlock:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function getOpenTokenForList(node: Node, list: Node[]) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
@@ -1102,13 +1092,13 @@ namespace ts.formatting {
|
||||
return SyntaxKind.Unknown;
|
||||
}
|
||||
|
||||
var internedSizes: { tabSize: number; indentSize: number };
|
||||
var internedTabsIndentation: string[];
|
||||
var internedSpacesIndentation: string[];
|
||||
let internedSizes: { tabSize: number; indentSize: number };
|
||||
let internedTabsIndentation: string[];
|
||||
let internedSpacesIndentation: string[];
|
||||
|
||||
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
|
||||
// reset interned strings if FormatCodeOptions were changed
|
||||
let resetInternedStrings =
|
||||
const resetInternedStrings =
|
||||
!internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize);
|
||||
|
||||
if (resetInternedStrings) {
|
||||
@@ -1117,8 +1107,8 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
if (!options.ConvertTabsToSpaces) {
|
||||
let tabs = Math.floor(indentation / options.TabSize);
|
||||
let spaces = indentation - tabs * options.TabSize;
|
||||
const tabs = Math.floor(indentation / options.TabSize);
|
||||
const spaces = indentation - tabs * options.TabSize;
|
||||
|
||||
let tabString: string;
|
||||
if (!internedTabsIndentation) {
|
||||
@@ -1126,7 +1116,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
if (internedTabsIndentation[tabs] === undefined) {
|
||||
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
|
||||
internedTabsIndentation[tabs] = tabString = repeat("\t", tabs);
|
||||
}
|
||||
else {
|
||||
tabString = internedTabsIndentation[tabs];
|
||||
@@ -1136,8 +1126,8 @@ namespace ts.formatting {
|
||||
}
|
||||
else {
|
||||
let spacesString: string;
|
||||
let quotient = Math.floor(indentation / options.IndentSize);
|
||||
let remainder = indentation % options.IndentSize;
|
||||
const quotient = Math.floor(indentation / options.IndentSize);
|
||||
const remainder = indentation % options.IndentSize;
|
||||
if (!internedSpacesIndentation) {
|
||||
internedSpacesIndentation = [];
|
||||
}
|
||||
@@ -1155,7 +1145,7 @@ namespace ts.formatting {
|
||||
|
||||
function repeat(value: string, count: number): string {
|
||||
let s = "";
|
||||
for (let i = 0; i < count; ++i) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
s += value;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,8 @@ namespace ts.formatting {
|
||||
|
||||
public TokensAreOnSameLine(): boolean {
|
||||
if (this.tokensAreOnSameLine === undefined) {
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
const startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
const endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
this.tokensAreOnSameLine = (startLine === endLine);
|
||||
}
|
||||
|
||||
@@ -82,17 +82,17 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
private NodeIsOnOneLine(node: Node): boolean {
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
const startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
const endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
return startLine === endLine;
|
||||
}
|
||||
|
||||
private BlockIsOnOneLine(node: Node): boolean {
|
||||
let openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
|
||||
let closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
|
||||
const openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
|
||||
const closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
|
||||
if (openBrace && closeBrace) {
|
||||
let startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
|
||||
let endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
const startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
|
||||
const endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
return startLine === endLine;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace ts.formatting {
|
||||
scanner.setText(sourceFile.text);
|
||||
scanner.setTextPos(startPos);
|
||||
|
||||
let wasNewLine: boolean = true;
|
||||
let wasNewLine = true;
|
||||
let leadingTrivia: TextRangeWithKind[];
|
||||
let trailingTrivia: TextRangeWithKind[];
|
||||
|
||||
@@ -56,13 +56,13 @@ namespace ts.formatting {
|
||||
scanner.setText(undefined);
|
||||
scanner = undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function advance(): void {
|
||||
Debug.assert(scanner !== undefined);
|
||||
|
||||
lastTokenInfo = undefined;
|
||||
let isStarted = scanner.getStartPos() !== startPos;
|
||||
const isStarted = scanner.getStartPos() !== startPos;
|
||||
|
||||
if (isStarted) {
|
||||
if (trailingTrivia) {
|
||||
@@ -81,23 +81,22 @@ namespace ts.formatting {
|
||||
scanner.scan();
|
||||
}
|
||||
|
||||
let t: SyntaxKind;
|
||||
let pos = scanner.getStartPos();
|
||||
|
||||
// Read leading trivia and token
|
||||
while (pos < endPos) {
|
||||
let t = scanner.getToken();
|
||||
const t = scanner.getToken();
|
||||
if (!isTrivia(t)) {
|
||||
break;
|
||||
}
|
||||
|
||||
// consume leading trivia
|
||||
scanner.scan();
|
||||
let item = {
|
||||
const item = {
|
||||
pos: pos,
|
||||
end: scanner.getStartPos(),
|
||||
kind: t
|
||||
}
|
||||
};
|
||||
|
||||
pos = scanner.getStartPos();
|
||||
|
||||
@@ -166,16 +165,16 @@ namespace ts.formatting {
|
||||
|
||||
// normally scanner returns the smallest available token
|
||||
// check the kind of context node to determine if scanner should have more greedy behavior and consume more text.
|
||||
let expectedScanAction =
|
||||
const expectedScanAction =
|
||||
shouldRescanGreaterThanToken(n)
|
||||
? ScanAction.RescanGreaterThanToken
|
||||
: shouldRescanSlashToken(n)
|
||||
? ScanAction.RescanSlashToken
|
||||
: shouldRescanSlashToken(n)
|
||||
? ScanAction.RescanSlashToken
|
||||
: shouldRescanTemplateToken(n)
|
||||
? ScanAction.RescanTemplateToken
|
||||
: shouldRescanJsxIdentifier(n)
|
||||
? ScanAction.RescanJsxIdentifier
|
||||
: ScanAction.Scan
|
||||
? ScanAction.RescanJsxIdentifier
|
||||
: ScanAction.Scan;
|
||||
|
||||
if (lastTokenInfo && expectedScanAction === lastScanAction) {
|
||||
// readTokenInfo was called before with the same expected scan action.
|
||||
@@ -218,11 +217,11 @@ namespace ts.formatting {
|
||||
lastScanAction = ScanAction.Scan;
|
||||
}
|
||||
|
||||
let token: TextRangeWithKind = {
|
||||
const token: TextRangeWithKind = {
|
||||
pos: scanner.getStartPos(),
|
||||
end: scanner.getTextPos(),
|
||||
kind: currentToken
|
||||
}
|
||||
};
|
||||
|
||||
// consume trailing trivia
|
||||
if (trailingTrivia) {
|
||||
@@ -233,7 +232,7 @@ namespace ts.formatting {
|
||||
if (!isTrivia(currentToken)) {
|
||||
break;
|
||||
}
|
||||
let trivia = {
|
||||
const trivia = {
|
||||
pos: scanner.getStartPos(),
|
||||
end: scanner.getTextPos(),
|
||||
kind: currentToken
|
||||
@@ -256,7 +255,7 @@ namespace ts.formatting {
|
||||
leadingTrivia: leadingTrivia,
|
||||
trailingTrivia: trailingTrivia,
|
||||
token: token
|
||||
}
|
||||
};
|
||||
|
||||
return fixTokenKind(lastTokenInfo, n);
|
||||
}
|
||||
@@ -264,8 +263,8 @@ namespace ts.formatting {
|
||||
function isOnToken(): boolean {
|
||||
Debug.assert(scanner !== undefined);
|
||||
|
||||
let current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken();
|
||||
let 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
/* @internal */
|
||||
namespace ts.formatting {
|
||||
export class RuleOperation {
|
||||
public Context: RuleOperationContext;
|
||||
public Action: RuleAction;
|
||||
|
||||
constructor() {
|
||||
this.Context = null;
|
||||
this.Action = null;
|
||||
}
|
||||
constructor(public Context: RuleOperationContext, public Action: RuleAction) {}
|
||||
|
||||
public toString(): string {
|
||||
return "[context=" + this.Context + "," +
|
||||
@@ -17,14 +11,11 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
static create1(action: RuleAction) {
|
||||
return RuleOperation.create2(RuleOperationContext.Any, action)
|
||||
return RuleOperation.create2(RuleOperationContext.Any, action);
|
||||
}
|
||||
|
||||
static create2(context: RuleOperationContext, action: RuleAction) {
|
||||
let result = new RuleOperation();
|
||||
result.Context = context;
|
||||
result.Action = action;
|
||||
return result;
|
||||
return new RuleOperation(context, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace ts.formatting {
|
||||
|
||||
export class RuleOperationContext {
|
||||
private customContextChecks: { (context: FormattingContext): boolean; }[];
|
||||
|
||||
|
||||
constructor(...funcs: { (context: FormattingContext): boolean; }[]) {
|
||||
this.customContextChecks = funcs;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ namespace ts.formatting {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (let check of this.customContextChecks) {
|
||||
for (const check of this.customContextChecks) {
|
||||
if (!check(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
namespace ts.formatting {
|
||||
export class Rules {
|
||||
public getRuleName(rule: Rule) {
|
||||
let o: ts.Map<any> = <any>this;
|
||||
for (let name in o) {
|
||||
const o: ts.Map<any> = <any>this;
|
||||
for (const name in o) {
|
||||
if (o[name] === rule) {
|
||||
return name;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ namespace ts.formatting {
|
||||
public NoSpaceAfterKeywordInControl: Rule;
|
||||
|
||||
// Open Brace braces after function
|
||||
//TypeScript: Function can have return types, which can be made of tons of different token kinds
|
||||
// TypeScript: Function can have return types, which can be made of tons of different token kinds
|
||||
public FunctionOpenBraceLeftTokenRange: Shared.TokenRange;
|
||||
public SpaceBeforeOpenBraceInFunction: Rule;
|
||||
public NewLineBeforeOpenBraceInFunction: Rule;
|
||||
@@ -313,7 +313,7 @@ namespace ts.formatting {
|
||||
this.SpaceAfterVoidOperator = new Rule(RuleDescriptor.create3(SyntaxKind.VoidKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), RuleAction.Space));
|
||||
|
||||
this.NoSpaceBetweenReturnAndSemicolon = new Rule(RuleDescriptor.create1(SyntaxKind.ReturnKeyword, SyntaxKind.SemicolonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
|
||||
// Add a space between statements. All keywords except (do,else,case) has open/close parens after them.
|
||||
// So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any]
|
||||
this.SpaceBetweenStatements = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.DoKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CaseKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotForContext), RuleAction.Space));
|
||||
@@ -458,7 +458,7 @@ namespace ts.formatting {
|
||||
this.NoSpaceAfterKeywordInControl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Keywords, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext), RuleAction.Delete));
|
||||
|
||||
// Open Brace braces after function
|
||||
//TypeScript: Function can have return types, which can be made of tons of different token kinds
|
||||
// TypeScript: Function can have return types, which can be made of tons of different token kinds
|
||||
this.NewLineBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines);
|
||||
|
||||
// Open Brace braces after TypeScript module/class/interface
|
||||
@@ -616,17 +616,17 @@ namespace ts.formatting {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.MethodSignature:
|
||||
//case SyntaxKind.MemberFunctionDeclaration:
|
||||
// case SyntaxKind.MemberFunctionDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
///case SyntaxKind.MethodSignature:
|
||||
// case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
//case SyntaxKind.ConstructorDeclaration:
|
||||
//case SyntaxKind.SimpleArrowFunctionExpression:
|
||||
//case SyntaxKind.ParenthesizedArrowFunctionExpression:
|
||||
// case SyntaxKind.ConstructorDeclaration:
|
||||
// case SyntaxKind.SimpleArrowFunctionExpression:
|
||||
// case SyntaxKind.ParenthesizedArrowFunctionExpression:
|
||||
case SyntaxKind.InterfaceDeclaration: // This one is not truly a function, but for formatting purposes, it acts just like one
|
||||
return true;
|
||||
}
|
||||
@@ -724,7 +724,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
static IsNotBeforeBlockInFunctionDeclarationContext(context: FormattingContext): boolean {
|
||||
return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context)
|
||||
return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context);
|
||||
}
|
||||
|
||||
static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean {
|
||||
@@ -755,7 +755,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
static IsObjectTypeContext(context: FormattingContext): boolean {
|
||||
return context.contextNode.kind === SyntaxKind.TypeLiteral;// && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
|
||||
return context.contextNode.kind === SyntaxKind.TypeLiteral; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration;
|
||||
}
|
||||
|
||||
static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean {
|
||||
|
||||
@@ -12,17 +12,17 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
static create(rules: Rule[]): RulesMap {
|
||||
let result = new RulesMap();
|
||||
const result = new RulesMap();
|
||||
result.Initialize(rules);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Initialize(rules: Rule[]) {
|
||||
this.mapRowLength = SyntaxKind.LastToken + 1;
|
||||
this.map = <any> new Array(this.mapRowLength * this.mapRowLength);//new Array<RulesBucket>(this.mapRowLength * this.mapRowLength);
|
||||
this.map = <any> new Array(this.mapRowLength * this.mapRowLength); // new Array<RulesBucket>(this.mapRowLength * this.mapRowLength);
|
||||
|
||||
// This array is used only during construction of the rulesbucket in the map
|
||||
let rulesBucketConstructionStateList: RulesBucketConstructionState[] = <any> new Array(this.map.length);//new Array<RulesBucketConstructionState>(this.map.length);
|
||||
const rulesBucketConstructionStateList: RulesBucketConstructionState[] = <any>new Array(this.map.length); // new Array<RulesBucketConstructionState>(this.map.length);
|
||||
|
||||
this.FillRules(rules, rulesBucketConstructionStateList);
|
||||
return this.map;
|
||||
@@ -35,18 +35,18 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
private GetRuleBucketIndex(row: number, column: number): number {
|
||||
let rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
//Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array.");
|
||||
const rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
// Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array.");
|
||||
return rulesBucketIndex;
|
||||
}
|
||||
|
||||
private FillRule(rule: Rule, rulesBucketConstructionStateList: RulesBucketConstructionState[]): void {
|
||||
let specificRule = rule.Descriptor.LeftTokenRange !== Shared.TokenRange.Any &&
|
||||
const specificRule = rule.Descriptor.LeftTokenRange !== Shared.TokenRange.Any &&
|
||||
rule.Descriptor.RightTokenRange !== Shared.TokenRange.Any;
|
||||
|
||||
rule.Descriptor.LeftTokenRange.GetTokens().forEach((left) => {
|
||||
rule.Descriptor.RightTokenRange.GetTokens().forEach((right) => {
|
||||
let rulesBucketIndex = this.GetRuleBucketIndex(left, right);
|
||||
const rulesBucketIndex = this.GetRuleBucketIndex(left, right);
|
||||
|
||||
let rulesBucket = this.map[rulesBucketIndex];
|
||||
if (rulesBucket === undefined) {
|
||||
@@ -54,26 +54,26 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
rulesBucket.AddRule(rule, specificRule, rulesBucketConstructionStateList, rulesBucketIndex);
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public GetRule(context: FormattingContext): Rule {
|
||||
let bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
|
||||
let bucket = this.map[bucketIndex];
|
||||
if (bucket != null) {
|
||||
for (let rule of bucket.Rules()) {
|
||||
const bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
|
||||
const bucket = this.map[bucketIndex];
|
||||
if (bucket) {
|
||||
for (const rule of bucket.Rules()) {
|
||||
if (rule.Operation.Context.InContext(context)) {
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
let MaskBitSize = 5;
|
||||
let Mask = 0x1f;
|
||||
const MaskBitSize = 5;
|
||||
const Mask = 0x1f;
|
||||
|
||||
export enum RulesPosition {
|
||||
IgnoreRulesSpecific = 0,
|
||||
@@ -167,7 +167,7 @@ namespace ts.formatting {
|
||||
if (state === undefined) {
|
||||
state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState();
|
||||
}
|
||||
let index = state.GetInsertionIndex(position);
|
||||
const index = state.GetInsertionIndex(position);
|
||||
this.rules.splice(index, 0, rule);
|
||||
state.IncreaseInsertionIndex(position);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,9 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
public ensureUpToDate(options: ts.FormatCodeOptions) {
|
||||
// TODO: Should this be '==='?
|
||||
if (this.options == null || !ts.compareDataObjects(this.options, options)) {
|
||||
let activeRules = this.createActiveRules(options);
|
||||
let rulesMap = RulesMap.create(activeRules);
|
||||
if (!this.options || !ts.compareDataObjects(this.options, options)) {
|
||||
const activeRules = this.createActiveRules(options);
|
||||
const rulesMap = RulesMap.create(activeRules);
|
||||
|
||||
this.activeRules = activeRules;
|
||||
this.rulesMap = rulesMap;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts.formatting {
|
||||
export module SmartIndenter {
|
||||
export namespace SmartIndenter {
|
||||
|
||||
const enum Value {
|
||||
Unknown = -1
|
||||
@@ -19,18 +19,18 @@ namespace ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let precedingToken = findPrecedingToken(position, sourceFile);
|
||||
const precedingToken = findPrecedingToken(position, sourceFile);
|
||||
if (!precedingToken) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// no indentation in string \regex\template literals
|
||||
let precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind);
|
||||
const precedingTokenIsLiteral = isStringOrRegularExpressionOrTemplateLiteral(precedingToken.kind);
|
||||
if (precedingTokenIsLiteral && precedingToken.getStart(sourceFile) <= position && precedingToken.end > position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
|
||||
// indentation is first non-whitespace character in a previous line
|
||||
// for block indentation, we should look for a line which contains something that's not
|
||||
@@ -40,21 +40,21 @@ namespace ts.formatting {
|
||||
// move backwards until we find a line with a non-whitespace character,
|
||||
// then find the first non-whitespace character for that line.
|
||||
let current = position;
|
||||
while (current > 0){
|
||||
let char = sourceFile.text.charCodeAt(current);
|
||||
while (current > 0) {
|
||||
const char = sourceFile.text.charCodeAt(current);
|
||||
if (!isWhiteSpace(char) && !isLineBreak(char)) {
|
||||
break;
|
||||
}
|
||||
current--;
|
||||
}
|
||||
|
||||
let lineStart = ts.getLineStartPositionForPosition(current, sourceFile);
|
||||
const lineStart = ts.getLineStartPositionForPosition(current, sourceFile);
|
||||
return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options);
|
||||
}
|
||||
|
||||
if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
|
||||
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||
let actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
|
||||
const actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number {
|
||||
let start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
const start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
|
||||
}
|
||||
|
||||
@@ -124,19 +124,19 @@ namespace ts.formatting {
|
||||
while (parent) {
|
||||
let useActualIndentation = true;
|
||||
if (ignoreActualIndentationRange) {
|
||||
let start = current.getStart(sourceFile);
|
||||
const start = current.getStart(sourceFile);
|
||||
useActualIndentation = start < ignoreActualIndentationRange.pos || start > ignoreActualIndentationRange.end;
|
||||
}
|
||||
|
||||
if (useActualIndentation) {
|
||||
// check if current node is a list item - if yes, take indentation from it
|
||||
let actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||
const actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + indentationDelta;
|
||||
}
|
||||
}
|
||||
parentStart = getParentStart(parent, current, sourceFile);
|
||||
let parentAndChildShareLine =
|
||||
const parentAndChildShareLine =
|
||||
parentStart.line === currentStart.line ||
|
||||
childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile);
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace ts.formatting {
|
||||
|
||||
|
||||
function getParentStart(parent: Node, child: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
let containingList = getContainingList(child, sourceFile);
|
||||
const containingList = getContainingList(child, sourceFile);
|
||||
if (containingList) {
|
||||
return sourceFile.getLineAndCharacterOfPosition(containingList.pos);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace ts.formatting {
|
||||
*/
|
||||
function getActualIndentationForListItemBeforeComma(commaToken: Node, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||
let commaItemInfo = findListItemInfo(commaToken);
|
||||
const commaItemInfo = findListItemInfo(commaToken);
|
||||
if (commaItemInfo && commaItemInfo.listItemIndex > 0) {
|
||||
return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options);
|
||||
}
|
||||
@@ -203,7 +203,7 @@ namespace ts.formatting {
|
||||
// actual indentation is used for statements\declarations if one of cases below is true:
|
||||
// - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
|
||||
// - parent and child are not on the same line
|
||||
let useActualIndentation =
|
||||
const useActualIndentation =
|
||||
(isDeclaration(current) || isStatement(current)) &&
|
||||
(parent.kind === SyntaxKind.SourceFile || !parentAndChildShareLine);
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): boolean {
|
||||
let nextToken = findNextToken(precedingToken, current);
|
||||
const nextToken = findNextToken(precedingToken, current);
|
||||
if (!nextToken) {
|
||||
return false;
|
||||
}
|
||||
@@ -234,7 +234,7 @@ namespace ts.formatting {
|
||||
// class A {
|
||||
// $}
|
||||
|
||||
let nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line;
|
||||
const nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line;
|
||||
return lineAtPosition === nextTokenStartLine;
|
||||
}
|
||||
|
||||
@@ -247,10 +247,10 @@ namespace ts.formatting {
|
||||
|
||||
export function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFile): boolean {
|
||||
if (parent.kind === SyntaxKind.IfStatement && (<IfStatement>parent).elseStatement === child) {
|
||||
let elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile);
|
||||
const elseKeyword = findChildOfKind(parent, SyntaxKind.ElseKeyword, sourceFile);
|
||||
Debug.assert(elseKeyword !== undefined);
|
||||
|
||||
let elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
|
||||
const elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
|
||||
return elseKeywordStartLine === childStartLine;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace ts.formatting {
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature: {
|
||||
let start = node.getStart(sourceFile);
|
||||
const start = node.getStart(sourceFile);
|
||||
if ((<SignatureDeclaration>node.parent).typeParameters &&
|
||||
rangeContainsStartEnd((<SignatureDeclaration>node.parent).typeParameters, start, node.getEnd())) {
|
||||
return (<SignatureDeclaration>node.parent).typeParameters;
|
||||
@@ -289,7 +289,7 @@ namespace ts.formatting {
|
||||
}
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.CallExpression: {
|
||||
let start = node.getStart(sourceFile);
|
||||
const start = node.getStart(sourceFile);
|
||||
if ((<CallExpression>node.parent).typeArguments &&
|
||||
rangeContainsStartEnd((<CallExpression>node.parent).typeArguments, start, node.getEnd())) {
|
||||
return (<CallExpression>node.parent).typeArguments;
|
||||
@@ -306,11 +306,11 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function getActualIndentationForListItem(node: Node, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
let containingList = getContainingList(node, sourceFile);
|
||||
const containingList = getContainingList(node, sourceFile);
|
||||
return containingList ? getActualIndentationFromList(containingList) : Value.Unknown;
|
||||
|
||||
function getActualIndentationFromList(list: Node[]): number {
|
||||
let index = indexOf(list, node);
|
||||
const index = indexOf(list, node);
|
||||
return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : Value.Unknown;
|
||||
}
|
||||
}
|
||||
@@ -327,15 +327,15 @@ namespace ts.formatting {
|
||||
node.parent.kind === SyntaxKind.NewExpression) &&
|
||||
(<CallExpression>node.parent).expression !== node) {
|
||||
|
||||
let fullCallOrNewExpression = (<CallExpression | NewExpression>node.parent).expression;
|
||||
let startingExpression = getStartingExpression(<PropertyAccessExpression | CallExpression | ElementAccessExpression>fullCallOrNewExpression);
|
||||
const fullCallOrNewExpression = (<CallExpression | NewExpression>node.parent).expression;
|
||||
const startingExpression = getStartingExpression(<PropertyAccessExpression | CallExpression | ElementAccessExpression>fullCallOrNewExpression);
|
||||
|
||||
if (fullCallOrNewExpression === startingExpression) {
|
||||
return Value.Unknown;
|
||||
}
|
||||
|
||||
let fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end);
|
||||
let startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end);
|
||||
const fullCallOrNewExpressionEnd = sourceFile.getLineAndCharacterOfPosition(fullCallOrNewExpression.end);
|
||||
const startingExpressionEnd = sourceFile.getLineAndCharacterOfPosition(startingExpression.end);
|
||||
|
||||
if (fullCallOrNewExpressionEnd.line === startingExpressionEnd.line) {
|
||||
return Value.Unknown;
|
||||
@@ -365,17 +365,17 @@ namespace ts.formatting {
|
||||
|
||||
function deriveActualIndentationFromList(list: Node[], index: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
Debug.assert(index >= 0 && index < list.length);
|
||||
let node = list[index];
|
||||
const node = list[index];
|
||||
|
||||
// walk toward the start of the list starting from current node and check if the line is the same for all items.
|
||||
// if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i]
|
||||
let lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
|
||||
for (let i = index - 1; i >= 0; --i) {
|
||||
for (let i = index - 1; i >= 0; i--) {
|
||||
if (list[i].kind === SyntaxKind.CommaToken) {
|
||||
continue;
|
||||
}
|
||||
// skip list items that ends on the same line with the current list element
|
||||
let prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
|
||||
const prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
|
||||
if (prevEndLine !== lineAndCharacter.line) {
|
||||
return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options);
|
||||
}
|
||||
@@ -386,7 +386,7 @@ namespace ts.formatting {
|
||||
}
|
||||
|
||||
function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter: LineAndCharacter, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
let lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
|
||||
const lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
|
||||
return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options);
|
||||
}
|
||||
|
||||
@@ -400,8 +400,8 @@ namespace ts.formatting {
|
||||
export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions) {
|
||||
let character = 0;
|
||||
let column = 0;
|
||||
for (let pos = startPos; pos < endPos; ++pos) {
|
||||
let ch = sourceFile.text.charCodeAt(pos);
|
||||
for (let pos = startPos; pos < endPos; pos++) {
|
||||
const ch = sourceFile.text.charCodeAt(pos);
|
||||
if (!isWhiteSpace(ch)) {
|
||||
break;
|
||||
}
|
||||
@@ -467,10 +467,10 @@ namespace ts.formatting {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* @internal */
|
||||
export function nodeWillIndentChild(parent: TextRangeWithKind, child: TextRangeWithKind, indentByDefault: boolean) {
|
||||
let childKind = child ? child.kind : SyntaxKind.Unknown;
|
||||
const childKind = child ? child.kind : SyntaxKind.Unknown;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.DoStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
@@ -497,7 +497,7 @@ namespace ts.formatting {
|
||||
Function returns true when the parent node should indent the given child by an explicit rule
|
||||
*/
|
||||
export function shouldIndentChildNode(parent: TextRangeWithKind, child?: TextRangeWithKind): boolean {
|
||||
return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, false);
|
||||
return nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(parent, child, /*indentByDefault*/ false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/* @internal */
|
||||
namespace ts.formatting {
|
||||
export module Shared {
|
||||
export namespace Shared {
|
||||
export interface ITokenAccess {
|
||||
GetTokens(): SyntaxKind[];
|
||||
Contains(token: SyntaxKind): boolean;
|
||||
@@ -60,7 +60,7 @@ namespace ts.formatting {
|
||||
|
||||
export class TokenAllAccess implements ITokenAccess {
|
||||
public GetTokens(): SyntaxKind[] {
|
||||
let result: SyntaxKind[] = [];
|
||||
const result: SyntaxKind[] = [];
|
||||
for (let token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) {
|
||||
result.push(token);
|
||||
}
|
||||
|
||||
@@ -323,6 +323,10 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return createItem(node, getModuleName(<ModuleDeclaration>node), ts.ScriptElementKind.moduleElement);
|
||||
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return createItem(node, getTextOfNode((<InterfaceDeclaration>node).name), ts.ScriptElementKind.interfaceElement);
|
||||
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
return createItem(node, "()", ts.ScriptElementKind.callSignatureElement);
|
||||
|
||||
@@ -333,6 +337,9 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.PropertySignature:
|
||||
return createItem(node, getTextOfNode((<PropertyDeclaration>node).name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
return createItem(node, getTextOfNode((<ClassDeclaration>node).name), ts.ScriptElementKind.classElement);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return createItem(node, getTextOfNode((<FunctionLikeDeclaration>node).name), ts.ScriptElementKind.functionElement);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ts.SignatureHelp {
|
||||
// To do this, the method will back parse the expression starting at the position required. it will try to parse the current expression as a generic type expression, if it did succeed it
|
||||
// will return the generic identifier that started the expression (e.g. "foo" in "foo<any, |"). It is then up to the caller to ensure that this is a valid generic expression through
|
||||
// looking up the type. The method will also keep track of the parameter index inside the expression.
|
||||
//public static isInPartiallyWrittenTypeArgumentList(syntaxTree: TypeScript.SyntaxTree, position: number): any {
|
||||
// public static isInPartiallyWrittenTypeArgumentList(syntaxTree: TypeScript.SyntaxTree, position: number): any {
|
||||
// let token = Syntax.findTokenOnLeft(syntaxTree.sourceUnit(), position, /*includeSkippedTokens*/ true);
|
||||
|
||||
// if (token && TypeScript.Syntax.hasAncestorOfKind(token, TypeScript.SyntaxKind.TypeParameterList)) {
|
||||
@@ -125,9 +125,9 @@ namespace ts.SignatureHelp {
|
||||
// }
|
||||
|
||||
// return null;
|
||||
//}
|
||||
// }
|
||||
|
||||
//private static moveBackUpTillMatchingTokenKind(token: TypeScript.ISyntaxToken, tokenKind: TypeScript.SyntaxKind, matchingTokenKind: TypeScript.SyntaxKind): TypeScript.ISyntaxToken {
|
||||
// private static moveBackUpTillMatchingTokenKind(token: TypeScript.ISyntaxToken, tokenKind: TypeScript.SyntaxKind, matchingTokenKind: TypeScript.SyntaxKind): TypeScript.ISyntaxToken {
|
||||
// if (!token || token.kind() !== tokenKind) {
|
||||
// throw TypeScript.Errors.invalidOperation();
|
||||
// }
|
||||
@@ -161,8 +161,8 @@ namespace ts.SignatureHelp {
|
||||
|
||||
// // Did not find matching token
|
||||
// return null;
|
||||
//}
|
||||
let emptyArray: any[] = [];
|
||||
// }
|
||||
const emptyArray: any[] = [];
|
||||
|
||||
const enum ArgumentListKind {
|
||||
TypeArguments,
|
||||
@@ -179,16 +179,16 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
|
||||
export function getSignatureHelpItems(program: Program, sourceFile: SourceFile, position: number, cancellationToken: CancellationToken): SignatureHelpItems {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
const typeChecker = program.getTypeChecker();
|
||||
|
||||
// Decide whether to show signature help
|
||||
let startingToken = findTokenOnLeftOfPosition(sourceFile, position);
|
||||
const startingToken = findTokenOnLeftOfPosition(sourceFile, position);
|
||||
if (!startingToken) {
|
||||
// We are at the beginning of the file
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let argumentInfo = getContainingArgumentInfo(startingToken);
|
||||
const argumentInfo = getContainingArgumentInfo(startingToken);
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
// Semantic filtering of signature help
|
||||
@@ -196,9 +196,9 @@ namespace ts.SignatureHelp {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let call = argumentInfo.invocation;
|
||||
let candidates = <Signature[]>[];
|
||||
let resolvedSignature = typeChecker.getResolvedSignature(call, candidates);
|
||||
const call = argumentInfo.invocation;
|
||||
const candidates = <Signature[]>[];
|
||||
const resolvedSignature = typeChecker.getResolvedSignature(call, candidates);
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
if (!candidates.length) {
|
||||
@@ -219,9 +219,9 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
|
||||
// See if we can find some symbol with the call expression name that has call signatures.
|
||||
let callExpression = <CallExpression>argumentInfo.invocation;
|
||||
let expression = callExpression.expression;
|
||||
let name = expression.kind === SyntaxKind.Identifier
|
||||
const callExpression = <CallExpression>argumentInfo.invocation;
|
||||
const expression = callExpression.expression;
|
||||
const name = expression.kind === SyntaxKind.Identifier
|
||||
? <Identifier> expression
|
||||
: expression.kind === SyntaxKind.PropertyAccessExpression
|
||||
? (<PropertyAccessExpression>expression).name
|
||||
@@ -231,18 +231,18 @@ namespace ts.SignatureHelp {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let typeChecker = program.getTypeChecker();
|
||||
for (let sourceFile of program.getSourceFiles()) {
|
||||
let nameToDeclarations = sourceFile.getNamedDeclarations();
|
||||
let declarations = getProperty(nameToDeclarations, name.text);
|
||||
const typeChecker = program.getTypeChecker();
|
||||
for (const sourceFile of program.getSourceFiles()) {
|
||||
const nameToDeclarations = sourceFile.getNamedDeclarations();
|
||||
const declarations = getProperty(nameToDeclarations, name.text);
|
||||
|
||||
if (declarations) {
|
||||
for (let declaration of declarations) {
|
||||
let symbol = declaration.symbol;
|
||||
for (const declaration of declarations) {
|
||||
const symbol = declaration.symbol;
|
||||
if (symbol) {
|
||||
let type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
|
||||
const type = typeChecker.getTypeOfSymbolAtLocation(symbol, declaration);
|
||||
if (type) {
|
||||
let callSignatures = type.getCallSignatures();
|
||||
const callSignatures = type.getCallSignatures();
|
||||
if (callSignatures && callSignatures.length) {
|
||||
return createSignatureHelpItems(callSignatures, callSignatures[0], argumentInfo);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ namespace ts.SignatureHelp {
|
||||
*/
|
||||
function getImmediatelyContainingArgumentInfo(node: Node): ArgumentListInfo {
|
||||
if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) {
|
||||
let callExpression = <CallExpression>node.parent;
|
||||
const callExpression = <CallExpression>node.parent;
|
||||
// There are 3 cases to handle:
|
||||
// 1. The token introduces a list, and should begin a sig help session
|
||||
// 2. The token is either not associated with a list, or ends a list, so the session should end
|
||||
@@ -278,8 +278,8 @@ namespace ts.SignatureHelp {
|
||||
node.kind === SyntaxKind.OpenParenToken) {
|
||||
// Find the list that starts right *after* the < or ( token.
|
||||
// If the user has just opened a list, consider this item 0.
|
||||
let list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile);
|
||||
let isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
|
||||
const list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile);
|
||||
const isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
|
||||
Debug.assert(list !== undefined);
|
||||
return {
|
||||
kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments,
|
||||
@@ -296,16 +296,16 @@ namespace ts.SignatureHelp {
|
||||
// - Between the type arguments and the arguments (greater than token)
|
||||
// - On the target of the call (parent.func)
|
||||
// - On the 'new' keyword in a 'new' expression
|
||||
let listItemInfo = findListItemInfo(node);
|
||||
const listItemInfo = findListItemInfo(node);
|
||||
if (listItemInfo) {
|
||||
let list = listItemInfo.list;
|
||||
let isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
|
||||
const list = listItemInfo.list;
|
||||
const isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos;
|
||||
|
||||
let argumentIndex = getArgumentIndex(list, node);
|
||||
let argumentCount = getArgumentCount(list);
|
||||
const argumentIndex = getArgumentIndex(list, node);
|
||||
const argumentCount = getArgumentCount(list);
|
||||
|
||||
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount,
|
||||
`argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
|
||||
`argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
|
||||
|
||||
return {
|
||||
kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments,
|
||||
@@ -324,18 +324,18 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
}
|
||||
else if (node.kind === SyntaxKind.TemplateHead && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
let templateExpression = <TemplateExpression>node.parent;
|
||||
let tagExpression = <TaggedTemplateExpression>templateExpression.parent;
|
||||
const templateExpression = <TemplateExpression>node.parent;
|
||||
const tagExpression = <TaggedTemplateExpression>templateExpression.parent;
|
||||
Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression);
|
||||
|
||||
let argumentIndex = isInsideTemplateLiteral(<LiteralExpression>node, position) ? 0 : 1;
|
||||
const argumentIndex = isInsideTemplateLiteral(<LiteralExpression>node, position) ? 0 : 1;
|
||||
|
||||
return getArgumentListInfoForTemplate(tagExpression, argumentIndex);
|
||||
}
|
||||
else if (node.parent.kind === SyntaxKind.TemplateSpan && node.parent.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
let templateSpan = <TemplateSpan>node.parent;
|
||||
let templateExpression = <TemplateExpression>templateSpan.parent;
|
||||
let tagExpression = <TaggedTemplateExpression>templateExpression.parent;
|
||||
const templateSpan = <TemplateSpan>node.parent;
|
||||
const templateExpression = <TemplateExpression>templateSpan.parent;
|
||||
const tagExpression = <TaggedTemplateExpression>templateExpression.parent;
|
||||
Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression);
|
||||
|
||||
// If we're just after a template tail, don't show signature help.
|
||||
@@ -343,12 +343,12 @@ namespace ts.SignatureHelp {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let spanIndex = templateExpression.templateSpans.indexOf(templateSpan);
|
||||
let argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node);
|
||||
const spanIndex = templateExpression.templateSpans.indexOf(templateSpan);
|
||||
const argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node);
|
||||
|
||||
return getArgumentListInfoForTemplate(tagExpression, argumentIndex);
|
||||
}
|
||||
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -365,8 +365,8 @@ namespace ts.SignatureHelp {
|
||||
// that trailing comma in the list, and we'll have generated the appropriate
|
||||
// arg index.
|
||||
let argumentIndex = 0;
|
||||
let listChildren = argumentsList.getChildren();
|
||||
for (let child of listChildren) {
|
||||
const listChildren = argumentsList.getChildren();
|
||||
for (const child of listChildren) {
|
||||
if (child === node) {
|
||||
break;
|
||||
}
|
||||
@@ -390,7 +390,7 @@ namespace ts.SignatureHelp {
|
||||
// we'll have: 'a' '<comma>' '<missing>'
|
||||
// That will give us 2 non-commas. We then add one for the last comma, givin us an
|
||||
// arg count of 3.
|
||||
let listChildren = argumentsList.getChildren();
|
||||
const listChildren = argumentsList.getChildren();
|
||||
|
||||
let argumentCount = countWhere(listChildren, arg => arg.kind !== SyntaxKind.CommaToken);
|
||||
if (listChildren.length > 0 && lastOrUndefined(listChildren).kind === SyntaxKind.CommaToken) {
|
||||
@@ -426,11 +426,11 @@ namespace ts.SignatureHelp {
|
||||
|
||||
function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, argumentIndex: number): ArgumentListInfo {
|
||||
// argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument.
|
||||
let argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral
|
||||
const argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral
|
||||
? 1
|
||||
: (<TemplateExpression>tagExpression.template).templateSpans.length + 1;
|
||||
|
||||
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
|
||||
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
|
||||
|
||||
return {
|
||||
kind: ArgumentListKind.TaggedTemplateArguments,
|
||||
@@ -450,14 +450,14 @@ namespace ts.SignatureHelp {
|
||||
//
|
||||
// The applicable span is from the first bar to the second bar (inclusive,
|
||||
// but not including parentheses)
|
||||
let applicableSpanStart = argumentsList.getFullStart();
|
||||
let applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false);
|
||||
const applicableSpanStart = argumentsList.getFullStart();
|
||||
const applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.getEnd(), /*stopAfterLineBreak*/ false);
|
||||
return createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
|
||||
}
|
||||
|
||||
function getApplicableSpanForTaggedTemplate(taggedTemplate: TaggedTemplateExpression): TextSpan {
|
||||
let template = taggedTemplate.template;
|
||||
let applicableSpanStart = template.getStart();
|
||||
const template = taggedTemplate.template;
|
||||
const applicableSpanStart = template.getStart();
|
||||
let applicableSpanEnd = template.getEnd();
|
||||
|
||||
// We need to adjust the end position for the case where the template does not have a tail.
|
||||
@@ -470,7 +470,7 @@ namespace ts.SignatureHelp {
|
||||
// This is because a Missing node has no width. However, what we actually want is to include trivia
|
||||
// leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail.
|
||||
if (template.kind === SyntaxKind.TemplateExpression) {
|
||||
let lastSpan = lastOrUndefined((<TemplateExpression>template).templateSpans);
|
||||
const lastSpan = lastOrUndefined((<TemplateExpression>template).templateSpans);
|
||||
if (lastSpan.literal.getFullWidth() === 0) {
|
||||
applicableSpanEnd = skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false);
|
||||
}
|
||||
@@ -491,7 +491,7 @@ namespace ts.SignatureHelp {
|
||||
Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind);
|
||||
}
|
||||
|
||||
let argumentInfo = getImmediatelyContainingArgumentInfo(n);
|
||||
const argumentInfo = getImmediatelyContainingArgumentInfo(n);
|
||||
if (argumentInfo) {
|
||||
return argumentInfo;
|
||||
}
|
||||
@@ -503,8 +503,8 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
|
||||
function getChildListThatStartsWithOpenerToken(parent: Node, openerToken: Node, sourceFile: SourceFile): Node {
|
||||
let children = parent.getChildren(sourceFile);
|
||||
let indexOfOpenerToken = children.indexOf(openerToken);
|
||||
const children = parent.getChildren(sourceFile);
|
||||
const indexOfOpenerToken = children.indexOf(openerToken);
|
||||
Debug.assert(indexOfOpenerToken >= 0 && children.length > indexOfOpenerToken + 1);
|
||||
return children[indexOfOpenerToken + 1];
|
||||
}
|
||||
@@ -521,7 +521,7 @@ namespace ts.SignatureHelp {
|
||||
let maxParamsSignatureIndex = -1;
|
||||
let maxParams = -1;
|
||||
for (let i = 0; i < candidates.length; i++) {
|
||||
let candidate = candidates[i];
|
||||
const candidate = candidates[i];
|
||||
|
||||
if (candidate.hasRestParameter || candidate.parameters.length >= argumentCount) {
|
||||
return i;
|
||||
@@ -537,17 +537,17 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
|
||||
function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentListInfo: ArgumentListInfo): SignatureHelpItems {
|
||||
let applicableSpan = argumentListInfo.argumentsSpan;
|
||||
let isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments;
|
||||
const applicableSpan = argumentListInfo.argumentsSpan;
|
||||
const isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments;
|
||||
|
||||
let invocation = argumentListInfo.invocation;
|
||||
let callTarget = getInvokedExpression(invocation)
|
||||
let callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget);
|
||||
let callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
|
||||
let items: SignatureHelpItem[] = map(candidates, candidateSignature => {
|
||||
const invocation = argumentListInfo.invocation;
|
||||
const callTarget = getInvokedExpression(invocation);
|
||||
const callTargetSymbol = typeChecker.getSymbolAtLocation(callTarget);
|
||||
const callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeChecker, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
|
||||
const items: SignatureHelpItem[] = map(candidates, candidateSignature => {
|
||||
let signatureHelpParameters: SignatureHelpParameter[];
|
||||
let prefixDisplayParts: SymbolDisplayPart[] = [];
|
||||
let suffixDisplayParts: SymbolDisplayPart[] = [];
|
||||
const prefixDisplayParts: SymbolDisplayPart[] = [];
|
||||
const suffixDisplayParts: SymbolDisplayPart[] = [];
|
||||
|
||||
if (callTargetDisplayParts) {
|
||||
addRange(prefixDisplayParts, callTargetDisplayParts);
|
||||
@@ -555,28 +555,28 @@ namespace ts.SignatureHelp {
|
||||
|
||||
if (isTypeParameterList) {
|
||||
prefixDisplayParts.push(punctuationPart(SyntaxKind.LessThanToken));
|
||||
let typeParameters = candidateSignature.typeParameters;
|
||||
const typeParameters = candidateSignature.typeParameters;
|
||||
signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray;
|
||||
suffixDisplayParts.push(punctuationPart(SyntaxKind.GreaterThanToken));
|
||||
let parameterParts = mapToDisplayParts(writer =>
|
||||
const parameterParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisType, candidateSignature.parameters, writer, invocation));
|
||||
addRange(suffixDisplayParts, parameterParts);
|
||||
}
|
||||
else {
|
||||
let typeParameterParts = mapToDisplayParts(writer =>
|
||||
const typeParameterParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation));
|
||||
addRange(prefixDisplayParts, typeParameterParts);
|
||||
prefixDisplayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
|
||||
let parameters = candidateSignature.parameters;
|
||||
const parameters = candidateSignature.parameters;
|
||||
signatureHelpParameters = parameters.length > 0 ? map(parameters, createSignatureHelpParameterForParameter) : emptyArray;
|
||||
suffixDisplayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
|
||||
}
|
||||
|
||||
let returnTypeParts = mapToDisplayParts(writer =>
|
||||
const returnTypeParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation));
|
||||
addRange(suffixDisplayParts, returnTypeParts);
|
||||
|
||||
|
||||
return {
|
||||
isVariadic: candidateSignature.hasRestParameter,
|
||||
prefixDisplayParts,
|
||||
@@ -587,17 +587,17 @@ namespace ts.SignatureHelp {
|
||||
};
|
||||
});
|
||||
|
||||
let argumentIndex = argumentListInfo.argumentIndex;
|
||||
const argumentIndex = argumentListInfo.argumentIndex;
|
||||
|
||||
// argumentCount is the *apparent* number of arguments.
|
||||
let argumentCount = argumentListInfo.argumentCount;
|
||||
const argumentCount = argumentListInfo.argumentCount;
|
||||
|
||||
let selectedItemIndex = candidates.indexOf(bestSignature);
|
||||
if (selectedItemIndex < 0) {
|
||||
selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount);
|
||||
}
|
||||
|
||||
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
|
||||
Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, `argumentCount < argumentIndex, ${argumentCount} < ${argumentIndex}`);
|
||||
|
||||
return {
|
||||
items,
|
||||
@@ -608,7 +608,7 @@ namespace ts.SignatureHelp {
|
||||
};
|
||||
|
||||
function createSignatureHelpParameterForParameter(parameter: Symbol): SignatureHelpParameter {
|
||||
let displayParts = mapToDisplayParts(writer =>
|
||||
const displayParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation));
|
||||
|
||||
return {
|
||||
@@ -620,7 +620,7 @@ namespace ts.SignatureHelp {
|
||||
}
|
||||
|
||||
function createSignatureHelpParameterForTypeParameter(typeParameter: TypeParameter): SignatureHelpParameter {
|
||||
let displayParts = mapToDisplayParts(writer =>
|
||||
const displayParts = mapToDisplayParts(writer =>
|
||||
typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation));
|
||||
|
||||
return {
|
||||
|
||||
+46
-46
@@ -7,8 +7,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number {
|
||||
let lineStarts = sourceFile.getLineStarts();
|
||||
let line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
const lineStarts = sourceFile.getLineStarts();
|
||||
const line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
return lineStarts[line];
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function startEndOverlapsWithStartEnd(start1: number, end1: number, start2: number, end2: number) {
|
||||
let start = Math.max(start1, start2);
|
||||
let end = Math.min(end1, end2);
|
||||
const start = Math.max(start1, start2);
|
||||
const end = Math.min(end1, end2);
|
||||
return start < end;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace ts {
|
||||
return isCompletedNode((<IterationStatement>n).statement, sourceFile);
|
||||
case SyntaxKind.DoStatement:
|
||||
// rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')';
|
||||
let hasWhileKeyword = findChildOfKind(n, SyntaxKind.WhileKeyword, sourceFile);
|
||||
const hasWhileKeyword = findChildOfKind(n, SyntaxKind.WhileKeyword, sourceFile);
|
||||
if (hasWhileKeyword) {
|
||||
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
|
||||
}
|
||||
@@ -145,13 +145,13 @@ namespace ts {
|
||||
case SyntaxKind.VoidExpression:
|
||||
case SyntaxKind.YieldExpression:
|
||||
case SyntaxKind.SpreadElementExpression:
|
||||
let unaryWordExpression = (<TypeOfExpression | DeleteExpression | VoidExpression | YieldExpression | SpreadElementExpression>n);
|
||||
const unaryWordExpression = (<TypeOfExpression | DeleteExpression | VoidExpression | YieldExpression | SpreadElementExpression>n);
|
||||
return isCompletedNode(unaryWordExpression.expression, sourceFile);
|
||||
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
return isCompletedNode((<TaggedTemplateExpression>n).template, sourceFile);
|
||||
case SyntaxKind.TemplateExpression:
|
||||
let lastSpan = lastOrUndefined((<TemplateExpression>n).templateSpans);
|
||||
const lastSpan = lastOrUndefined((<TemplateExpression>n).templateSpans);
|
||||
return isCompletedNode(lastSpan, sourceFile);
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return nodeIsPresent((<TemplateSpan>n).literal);
|
||||
@@ -173,9 +173,9 @@ namespace ts {
|
||||
* If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'.
|
||||
*/
|
||||
function nodeEndsWith(n: Node, expectedLastToken: SyntaxKind, sourceFile: SourceFile): boolean {
|
||||
let children = n.getChildren(sourceFile);
|
||||
const children = n.getChildren(sourceFile);
|
||||
if (children.length) {
|
||||
let last = lastOrUndefined(children);
|
||||
const last = lastOrUndefined(children);
|
||||
if (last.kind === expectedLastToken) {
|
||||
return true;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function findListItemInfo(node: Node): ListItemInfo {
|
||||
let list = findContainingList(node);
|
||||
const list = findContainingList(node);
|
||||
|
||||
// It is possible at this point for syntaxList to be undefined, either if
|
||||
// node.parent had no list child, or if none of its list children contained
|
||||
@@ -197,8 +197,8 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let children = list.getChildren();
|
||||
let listItemIndex = indexOf(children, node);
|
||||
const children = list.getChildren();
|
||||
const listItemIndex = indexOf(children, node);
|
||||
|
||||
return {
|
||||
listItemIndex,
|
||||
@@ -219,7 +219,7 @@ namespace ts {
|
||||
// be parented by the container of the SyntaxList, not the SyntaxList itself.
|
||||
// In order to find the list item index, we first need to locate SyntaxList itself and then search
|
||||
// for the position of the relevant node (or comma).
|
||||
let syntaxList = forEach(node.parent.getChildren(), c => {
|
||||
const syntaxList = forEach(node.parent.getChildren(), c => {
|
||||
// find syntax list that covers the span of the node
|
||||
if (c.kind === SyntaxKind.SyntaxList && c.pos <= node.pos && c.end >= node.end) {
|
||||
return c;
|
||||
@@ -266,16 +266,16 @@ namespace ts {
|
||||
|
||||
// find the child that contains 'position'
|
||||
for (let i = 0, n = current.getChildCount(sourceFile); i < n; i++) {
|
||||
let child = current.getChildAt(i);
|
||||
let start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile);
|
||||
const child = current.getChildAt(i);
|
||||
const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile);
|
||||
if (start <= position) {
|
||||
let end = child.getEnd();
|
||||
const end = child.getEnd();
|
||||
if (position < end || (position === end && child.kind === SyntaxKind.EndOfFileToken)) {
|
||||
current = child;
|
||||
continue outer;
|
||||
}
|
||||
else if (includeItemAtEndPosition && end === position) {
|
||||
let previousToken = findPrecedingToken(position, sourceFile, child);
|
||||
const previousToken = findPrecedingToken(position, sourceFile, child);
|
||||
if (previousToken && includeItemAtEndPosition(previousToken)) {
|
||||
return previousToken;
|
||||
}
|
||||
@@ -297,7 +297,7 @@ namespace ts {
|
||||
export function findTokenOnLeftOfPosition(file: SourceFile, position: number): Node {
|
||||
// Ideally, getTokenAtPosition should return a token. However, it is currently
|
||||
// broken, so we do a check to make sure the result was indeed a token.
|
||||
let tokenAtPosition = getTokenAtPosition(file, position);
|
||||
const tokenAtPosition = getTokenAtPosition(file, position);
|
||||
if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) {
|
||||
return tokenAtPosition;
|
||||
}
|
||||
@@ -314,9 +314,9 @@ namespace ts {
|
||||
return n;
|
||||
}
|
||||
|
||||
let children = n.getChildren();
|
||||
for (let child of children) {
|
||||
let shouldDiveInChildNode =
|
||||
const children = n.getChildren();
|
||||
for (const child of children) {
|
||||
const shouldDiveInChildNode =
|
||||
// previous token is enclosed somewhere in the child
|
||||
(child.pos <= previousToken.pos && child.end > previousToken.end) ||
|
||||
// previous token ends exactly at the beginning of child
|
||||
@@ -339,8 +339,8 @@ namespace ts {
|
||||
return n;
|
||||
}
|
||||
|
||||
let children = n.getChildren();
|
||||
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
|
||||
const children = n.getChildren();
|
||||
const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
|
||||
return candidate && findRightmostToken(candidate);
|
||||
|
||||
}
|
||||
@@ -352,7 +352,7 @@ namespace ts {
|
||||
|
||||
const children = n.getChildren();
|
||||
for (let i = 0, len = children.length; i < len; i++) {
|
||||
let child = children[i];
|
||||
const child = children[i];
|
||||
// condition 'position < child.end' checks if child node end after the position
|
||||
// in the example below this condition will be false for 'aaaa' and 'bbbb' and true for 'ccc'
|
||||
// aaaa___bbbb___$__ccc
|
||||
@@ -369,7 +369,7 @@ namespace ts {
|
||||
|
||||
if (lookInPreviousChild) {
|
||||
// actual start of the node is past the position - previous token should be at the end of previous child
|
||||
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
|
||||
const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
|
||||
return candidate && findRightmostToken(candidate);
|
||||
}
|
||||
else {
|
||||
@@ -386,14 +386,14 @@ namespace ts {
|
||||
// Try to find the rightmost token in the file without filtering.
|
||||
// Namely we are skipping the check: 'position < node.end'
|
||||
if (children.length) {
|
||||
let candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
|
||||
const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
|
||||
return candidate && findRightmostToken(candidate);
|
||||
}
|
||||
}
|
||||
|
||||
/// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition'
|
||||
function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node {
|
||||
for (let i = exclusiveStartPosition - 1; i >= 0; --i) {
|
||||
for (let i = exclusiveStartPosition - 1; i >= 0; i--) {
|
||||
if (nodeHasTokens(children[i])) {
|
||||
return children[i];
|
||||
}
|
||||
@@ -402,7 +402,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isInString(sourceFile: SourceFile, position: number) {
|
||||
let token = getTokenAtPosition(sourceFile, position);
|
||||
const token = getTokenAtPosition(sourceFile, position);
|
||||
return token && (token.kind === SyntaxKind.StringLiteral || token.kind === SyntaxKind.StringLiteralType) && position > token.getStart(sourceFile);
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace ts {
|
||||
* returns true if the position is in between the open and close elements of an JSX expression.
|
||||
*/
|
||||
export function isInsideJsxElementOrAttribute(sourceFile: SourceFile, position: number) {
|
||||
let token = getTokenAtPosition(sourceFile, position);
|
||||
const token = getTokenAtPosition(sourceFile, position);
|
||||
|
||||
if (!token) {
|
||||
return false;
|
||||
@@ -446,7 +446,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function isInTemplateString(sourceFile: SourceFile, position: number) {
|
||||
let token = getTokenAtPosition(sourceFile, position);
|
||||
const token = getTokenAtPosition(sourceFile, position);
|
||||
return isTemplateLiteralKind(token.kind) && position > token.getStart(sourceFile);
|
||||
}
|
||||
|
||||
@@ -455,10 +455,10 @@ namespace ts {
|
||||
* satisfies predicate, and false otherwise.
|
||||
*/
|
||||
export function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean {
|
||||
let token = getTokenAtPosition(sourceFile, position);
|
||||
const token = getTokenAtPosition(sourceFile, position);
|
||||
|
||||
if (token && position <= token.getStart(sourceFile)) {
|
||||
let commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
||||
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
||||
|
||||
// The end marker of a single-line comment does not include the newline character.
|
||||
// In the following case, we are inside a comment (^ denotes the cursor position):
|
||||
@@ -482,10 +482,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function hasDocComment(sourceFile: SourceFile, position: number) {
|
||||
let token = getTokenAtPosition(sourceFile, position);
|
||||
const token = getTokenAtPosition(sourceFile, position);
|
||||
|
||||
// First, we have to see if this position actually landed in a comment.
|
||||
let commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
||||
const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos);
|
||||
|
||||
return forEach(commentRanges, jsDocPrefix);
|
||||
|
||||
@@ -515,9 +515,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (node) {
|
||||
let jsDocComment = node.jsDocComment;
|
||||
const jsDocComment = node.jsDocComment;
|
||||
if (jsDocComment) {
|
||||
for (let tag of jsDocComment.tags) {
|
||||
for (const tag of jsDocComment.tags) {
|
||||
if (tag.pos <= position && position <= tag.end) {
|
||||
return tag;
|
||||
}
|
||||
@@ -535,8 +535,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function getNodeModifiers(node: Node): string {
|
||||
let flags = getCombinedNodeFlags(node);
|
||||
let result: string[] = [];
|
||||
const flags = getCombinedNodeFlags(node);
|
||||
const result: string[] = [];
|
||||
|
||||
if (flags & NodeFlags.Private) result.push(ScriptElementKindModifier.privateMemberModifier);
|
||||
if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier);
|
||||
@@ -608,7 +608,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function compareDataObjects(dst: any, src: any): boolean {
|
||||
for (let e in dst) {
|
||||
for (const e in dst) {
|
||||
if (typeof dst[e] === "object") {
|
||||
if (!compareDataObjects(dst[e], src[e])) {
|
||||
return false;
|
||||
@@ -661,7 +661,7 @@ namespace ts {
|
||||
return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === SyntaxKind.Parameter;
|
||||
}
|
||||
|
||||
let displayPartWriter = getDisplayPartWriter();
|
||||
const displayPartWriter = getDisplayPartWriter();
|
||||
function getDisplayPartWriter(): DisplayPartsSymbolWriter {
|
||||
let displayParts: SymbolDisplayPart[];
|
||||
let lineStart: boolean;
|
||||
@@ -687,7 +687,7 @@ namespace ts {
|
||||
|
||||
function writeIndent() {
|
||||
if (lineStart) {
|
||||
let indentString = getIndentString(indent);
|
||||
const indentString = getIndentString(indent);
|
||||
if (indentString) {
|
||||
displayParts.push(displayPart(indentString, SymbolDisplayPartKind.space));
|
||||
}
|
||||
@@ -721,7 +721,7 @@ namespace ts {
|
||||
return displayPart(text, displayPartKind(symbol), symbol);
|
||||
|
||||
function displayPartKind(symbol: Symbol): SymbolDisplayPartKind {
|
||||
let flags = symbol.flags;
|
||||
const flags = symbol.flags;
|
||||
|
||||
if (flags & SymbolFlags.Variable) {
|
||||
return isFirstDeclarationOfSymbolParameter(symbol) ? SymbolDisplayPartKind.parameterName : SymbolDisplayPartKind.localName;
|
||||
@@ -792,7 +792,7 @@ namespace ts {
|
||||
|
||||
export function mapToDisplayParts(writeDisplayParts: (writer: DisplayPartsSymbolWriter) => void): SymbolDisplayPart[] {
|
||||
writeDisplayParts(displayPartWriter);
|
||||
let result = displayPartWriter.displayParts();
|
||||
const result = displayPartWriter.displayParts();
|
||||
displayPartWriter.clear();
|
||||
return result;
|
||||
}
|
||||
@@ -828,9 +828,9 @@ namespace ts {
|
||||
|
||||
// Try to get the local symbol if we're dealing with an 'export default'
|
||||
// since that symbol has the "true" name.
|
||||
let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol);
|
||||
const localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol);
|
||||
|
||||
let name = typeChecker.symbolToString(localExportDefaultSymbol || symbol);
|
||||
const name = typeChecker.symbolToString(localExportDefaultSymbol || symbol);
|
||||
|
||||
return name;
|
||||
}
|
||||
@@ -847,7 +847,7 @@ namespace ts {
|
||||
* @return non-quoted string
|
||||
*/
|
||||
export function stripQuotes(name: string) {
|
||||
let length = name.length;
|
||||
const length = name.length;
|
||||
if (length >= 2 &&
|
||||
name.charCodeAt(0) === name.charCodeAt(length - 1) &&
|
||||
(name.charCodeAt(0) === CharacterCodes.doubleQuote || name.charCodeAt(0) === CharacterCodes.singleQuote)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(10,15): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(14,5): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(18,13): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts(22,5): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflictingMembers.ts (4 errors) ====
|
||||
@@ -16,23 +16,23 @@ tests/cases/conformance/classes/classDeclarations/classAndInterfaceMergeConflict
|
||||
declare class C2 {
|
||||
protected x : number;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
|
||||
interface C2 {
|
||||
x : number;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
|
||||
declare class C3 {
|
||||
private x : number;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
|
||||
interface C3 {
|
||||
x : number;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
+14
-5
@@ -1,8 +1,11 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(4,17): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(4,27): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(5,24): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(5,35): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(9,17): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(9,25): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(10,24): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(9,25): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(10,24): error TS2300: Duplicate identifier 'x'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(10,24): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(14,17): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(19,10): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(20,10): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
@@ -14,7 +17,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatur
|
||||
tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts(35,10): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts (14 errors) ====
|
||||
==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatureWithAccessibilityModifiersOnParameters2.ts (17 errors) ====
|
||||
// Parameter properties are not valid in overloads of constructors
|
||||
|
||||
class C {
|
||||
@@ -24,6 +27,10 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatur
|
||||
~~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
constructor(public x, private y) { }
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
}
|
||||
|
||||
class C2 {
|
||||
@@ -31,10 +38,12 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/constructSignatur
|
||||
~~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
constructor(public x) { }
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2300: Duplicate identifier 'x'.
|
||||
~
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
}
|
||||
|
||||
class C3 {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(11,24): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(18,5): error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(18,5): error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(19,25): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(19,25): error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(26,5): error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(19,25): error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(26,5): error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(27,27): error TS2300: Duplicate identifier 'y'.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(27,27): error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(27,27): error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts (7 errors) ====
|
||||
@@ -29,12 +29,12 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
|
||||
class E {
|
||||
y: number;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
constructor(private y: number) { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
~
|
||||
!!! error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
}
|
||||
|
||||
var e: E;
|
||||
@@ -43,12 +43,12 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co
|
||||
class F {
|
||||
y: number;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
constructor(protected y: number) { } // error
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'y'.
|
||||
~
|
||||
!!! error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
}
|
||||
|
||||
var f: F;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/compiler/duplicateIdentifierComputedName.ts(3,5): error TS2300: Duplicate identifier 'a'.
|
||||
tests/cases/compiler/duplicateIdentifierComputedName.ts(3,5): error TS2300: Duplicate identifier '["a"]'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateIdentifierComputedName.ts (1 errors) ====
|
||||
@@ -6,6 +6,6 @@ tests/cases/compiler/duplicateIdentifierComputedName.ts(3,5): error TS2300: Dupl
|
||||
["a"]: string;
|
||||
["a"]: string;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'a'.
|
||||
!!! error TS2300: Duplicate identifier '["a"]'.
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(2,15): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(3,15): error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(16,11): error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(20,3): error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(2,15): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(3,15): error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(16,11): error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(20,3): error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
|
||||
|
||||
==== tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts (4 errors) ====
|
||||
// Not OK
|
||||
interface B { x; }
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
interface B { x?; }
|
||||
~
|
||||
!!! error TS2686: All declarations of 'x' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'x' must have identical modifiers.
|
||||
|
||||
// OK
|
||||
class A {
|
||||
@@ -26,12 +26,12 @@ tests/cases/compiler/duplicateIdentifierDifferentModifiers.ts(20,3): error TS268
|
||||
class C {
|
||||
private y: string;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
}
|
||||
|
||||
interface C {
|
||||
y: string;
|
||||
~
|
||||
!!! error TS2686: All declarations of 'y' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'y' must have identical modifiers.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [intersectionTypeInference1.ts]
|
||||
// Repro from #8801
|
||||
|
||||
function alert(s: string) {}
|
||||
|
||||
const parameterFn = (props:{store:string}) => alert(props.store)
|
||||
const brokenFunction = <OwnProps>(f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o
|
||||
export const Form3 = brokenFunction(parameterFn)({store: "hello"})
|
||||
|
||||
|
||||
//// [intersectionTypeInference1.js]
|
||||
// Repro from #8801
|
||||
"use strict";
|
||||
function alert(s) { }
|
||||
var parameterFn = function (props) { return alert(props.store); };
|
||||
var brokenFunction = function (f) { return function (o) { return o; }; };
|
||||
exports.Form3 = brokenFunction(parameterFn)({ store: "hello" });
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/compiler/intersectionTypeInference1.ts ===
|
||||
// Repro from #8801
|
||||
|
||||
function alert(s: string) {}
|
||||
>alert : Symbol(alert, Decl(intersectionTypeInference1.ts, 0, 0))
|
||||
>s : Symbol(s, Decl(intersectionTypeInference1.ts, 2, 15))
|
||||
|
||||
const parameterFn = (props:{store:string}) => alert(props.store)
|
||||
>parameterFn : Symbol(parameterFn, Decl(intersectionTypeInference1.ts, 4, 5))
|
||||
>props : Symbol(props, Decl(intersectionTypeInference1.ts, 4, 21))
|
||||
>store : Symbol(store, Decl(intersectionTypeInference1.ts, 4, 28))
|
||||
>alert : Symbol(alert, Decl(intersectionTypeInference1.ts, 0, 0))
|
||||
>props.store : Symbol(store, Decl(intersectionTypeInference1.ts, 4, 28))
|
||||
>props : Symbol(props, Decl(intersectionTypeInference1.ts, 4, 21))
|
||||
>store : Symbol(store, Decl(intersectionTypeInference1.ts, 4, 28))
|
||||
|
||||
const brokenFunction = <OwnProps>(f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o
|
||||
>brokenFunction : Symbol(brokenFunction, Decl(intersectionTypeInference1.ts, 5, 5))
|
||||
>OwnProps : Symbol(OwnProps, Decl(intersectionTypeInference1.ts, 5, 24))
|
||||
>f : Symbol(f, Decl(intersectionTypeInference1.ts, 5, 34))
|
||||
>p : Symbol(p, Decl(intersectionTypeInference1.ts, 5, 38))
|
||||
>dispatch : Symbol(dispatch, Decl(intersectionTypeInference1.ts, 5, 42))
|
||||
>OwnProps : Symbol(OwnProps, Decl(intersectionTypeInference1.ts, 5, 24))
|
||||
>o : Symbol(o, Decl(intersectionTypeInference1.ts, 5, 85))
|
||||
>OwnProps : Symbol(OwnProps, Decl(intersectionTypeInference1.ts, 5, 24))
|
||||
>o : Symbol(o, Decl(intersectionTypeInference1.ts, 5, 85))
|
||||
|
||||
export const Form3 = brokenFunction(parameterFn)({store: "hello"})
|
||||
>Form3 : Symbol(Form3, Decl(intersectionTypeInference1.ts, 6, 12))
|
||||
>brokenFunction : Symbol(brokenFunction, Decl(intersectionTypeInference1.ts, 5, 5))
|
||||
>parameterFn : Symbol(parameterFn, Decl(intersectionTypeInference1.ts, 4, 5))
|
||||
>store : Symbol(store, Decl(intersectionTypeInference1.ts, 6, 50))
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
=== tests/cases/compiler/intersectionTypeInference1.ts ===
|
||||
// Repro from #8801
|
||||
|
||||
function alert(s: string) {}
|
||||
>alert : (s: string) => void
|
||||
>s : string
|
||||
|
||||
const parameterFn = (props:{store:string}) => alert(props.store)
|
||||
>parameterFn : (props: { store: string; }) => void
|
||||
>(props:{store:string}) => alert(props.store) : (props: { store: string; }) => void
|
||||
>props : { store: string; }
|
||||
>store : string
|
||||
>alert(props.store) : void
|
||||
>alert : (s: string) => void
|
||||
>props.store : string
|
||||
>props : { store: string; }
|
||||
>store : string
|
||||
|
||||
const brokenFunction = <OwnProps>(f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o
|
||||
>brokenFunction : <OwnProps>(f: (p: { dispatch: number; } & OwnProps) => void) => (o: OwnProps) => OwnProps
|
||||
><OwnProps>(f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o : <OwnProps>(f: (p: { dispatch: number; } & OwnProps) => void) => (o: OwnProps) => OwnProps
|
||||
>OwnProps : OwnProps
|
||||
>f : (p: { dispatch: number; } & OwnProps) => void
|
||||
>p : { dispatch: number; } & OwnProps
|
||||
>dispatch : number
|
||||
>OwnProps : OwnProps
|
||||
>(o: OwnProps) => o : (o: OwnProps) => OwnProps
|
||||
>o : OwnProps
|
||||
>OwnProps : OwnProps
|
||||
>o : OwnProps
|
||||
|
||||
export const Form3 = brokenFunction(parameterFn)({store: "hello"})
|
||||
>Form3 : { store: string; }
|
||||
>brokenFunction(parameterFn)({store: "hello"}) : { store: string; }
|
||||
>brokenFunction(parameterFn) : (o: { store: string; }) => { store: string; }
|
||||
>brokenFunction : <OwnProps>(f: (p: { dispatch: number; } & OwnProps) => void) => (o: OwnProps) => OwnProps
|
||||
>parameterFn : (props: { store: string; }) => void
|
||||
>{store: "hello"} : { store: string; }
|
||||
>store : string
|
||||
>"hello" : string
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/compiler/numericClassMembers1.ts(3,3): error TS2300: Duplicate identifier '0'.
|
||||
tests/cases/compiler/numericClassMembers1.ts(8,2): error TS2300: Duplicate identifier '0'.
|
||||
tests/cases/compiler/numericClassMembers1.ts(3,3): error TS2300: Duplicate identifier '0.0'.
|
||||
tests/cases/compiler/numericClassMembers1.ts(8,2): error TS2300: Duplicate identifier ''0''.
|
||||
|
||||
|
||||
==== tests/cases/compiler/numericClassMembers1.ts (2 errors) ====
|
||||
@@ -7,14 +7,14 @@ tests/cases/compiler/numericClassMembers1.ts(8,2): error TS2300: Duplicate ident
|
||||
0 = 1;
|
||||
0.0 = 2;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '0'.
|
||||
!!! error TS2300: Duplicate identifier '0.0'.
|
||||
}
|
||||
|
||||
class C235 {
|
||||
0.0 = 1;
|
||||
'0' = 2;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '0'.
|
||||
!!! error TS2300: Duplicate identifier ''0''.
|
||||
}
|
||||
|
||||
class C236 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedPropertyDuplicates.ts(3,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedPropertyDuplicates.ts(3,5): error TS2300: Duplicate identifier '1.0'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedPropertyDuplicates.ts(5,12): error TS2300: Duplicate identifier '2'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedPropertyDuplicates.ts(9,5): error TS2300: Duplicate identifier '2'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedPropertyDuplicates.ts(10,5): error TS2300: Duplicate identifier '2'.
|
||||
@@ -12,7 +12,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericNamedP
|
||||
1: number;
|
||||
1.0: number;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '1'.
|
||||
!!! error TS2300: Duplicate identifier '1.0'.
|
||||
static 2: number;
|
||||
static 2: number;
|
||||
~
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(6,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(6,5): error TS2300: Duplicate identifier '1.0'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(10,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(12,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericStringNamedPropertyEquivalence.ts(16,5): error TS2300: Duplicate identifier '1'.
|
||||
@@ -15,7 +15,7 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/numericString
|
||||
"1.0": number; // not a duplicate
|
||||
1.0: number;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '1'.
|
||||
!!! error TS2300: Duplicate identifier '1.0'.
|
||||
}
|
||||
|
||||
interface I {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(6,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(7,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(8,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(6,5): error TS2300: Duplicate identifier '1.0'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(7,5): error TS2300: Duplicate identifier '1.'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(8,5): error TS2300: Duplicate identifier '1.00'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(12,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(13,5): error TS2300: Duplicate identifier '1'.
|
||||
tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(14,5): error TS2300: Duplicate identifier '1'.
|
||||
@@ -22,13 +22,13 @@ tests/cases/conformance/types/members/objectTypeWithDuplicateNumericProperty.ts(
|
||||
1;
|
||||
1.0;
|
||||
~~~
|
||||
!!! error TS2300: Duplicate identifier '1'.
|
||||
!!! error TS2300: Duplicate identifier '1.0'.
|
||||
1.;
|
||||
~~
|
||||
!!! error TS2300: Duplicate identifier '1'.
|
||||
!!! error TS2300: Duplicate identifier '1.'.
|
||||
1.00;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier '1'.
|
||||
!!! error TS2300: Duplicate identifier '1.00'.
|
||||
}
|
||||
|
||||
interface I {
|
||||
|
||||
@@ -5,9 +5,9 @@ tests/cases/compiler/optionalPropertiesSyntax.ts(12,5): error TS1131: Property o
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(18,11): error TS1005: ';' expected.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(18,12): error TS1131: Property or signature expected.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(24,5): error TS2300: Duplicate identifier 'prop'.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(24,5): error TS2686: All declarations of 'prop' must have identical modifiers.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(24,5): error TS2687: All declarations of 'prop' must have identical modifiers.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(25,5): error TS2300: Duplicate identifier 'prop'.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(25,5): error TS2686: All declarations of 'prop' must have identical modifiers.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(25,5): error TS2687: All declarations of 'prop' must have identical modifiers.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(32,5): error TS2375: Duplicate number index signature.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(32,18): error TS1005: ';' expected.
|
||||
tests/cases/compiler/optionalPropertiesSyntax.ts(32,19): error TS1131: Property or signature expected.
|
||||
@@ -56,12 +56,12 @@ tests/cases/compiler/optionalPropertiesSyntax.ts(34,5): error TS2375: Duplicate
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'prop'.
|
||||
~~~~
|
||||
!!! error TS2686: All declarations of 'prop' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'prop' must have identical modifiers.
|
||||
prop?: any;
|
||||
~~~~
|
||||
!!! error TS2300: Duplicate identifier 'prop'.
|
||||
~~~~
|
||||
!!! error TS2686: All declarations of 'prop' must have identical modifiers.
|
||||
!!! error TS2687: All declarations of 'prop' must have identical modifiers.
|
||||
prop2?: any;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
tests/cases/compiler/parameterPropertyInConstructor2.ts(3,5): error TS2394: Overload signature is not compatible with function implementation.
|
||||
tests/cases/compiler/parameterPropertyInConstructor2.ts(3,17): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
tests/cases/compiler/parameterPropertyInConstructor2.ts(4,24): error TS2300: Duplicate identifier 'names'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/parameterPropertyInConstructor2.ts (2 errors) ====
|
||||
==== tests/cases/compiler/parameterPropertyInConstructor2.ts (3 errors) ====
|
||||
module mod {
|
||||
class Customers {
|
||||
constructor(public names: string);
|
||||
@@ -11,6 +12,8 @@ tests/cases/compiler/parameterPropertyInConstructor2.ts(3,17): error TS2369: A p
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||
constructor(public names: string, public ages: number) {
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'names'.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts(3,5): error TS2300: Duplicate identifier 'a b'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts(5,12): error TS2300: Duplicate identifier 'c d'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts(3,5): error TS2300: Duplicate identifier '"a b"'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts(5,12): error TS2300: Duplicate identifier '"c d"'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts(9,5): error TS2300: Duplicate identifier 'a b'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts(10,5): error TS2300: Duplicate identifier 'a b'.
|
||||
tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPropertyDuplicates.ts(14,5): error TS2300: Duplicate identifier 'a b'.
|
||||
@@ -12,11 +12,11 @@ tests/cases/conformance/types/objectTypeLiteral/propertySignatures/stringNamedPr
|
||||
"a b": number;
|
||||
"a b": number;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'a b'.
|
||||
!!! error TS2300: Duplicate identifier '"a b"'.
|
||||
static "c d": number;
|
||||
static "c d": number;
|
||||
~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'c d'.
|
||||
!!! error TS2300: Duplicate identifier '"c d"'.
|
||||
}
|
||||
|
||||
interface I {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty44.ts(2,9): error TS2300: Duplicate identifier '[Symbol.hasInstance]'.
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty44.ts(5,9): error TS2300: Duplicate identifier '[Symbol.hasInstance]'.
|
||||
tests/cases/conformance/es6/Symbols/symbolProperty44.ts(5,9): error TS2300: Duplicate identifier '__@hasInstance'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/Symbols/symbolProperty44.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/Symbols/symbolProperty44.ts (2 errors) ====
|
||||
class C {
|
||||
get [Symbol.hasInstance]() {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -13,8 +12,6 @@ tests/cases/conformance/es6/Symbols/symbolProperty44.ts(5,9): error TS2300: Dupl
|
||||
get [Symbol.hasInstance]() {
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '[Symbol.hasInstance]'.
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier '__@hasInstance'.
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// Repro from #8801
|
||||
|
||||
function alert(s: string) {}
|
||||
|
||||
const parameterFn = (props:{store:string}) => alert(props.store)
|
||||
const brokenFunction = <OwnProps>(f: (p: {dispatch: number} & OwnProps) => void) => (o: OwnProps) => o
|
||||
export const Form3 = brokenFunction(parameterFn)({store: "hello"})
|
||||
@@ -5,7 +5,7 @@
|
||||
//// ["bar"]: string;
|
||||
////}
|
||||
|
||||
verify.navigationBarCount(3);
|
||||
verify.navigationBarCount(5);
|
||||
verify.navigationBarContains("C", "class");
|
||||
verify.navigationBarChildItem("C", "[\"bar\"]", "property");
|
||||
verify.navigationBarChildItem("C", "foo", "property");
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//// {| "itemName": "Windows", "kind": "module", "parentName": "<global>" |}declare module Windows {
|
||||
//// {| "itemName": "Foundation", "kind": "module", "parentName": "Windows" |}export module Foundation {
|
||||
//// export var {| "itemName": "A", "kind": "var" |}A;
|
||||
//// {| "itemName": "Test", "kind": "class" |}export class Test {
|
||||
//// {| "itemName": "Test", "kind": "class", "parentName": "Foundation" |}export class Test {
|
||||
//// {| "itemName": "wow", "kind": "method" |}public wow();
|
||||
//// }
|
||||
//// }
|
||||
@@ -38,4 +38,5 @@ test.markers().forEach(marker => {
|
||||
marker.position);
|
||||
}
|
||||
});
|
||||
verify.navigationBarCount(17);
|
||||
|
||||
verify.navigationBarCount(19);
|
||||
|
||||
@@ -11,4 +11,4 @@
|
||||
//// }
|
||||
////}
|
||||
|
||||
verify.navigationBarCount(6); // 2x(class + field + constructor)
|
||||
verify.navigationBarCount(9); // global + 2 children + 2x(class + field + constructor)
|
||||
|
||||
@@ -9,4 +9,4 @@ verify.navigationBarContains("Test", "class");
|
||||
verify.navigationBarContains("constructor", "constructor");
|
||||
|
||||
// no other items
|
||||
verify.navigationBarCount(2);
|
||||
verify.navigationBarCount(4); // global + 1 child, Test + 1 child
|
||||
@@ -6,7 +6,7 @@
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// {| "itemName": "LocalInterfaceInConstrcutor", "kind": "interface", "parentName": ""|}interface LocalInterfaceInConstrcutor {
|
||||
//// {| "itemName": "LocalInterfaceInConstrcutor", "kind": "interface", "parentName": "constructor"|}interface LocalInterfaceInConstrcutor {
|
||||
//// }
|
||||
////
|
||||
//// {| "itemName": "LocalEnumInConstructor", "kind": "enum", "parentName": "constructor"|}enum LocalEnumInConstructor {
|
||||
@@ -21,7 +21,7 @@
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// {| "itemName": "LocalInterfaceInMethod", "kind": "interface", "parentName": ""|}interface LocalInterfaceInMethod {
|
||||
//// {| "itemName": "LocalInterfaceInMethod", "kind": "interface", "parentName": "method"|}interface LocalInterfaceInMethod {
|
||||
//// }
|
||||
////
|
||||
//// {| "itemName": "LocalEnumInMethod", "kind": "enum", "parentName": "method"|}enum LocalEnumInMethod {
|
||||
@@ -39,4 +39,4 @@ test.markers().forEach((marker) => {
|
||||
});
|
||||
|
||||
// no other items
|
||||
verify.navigationBarCount(19);
|
||||
verify.navigationBarCount(23);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////// Interface
|
||||
////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint {
|
||||
////{| "itemName": "IPoint", "kind": "interface", "parentName": "<global>" |}interface IPoint {
|
||||
//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number;
|
||||
//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint;
|
||||
//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any;
|
||||
@@ -13,7 +13,7 @@
|
||||
////{| "itemName": "Shapes", "kind": "module", "parentName": "<global>" |}module Shapes {
|
||||
////
|
||||
//// // Class
|
||||
//// {| "itemName": "Point", "kind": "class", "parentName": "" |}export class Point implements IPoint {
|
||||
//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint {
|
||||
//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Point" |}constructor (public x: number, public y: number) { }
|
||||
////
|
||||
//// // Instance member
|
||||
@@ -49,4 +49,4 @@ test.markers().forEach((marker) => {
|
||||
}
|
||||
});
|
||||
|
||||
verify.navigationBarCount(25);
|
||||
verify.navigationBarCount(27);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
|
||||
////{| "itemName": "Bar", "kind": "class", "parentName": "\"navigationBarItemsItemsExternalModules\"" |}export class Bar {
|
||||
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
|
||||
////}
|
||||
|
||||
@@ -8,4 +8,4 @@ test.markers().forEach((marker) => {
|
||||
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.navigationBarCount(2); // external module node + class + property
|
||||
verify.navigationBarCount(4); // external module node + class + property
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// @Filename: test/file.ts
|
||||
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
|
||||
////{| "itemName": "Bar", "kind": "class", "parentName": "\"file\"" |}export class Bar {
|
||||
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
|
||||
////}
|
||||
////{| "itemName": "\"file\"", "kind": "module" |}
|
||||
@@ -12,4 +12,4 @@ test.markers().forEach((marker) => {
|
||||
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.navigationBarCount(4); // external module node + variable in module + class + property
|
||||
verify.navigationBarCount(5); // external module node + variable in module + class + property
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
// @Filename: test/my fil"e.ts
|
||||
////{| "itemName": "Bar", "kind": "class" |}export class Bar {
|
||||
////{| "itemName": "Bar", "kind": "class", "parentName": "\"my fil\\\"e\"" |}export class Bar {
|
||||
//// {| "itemName": "s", "kind": "property", "parentName": "Bar" |}public s: string;
|
||||
////}
|
||||
////{| "itemName": "\"my fil\\\"e\"", "kind": "module" |}
|
||||
@@ -12,4 +12,4 @@ test.markers().forEach((marker) => {
|
||||
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.navigationBarCount(4); // external module node + variable in module + class + property
|
||||
verify.navigationBarCount(5); // external module node + 2 children + class + property
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/////**
|
||||
//// * This is a class.
|
||||
//// */
|
||||
////{| "itemName": "C", "kind": "class" |} class C {
|
||||
////{| "itemName": "C", "kind": "class", "parentName": "\"navigationBarItemsMissingName1\"" |} class C {
|
||||
//// {| "itemName": "foo", "kind": "method" |} foo() {
|
||||
//// }
|
||||
////}
|
||||
@@ -12,5 +12,5 @@ test.markers().forEach((marker) => {
|
||||
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
/// Only have two named elements.
|
||||
verify.navigationBarCount(2);
|
||||
/// Root + 1 child, class + 1 child
|
||||
verify.navigationBarCount(4);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
////{| "itemName": "\"MultilineMadness\"", "kind": "module", "parentName": "<global>" |}
|
||||
////declare module "MultilineMadness" {}
|
||||
////
|
||||
////{| "itemName": "Foo", "kind": "interface" |}
|
||||
////{| "itemName": "Foo", "kind": "interface", "parentName": "<global>" |}
|
||||
////interface Foo {
|
||||
//// {| "itemName": "\"a1\\\\\\r\\nb\"", "kind": "property", "parentName": "Foo" |}
|
||||
//// "a1\\\r\nb";
|
||||
@@ -20,7 +20,7 @@
|
||||
//// b"(): Foo;
|
||||
////}
|
||||
////
|
||||
////{| "itemName": "Bar", "kind": "class" |}
|
||||
////{| "itemName": "Bar", "kind": "class", "parentName": "<global>" |}
|
||||
////class Bar implements Foo {
|
||||
//// {| "itemName": "'a1\\\\\\r\\nb'", "kind": "property", "parentName": "Bar" |}
|
||||
//// 'a1\\\r\nb': Foo;
|
||||
@@ -38,4 +38,4 @@ test.markers().forEach((marker) => {
|
||||
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.navigationBarCount(13);
|
||||
verify.navigationBarCount(15);
|
||||
|
||||
@@ -12,4 +12,4 @@ verify.navigationBarContains("a", "property");
|
||||
verify.navigationBarContains("b", "property");
|
||||
|
||||
// no other items
|
||||
verify.navigationBarCount(4);
|
||||
verify.navigationBarCount(6);
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////{| "itemName": "C", "kind": "class", "parentName": "" |}
|
||||
////{| "itemName": "C", "kind": "class", "parentName": "<global>" |}
|
||||
////class C {
|
||||
//// {| "itemName": "[Symbol.isRegExp]", "kind": "property", "parentName": "C" |}
|
||||
//// [Symbol.isRegExp] = 0;
|
||||
@@ -14,4 +14,5 @@ test.markers().forEach(marker => {
|
||||
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.navigationBarCount(test.markers().length);
|
||||
// 2 lack markers: <global> and its child
|
||||
verify.navigationBarCount(2 + test.markers().length);
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////{| "itemName": "I", "kind": "interface", "parentName": "" |}
|
||||
////{| "itemName": "I", "kind": "interface", "parentName": "<global>" |}
|
||||
////interface I {
|
||||
//// {| "itemName": "[Symbol.isRegExp]", "kind": "property", "parentName": "I" |}
|
||||
//// [Symbol.isRegExp]: string;
|
||||
@@ -12,4 +12,5 @@ test.markers().forEach(marker => {
|
||||
verify.navigationBarContains(marker.data.itemName, marker.data.kind, marker.fileName, marker.data.parentName);
|
||||
});
|
||||
|
||||
verify.navigationBarCount(test.markers().length);
|
||||
// 2 are not marked: <global> and its child.
|
||||
verify.navigationBarCount(2 + test.markers().length);
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="../fourslash.ts"/>
|
||||
|
||||
////// Interface
|
||||
////{| "itemName": "IPoint", "kind": "interface", "parentName": "" |}interface IPoint {
|
||||
////{| "itemName": "IPoint", "kind": "interface", "parentName": "<global>" |}interface IPoint {
|
||||
//// {| "itemName": "getDist", "kind": "method", "parentName": "IPoint" |}getDist(): number;
|
||||
//// {| "itemName": "new()", "kind": "construct", "parentName": "IPoint" |}new(): IPoint;
|
||||
//// {| "itemName": "()", "kind": "call", "parentName": "IPoint" |}(): any;
|
||||
@@ -13,7 +13,7 @@
|
||||
////{| "itemName": "Shapes", "kind": "module", "parentName": "<global>" |}module Shapes {
|
||||
////
|
||||
//// // Class
|
||||
//// {| "itemName": "Point", "kind": "class", "parentName": "" |}export class Point implements IPoint {
|
||||
//// {| "itemName": "Point", "kind": "class", "parentName": "Shapes" |}export class Point implements IPoint {
|
||||
//// {| "itemName": "constructor", "kind": "constructor", "parentName": "Point" |}constructor (public x: number, public y: number) { }
|
||||
////
|
||||
//// // Instance member
|
||||
@@ -49,4 +49,4 @@ test.markers().forEach((marker) => {
|
||||
}
|
||||
});
|
||||
|
||||
verify.navigationBarCount(25);
|
||||
verify.navigationBarCount(27);
|
||||
|
||||
Reference in New Issue
Block a user