typescript 4.8.0-dev.20220613 → 4.8.0-dev.20220616
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 +68 -16
- package/lib/tsserver.js +466 -33
- package/lib/tsserverlibrary.d.ts +10 -2
- package/lib/tsserverlibrary.js +405 -32
- package/lib/typescript.js +160 -18
- package/lib/typescriptServices.js +160 -18
- package/lib/typingsInstaller.js +78 -17
- package/package.json +2 -1
|
@@ -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.20220616";
|
|
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}'."),
|
|
@@ -35970,10 +35974,11 @@ var ts;
|
|
|
35970
35974
|
}
|
|
35971
35975
|
nextToken();
|
|
35972
35976
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35973
|
-
if (
|
|
35977
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35974
35978
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35975
35979
|
return undefined;
|
|
35976
35980
|
}
|
|
35981
|
+
nextToken();
|
|
35977
35982
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35978
35983
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35979
35984
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -49387,6 +49392,7 @@ var ts;
|
|
|
49387
49392
|
var potentialNewTargetCollisions = [];
|
|
49388
49393
|
var potentialWeakMapSetCollisions = [];
|
|
49389
49394
|
var potentialReflectCollisions = [];
|
|
49395
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49390
49396
|
var awaitedTypeStack = [];
|
|
49391
49397
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49392
49398
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -52722,6 +52728,9 @@ var ts;
|
|
|
52722
52728
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52723
52729
|
return { accessibility: 0 /* Accessible */ };
|
|
52724
52730
|
}
|
|
52731
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52732
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52733
|
+
}
|
|
52725
52734
|
// Verify if the symbol is accessible
|
|
52726
52735
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52727
52736
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -53894,15 +53903,22 @@ var ts;
|
|
|
53894
53903
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53895
53904
|
return parameterNode;
|
|
53896
53905
|
function cloneBindingName(node) {
|
|
53897
|
-
return
|
|
53898
|
-
function
|
|
53906
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53907
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53899
53908
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53900
53909
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53901
53910
|
}
|
|
53902
|
-
var visited = ts.visitEachChild(node,
|
|
53911
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53903
53912
|
if (ts.isBindingElement(visited)) {
|
|
53904
|
-
visited
|
|
53905
|
-
|
|
53913
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53914
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53915
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53916
|
+
/*initializer*/ undefined);
|
|
53917
|
+
}
|
|
53918
|
+
else {
|
|
53919
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53920
|
+
/*initializer*/ undefined);
|
|
53921
|
+
}
|
|
53906
53922
|
}
|
|
53907
53923
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53908
53924
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -65112,7 +65128,7 @@ var ts;
|
|
|
65112
65128
|
return true;
|
|
65113
65129
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
65114
65130
|
return true;
|
|
65115
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
65131
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */)))
|
|
65116
65132
|
return true;
|
|
65117
65133
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
65118
65134
|
if (s & 1 /* Any */)
|
|
@@ -65675,8 +65691,13 @@ var ts;
|
|
|
65675
65691
|
return;
|
|
65676
65692
|
}
|
|
65677
65693
|
reportRelationError(headMessage, source, target);
|
|
65678
|
-
if (
|
|
65679
|
-
|
|
65694
|
+
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)) {
|
|
65695
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65696
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65697
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65698
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65699
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65700
|
+
}
|
|
65680
65701
|
}
|
|
65681
65702
|
}
|
|
65682
65703
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -65815,7 +65836,7 @@ var ts;
|
|
|
65815
65836
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
65816
65837
|
}
|
|
65817
65838
|
if (target.flags & 2097152 /* Intersection */) {
|
|
65818
|
-
return typeRelatedToEachType(
|
|
65839
|
+
return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */);
|
|
65819
65840
|
}
|
|
65820
65841
|
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
65821
65842
|
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
@@ -68226,12 +68247,13 @@ var ts;
|
|
|
68226
68247
|
* with no call or construct signatures.
|
|
68227
68248
|
*/
|
|
68228
68249
|
function isObjectTypeWithInferableIndex(type) {
|
|
68250
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68229
68251
|
return type.flags & 2097152 /* Intersection */
|
|
68230
68252
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68231
68253
|
: !!(type.symbol
|
|
68232
68254
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68233
68255
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68234
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68256
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68235
68257
|
}
|
|
68236
68258
|
function createSymbolWithType(source, type) {
|
|
68237
68259
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -82830,6 +82852,22 @@ var ts;
|
|
|
82830
82852
|
}
|
|
82831
82853
|
});
|
|
82832
82854
|
}
|
|
82855
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82856
|
+
var _a;
|
|
82857
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82858
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82859
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82860
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82861
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82862
|
+
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));
|
|
82863
|
+
if (!wrappingDeclaration.type) {
|
|
82864
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82865
|
+
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)));
|
|
82866
|
+
}
|
|
82867
|
+
diagnostics.add(diagnostic);
|
|
82868
|
+
}
|
|
82869
|
+
}
|
|
82870
|
+
}
|
|
82833
82871
|
function bindingNameText(name) {
|
|
82834
82872
|
switch (name.kind) {
|
|
82835
82873
|
case 79 /* Identifier */:
|
|
@@ -83131,6 +83169,17 @@ var ts;
|
|
|
83131
83169
|
}
|
|
83132
83170
|
}
|
|
83133
83171
|
if (ts.isBindingElement(node)) {
|
|
83172
|
+
if (node.propertyName &&
|
|
83173
|
+
ts.isIdentifier(node.name) &&
|
|
83174
|
+
ts.isParameterDeclaration(node) &&
|
|
83175
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
83176
|
+
// type F = ({a: string}) => void;
|
|
83177
|
+
// ^^^^^^
|
|
83178
|
+
// variable renaming in function type notation is confusing,
|
|
83179
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
83180
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
83181
|
+
return;
|
|
83182
|
+
}
|
|
83134
83183
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
83135
83184
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
83136
83185
|
}
|
|
@@ -86594,6 +86643,7 @@ var ts;
|
|
|
86594
86643
|
ts.clear(potentialNewTargetCollisions);
|
|
86595
86644
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86596
86645
|
ts.clear(potentialReflectCollisions);
|
|
86646
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86597
86647
|
ts.forEach(node.statements, checkSourceElement);
|
|
86598
86648
|
checkSourceElement(node.endOfFileToken);
|
|
86599
86649
|
checkDeferredNodes(node);
|
|
@@ -86609,6 +86659,9 @@ var ts;
|
|
|
86609
86659
|
}
|
|
86610
86660
|
});
|
|
86611
86661
|
}
|
|
86662
|
+
if (!node.isDeclarationFile) {
|
|
86663
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86664
|
+
}
|
|
86612
86665
|
});
|
|
86613
86666
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86614
86667
|
!node.isDeclarationFile &&
|
|
@@ -109350,7 +109403,7 @@ var ts;
|
|
|
109350
109403
|
});
|
|
109351
109404
|
return ret;
|
|
109352
109405
|
}
|
|
109353
|
-
function
|
|
109406
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109354
109407
|
if (name.kind === 79 /* Identifier */) {
|
|
109355
109408
|
return name;
|
|
109356
109409
|
}
|
|
@@ -109366,7 +109419,12 @@ var ts;
|
|
|
109366
109419
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109367
109420
|
return elem;
|
|
109368
109421
|
}
|
|
109369
|
-
|
|
109422
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109423
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109424
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109425
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109426
|
+
}
|
|
109427
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109370
109428
|
}
|
|
109371
109429
|
}
|
|
109372
109430
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109375,7 +109433,7 @@ var ts;
|
|
|
109375
109433
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109376
109434
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109377
109435
|
}
|
|
109378
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109436
|
+
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
109437
|
ensureNoInitializer(p));
|
|
109380
109438
|
if (!suppressNewDiagnosticContexts) {
|
|
109381
109439
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -117518,6 +117576,7 @@ var ts;
|
|
|
117518
117576
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117519
117577
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117520
117578
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117579
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117521
117580
|
]);
|
|
117522
117581
|
/**
|
|
117523
117582
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -122652,9 +122711,11 @@ var ts;
|
|
|
122652
122711
|
}
|
|
122653
122712
|
function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
|
|
122654
122713
|
ts.Debug.assert(!!resolution.refCount);
|
|
122714
|
+
var affectingLocations = resolution.affectingLocations;
|
|
122715
|
+
if (!affectingLocations.length)
|
|
122716
|
+
return;
|
|
122655
122717
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
122656
122718
|
resolutionsWithOnlyAffectingLocations.push(resolution);
|
|
122657
|
-
var affectingLocations = resolution.affectingLocations;
|
|
122658
122719
|
// Watch package json
|
|
122659
122720
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122660
122721
|
var affectingLocation = affectingLocations_1[_i];
|
|
@@ -145770,7 +145831,7 @@ var ts;
|
|
|
145770
145831
|
return type.symbol && (type.symbol.flags & 1536 /* Module */);
|
|
145771
145832
|
}
|
|
145772
145833
|
function visitVariableLikeDeclaration(decl) {
|
|
145773
|
-
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
|
|
145834
|
+
if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
|
145774
145835
|
return;
|
|
145775
145836
|
}
|
|
145776
145837
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
|
|
@@ -145898,6 +145959,9 @@ var ts;
|
|
|
145898
145959
|
}
|
|
145899
145960
|
for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
|
145900
145961
|
var param = node.parameters[i];
|
|
145962
|
+
if (!isHintableDeclaration(param)) {
|
|
145963
|
+
continue;
|
|
145964
|
+
}
|
|
145901
145965
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
|
|
145902
145966
|
if (effectiveTypeAnnotation) {
|
|
145903
145967
|
continue;
|
|
@@ -145939,6 +146003,13 @@ var ts;
|
|
|
145939
146003
|
function isUndefined(name) {
|
|
145940
146004
|
return name === "undefined";
|
|
145941
146005
|
}
|
|
146006
|
+
function isHintableDeclaration(node) {
|
|
146007
|
+
if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
|
|
146008
|
+
var initializer = ts.skipParentheses(node.initializer);
|
|
146009
|
+
return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
|
|
146010
|
+
}
|
|
146011
|
+
return true;
|
|
146012
|
+
}
|
|
145942
146013
|
}
|
|
145943
146014
|
InlayHints.provideInlayHints = provideInlayHints;
|
|
145944
146015
|
})(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
|
|
@@ -155377,6 +155448,77 @@ var ts;
|
|
|
155377
155448
|
})(ts || (ts = {}));
|
|
155378
155449
|
/* @internal */
|
|
155379
155450
|
var ts;
|
|
155451
|
+
(function (ts) {
|
|
155452
|
+
var codefix;
|
|
155453
|
+
(function (codefix) {
|
|
155454
|
+
var fixId = "addMissingConstraint";
|
|
155455
|
+
var errorCodes = [
|
|
155456
|
+
// We want errors this could be attached to:
|
|
155457
|
+
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
155458
|
+
ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
155459
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
|
|
155460
|
+
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,
|
|
155461
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
155462
|
+
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,
|
|
155463
|
+
ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
|
|
155464
|
+
ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
|
|
155465
|
+
ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
|
|
155466
|
+
];
|
|
155467
|
+
codefix.registerCodeFix({
|
|
155468
|
+
errorCodes: errorCodes,
|
|
155469
|
+
getCodeActions: function (context) {
|
|
155470
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155471
|
+
var related = getDiagnosticRelatedInfo(program, sourceFile, span);
|
|
155472
|
+
if (!related) {
|
|
155473
|
+
return;
|
|
155474
|
+
}
|
|
155475
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155476
|
+
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155477
|
+
},
|
|
155478
|
+
fixIds: [fixId],
|
|
155479
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
155480
|
+
var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
|
|
155481
|
+
if (!info)
|
|
155482
|
+
return;
|
|
155483
|
+
return addMissingConstraint(changes, info);
|
|
155484
|
+
}); },
|
|
155485
|
+
});
|
|
155486
|
+
function getDiagnosticRelatedInfo(program, sourceFile, span) {
|
|
155487
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155488
|
+
if (!diag || !diag.relatedInformation)
|
|
155489
|
+
return;
|
|
155490
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155491
|
+
if (!related)
|
|
155492
|
+
return;
|
|
155493
|
+
return related;
|
|
155494
|
+
}
|
|
155495
|
+
function addMissingConstraint(changes, related) {
|
|
155496
|
+
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155497
|
+
if (!decl)
|
|
155498
|
+
return;
|
|
155499
|
+
if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
|
|
155500
|
+
decl = decl.parent;
|
|
155501
|
+
}
|
|
155502
|
+
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155503
|
+
return; // should only issue fix on type parameters written using `extends`
|
|
155504
|
+
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155505
|
+
if (!newConstraint)
|
|
155506
|
+
return;
|
|
155507
|
+
var newConstraintText = newConstraint[1];
|
|
155508
|
+
changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
|
|
155509
|
+
}
|
|
155510
|
+
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155511
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155512
|
+
var end = ts.textSpanEnd(span);
|
|
155513
|
+
while (token.end < end) {
|
|
155514
|
+
token = token.parent;
|
|
155515
|
+
}
|
|
155516
|
+
return token;
|
|
155517
|
+
}
|
|
155518
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155519
|
+
})(ts || (ts = {}));
|
|
155520
|
+
/* @internal */
|
|
155521
|
+
var ts;
|
|
155380
155522
|
(function (ts) {
|
|
155381
155523
|
var codefix;
|
|
155382
155524
|
(function (codefix) {
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220616";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8463,9 +8463,11 @@ var ts;
|
|
|
8463
8463
|
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),
|
|
8464
8464
|
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."),
|
|
8465
8465
|
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."),
|
|
8466
|
-
|
|
8466
|
+
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."),
|
|
8467
8467
|
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."),
|
|
8468
8468
|
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."),
|
|
8469
|
+
Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
8470
|
+
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"),
|
|
8469
8471
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8470
8472
|
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."),
|
|
8471
8473
|
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."),
|
|
@@ -8951,6 +8953,8 @@ var ts;
|
|
|
8951
8953
|
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."),
|
|
8952
8954
|
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"),
|
|
8953
8955
|
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'."),
|
|
8956
|
+
_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?"),
|
|
8957
|
+
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."),
|
|
8954
8958
|
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}'."),
|
|
8955
8959
|
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}'."),
|
|
8956
8960
|
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}'."),
|
|
@@ -35765,10 +35769,11 @@ var ts;
|
|
|
35765
35769
|
}
|
|
35766
35770
|
nextToken();
|
|
35767
35771
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35768
|
-
if (
|
|
35772
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35769
35773
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35770
35774
|
return undefined;
|
|
35771
35775
|
}
|
|
35776
|
+
nextToken();
|
|
35772
35777
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35773
35778
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35774
35779
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -49182,6 +49187,7 @@ var ts;
|
|
|
49182
49187
|
var potentialNewTargetCollisions = [];
|
|
49183
49188
|
var potentialWeakMapSetCollisions = [];
|
|
49184
49189
|
var potentialReflectCollisions = [];
|
|
49190
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49185
49191
|
var awaitedTypeStack = [];
|
|
49186
49192
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49187
49193
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -52517,6 +52523,9 @@ var ts;
|
|
|
52517
52523
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52518
52524
|
return { accessibility: 0 /* Accessible */ };
|
|
52519
52525
|
}
|
|
52526
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52527
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52528
|
+
}
|
|
52520
52529
|
// Verify if the symbol is accessible
|
|
52521
52530
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52522
52531
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -53689,15 +53698,22 @@ var ts;
|
|
|
53689
53698
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53690
53699
|
return parameterNode;
|
|
53691
53700
|
function cloneBindingName(node) {
|
|
53692
|
-
return
|
|
53693
|
-
function
|
|
53701
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53702
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53694
53703
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53695
53704
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53696
53705
|
}
|
|
53697
|
-
var visited = ts.visitEachChild(node,
|
|
53706
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53698
53707
|
if (ts.isBindingElement(visited)) {
|
|
53699
|
-
visited
|
|
53700
|
-
|
|
53708
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53709
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53710
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53711
|
+
/*initializer*/ undefined);
|
|
53712
|
+
}
|
|
53713
|
+
else {
|
|
53714
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53715
|
+
/*initializer*/ undefined);
|
|
53716
|
+
}
|
|
53701
53717
|
}
|
|
53702
53718
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53703
53719
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -64907,7 +64923,7 @@ var ts;
|
|
|
64907
64923
|
return true;
|
|
64908
64924
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
64909
64925
|
return true;
|
|
64910
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
64926
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */)))
|
|
64911
64927
|
return true;
|
|
64912
64928
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
64913
64929
|
if (s & 1 /* Any */)
|
|
@@ -65470,8 +65486,13 @@ var ts;
|
|
|
65470
65486
|
return;
|
|
65471
65487
|
}
|
|
65472
65488
|
reportRelationError(headMessage, source, target);
|
|
65473
|
-
if (
|
|
65474
|
-
|
|
65489
|
+
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)) {
|
|
65490
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65491
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65492
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65493
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65494
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65495
|
+
}
|
|
65475
65496
|
}
|
|
65476
65497
|
}
|
|
65477
65498
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -65610,7 +65631,7 @@ var ts;
|
|
|
65610
65631
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
65611
65632
|
}
|
|
65612
65633
|
if (target.flags & 2097152 /* Intersection */) {
|
|
65613
|
-
return typeRelatedToEachType(
|
|
65634
|
+
return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */);
|
|
65614
65635
|
}
|
|
65615
65636
|
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
65616
65637
|
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
@@ -68021,12 +68042,13 @@ var ts;
|
|
|
68021
68042
|
* with no call or construct signatures.
|
|
68022
68043
|
*/
|
|
68023
68044
|
function isObjectTypeWithInferableIndex(type) {
|
|
68045
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68024
68046
|
return type.flags & 2097152 /* Intersection */
|
|
68025
68047
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68026
68048
|
: !!(type.symbol
|
|
68027
68049
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68028
68050
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68029
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68051
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68030
68052
|
}
|
|
68031
68053
|
function createSymbolWithType(source, type) {
|
|
68032
68054
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -82625,6 +82647,22 @@ var ts;
|
|
|
82625
82647
|
}
|
|
82626
82648
|
});
|
|
82627
82649
|
}
|
|
82650
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82651
|
+
var _a;
|
|
82652
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82653
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82654
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82655
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82656
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82657
|
+
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));
|
|
82658
|
+
if (!wrappingDeclaration.type) {
|
|
82659
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82660
|
+
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)));
|
|
82661
|
+
}
|
|
82662
|
+
diagnostics.add(diagnostic);
|
|
82663
|
+
}
|
|
82664
|
+
}
|
|
82665
|
+
}
|
|
82628
82666
|
function bindingNameText(name) {
|
|
82629
82667
|
switch (name.kind) {
|
|
82630
82668
|
case 79 /* Identifier */:
|
|
@@ -82926,6 +82964,17 @@ var ts;
|
|
|
82926
82964
|
}
|
|
82927
82965
|
}
|
|
82928
82966
|
if (ts.isBindingElement(node)) {
|
|
82967
|
+
if (node.propertyName &&
|
|
82968
|
+
ts.isIdentifier(node.name) &&
|
|
82969
|
+
ts.isParameterDeclaration(node) &&
|
|
82970
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
82971
|
+
// type F = ({a: string}) => void;
|
|
82972
|
+
// ^^^^^^
|
|
82973
|
+
// variable renaming in function type notation is confusing,
|
|
82974
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
82975
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
82976
|
+
return;
|
|
82977
|
+
}
|
|
82929
82978
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
82930
82979
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
82931
82980
|
}
|
|
@@ -86389,6 +86438,7 @@ var ts;
|
|
|
86389
86438
|
ts.clear(potentialNewTargetCollisions);
|
|
86390
86439
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86391
86440
|
ts.clear(potentialReflectCollisions);
|
|
86441
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86392
86442
|
ts.forEach(node.statements, checkSourceElement);
|
|
86393
86443
|
checkSourceElement(node.endOfFileToken);
|
|
86394
86444
|
checkDeferredNodes(node);
|
|
@@ -86404,6 +86454,9 @@ var ts;
|
|
|
86404
86454
|
}
|
|
86405
86455
|
});
|
|
86406
86456
|
}
|
|
86457
|
+
if (!node.isDeclarationFile) {
|
|
86458
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86459
|
+
}
|
|
86407
86460
|
});
|
|
86408
86461
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86409
86462
|
!node.isDeclarationFile &&
|
|
@@ -109145,7 +109198,7 @@ var ts;
|
|
|
109145
109198
|
});
|
|
109146
109199
|
return ret;
|
|
109147
109200
|
}
|
|
109148
|
-
function
|
|
109201
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109149
109202
|
if (name.kind === 79 /* Identifier */) {
|
|
109150
109203
|
return name;
|
|
109151
109204
|
}
|
|
@@ -109161,7 +109214,12 @@ var ts;
|
|
|
109161
109214
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109162
109215
|
return elem;
|
|
109163
109216
|
}
|
|
109164
|
-
|
|
109217
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109218
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109219
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109220
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109221
|
+
}
|
|
109222
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109165
109223
|
}
|
|
109166
109224
|
}
|
|
109167
109225
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109170,7 +109228,7 @@ var ts;
|
|
|
109170
109228
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109171
109229
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109172
109230
|
}
|
|
109173
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109231
|
+
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
|
|
109174
109232
|
ensureNoInitializer(p));
|
|
109175
109233
|
if (!suppressNewDiagnosticContexts) {
|
|
109176
109234
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -117313,6 +117371,7 @@ var ts;
|
|
|
117313
117371
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117314
117372
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117315
117373
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117374
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117316
117375
|
]);
|
|
117317
117376
|
/**
|
|
117318
117377
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -122447,9 +122506,11 @@ var ts;
|
|
|
122447
122506
|
}
|
|
122448
122507
|
function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
|
|
122449
122508
|
ts.Debug.assert(!!resolution.refCount);
|
|
122509
|
+
var affectingLocations = resolution.affectingLocations;
|
|
122510
|
+
if (!affectingLocations.length)
|
|
122511
|
+
return;
|
|
122450
122512
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
122451
122513
|
resolutionsWithOnlyAffectingLocations.push(resolution);
|
|
122452
|
-
var affectingLocations = resolution.affectingLocations;
|
|
122453
122514
|
// Watch package json
|
|
122454
122515
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122455
122516
|
var affectingLocation = affectingLocations_1[_i];
|