typescript 4.8.0-dev.20220614 → 4.8.0-dev.20220617
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dynamicImportCompat.js +25 -0
- package/lib/tsc.js +115 -23
- package/lib/tsserver.js +617 -78
- package/lib/tsserverlibrary.d.ts +18 -2
- package/lib/tsserverlibrary.js +556 -77
- package/lib/typescript.d.ts +8 -0
- package/lib/typescript.js +279 -41
- package/lib/typescriptServices.d.ts +8 -0
- package/lib/typescriptServices.js +279 -41
- package/lib/typingsInstaller.js +133 -24
- package/package.json +20 -20
package/lib/typescript.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220617";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8668,9 +8668,11 @@ var ts;
|
|
|
8668
8668
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8669
8669
|
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8670
8670
|
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8671
|
-
|
|
8671
|
+
This_type_parameter_might_need_an_extends_0_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."),
|
|
8672
8672
|
The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8673
8673
|
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8674
|
+
Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
8675
|
+
Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
|
|
8674
8676
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8675
8677
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8676
8678
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -9156,6 +9158,8 @@ var ts;
|
|
|
9156
9158
|
This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
|
|
9157
9159
|
An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
|
|
9158
9160
|
The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
9161
|
+
_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
|
|
9162
|
+
We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
|
|
9159
9163
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
9160
9164
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
9161
9165
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -9853,6 +9857,8 @@ var ts;
|
|
|
9853
9857
|
Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
|
|
9854
9858
|
A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
|
|
9855
9859
|
The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
|
|
9860
|
+
You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."),
|
|
9861
|
+
You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
|
|
9856
9862
|
Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
|
|
9857
9863
|
Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
|
|
9858
9864
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
@@ -35970,10 +35976,11 @@ var ts;
|
|
|
35970
35976
|
}
|
|
35971
35977
|
nextToken();
|
|
35972
35978
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35973
|
-
if (
|
|
35979
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35974
35980
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35975
35981
|
return undefined;
|
|
35976
35982
|
}
|
|
35983
|
+
nextToken();
|
|
35977
35984
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35978
35985
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35979
35986
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -49090,9 +49097,9 @@ var ts;
|
|
|
49090
49097
|
return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
|
|
49091
49098
|
},
|
|
49092
49099
|
resolveExternalModuleSymbol: resolveExternalModuleSymbol,
|
|
49093
|
-
tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
|
|
49100
|
+
tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
|
|
49094
49101
|
var node = ts.getParseTreeNode(nodeIn);
|
|
49095
|
-
return node && tryGetThisTypeAt(node, includeGlobalThis);
|
|
49102
|
+
return node && tryGetThisTypeAt(node, includeGlobalThis, container);
|
|
49096
49103
|
},
|
|
49097
49104
|
getTypeArgumentConstraint: function (nodeIn) {
|
|
49098
49105
|
var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
|
|
@@ -49387,6 +49394,7 @@ var ts;
|
|
|
49387
49394
|
var potentialNewTargetCollisions = [];
|
|
49388
49395
|
var potentialWeakMapSetCollisions = [];
|
|
49389
49396
|
var potentialReflectCollisions = [];
|
|
49397
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49390
49398
|
var awaitedTypeStack = [];
|
|
49391
49399
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49392
49400
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -52722,6 +52730,9 @@ var ts;
|
|
|
52722
52730
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52723
52731
|
return { accessibility: 0 /* Accessible */ };
|
|
52724
52732
|
}
|
|
52733
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52734
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52735
|
+
}
|
|
52725
52736
|
// Verify if the symbol is accessible
|
|
52726
52737
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52727
52738
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -53894,15 +53905,22 @@ var ts;
|
|
|
53894
53905
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53895
53906
|
return parameterNode;
|
|
53896
53907
|
function cloneBindingName(node) {
|
|
53897
|
-
return
|
|
53898
|
-
function
|
|
53908
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53909
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53899
53910
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53900
53911
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53901
53912
|
}
|
|
53902
|
-
var visited = ts.visitEachChild(node,
|
|
53913
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53903
53914
|
if (ts.isBindingElement(visited)) {
|
|
53904
|
-
visited
|
|
53905
|
-
|
|
53915
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53916
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53917
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53918
|
+
/*initializer*/ undefined);
|
|
53919
|
+
}
|
|
53920
|
+
else {
|
|
53921
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53922
|
+
/*initializer*/ undefined);
|
|
53923
|
+
}
|
|
53906
53924
|
}
|
|
53907
53925
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53908
53926
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -59529,7 +59547,7 @@ var ts;
|
|
|
59529
59547
|
}
|
|
59530
59548
|
if (t.flags & 268435456 /* StringMapping */) {
|
|
59531
59549
|
var constraint = getBaseConstraint(t.type);
|
|
59532
|
-
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59550
|
+
return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59533
59551
|
}
|
|
59534
59552
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
59535
59553
|
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
@@ -62499,9 +62517,12 @@ var ts;
|
|
|
62499
62517
|
}
|
|
62500
62518
|
function getStringMappingType(symbol, type) {
|
|
62501
62519
|
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
62502
|
-
|
|
62503
|
-
|
|
62504
|
-
|
|
62520
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
62521
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
|
|
62522
|
+
isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
|
|
62523
|
+
type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
62524
|
+
type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
62525
|
+
type;
|
|
62505
62526
|
}
|
|
62506
62527
|
function applyStringMapping(symbol, str) {
|
|
62507
62528
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -62512,6 +62533,15 @@ var ts;
|
|
|
62512
62533
|
}
|
|
62513
62534
|
return str;
|
|
62514
62535
|
}
|
|
62536
|
+
function applyTemplateStringMapping(symbol, texts, types) {
|
|
62537
|
+
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
62538
|
+
case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62539
|
+
case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62540
|
+
case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
|
|
62541
|
+
case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
|
|
62542
|
+
}
|
|
62543
|
+
return [texts, types];
|
|
62544
|
+
}
|
|
62515
62545
|
function getStringMappingTypeForGenericType(symbol, type) {
|
|
62516
62546
|
var id = getSymbolId(symbol) + "," + getTypeId(type);
|
|
62517
62547
|
var result = stringMappingTypes.get(id);
|
|
@@ -62753,7 +62783,7 @@ var ts;
|
|
|
62753
62783
|
accessNode;
|
|
62754
62784
|
}
|
|
62755
62785
|
function isPatternLiteralPlaceholderType(type) {
|
|
62756
|
-
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
|
|
62786
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
|
|
62757
62787
|
}
|
|
62758
62788
|
function isPatternLiteralType(type) {
|
|
62759
62789
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
|
|
@@ -65675,8 +65705,13 @@ var ts;
|
|
|
65675
65705
|
return;
|
|
65676
65706
|
}
|
|
65677
65707
|
reportRelationError(headMessage, source, target);
|
|
65678
|
-
if (
|
|
65679
|
-
|
|
65708
|
+
if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) {
|
|
65709
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65710
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65711
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65712
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65713
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65714
|
+
}
|
|
65680
65715
|
}
|
|
65681
65716
|
}
|
|
65682
65717
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -66460,6 +66495,13 @@ var ts;
|
|
|
66460
66495
|
return -1 /* True */;
|
|
66461
66496
|
}
|
|
66462
66497
|
}
|
|
66498
|
+
else if (target.flags & 268435456 /* StringMapping */) {
|
|
66499
|
+
if (!(source.flags & 268435456 /* StringMapping */)) {
|
|
66500
|
+
if (isMemberOfStringMapping(source, target)) {
|
|
66501
|
+
return -1 /* True */;
|
|
66502
|
+
}
|
|
66503
|
+
}
|
|
66504
|
+
}
|
|
66463
66505
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
66464
66506
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
66465
66507
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
@@ -66503,7 +66545,10 @@ var ts;
|
|
|
66503
66545
|
}
|
|
66504
66546
|
}
|
|
66505
66547
|
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
66506
|
-
if (targetFlags & 268435456 /* StringMapping */
|
|
66548
|
+
if (targetFlags & 268435456 /* StringMapping */) {
|
|
66549
|
+
if (source.symbol !== target.symbol) {
|
|
66550
|
+
return 0 /* False */;
|
|
66551
|
+
}
|
|
66507
66552
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66508
66553
|
resetErrorInfo(saveErrorInfo);
|
|
66509
66554
|
return result;
|
|
@@ -67428,7 +67473,7 @@ var ts;
|
|
|
67428
67473
|
return typeCouldHaveTopLevelSingletonTypes(constraint);
|
|
67429
67474
|
}
|
|
67430
67475
|
}
|
|
67431
|
-
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
|
|
67476
|
+
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
|
|
67432
67477
|
}
|
|
67433
67478
|
function getExactOptionalUnassignableProperties(source, target) {
|
|
67434
67479
|
if (isTupleType(source) && isTupleType(target))
|
|
@@ -68226,12 +68271,13 @@ var ts;
|
|
|
68226
68271
|
* with no call or construct signatures.
|
|
68227
68272
|
*/
|
|
68228
68273
|
function isObjectTypeWithInferableIndex(type) {
|
|
68274
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68229
68275
|
return type.flags & 2097152 /* Intersection */
|
|
68230
68276
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68231
68277
|
: !!(type.symbol
|
|
68232
68278
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68233
68279
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68234
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68280
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68235
68281
|
}
|
|
68236
68282
|
function createSymbolWithType(source, type) {
|
|
68237
68283
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -68898,6 +68944,31 @@ var ts;
|
|
|
68898
68944
|
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68899
68945
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68900
68946
|
}
|
|
68947
|
+
function isMemberOfStringMapping(source, target) {
|
|
68948
|
+
if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
|
|
68949
|
+
return true;
|
|
68950
|
+
}
|
|
68951
|
+
if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
68952
|
+
return isTypeAssignableTo(source, target);
|
|
68953
|
+
}
|
|
68954
|
+
if (target.flags & 268435456 /* StringMapping */) {
|
|
68955
|
+
// We need to see whether applying the same mappings of the target
|
|
68956
|
+
// onto the source would produce an identical type *and* that
|
|
68957
|
+
// it's compatible with the inner-most non-string-mapped type.
|
|
68958
|
+
//
|
|
68959
|
+
// The intuition here is that if same mappings don't affect the source at all,
|
|
68960
|
+
// and the source is compatible with the unmapped target, then they must
|
|
68961
|
+
// still reside in the same domain.
|
|
68962
|
+
var mappingStack = [];
|
|
68963
|
+
while (target.flags & 268435456 /* StringMapping */) {
|
|
68964
|
+
mappingStack.unshift(target.symbol);
|
|
68965
|
+
target = target.type;
|
|
68966
|
+
}
|
|
68967
|
+
var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
|
|
68968
|
+
return mappedSource === source && isMemberOfStringMapping(source, target);
|
|
68969
|
+
}
|
|
68970
|
+
return false;
|
|
68971
|
+
}
|
|
68901
68972
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68902
68973
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68903
68974
|
return true;
|
|
@@ -68906,7 +68977,8 @@ var ts;
|
|
|
68906
68977
|
var value = source.value;
|
|
68907
68978
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68908
68979
|
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68909
|
-
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName
|
|
68980
|
+
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
|
|
68981
|
+
target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
|
|
68910
68982
|
}
|
|
68911
68983
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
68912
68984
|
var texts = source.texts;
|
|
@@ -82830,6 +82902,22 @@ var ts;
|
|
|
82830
82902
|
}
|
|
82831
82903
|
});
|
|
82832
82904
|
}
|
|
82905
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82906
|
+
var _a;
|
|
82907
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82908
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82909
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82910
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82911
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82912
|
+
var diagnostic = ts.createDiagnosticForNode(node.name, ts.Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, ts.declarationNameToString(node.name), ts.declarationNameToString(node.propertyName));
|
|
82913
|
+
if (!wrappingDeclaration.type) {
|
|
82914
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82915
|
+
ts.addRelatedInfo(diagnostic, ts.createFileDiagnostic(ts.getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, ts.Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, ts.declarationNameToString(node.propertyName)));
|
|
82916
|
+
}
|
|
82917
|
+
diagnostics.add(diagnostic);
|
|
82918
|
+
}
|
|
82919
|
+
}
|
|
82920
|
+
}
|
|
82833
82921
|
function bindingNameText(name) {
|
|
82834
82922
|
switch (name.kind) {
|
|
82835
82923
|
case 79 /* Identifier */:
|
|
@@ -83131,6 +83219,17 @@ var ts;
|
|
|
83131
83219
|
}
|
|
83132
83220
|
}
|
|
83133
83221
|
if (ts.isBindingElement(node)) {
|
|
83222
|
+
if (node.propertyName &&
|
|
83223
|
+
ts.isIdentifier(node.name) &&
|
|
83224
|
+
ts.isParameterDeclaration(node) &&
|
|
83225
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
83226
|
+
// type F = ({a: string}) => void;
|
|
83227
|
+
// ^^^^^^
|
|
83228
|
+
// variable renaming in function type notation is confusing,
|
|
83229
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
83230
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
83231
|
+
return;
|
|
83232
|
+
}
|
|
83134
83233
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
83135
83234
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
83136
83235
|
}
|
|
@@ -86594,6 +86693,7 @@ var ts;
|
|
|
86594
86693
|
ts.clear(potentialNewTargetCollisions);
|
|
86595
86694
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86596
86695
|
ts.clear(potentialReflectCollisions);
|
|
86696
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86597
86697
|
ts.forEach(node.statements, checkSourceElement);
|
|
86598
86698
|
checkSourceElement(node.endOfFileToken);
|
|
86599
86699
|
checkDeferredNodes(node);
|
|
@@ -86609,6 +86709,9 @@ var ts;
|
|
|
86609
86709
|
}
|
|
86610
86710
|
});
|
|
86611
86711
|
}
|
|
86712
|
+
if (!node.isDeclarationFile) {
|
|
86713
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86714
|
+
}
|
|
86612
86715
|
});
|
|
86613
86716
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86614
86717
|
!node.isDeclarationFile &&
|
|
@@ -109350,7 +109453,7 @@ var ts;
|
|
|
109350
109453
|
});
|
|
109351
109454
|
return ret;
|
|
109352
109455
|
}
|
|
109353
|
-
function
|
|
109456
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109354
109457
|
if (name.kind === 79 /* Identifier */) {
|
|
109355
109458
|
return name;
|
|
109356
109459
|
}
|
|
@@ -109366,7 +109469,12 @@ var ts;
|
|
|
109366
109469
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109367
109470
|
return elem;
|
|
109368
109471
|
}
|
|
109369
|
-
|
|
109472
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109473
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109474
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109475
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109476
|
+
}
|
|
109477
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109370
109478
|
}
|
|
109371
109479
|
}
|
|
109372
109480
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109375,7 +109483,7 @@ var ts;
|
|
|
109375
109483
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109376
109484
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109377
109485
|
}
|
|
109378
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109486
|
+
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
|
|
109379
109487
|
ensureNoInitializer(p));
|
|
109380
109488
|
if (!suppressNewDiagnosticContexts) {
|
|
109381
109489
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -117518,6 +117626,7 @@ var ts;
|
|
|
117518
117626
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117519
117627
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117520
117628
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117629
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117521
117630
|
]);
|
|
117522
117631
|
/**
|
|
117523
117632
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -135327,7 +135436,7 @@ var ts;
|
|
|
135327
135436
|
}
|
|
135328
135437
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
135329
135438
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
|
|
135330
|
-
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
135439
|
+
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
|
|
135331
135440
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
135332
135441
|
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
135333
135442
|
var symbol = _a[_i];
|
|
@@ -144665,10 +144774,10 @@ var ts;
|
|
|
144665
144774
|
(function (ts) {
|
|
144666
144775
|
var Rename;
|
|
144667
144776
|
(function (Rename) {
|
|
144668
|
-
function getRenameInfo(program, sourceFile, position,
|
|
144777
|
+
function getRenameInfo(program, sourceFile, position, preferences) {
|
|
144669
144778
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
144670
144779
|
if (nodeIsEligibleForRename(node)) {
|
|
144671
|
-
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program,
|
|
144780
|
+
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
|
|
144672
144781
|
if (renameInfo) {
|
|
144673
144782
|
return renameInfo;
|
|
144674
144783
|
}
|
|
@@ -144676,7 +144785,7 @@ var ts;
|
|
|
144676
144785
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
|
|
144677
144786
|
}
|
|
144678
144787
|
Rename.getRenameInfo = getRenameInfo;
|
|
144679
|
-
function getRenameInfoForNode(node, typeChecker, sourceFile, program,
|
|
144788
|
+
function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
|
|
144680
144789
|
var symbol = typeChecker.getSymbolAtLocation(node);
|
|
144681
144790
|
if (!symbol) {
|
|
144682
144791
|
if (ts.isStringLiteralLike(node)) {
|
|
@@ -144704,7 +144813,12 @@ var ts;
|
|
|
144704
144813
|
return undefined;
|
|
144705
144814
|
}
|
|
144706
144815
|
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
|
|
144707
|
-
return
|
|
144816
|
+
return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
|
|
144817
|
+
}
|
|
144818
|
+
// Disallow rename for elements that would rename across `*/node_modules/*` packages.
|
|
144819
|
+
var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
|
|
144820
|
+
if (wouldRenameNodeModules) {
|
|
144821
|
+
return getRenameInfoError(wouldRenameNodeModules);
|
|
144708
144822
|
}
|
|
144709
144823
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
|
144710
144824
|
var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
|
|
@@ -144718,6 +144832,49 @@ var ts;
|
|
|
144718
144832
|
var sourceFile = declaration.getSourceFile();
|
|
144719
144833
|
return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
|
|
144720
144834
|
}
|
|
144835
|
+
function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
|
|
144836
|
+
if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
|
|
144837
|
+
var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
|
|
144838
|
+
if (importSpecifier && !importSpecifier.propertyName) {
|
|
144839
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
144840
|
+
}
|
|
144841
|
+
}
|
|
144842
|
+
var declarations = symbol.declarations;
|
|
144843
|
+
if (!declarations) {
|
|
144844
|
+
return undefined;
|
|
144845
|
+
}
|
|
144846
|
+
var originalPackage = getPackagePathComponents(originalFile.path);
|
|
144847
|
+
if (originalPackage === undefined) { // original source file is not in node_modules
|
|
144848
|
+
if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
|
|
144849
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
|
|
144850
|
+
}
|
|
144851
|
+
else {
|
|
144852
|
+
return undefined;
|
|
144853
|
+
}
|
|
144854
|
+
}
|
|
144855
|
+
// original source file is in node_modules
|
|
144856
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
144857
|
+
var declaration = declarations_4[_i];
|
|
144858
|
+
var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
|
|
144859
|
+
if (declPackage) {
|
|
144860
|
+
var length_2 = Math.min(originalPackage.length, declPackage.length);
|
|
144861
|
+
for (var i = 0; i <= length_2; i++) {
|
|
144862
|
+
if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
|
|
144863
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
|
|
144864
|
+
}
|
|
144865
|
+
}
|
|
144866
|
+
}
|
|
144867
|
+
}
|
|
144868
|
+
return undefined;
|
|
144869
|
+
}
|
|
144870
|
+
function getPackagePathComponents(filePath) {
|
|
144871
|
+
var components = ts.getPathComponents(filePath);
|
|
144872
|
+
var nodeModulesIdx = components.lastIndexOf("node_modules");
|
|
144873
|
+
if (nodeModulesIdx === -1) {
|
|
144874
|
+
return undefined;
|
|
144875
|
+
}
|
|
144876
|
+
return components.slice(0, nodeModulesIdx + 2);
|
|
144877
|
+
}
|
|
144721
144878
|
function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
|
|
144722
144879
|
if (!ts.isExternalModuleNameRelative(node.text)) {
|
|
144723
144880
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
|
|
@@ -145772,7 +145929,7 @@ var ts;
|
|
|
145772
145929
|
return type.symbol && (type.symbol.flags & 1536 /* Module */);
|
|
145773
145930
|
}
|
|
145774
145931
|
function visitVariableLikeDeclaration(decl) {
|
|
145775
|
-
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
|
|
145932
|
+
if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
|
145776
145933
|
return;
|
|
145777
145934
|
}
|
|
145778
145935
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
|
|
@@ -145900,6 +146057,9 @@ var ts;
|
|
|
145900
146057
|
}
|
|
145901
146058
|
for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
|
145902
146059
|
var param = node.parameters[i];
|
|
146060
|
+
if (!isHintableDeclaration(param)) {
|
|
146061
|
+
continue;
|
|
146062
|
+
}
|
|
145903
146063
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
|
|
145904
146064
|
if (effectiveTypeAnnotation) {
|
|
145905
146065
|
continue;
|
|
@@ -145941,6 +146101,13 @@ var ts;
|
|
|
145941
146101
|
function isUndefined(name) {
|
|
145942
146102
|
return name === "undefined";
|
|
145943
146103
|
}
|
|
146104
|
+
function isHintableDeclaration(node) {
|
|
146105
|
+
if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
|
|
146106
|
+
var initializer = ts.skipParentheses(node.initializer);
|
|
146107
|
+
return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
|
|
146108
|
+
}
|
|
146109
|
+
return true;
|
|
146110
|
+
}
|
|
145944
146111
|
}
|
|
145945
146112
|
InlayHints.provideInlayHints = provideInlayHints;
|
|
145946
146113
|
})(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
|
|
@@ -155379,6 +155546,77 @@ var ts;
|
|
|
155379
155546
|
})(ts || (ts = {}));
|
|
155380
155547
|
/* @internal */
|
|
155381
155548
|
var ts;
|
|
155549
|
+
(function (ts) {
|
|
155550
|
+
var codefix;
|
|
155551
|
+
(function (codefix) {
|
|
155552
|
+
var fixId = "addMissingConstraint";
|
|
155553
|
+
var errorCodes = [
|
|
155554
|
+
// We want errors this could be attached to:
|
|
155555
|
+
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
155556
|
+
ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
155557
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
|
|
155558
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
|
|
155559
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
155560
|
+
ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
|
|
155561
|
+
ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
|
|
155562
|
+
ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
|
|
155563
|
+
ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
|
|
155564
|
+
];
|
|
155565
|
+
codefix.registerCodeFix({
|
|
155566
|
+
errorCodes: errorCodes,
|
|
155567
|
+
getCodeActions: function (context) {
|
|
155568
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155569
|
+
var related = getDiagnosticRelatedInfo(program, sourceFile, span);
|
|
155570
|
+
if (!related) {
|
|
155571
|
+
return;
|
|
155572
|
+
}
|
|
155573
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155574
|
+
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155575
|
+
},
|
|
155576
|
+
fixIds: [fixId],
|
|
155577
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
155578
|
+
var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
|
|
155579
|
+
if (!info)
|
|
155580
|
+
return;
|
|
155581
|
+
return addMissingConstraint(changes, info);
|
|
155582
|
+
}); },
|
|
155583
|
+
});
|
|
155584
|
+
function getDiagnosticRelatedInfo(program, sourceFile, span) {
|
|
155585
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155586
|
+
if (!diag || !diag.relatedInformation)
|
|
155587
|
+
return;
|
|
155588
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155589
|
+
if (!related)
|
|
155590
|
+
return;
|
|
155591
|
+
return related;
|
|
155592
|
+
}
|
|
155593
|
+
function addMissingConstraint(changes, related) {
|
|
155594
|
+
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155595
|
+
if (!decl)
|
|
155596
|
+
return;
|
|
155597
|
+
if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
|
|
155598
|
+
decl = decl.parent;
|
|
155599
|
+
}
|
|
155600
|
+
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155601
|
+
return; // should only issue fix on type parameters written using `extends`
|
|
155602
|
+
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155603
|
+
if (!newConstraint)
|
|
155604
|
+
return;
|
|
155605
|
+
var newConstraintText = newConstraint[1];
|
|
155606
|
+
changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
|
|
155607
|
+
}
|
|
155608
|
+
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155609
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155610
|
+
var end = ts.textSpanEnd(span);
|
|
155611
|
+
while (token.end < end) {
|
|
155612
|
+
token = token.parent;
|
|
155613
|
+
}
|
|
155614
|
+
return token;
|
|
155615
|
+
}
|
|
155616
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155617
|
+
})(ts || (ts = {}));
|
|
155618
|
+
/* @internal */
|
|
155619
|
+
var ts;
|
|
155382
155620
|
(function (ts) {
|
|
155383
155621
|
var codefix;
|
|
155384
155622
|
(function (codefix) {
|
|
@@ -161676,11 +161914,11 @@ var ts;
|
|
|
161676
161914
|
}
|
|
161677
161915
|
}
|
|
161678
161916
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
161679
|
-
var
|
|
161917
|
+
var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
161680
161918
|
var numInitializers = 0;
|
|
161681
161919
|
var lastInitializer = void 0;
|
|
161682
|
-
for (var _i = 0,
|
|
161683
|
-
var declaration =
|
|
161920
|
+
for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
|
|
161921
|
+
var declaration = declarations_5[_i];
|
|
161684
161922
|
if (declaration.initializer) {
|
|
161685
161923
|
numInitializers++;
|
|
161686
161924
|
lastInitializer = declaration.initializer;
|
|
@@ -165817,8 +166055,8 @@ var ts;
|
|
|
165817
166055
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
165818
166056
|
}
|
|
165819
166057
|
};
|
|
165820
|
-
for (var _i = 0,
|
|
165821
|
-
var declaration =
|
|
166058
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
166059
|
+
var declaration = declarations_7[_i];
|
|
165822
166060
|
_loop_21(declaration);
|
|
165823
166061
|
}
|
|
165824
166062
|
}
|
|
@@ -165844,8 +166082,8 @@ var ts;
|
|
|
165844
166082
|
if (inheritedDocs)
|
|
165845
166083
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
165846
166084
|
};
|
|
165847
|
-
for (var _i = 0,
|
|
165848
|
-
var declaration =
|
|
166085
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
166086
|
+
var declaration = declarations_8[_i];
|
|
165849
166087
|
_loop_22(declaration);
|
|
165850
166088
|
}
|
|
165851
166089
|
}
|
|
@@ -167422,9 +167660,9 @@ var ts;
|
|
|
167422
167660
|
return ts.stringContains(path, "/node_modules/");
|
|
167423
167661
|
}
|
|
167424
167662
|
}
|
|
167425
|
-
function getRenameInfo(fileName, position,
|
|
167663
|
+
function getRenameInfo(fileName, position, preferences) {
|
|
167426
167664
|
synchronizeHostData();
|
|
167427
|
-
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position,
|
|
167665
|
+
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
|
|
167428
167666
|
}
|
|
167429
167667
|
function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
|
|
167430
167668
|
var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
|
|
@@ -168790,9 +169028,9 @@ var ts;
|
|
|
168790
169028
|
var _this = this;
|
|
168791
169029
|
return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
|
|
168792
169030
|
};
|
|
168793
|
-
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position,
|
|
169031
|
+
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
|
|
168794
169032
|
var _this = this;
|
|
168795
|
-
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position,
|
|
169033
|
+
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
|
|
168796
169034
|
};
|
|
168797
169035
|
LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
|
|
168798
169036
|
var _this = this;
|